Focus selected widgets in the accounts dialog

Previously, you had to issue two clicks in order to enter something into
the text fields.

This also replaces the `Entry` widgets with their label counterparts
once they lose focus. Since the `ComboBox` handling of focus seems to be
buggy (`focus_out_event` not firing), the OpenPGP key selection lacks
the latter feature.
This commit is contained in:
hrxi 2017-08-23 17:49:55 +02:00 committed by fiaxh
parent d0e86d0a8e
commit 2cd6e94cc5
2 changed files with 13 additions and 2 deletions

View file

@ -20,6 +20,7 @@ public class LabelHybrid : Stack {
public void show_widget() { public void show_widget() {
visible_child_name = "widget"; visible_child_name = "widget";
get_child_by_name("widget").grab_focus();
} }
public void show_label() { public void show_label() {
@ -86,6 +87,10 @@ public class EntryLabelHybrid : LabelHybrid {
} }
return false; return false;
}); });
entry.focus_out_event.connect(() => {
show_label();
return false;
});
} }
private void update_label() { private void update_label() {
@ -134,6 +139,11 @@ public class ComboBoxTextLabelHybrid : LabelHybrid {
update_label(); update_label();
show_label(); show_label();
}); });
combobox.focus_out_event.connect(() => {
update_label();
show_label();
return false;
});
button.clicked.connect(() => { button.clicked.connect(() => {
combobox.popup(); combobox.popup();
}); });

View file

@ -31,7 +31,7 @@ private class AccountSettingsWidget : Stack, Plugins.AccountSettingsWidget {
} }
public void deactivate() { public void deactivate() {
this.set_visible_child_name("label"); set_visible_child_name("label");
} }
public void set_account(Account account) { public void set_account(Account account) {
@ -45,7 +45,8 @@ private class AccountSettingsWidget : Stack, Plugins.AccountSettingsWidget {
private void on_button_clicked() { private void on_button_clicked() {
activated(); activated();
this.set_visible_child_name("entry"); set_visible_child_name("entry");
combobox.grab_focus();
combobox.popup(); combobox.popup();
} }