Fix some form entries not updating properly
This commit is contained in:
parent
1559a7a603
commit
32ae87a3c4
|
@ -13,7 +13,7 @@ public class Account : Object {
|
||||||
public Jid full_jid { get; private set; }
|
public Jid full_jid { get; private set; }
|
||||||
public string? password { get; set; }
|
public string? password { get; set; }
|
||||||
public string display_name {
|
public string display_name {
|
||||||
owned get { return alias ?? bare_jid.to_string(); }
|
owned get { return (alias != null && alias.length > 0) ? alias.dup() : bare_jid.to_string(); }
|
||||||
}
|
}
|
||||||
public string? alias { get; set; }
|
public string? alias { get; set; }
|
||||||
public bool enabled { get; set; default = false; }
|
public bool enabled { get; set; default = false; }
|
||||||
|
|
|
@ -110,13 +110,8 @@ protected class ConferenceDetailsFragment : Box {
|
||||||
// nick_entry.key_release_event.connect(on_nick_key_release_event);
|
// nick_entry.key_release_event.connect(on_nick_key_release_event);
|
||||||
// password_entry.key_release_event.connect(on_password_key_release_event);
|
// password_entry.key_release_event.connect(on_password_key_release_event);
|
||||||
|
|
||||||
var jid_entry_controller = new EventControllerKey();
|
jid_entry.changed.connect(() => { check_if_done(); });
|
||||||
jid_entry_controller.key_released.connect(() => { check_if_done(); });
|
nick_entry.changed.connect(() => { check_if_done(); });
|
||||||
jid_entry.add_controller(jid_entry_controller);
|
|
||||||
|
|
||||||
var nick_entry_controller = new EventControllerKey();
|
|
||||||
nick_entry_controller.key_released.connect(() => { check_if_done(); });
|
|
||||||
nick_entry.add_controller(nick_entry_controller);
|
|
||||||
|
|
||||||
check_if_done();
|
check_if_done();
|
||||||
|
|
||||||
|
|
|
@ -42,8 +42,8 @@ public class Dialog : Gtk.Dialog {
|
||||||
if (selected_account != null) remove_account(account_row);
|
if (selected_account != null) remove_account(account_row);
|
||||||
});
|
});
|
||||||
image_button.clicked.connect(show_select_avatar);
|
image_button.clicked.connect(show_select_avatar);
|
||||||
// alias_hybrid.entry.key_release_event.connect(() => { selected_account.alias = alias_hybrid.text; return false; });
|
alias_hybrid.entry.changed.connect(() => { selected_account.alias = alias_hybrid.text; });
|
||||||
// password_hybrid.entry.key_release_event.connect(() => { selected_account.password = password_hybrid.text; return false; });
|
password_hybrid.entry.changed.connect(() => { selected_account.password = password_hybrid.text; });
|
||||||
|
|
||||||
Util.LabelHybridGroup label_hybrid_group = new Util.LabelHybridGroup();
|
Util.LabelHybridGroup label_hybrid_group = new Util.LabelHybridGroup();
|
||||||
label_hybrid_group.add(alias_hybrid);
|
label_hybrid_group.add(alias_hybrid);
|
||||||
|
|
|
@ -35,21 +35,13 @@ public static Widget? get_data_form_field_widget(DataForms.DataForm.Field field)
|
||||||
return null;
|
return null;
|
||||||
case DataForms.DataForm.Type.TEXT_PRIVATE:
|
case DataForms.DataForm.Type.TEXT_PRIVATE:
|
||||||
DataForms.DataForm.TextPrivateField text_private_field = field as DataForms.DataForm.TextPrivateField;
|
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 };
|
PasswordEntry entry = new PasswordEntry() { text=text_private_field.value ?? "", valign=Align.CENTER };
|
||||||
var entry_key_events = new EventControllerKey();
|
entry.changed.connect(() => { text_private_field.value = entry.text; });
|
||||||
entry_key_events.key_released.connect(() => {
|
|
||||||
text_private_field.value = entry.text;
|
|
||||||
});
|
|
||||||
entry.add_controller(entry_key_events);
|
|
||||||
return entry;
|
return entry;
|
||||||
case DataForms.DataForm.Type.TEXT_SINGLE:
|
case DataForms.DataForm.Type.TEXT_SINGLE:
|
||||||
DataForms.DataForm.TextSingleField text_single_field = field as DataForms.DataForm.TextSingleField;
|
DataForms.DataForm.TextSingleField text_single_field = field as DataForms.DataForm.TextSingleField;
|
||||||
Entry entry = new Entry() { text=text_single_field.value ?? "", valign=Align.CENTER };
|
Entry entry = new Entry() { text=text_single_field.value ?? "", valign=Align.CENTER };
|
||||||
var entry_key_events = new EventControllerKey();
|
entry.changed.connect(() => { text_single_field.value = entry.text; });
|
||||||
entry_key_events.key_released.connect(() => {
|
|
||||||
text_single_field.value = entry.text;
|
|
||||||
});
|
|
||||||
entry.add_controller(entry_key_events);
|
|
||||||
return entry;
|
return entry;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -40,8 +40,8 @@ public class EntryLabelHybrid : LabelHybrid {
|
||||||
public string text {
|
public string text {
|
||||||
get { return entry.text; }
|
get { return entry.text; }
|
||||||
set {
|
set {
|
||||||
entry.text = value;
|
entry.text = value.dup();
|
||||||
set_label_label(value);
|
update_label();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,22 +79,21 @@ public class EntryLabelHybrid : LabelHybrid {
|
||||||
if (e == null) return;
|
if (e == null) return;
|
||||||
entry = e;
|
entry = e;
|
||||||
base.init(entry);
|
base.init(entry);
|
||||||
set_label_label(entry.text);
|
update_label();
|
||||||
|
|
||||||
var key_events = new EventControllerKey();
|
var key_events = new EventControllerKey();
|
||||||
key_events.key_released.connect(on_key_released);
|
key_events.key_released.connect(on_key_released);
|
||||||
entry.add_controller(key_events);
|
entry.add_controller(key_events);
|
||||||
|
entry.changed.connect(update_label);
|
||||||
|
|
||||||
var focus_events = new EventControllerFocus();
|
var focus_events = new EventControllerFocus();
|
||||||
focus_events.leave.connect(on_focus_leave);
|
focus_events.leave.connect(update_label);
|
||||||
entry.add_controller(focus_events);
|
entry.add_controller(focus_events);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void on_key_released(uint keyval) {
|
private void on_key_released(uint keyval) {
|
||||||
if (keyval == Gdk.Key.Return) {
|
if (keyval == Gdk.Key.Return) {
|
||||||
show_label();
|
show_label();
|
||||||
} else {
|
|
||||||
set_label_label(entry.text);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,12 +101,12 @@ public class EntryLabelHybrid : LabelHybrid {
|
||||||
show_label();
|
show_label();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void set_label_label(string value) {
|
private void update_label() {
|
||||||
if (visibility) {
|
if (visibility) {
|
||||||
label.label = value;
|
label.label = entry.text;
|
||||||
} else {
|
} else {
|
||||||
string filler = "";
|
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;
|
label.label = filler;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue