diff options
Diffstat (limited to 'main/src/ui/util')
-rw-r--r-- | main/src/ui/util/data_forms.vala | 14 | ||||
-rw-r--r-- | main/src/ui/util/label_hybrid.vala | 17 |
2 files changed, 11 insertions, 20 deletions
diff --git a/main/src/ui/util/data_forms.vala b/main/src/ui/util/data_forms.vala index af8789a7..1f598025 100644 --- a/main/src/ui/util/data_forms.vala +++ b/main/src/ui/util/data_forms.vala @@ -35,21 +35,13 @@ 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, visibility=false }; - var entry_key_events = new EventControllerKey(); - entry_key_events.key_released.connect(() => { - text_private_field.value = entry.text; - }); - entry.add_controller(entry_key_events); + PasswordEntry entry = new PasswordEntry() { text=text_private_field.value ?? "", valign=Align.CENTER }; + entry.changed.connect(() => { text_private_field.value = entry.text; }); 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 }; - var entry_key_events = new EventControllerKey(); - entry_key_events.key_released.connect(() => { - text_single_field.value = entry.text; - }); - entry.add_controller(entry_key_events); + entry.changed.connect(() => { text_single_field.value = entry.text; }); return entry; default: return null; diff --git a/main/src/ui/util/label_hybrid.vala b/main/src/ui/util/label_hybrid.vala index 53f0fbca..f426de7e 100644 --- a/main/src/ui/util/label_hybrid.vala +++ b/main/src/ui/util/label_hybrid.vala @@ -40,8 +40,8 @@ public class EntryLabelHybrid : LabelHybrid { public string text { get { return entry.text; } set { - entry.text = value; - set_label_label(value); + entry.text = value.dup(); + update_label(); } } @@ -79,22 +79,21 @@ public class EntryLabelHybrid : LabelHybrid { if (e == null) return; entry = e; base.init(entry); - set_label_label(entry.text); + update_label(); var key_events = new EventControllerKey(); key_events.key_released.connect(on_key_released); entry.add_controller(key_events); + entry.changed.connect(update_label); var focus_events = new EventControllerFocus(); - focus_events.leave.connect(on_focus_leave); + focus_events.leave.connect(update_label); entry.add_controller(focus_events); } private void on_key_released(uint keyval) { if (keyval == Gdk.Key.Return) { show_label(); - } else { - set_label_label(entry.text); } } @@ -102,12 +101,12 @@ public class EntryLabelHybrid : LabelHybrid { show_label(); } - private void set_label_label(string value) { + private void update_label() { if (visibility) { - label.label = value; + label.label = entry.text; } else { string filler = ""; - for (int i = 0; i < value.length; i++) filler += entry.get_invisible_char().to_string(); + for (int i = 0; i < entry.text.length; i++) filler += entry.get_invisible_char().to_string(); label.label = filler; } } |