diff options
-rw-r--r-- | widgets/misc/e-gui-utils.c | 31 | ||||
-rw-r--r-- | widgets/misc/e-gui-utils.h | 2 |
2 files changed, 33 insertions, 0 deletions
diff --git a/widgets/misc/e-gui-utils.c b/widgets/misc/e-gui-utils.c index 14ab11c565..86cb3c3b5c 100644 --- a/widgets/misc/e-gui-utils.c +++ b/widgets/misc/e-gui-utils.c @@ -171,3 +171,34 @@ e_container_change_tab_order(GtkContainer *container, GList *widgets) e_container_change_tab_order_destroy_notify, FALSE, FALSE); } + +struct widgetandint { + GtkWidget *widget; + int count; +}; + +static void +nth_entry_callback(GtkWidget *widget, struct widgetandint *data) +{ + if (GTK_IS_ENTRY(widget)) { + if (data->count > 1) { + data->count --; + data->widget = widget; + } else if (data->count == 1) { + data->count --; + data->widget = NULL; + gtk_widget_grab_focus(widget); + } + } +} + +void +e_container_focus_nth_entry(GtkContainer *container, int n) +{ + struct widgetandint data; + data.widget = NULL; + data.count = n; + e_container_foreach_leaf(container, (GtkCallback) nth_entry_callback, &data); + if (data.widget) + gtk_widget_grab_focus(data.widget); +} diff --git a/widgets/misc/e-gui-utils.h b/widgets/misc/e-gui-utils.h index 215544e942..b6785aecdd 100644 --- a/widgets/misc/e-gui-utils.h +++ b/widgets/misc/e-gui-utils.h @@ -12,6 +12,8 @@ void e_notice (GtkWindow *window, const char *type, const void e_container_foreach_leaf (GtkContainer *container, GtkCallback callback, gpointer closure); +void e_container_focus_nth_entry (GtkContainer *container, + int n); gint e_container_change_tab_order (GtkContainer *container, GList *widgets); |