X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fwidgets%2Fmodest-window-mgr.c;h=a7d8a241011db7199cb215d7912945ea05155cf3;hb=9da610e098595e62de5d0085b3c4fe53ba135dff;hp=1a27e00875a2cddf0d9804dd1f89095278e9e515;hpb=76380df99326d051264ab09a5e6ea192076bd4a9;p=modest diff --git a/src/widgets/modest-window-mgr.c b/src/widgets/modest-window-mgr.c index 1a27e00..a7d8a24 100644 --- a/src/widgets/modest-window-mgr.c +++ b/src/widgets/modest-window-mgr.c @@ -76,6 +76,7 @@ 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); static gboolean modest_window_mgr_screen_is_on_default (ModestWindowMgr *self); +static ModestWindow *modest_window_mgr_get_folder_window_default (ModestWindowMgr *self); static void modest_window_mgr_create_caches_default (ModestWindowMgr *self); static void modest_window_mgr_on_queue_changed (ModestMailOperationQueue *queue, ModestMailOperation *mail_op, @@ -85,6 +86,7 @@ static void on_mail_operation_started (ModestMailOperation *mail_op, gpointer user_data); static void on_mail_operation_finished (ModestMailOperation *mail_op, gpointer user_data); +static gboolean modest_window_mgr_close_all_but_initial_default (ModestWindowMgr *self); /* list my signals */ enum { @@ -177,6 +179,8 @@ modest_window_mgr_class_init (ModestWindowMgrClass *klass) mgr_class->get_current_top = modest_window_mgr_get_current_top_default; mgr_class->screen_is_on = modest_window_mgr_screen_is_on_default; mgr_class->create_caches = modest_window_mgr_create_caches_default; + mgr_class->close_all_but_initial = modest_window_mgr_close_all_but_initial_default; + mgr_class->get_folder_window = modest_window_mgr_get_folder_window_default; g_type_class_add_private (gobject_class, sizeof(ModestWindowMgrPrivate)); @@ -441,11 +445,12 @@ modest_window_mgr_register_help_id (ModestWindowMgr *self, GtkWindow *win, const /* we don't need 'self', but for API consistency... */ g_return_if_fail (self && MODEST_IS_WINDOW_MGR(self)); - g_return_if_fail (win && GTK_IS_WINDOW(win)); g_return_if_fail (help_id); - - g_object_set_data_full (G_OBJECT(win), MODEST_WINDOW_HELP_ID_PARAM, - g_strdup(help_id), g_free); + + if (GTK_IS_WINDOW (win)) { + g_object_set_data_full (G_OBJECT(win), MODEST_WINDOW_HELP_ID_PARAM, + g_strdup(help_id), g_free); + } } @@ -562,7 +567,7 @@ modest_window_mgr_register_window_default (ModestWindowMgr *self, ModestWindowMgrPrivate *priv; g_return_val_if_fail (MODEST_IS_WINDOW_MGR (self), FALSE); - g_return_val_if_fail (GTK_IS_WINDOW (window), FALSE); + g_return_val_if_fail (MODEST_IS_WINDOW (window), FALSE); priv = MODEST_WINDOW_MGR_GET_PRIVATE (self); @@ -574,18 +579,6 @@ modest_window_mgr_register_window_default (ModestWindowMgr *self, self); } -#ifndef MODEST_TOOLKIT_HILDON2 - /* Check that it's not a second main window */ - if (MODEST_IS_MAIN_WINDOW (window)) { - if (priv->main_window) { - g_warning ("%s: trying to register a second main window", - __FUNCTION__); - return FALSE; - } else { - priv->main_window = window; - } - } -#endif /* remove from the list of pre-registered uids */ if (MODEST_IS_MSG_VIEW_WINDOW(window)) { @@ -706,17 +699,7 @@ modest_window_mgr_get_main_window (ModestWindowMgr *self, gboolean show) static ModestWindow* modest_window_mgr_get_main_window_default (ModestWindowMgr *self, gboolean show) { - ModestWindowMgrPrivate *priv; - - g_return_val_if_fail (MODEST_IS_WINDOW_MGR (self), NULL); - - priv = MODEST_WINDOW_MGR_GET_PRIVATE (self); - if (priv->main_window) - return priv->main_window; - - if (show) - return modest_main_window_new (); - else return NULL; + return NULL; } @@ -1167,3 +1150,79 @@ modest_window_mgr_has_progress_operation_on_account (ModestWindowMgr *self, return account_ops; } +/* 'Protected method' must be only called by children */ +gboolean +_modest_window_mgr_close_active_modals (ModestWindowMgr *self) +{ + GtkWidget *modal; + + /* Exit if there are no windows */ + if (!modest_window_mgr_get_num_windows (self)) { + g_warning ("%s: there are no windows to close", __FUNCTION__); + return FALSE; + } + + /* Check that there is no active modal dialog */ + modal = (GtkWidget *) modest_window_mgr_get_modal (self); + while (modal && GTK_IS_DIALOG (modal)) { + GtkWidget *parent; + +#if defined(MODEST_TOOLKIT_HILDON2) || defined(MODEST_TOOLKIT_HILDON) +#include + /* If it's a hildon note then don't try to close it as + this is the default behaviour of WM, delete event + is not issued for this kind of notes as we want the + user to always click on a button */ + if (HILDON_IS_NOTE (modal)) { + gtk_window_present (GTK_WINDOW (modal)); + return FALSE; + } +#endif + + /* Get the parent */ + parent = (GtkWidget *) gtk_window_get_transient_for (GTK_WINDOW (modal)); + + /* Try to close it */ + gtk_dialog_response (GTK_DIALOG (modal), GTK_RESPONSE_DELETE_EVENT); + + /* Maybe the dialog was not closed, because a close + confirmation dialog for example. Then ignore the + register process */ + if (GTK_IS_WINDOW (modal)) { + gtk_window_present (GTK_WINDOW (modal)); + return FALSE; + } + + /* Get next modal */ + modal = parent; + } + return TRUE; +} + +gboolean +modest_window_mgr_close_all_but_initial (ModestWindowMgr *self) +{ + return MODEST_WINDOW_MGR_GET_CLASS (self)->close_all_but_initial (self); +} + +static gboolean +modest_window_mgr_close_all_but_initial_default (ModestWindowMgr *self) +{ + /* Empty default implementation */ + return FALSE; +} + +ModestWindow * +modest_window_mgr_get_folder_window (ModestWindowMgr *self) +{ + return MODEST_WINDOW_MGR_GET_CLASS (self)->get_folder_window (self); +} + +static ModestWindow * +modest_window_mgr_get_folder_window_default (ModestWindowMgr *self) +{ + /* Default implementation returns NULL always */ + + return NULL; +} +