From: Sergio Villar Senin Date: Wed, 7 Jan 2009 17:42:43 +0000 (+0000) Subject: * Added a new call modest_window_mgr_get_current_top that returns the topmost window X-Git-Tag: git_migration_finished~852 X-Git-Url: http://git.maemo.org/git/?p=modest;a=commitdiff_plain;h=0665dc4b8ea24124da9764016328e2fb9efe11de * Added a new call modest_window_mgr_get_current_top that returns the topmost window * Fixes NB#97118, the "hang" was caused by the huge amount of notifications that we're getting pmo-trunk-r7077 --- diff --git a/src/hildon2/modest-hildon2-window-mgr.c b/src/hildon2/modest-hildon2-window-mgr.c index ffa54a8..d30af5d 100644 --- a/src/hildon2/modest-hildon2-window-mgr.c +++ b/src/hildon2/modest-hildon2-window-mgr.c @@ -77,6 +77,7 @@ static gboolean modest_hildon2_window_mgr_close_all_windows (ModestWindowMgr *se static gboolean window_can_close (ModestWindow *window); static gboolean window_has_modals (ModestWindow *window); static ModestWindow *modest_hildon2_window_mgr_show_initial_window (ModestWindowMgr *self); +static ModestWindow *modest_hildon2_window_mgr_get_current_top (ModestWindowMgr *self); typedef struct _ModestHildon2WindowMgrPrivate ModestHildon2WindowMgrPrivate; struct _ModestHildon2WindowMgrPrivate { @@ -148,6 +149,7 @@ modest_hildon2_window_mgr_class_init (ModestHildon2WindowMgrClass *klass) mgr_class->get_window_list = modest_hildon2_window_mgr_get_window_list; mgr_class->close_all_windows = modest_hildon2_window_mgr_close_all_windows; mgr_class->show_initial_window = modest_hildon2_window_mgr_show_initial_window; + mgr_class->get_current_top = modest_hildon2_window_mgr_get_current_top; g_type_class_add_private (gobject_class, sizeof(ModestHildon2WindowMgrPrivate)); @@ -336,7 +338,6 @@ modest_hildon2_window_mgr_register_window (ModestWindowMgr *self, ModestHildon2WindowMgrPrivate *priv; gint *handler_id; HildonProgram *program; - GtkWidget *current_top; HildonWindowStack *stack; gboolean nested_msg = FALSE; @@ -364,27 +365,28 @@ modest_hildon2_window_mgr_register_window (ModestWindowMgr *self, g_object_ref (window); priv->window_list = g_list_prepend (priv->window_list, window); - current_top = hildon_window_stack_peek (stack); + if (priv->current_top == NULL) + priv->current_top = (ModestWindow *) hildon_window_stack_peek (stack); nested_msg = MODEST_IS_MSG_VIEW_WINDOW (window) && MODEST_IS_MSG_VIEW_WINDOW (parent); /* Close views if they're being shown. Nevertheless we must allow nested messages */ if (!nested_msg && - (MODEST_IS_MSG_EDIT_WINDOW (current_top) || - MODEST_IS_MSG_VIEW_WINDOW (current_top))) { + (MODEST_IS_MSG_EDIT_WINDOW (priv->current_top) || + MODEST_IS_MSG_VIEW_WINDOW (priv->current_top))) { gboolean retval; /* If the current view has modal dialogs then we fail to register the new view */ - if ((current_top != NULL) && - window_has_modals (MODEST_WINDOW (current_top))) { + if ((priv->current_top != NULL) && + window_has_modals (MODEST_WINDOW (priv->current_top))) { /* Window on top but it has opened dialogs */ goto fail; } /* Close the current view */ - g_signal_emit_by_name (G_OBJECT (current_top), "delete-event", NULL, &retval); + g_signal_emit_by_name (G_OBJECT (priv->current_top), "delete-event", NULL, &retval); if (retval == TRUE) { /* Cancelled closing top window, then we fail to register */ goto fail; @@ -404,9 +406,9 @@ fail: /* Add to list. Keep a reference to the window */ priv->window_list = g_list_remove (priv->window_list, window); g_object_unref (window); - current_top = hildon_window_stack_peek (stack); - if (current_top) - gtk_window_present (GTK_WINDOW (current_top)); + priv->current_top = (ModestWindow *) hildon_window_stack_peek (stack); + if (priv->current_top) + gtk_window_present (GTK_WINDOW (priv->current_top)); return FALSE; } @@ -721,7 +723,17 @@ modest_hildon2_window_mgr_show_initial_window (ModestWindowMgr *self) return initial_window; } -gint + +static ModestWindow * +modest_hildon2_window_mgr_get_current_top (ModestWindowMgr *self) +{ + ModestHildon2WindowMgrPrivate *priv; + + priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self); + return priv->current_top; +} + +static gint find_folder_window (gconstpointer a, gconstpointer b) { diff --git a/src/modest-tny-account-store.c b/src/modest-tny-account-store.c index 4d88938..29420e6 100644 --- a/src/modest-tny-account-store.c +++ b/src/modest-tny-account-store.c @@ -1512,9 +1512,9 @@ connection_status_changed (TnyAccount *account, runnning */ if (status == TNY_CONNECTION_STATUS_CONNECTED) { const gchar *account_name; - ModestWindow *main_window; + ModestWindow *top_window; ModestTnyAccountStorePrivate *priv = NULL; - + priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE (data); /* Remove this handler */ @@ -1524,8 +1524,8 @@ connection_status_changed (TnyAccount *account, /* Perform a send receive */ account_name = modest_tny_account_get_parent_modest_account_name_for_server_account (account); - main_window = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr (), FALSE); - modest_ui_actions_do_send_receive (account_name, FALSE, FALSE, TRUE, main_window); + top_window = modest_window_mgr_get_current_top (modest_runtime_get_window_mgr ()); + modest_ui_actions_do_send_receive (account_name, FALSE, FALSE, TRUE, top_window); } } diff --git a/src/widgets/modest-hildon1-window-mgr.c b/src/widgets/modest-hildon1-window-mgr.c index a7da42e..01a2434 100644 --- a/src/widgets/modest-hildon1-window-mgr.c +++ b/src/widgets/modest-hildon1-window-mgr.c @@ -85,6 +85,7 @@ static gboolean modest_hildon1_window_mgr_find_registered_header (ModestWindowMg ModestWindow **win); static GList *modest_hildon1_window_mgr_get_window_list (ModestWindowMgr *self); static gboolean modest_hildon1_window_mgr_close_all_windows (ModestWindowMgr *self); +static ModestWindow *modest_hildon1_window_mgr_get_current_top (ModestWindowMgr *self); typedef struct _ModestHildon1WindowMgrPrivate ModestHildon1WindowMgrPrivate; struct _ModestHildon1WindowMgrPrivate { @@ -155,6 +156,7 @@ modest_hildon1_window_mgr_class_init (ModestHildon1WindowMgrClass *klass) mgr_class->find_registered_header = modest_hildon1_window_mgr_find_registered_header; mgr_class->get_window_list = modest_hildon1_window_mgr_get_window_list; mgr_class->close_all_windows = modest_hildon1_window_mgr_close_all_windows; + mgr_class->get_current_top = modest_hildon1_window_mgr_get_current_top; g_type_class_add_private (gobject_class, sizeof(ModestHildon1WindowMgrPrivate)); @@ -1025,3 +1027,12 @@ on_modal_dialog_destroy (GtkObject *object, remove_modal_from_queue (GTK_WIDGET (object), self); } +static ModestWindow* +modest_hildon1_window_mgr_get_current_top (ModestWindowMgr *self) +{ + ModestHildon1WindowMgrPrivate *priv; + + priv = MODEST_HILDON1_WINDOW_MGR_GET_PRIVATE (self); + + return priv->current_top; +} diff --git a/src/widgets/modest-window-mgr.c b/src/widgets/modest-window-mgr.c index d970434..228e036 100644 --- a/src/widgets/modest-window-mgr.c +++ b/src/widgets/modest-window-mgr.c @@ -67,6 +67,7 @@ static gboolean modest_window_mgr_find_registered_header_default (ModestWindowMg ModestWindow **win); static GList *modest_window_mgr_get_window_list_default (ModestWindowMgr *self); static ModestWindow *modest_window_mgr_show_initial_window_default (ModestWindowMgr *self); +static ModestWindow *modest_window_mgr_get_current_top_default (ModestWindowMgr *self); /* list my signals */ enum { @@ -147,6 +148,7 @@ modest_window_mgr_class_init (ModestWindowMgrClass *klass) mgr_class->find_registered_header = modest_window_mgr_find_registered_header_default; mgr_class->get_window_list = modest_window_mgr_get_window_list_default; mgr_class->show_initial_window = modest_window_mgr_show_initial_window_default; + mgr_class->get_current_top = modest_window_mgr_get_current_top_default; g_type_class_add_private (gobject_class, sizeof(ModestWindowMgrPrivate)); @@ -861,3 +863,17 @@ modest_window_mgr_show_initial_window_default (ModestWindowMgr *self) needed */ return modest_window_mgr_get_main_window (self, TRUE); } + + +ModestWindow * +modest_window_mgr_get_current_top (ModestWindowMgr *self) +{ + return MODEST_WINDOW_MGR_GET_CLASS (self)->get_current_top (self); +} + + +static ModestWindow * +modest_window_mgr_get_current_top_default (ModestWindowMgr *self) +{ + g_return_val_if_reached (NULL); +} diff --git a/src/widgets/modest-window-mgr.h b/src/widgets/modest-window-mgr.h index 2398be2..34a87ef 100644 --- a/src/widgets/modest-window-mgr.h +++ b/src/widgets/modest-window-mgr.h @@ -78,7 +78,7 @@ struct _ModestWindowMgrClass { ModestWindow **win); GList * (*get_window_list) (ModestWindowMgr *self); ModestWindow * (*show_initial_window) (ModestWindowMgr *self); - + ModestWindow * (*get_current_top) (ModestWindowMgr *self); /* Signals */ void (*window_list_empty) (ModestWindowMgr *self); }; @@ -393,6 +393,16 @@ GtkWidget * modest_window_mgr_get_msg_edit_window (ModestWindowMgr *self); **/ ModestWindow* modest_window_mgr_show_initial_window (ModestWindowMgr *self); +/** + * modest_window_mgr_get_current_top: + * @self: a #ModestWindowMgr + * + * this function returns the ModestWindow that is currently on top of all the others + * + * Returns: the topmost #ModestWindow + **/ +ModestWindow* modest_window_mgr_get_current_top (ModestWindowMgr *self); + G_END_DECLS #endif /* __MODEST_WINDOW_MGR_H__ */