From: Jose Dapena Paz Date: Fri, 3 Aug 2007 18:43:54 +0000 (+0000) Subject: Improvements in focus management of Check names operation X-Git-Tag: git_migration_finished~2632 X-Git-Url: http://git.maemo.org/git/?p=modest;a=commitdiff_plain;h=bc0af9ec72e2b7f4c5aee427f22d36befebef8e7 Improvements in focus management of Check names operation (fixes NB#59427). * src/widgets/modest-recpt-editor.[ch]: * New method (modest_recpt_editor_has_focus). This is used to be able to know if a recipient editor text view is focused. * src/maemo/modest-address-book.c: * Removed all recipient editor focus management. Now we rely on the window implementation. * src/maemo/modest-msg-edit-window.c: * Now we set focus of the failing recipient editor in check names if it fails. * If check names does not fail, and focus is in a recipient field, it does not change the focus from them to to: field. pmo-trunk-r2929 --- diff --git a/src/maemo/modest-address-book.c b/src/maemo/modest-address-book.c index ac1996e..f6eca8a 100644 --- a/src/maemo/modest-address-book.c +++ b/src/maemo/modest-address-book.c @@ -754,7 +754,6 @@ modest_address_book_check_names (ModestRecptEditor *recpt_editor, gboolean updat gtk_widget_destroy (banner); g_object_unref (G_OBJECT (banner)); } - modest_recpt_editor_grab_focus (recpt_editor); g_slist_foreach (start_indexes, (GFunc) g_free, NULL); g_slist_foreach (end_indexes, (GFunc) g_free, NULL); diff --git a/src/maemo/modest-msg-edit-window.c b/src/maemo/modest-msg-edit-window.c index 77e9e93..0830961 100644 --- a/src/maemo/modest-msg-edit-window.c +++ b/src/maemo/modest-msg-edit-window.c @@ -2736,14 +2736,22 @@ modest_msg_edit_window_check_names (ModestMsgEditWindow *window, gboolean add_to return FALSE; } - if (!modest_address_book_check_names (MODEST_RECPT_EDITOR (priv->to_field), add_to_addressbook)) + if (!modest_address_book_check_names (MODEST_RECPT_EDITOR (priv->to_field), add_to_addressbook)) { + modest_recpt_editor_grab_focus (MODEST_RECPT_EDITOR (priv->to_field)); return FALSE; - if (!modest_address_book_check_names (MODEST_RECPT_EDITOR (priv->cc_field), add_to_addressbook)) + } + if (!modest_address_book_check_names (MODEST_RECPT_EDITOR (priv->cc_field), add_to_addressbook)) { + modest_recpt_editor_grab_focus (MODEST_RECPT_EDITOR (priv->cc_field)); return FALSE; - if (!modest_address_book_check_names (MODEST_RECPT_EDITOR (priv->bcc_field), add_to_addressbook)) + } + if (!modest_address_book_check_names (MODEST_RECPT_EDITOR (priv->bcc_field), add_to_addressbook)) { + modest_recpt_editor_grab_focus (MODEST_RECPT_EDITOR (priv->bcc_field)); return FALSE; + } - modest_recpt_editor_grab_focus (MODEST_RECPT_EDITOR (priv->to_field)); + if (!modest_recpt_editor_has_focus (MODEST_RECPT_EDITOR (priv->cc_field)) && + !modest_recpt_editor_has_focus (MODEST_RECPT_EDITOR (priv->bcc_field))) + modest_recpt_editor_grab_focus (MODEST_RECPT_EDITOR (priv->to_field)); return TRUE; diff --git a/src/widgets/modest-recpt-editor.c b/src/widgets/modest-recpt-editor.c index 1f96cd2..c713db9 100644 --- a/src/widgets/modest-recpt-editor.c +++ b/src/widgets/modest-recpt-editor.c @@ -847,6 +847,17 @@ modest_recpt_editor_grab_focus (ModestRecptEditor *recpt_editor) gtk_widget_grab_focus (priv->text_view); } +gboolean +modest_recpt_editor_has_focus (ModestRecptEditor *recpt_editor) +{ + ModestRecptEditorPrivate *priv; + + g_return_val_if_fail (MODEST_IS_RECPT_EDITOR (recpt_editor), FALSE); + priv = MODEST_RECPT_EDITOR_GET_PRIVATE (recpt_editor); + + return gtk_widget_is_focus (priv->text_view); +} + static void modest_recpt_editor_finalize (GObject *object) { diff --git a/src/widgets/modest-recpt-editor.h b/src/widgets/modest-recpt-editor.h index 0956a50..c4049d3 100644 --- a/src/widgets/modest-recpt-editor.h +++ b/src/widgets/modest-recpt-editor.h @@ -79,6 +79,7 @@ void modest_recpt_editor_replace_with_resolved_recipient (ModestRecptEditor *rec void modest_recpt_editor_set_field_size_group (ModestRecptEditor *recpt_editor, GtkSizeGroup *size_group); GtkTextBuffer *modest_recpt_editor_get_buffer (ModestRecptEditor *recpt_editor); void modest_recpt_editor_grab_focus (ModestRecptEditor *recpt_editor); +gboolean modest_recpt_editor_has_focus (ModestRecptEditor *recpt_editor); G_END_DECLS