From 4813d6259ff1b9b88e127bb171b3fe5c412a9585 Mon Sep 17 00:00:00 2001 From: Milan Crha Date: Thu, 19 Jun 2008 16:38:18 +0000 Subject: ** Fix for bug #382783 2008-06-19 Milan Crha ** Fix for bug #382783 * filter/filter-rule.c: (do_grab_focus_cb), (more_parts), (get_widget): * mail/em-filter-rule.c: (do_grab_focus_cb), (more_parts), (get_widget): Grab focus of new rule part on adding and scroll to the bottom too. svn path=/trunk/; revision=35654 --- mail/ChangeLog | 7 +++++++ mail/em-filter-rule.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) (limited to 'mail') diff --git a/mail/ChangeLog b/mail/ChangeLog index 37c746db00..33232d1008 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,10 @@ +2008-06-19 Milan Crha + + ** Fix for bug #382783 + + * em-filter-rule.c: (do_grab_focus_cb), (more_parts), (get_widget): + Grab focus of new rule part on adding and scroll to the bottom too. + 2008-06-18 Milan Crha ** Fix for bug #423395 diff --git a/mail/em-filter-rule.c b/mail/em-filter-rule.c index aaec41ba3b..6f9a9e2c28 100644 --- a/mail/em-filter-rule.c +++ b/mail/em-filter-rule.c @@ -448,6 +448,20 @@ attach_rule(GtkWidget *rule, struct _rule_data *data, FilterPart *part, int row) gtk_widget_show(remove); } +static void +do_grab_focus_cb (GtkWidget *widget, gpointer data) +{ + gboolean *done = (gboolean *) data; + + if (*done) + return; + + if (widget && GTK_WIDGET_CAN_FOCUS (widget)) { + *done = TRUE; + gtk_widget_grab_focus (widget); + } +} + static void more_parts(GtkWidget *button, struct _rule_data *data) { @@ -466,6 +480,24 @@ more_parts(GtkWidget *button, struct _rule_data *data) rows = GTK_TABLE(data->parts)->nrows; gtk_table_resize(GTK_TABLE(data->parts), rows + 1, 2); attach_rule(w, data, new, rows); + + if (GTK_IS_CONTAINER (w)) { + gboolean done = FALSE; + + gtk_container_foreach (GTK_CONTAINER (w), do_grab_focus_cb, &done); + } else + gtk_widget_grab_focus (w); + + /* also scroll down to see new part */ + w = (GtkWidget*) g_object_get_data (G_OBJECT (button), "scrolled-window"); + if (w) { + GtkAdjustment *adjustment; + + adjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (w)); + if (adjustment) + gtk_adjustment_set_value (adjustment, adjustment->upper); + + } } } @@ -543,6 +575,8 @@ get_widget(FilterRule *fr, RuleContext *rc) /*gtk_box_pack_start(GTK_BOX(inframe), parts, FALSE, FALSE, 3);*/ + g_object_set_data (G_OBJECT (add), "scrolled-window", scrolledwindow); + gtk_widget_show_all(widget); return widget; -- cgit