diff options
author | fiaxh <git@lightrise.org> | 2022-05-14 14:45:59 +0200 |
---|---|---|
committer | fiaxh <git@lightrise.org> | 2022-07-27 20:34:20 +0200 |
commit | f44cbe02c17df1f02ad49c63cd784fec0ea02d85 (patch) | |
tree | 4cab9b5f84d88769d19b0698e24b318f50b6144e /main/src/ui/util | |
parent | 2b3ce5fc95c63ed7d54e207db0585c8b8bbcd603 (diff) | |
download | dino-f44cbe02c17df1f02ad49c63cd784fec0ea02d85.tar.gz dino-f44cbe02c17df1f02ad49c63cd784fec0ea02d85.zip |
Improve Gtk4 port
Diffstat (limited to 'main/src/ui/util')
-rw-r--r-- | main/src/ui/util/data_forms.vala | 8 | ||||
-rw-r--r-- | main/src/ui/util/label_hybrid.vala | 23 | ||||
-rw-r--r-- | main/src/ui/util/scaling_image.vala | 14 | ||||
-rw-r--r-- | main/src/ui/util/sizing_bin.vala | 5 |
4 files changed, 21 insertions, 29 deletions
diff --git a/main/src/ui/util/data_forms.vala b/main/src/ui/util/data_forms.vala index 53439149..af8789a7 100644 --- a/main/src/ui/util/data_forms.vala +++ b/main/src/ui/util/data_forms.vala @@ -11,7 +11,7 @@ public static Widget? get_data_form_field_widget(DataForms.DataForm.Field field) switch (field.type_) { case DataForms.DataForm.Type.BOOLEAN: DataForms.DataForm.BooleanField boolean_field = field as DataForms.DataForm.BooleanField; - Switch sw = new Switch() { active=boolean_field.value, halign=Align.START, valign=Align.CENTER, visible=true }; + Switch sw = new Switch() { active=boolean_field.value, halign=Align.START, valign=Align.CENTER }; sw.state_set.connect((state) => { boolean_field.value = state; return false; @@ -21,7 +21,7 @@ public static Widget? get_data_form_field_widget(DataForms.DataForm.Field field) return null; case DataForms.DataForm.Type.LIST_SINGLE: DataForms.DataForm.ListSingleField list_single_field = field as DataForms.DataForm.ListSingleField; - ComboBoxText combobox = new ComboBoxText() { valign=Align.CENTER, visible=true }; + ComboBoxText combobox = new ComboBoxText() { valign=Align.CENTER }; for (int i = 0; i < list_single_field.options.size; i++) { DataForms.DataForm.Option option = list_single_field.options[i]; combobox.append(option.value, option.label); @@ -35,7 +35,7 @@ public static Widget? get_data_form_field_widget(DataForms.DataForm.Field field) return null; case DataForms.DataForm.Type.TEXT_PRIVATE: DataForms.DataForm.TextPrivateField text_private_field = field as DataForms.DataForm.TextPrivateField; - Entry entry = new Entry() { text=text_private_field.value ?? "", valign=Align.CENTER, visible=true, visibility=false }; + Entry entry = new Entry() { text=text_private_field.value ?? "", valign=Align.CENTER, visibility=false }; var entry_key_events = new EventControllerKey(); entry_key_events.key_released.connect(() => { text_private_field.value = entry.text; @@ -44,7 +44,7 @@ public static Widget? get_data_form_field_widget(DataForms.DataForm.Field field) return entry; case DataForms.DataForm.Type.TEXT_SINGLE: DataForms.DataForm.TextSingleField text_single_field = field as DataForms.DataForm.TextSingleField; - Entry entry = new Entry() { text=text_single_field.value ?? "", valign=Align.CENTER, visible=true }; + Entry entry = new Entry() { text=text_single_field.value ?? "", valign=Align.CENTER }; var entry_key_events = new EventControllerKey(); entry_key_events.key_released.connect(() => { text_single_field.value = entry.text; diff --git a/main/src/ui/util/label_hybrid.vala b/main/src/ui/util/label_hybrid.vala index d880ba6f..53f0fbca 100644 --- a/main/src/ui/util/label_hybrid.vala +++ b/main/src/ui/util/label_hybrid.vala @@ -6,12 +6,12 @@ namespace Dino.Ui.Util { public class LabelHybrid : Widget { public Stack stack = new Stack(); - public Label label = new Label("") { visible=true, max_width_chars=1, ellipsize=Pango.EllipsizeMode.END }; - protected Button button = new Button() { has_frame=false, visible=true }; + public Label label = new Label("") { max_width_chars=1, ellipsize=Pango.EllipsizeMode.END }; + protected Button button = new Button() { has_frame=false }; internal virtual void init(Widget widget) { this.layout_manager = new BinLayout(); - stack.insert_after(this, null); + stack.set_parent(this); button.child = label; stack.add_named(button, "label"); stack.add_named(widget, "widget"); @@ -29,6 +29,10 @@ public class LabelHybrid : Widget { public void show_label() { stack.visible_child_name = "label"; } + + public override void dispose() { + stack.unparent(); + } } public class EntryLabelHybrid : LabelHybrid { @@ -58,7 +62,7 @@ public class EntryLabelHybrid : LabelHybrid { public Entry entry { get { if (entry_ == null) { - entry_ = new Entry() { visible=true }; + entry_ = new Entry(); init(entry_); } return entry_; @@ -71,10 +75,11 @@ public class EntryLabelHybrid : LabelHybrid { } internal override void init(Widget widget) { - Entry? e = widget as Entry; if (e == null) return; + Entry? e = widget as Entry; + if (e == null) return; entry = e; base.init(entry); - update_label(); + set_label_label(entry.text); var key_events = new EventControllerKey(); key_events.key_released.connect(on_key_released); @@ -106,10 +111,6 @@ public class EntryLabelHybrid : LabelHybrid { label.label = filler; } } - - private void update_label() { - text = text; - } } public class ComboBoxTextLabelHybrid : LabelHybrid { @@ -128,7 +129,7 @@ public class ComboBoxTextLabelHybrid : LabelHybrid { public ComboBoxText combobox { get { if (combobox_ == null) { - combobox_ = new ComboBoxText() { visible=true }; + combobox_ = new ComboBoxText(); init(combobox_); } return combobox_; diff --git a/main/src/ui/util/scaling_image.vala b/main/src/ui/util/scaling_image.vala index 3dd3221f..20ff6718 100644 --- a/main/src/ui/util/scaling_image.vala +++ b/main/src/ui/util/scaling_image.vala @@ -177,20 +177,6 @@ class ScalingImage : Widget { minimum_baseline = natural_baseline = -1; } -// public override void get_preferred_height_for_width(int width, out int minimum_height, out int natural_height) { -// double exact_width = width, exact_height = -1; -// calculate_size(ref exact_width, ref exact_height); -// natural_height = (int) Math.ceil(exact_height); -// minimum_height = natural_height; -// } -// -// public override void get_preferred_width_for_height(int height, out int minimum_width, out int natural_width) { -// double exact_width = -1, exact_height = height; -// calculate_size(ref exact_width, ref exact_height); -// natural_width = (int) Math.ceil(exact_width); -// minimum_width = natural_width; -// } - public override SizeRequestMode get_request_mode() { return SizeRequestMode.HEIGHT_FOR_WIDTH; } diff --git a/main/src/ui/util/sizing_bin.vala b/main/src/ui/util/sizing_bin.vala index 939022a1..c17cb3cc 100644 --- a/main/src/ui/util/sizing_bin.vala +++ b/main/src/ui/util/sizing_bin.vala @@ -33,5 +33,10 @@ public class SizingBin : Widget { natural = int.max(natural, minimum); } } + + public override void dispose() { + var child = this.get_first_child(); + if (child != null) child.unparent(); + } } } |