[geary/wip/714104-refine-account-dialog] Provide decent initial widget focus for all account editor panes
- From: Michael Gratton <mjog src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [geary/wip/714104-refine-account-dialog] Provide decent initial widget focus for all account editor panes
- Date: Thu, 27 Dec 2018 00:06:54 +0000 (UTC)
commit 543a5e1c19d99800b09cc488b4d93ff589dccefa
Author: Michael Gratton <mike vee net>
Date: Fri Dec 21 10:11:25 2018 +1100
Provide decent initial widget focus for all account editor panes
src/client/accounts/accounts-editor-add-pane.vala | 4 ++++
src/client/accounts/accounts-editor-edit-pane.vala | 4 ++++
src/client/accounts/accounts-editor-list-pane.vala | 18 ++++++++++-----
.../accounts/accounts-editor-remove-pane.vala | 7 ++++++
.../accounts/accounts-editor-servers-pane.vala | 4 ++++
src/client/accounts/accounts-editor.vala | 26 +++++++++++++++++-----
6 files changed, 53 insertions(+), 10 deletions(-)
---
diff --git a/src/client/accounts/accounts-editor-add-pane.vala
b/src/client/accounts/accounts-editor-add-pane.vala
index 8a872be8..196dae8c 100644
--- a/src/client/accounts/accounts-editor-add-pane.vala
+++ b/src/client/accounts/accounts-editor-add-pane.vala
@@ -12,6 +12,10 @@
internal class Accounts.EditorAddPane : Gtk.Grid, EditorPane {
+ internal Gtk.Widget initial_widget {
+ get { return this.real_name.value; }
+ }
+
protected weak Accounts.Editor editor { get; set; }
private Geary.ServiceProvider provider;
diff --git a/src/client/accounts/accounts-editor-edit-pane.vala
b/src/client/accounts/accounts-editor-edit-pane.vala
index d4c2251f..081135c8 100644
--- a/src/client/accounts/accounts-editor-edit-pane.vala
+++ b/src/client/accounts/accounts-editor-edit-pane.vala
@@ -12,6 +12,10 @@
internal class Accounts.EditorEditPane : Gtk.Grid, EditorPane, AccountPane {
+ internal Gtk.Widget initial_widget {
+ get { return this.details_list.get_row_at_index(0); }
+ }
+
internal Geary.AccountInformation account { get ; protected set; }
/** Command stack for edit pane user commands. */
diff --git a/src/client/accounts/accounts-editor-list-pane.vala
b/src/client/accounts/accounts-editor-list-pane.vala
index 95b764fd..81b028c8 100644
--- a/src/client/accounts/accounts-editor-list-pane.vala
+++ b/src/client/accounts/accounts-editor-list-pane.vala
@@ -28,10 +28,22 @@ internal class Accounts.EditorListPane : Gtk.Grid, EditorPane {
}
+ internal Gtk.Widget initial_widget {
+ get {
+ return this.show_welcome ? this.service_list : this.accounts_list;
+ }
+ }
+
internal Manager accounts { get; private set; }
protected weak Accounts.Editor editor { get; set; }
+ private bool show_welcome {
+ get {
+ return (this.accounts_list.get_row_at_index(0) == null);
+ }
+ }
+
private Application.CommandStack commands = new Application.CommandStack();
[GtkChild]
@@ -143,10 +155,6 @@ internal class Accounts.EditorListPane : Gtk.Grid, EditorPane {
}
}
- internal void pane_shown() {
- update_actions();
- }
-
internal void undo() {
this.commands.undo.begin(null);
}
@@ -182,7 +190,7 @@ internal class Accounts.EditorListPane : Gtk.Grid, EditorPane {
}
private void update_welcome_panel() {
- if (this.accounts_list.get_row_at_index(0) == null) {
+ if (this.show_welcome) {
// No accounts are available, so show only the welcome
// pane and service list.
this.welcome_panel.show();
diff --git a/src/client/accounts/accounts-editor-remove-pane.vala
b/src/client/accounts/accounts-editor-remove-pane.vala
index 5e212db2..76a67118 100644
--- a/src/client/accounts/accounts-editor-remove-pane.vala
+++ b/src/client/accounts/accounts-editor-remove-pane.vala
@@ -12,6 +12,10 @@
internal class Accounts.EditorRemovePane : Gtk.Grid, EditorPane, AccountPane {
+ internal Gtk.Widget initial_widget {
+ get { return this.remove_button; }
+ }
+
internal Geary.AccountInformation account { get ; protected set; }
protected weak Accounts.Editor editor { get; set; }
@@ -22,6 +26,9 @@ internal class Accounts.EditorRemovePane : Gtk.Grid, EditorPane, AccountPane {
[GtkChild]
private Gtk.Label warning_label;
+ [GtkChild]
+ private Gtk.Button remove_button;
+
public EditorRemovePane(Editor editor, Geary.AccountInformation account) {
this.editor = editor;
diff --git a/src/client/accounts/accounts-editor-servers-pane.vala
b/src/client/accounts/accounts-editor-servers-pane.vala
index b312fc6e..45fa0aa4 100644
--- a/src/client/accounts/accounts-editor-servers-pane.vala
+++ b/src/client/accounts/accounts-editor-servers-pane.vala
@@ -13,6 +13,10 @@
internal class Accounts.EditorServersPane : Gtk.Grid, EditorPane, AccountPane {
+ internal Gtk.Widget initial_widget {
+ get { return this.details_list; }
+ }
+
internal Geary.AccountInformation account { get ; protected set; }
/** Command stack for pane user commands. */
diff --git a/src/client/accounts/accounts-editor.vala b/src/client/accounts/accounts-editor.vala
index 296e494a..2c253192 100644
--- a/src/client/accounts/accounts-editor.vala
+++ b/src/client/accounts/accounts-editor.vala
@@ -55,7 +55,7 @@ public class Accounts.Editor : Gtk.Dialog {
this.editor_panes.set_transition_type(
Gtk.StackTransitionType.SLIDE_LEFT_RIGHT
);
- this.editor_panes.notify["visible-child"].connect(on_pane_changed);
+ this.editor_panes.notify["visible-child"].connect_after(on_pane_changed);
this.editor_panes.show();
this.actions.add_action_entries(ACTION_ENTRIES, this);
@@ -118,8 +118,6 @@ public class Accounts.Editor : Gtk.Dialog {
this.editor_pane_stack.add(pane);
this.editor_panes.add(pane);
this.editor_panes.set_visible_child(pane);
-
- pane.pane_shown();
}
internal void pop() {
@@ -156,7 +154,23 @@ public class Accounts.Editor : Gtk.Dialog {
private void on_pane_changed() {
EditorPane? visible = get_current_pane();
- set_titlebar(visible != null ? visible.get_header() : null);
+ Gtk.Widget? header = null;
+ debug(
+ "Have pane: %s, transitions running: %s",
+ (visible != null).to_string(),
+ this.editor_panes.transition_running.to_string()
+ );
+ if (visible != null) {
+ visible.pane_shown();
+ // Do this in an idle callback since it's not 100%
+ // reliable to just call it here for some reason :(
+ GLib.Idle.add(() => {
+ visible.initial_widget.grab_focus();
+ return GLib.Source.REMOVE;
+ });
+ header = visible.get_header();
+ }
+ set_titlebar(header);
}
}
@@ -181,8 +195,10 @@ internal interface Accounts.EditorPane : Gtk.Grid {
/** The editor displaying this pane. */
- protected abstract weak Accounts.Editor editor { get; set; }
+ internal abstract Gtk.Widget initial_widget { get; }
+ /** The editor displaying this pane. */
+ protected abstract weak Accounts.Editor editor { get; set; }
/** The GTK header bar to display for this pane. */
internal abstract Gtk.HeaderBar get_header();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]