X-Git-Url: http://git.maemo.org/git/?a=blobdiff_plain;f=src%2Fwidgets%2Fmodest-window-mgr.c;h=4deb1ad6fd8a4563bb55b1168de6c225ae560fdb;hb=4dfa1c7bfcc93023e02efbba4d09ab373c7c92c4;hp=6259a39f953ebf58349b2d4bc2560dc0e96012cb;hpb=e27066ce5e3bb2b6ebf8cb0cfabe517a87b7368f;p=modest diff --git a/src/widgets/modest-window-mgr.c b/src/widgets/modest-window-mgr.c index 6259a39..4deb1ad 100644 --- a/src/widgets/modest-window-mgr.c +++ b/src/widgets/modest-window-mgr.c @@ -68,6 +68,7 @@ enum { typedef struct _ModestWindowMgrPrivate ModestWindowMgrPrivate; struct _ModestWindowMgrPrivate { GList *window_list; + guint banner_counter; ModestWindow *main_window; @@ -194,6 +195,7 @@ modest_window_mgr_init (ModestWindowMgr *obj) priv = MODEST_WINDOW_MGR_GET_PRIVATE(obj); priv->window_list = NULL; + priv->banner_counter = 0; priv->main_window = NULL; priv->fullscreen_mode = FALSE; @@ -671,9 +673,8 @@ on_window_destroy (ModestWindow *window, /* If the user wants to close all the windows */ if ((dialog_response == GTK_RESPONSE_OK) - || (dialog_response == GTK_RESPONSE_ACCEPT) - || (dialog_response == GTK_RESPONSE_YES)) - { + || (dialog_response == GTK_RESPONSE_ACCEPT) + || (dialog_response == GTK_RESPONSE_YES)) { GList *iter = priv->window_list; do { if (iter->data != window) { @@ -686,11 +687,9 @@ on_window_destroy (ModestWindow *window, iter = g_list_next (iter); } } while (iter); - } - else - { - return TRUE; - } + } else { + return TRUE; + } } } else { @@ -709,8 +708,9 @@ on_window_destroy (ModestWindow *window, modest_platform_run_confirmation_dialog (GTK_WINDOW (window), _("mcen_nc_no_email_message_modified_save_changes")); /* Save to drafts */ - if (response != GTK_RESPONSE_CANCEL) - modest_ui_actions_on_save_to_drafts (NULL, MODEST_MSG_EDIT_WINDOW (window)); + if (response == GTK_RESPONSE_OK) + if (!modest_ui_actions_on_save_to_drafts (NULL, MODEST_MSG_EDIT_WINDOW (window))) + return TRUE; } } } @@ -740,6 +740,7 @@ modest_window_mgr_unregister_window (ModestWindowMgr *self, GList *win; ModestWindowMgrPrivate *priv; gulong *tmp, handler_id; + GSList* pending_ops = NULL; g_return_if_fail (MODEST_IS_WINDOW_MGR (self)); g_return_if_fail (MODEST_IS_WINDOW (window)); @@ -790,23 +791,20 @@ modest_window_mgr_unregister_window (ModestWindowMgr *self, g_hash_table_remove (priv->destroy_handlers, window); /* cancel open and receive operations */ - if (MODEST_IS_MSG_VIEW_WINDOW (window)) { + pending_ops = modest_mail_operation_queue_get_by_source (modest_runtime_get_mail_operation_queue (), + G_OBJECT (window)); + while (pending_ops != NULL) { ModestMailOperationTypeOperation type; - GSList* pending_ops = NULL; GSList* tmp_list = NULL; - pending_ops = modest_mail_operation_queue_get_by_source ( - modest_runtime_get_mail_operation_queue (), - G_OBJECT (window)); - while (pending_ops != NULL) { - type = modest_mail_operation_get_type_operation (MODEST_MAIL_OPERATION (pending_ops->data)); - if (type == MODEST_MAIL_OPERATION_TYPE_RECEIVE || type == MODEST_MAIL_OPERATION_TYPE_OPEN) { - modest_mail_operation_cancel (pending_ops->data); - } - g_object_unref (G_OBJECT (pending_ops->data)); - tmp_list = pending_ops; - pending_ops = g_slist_next (pending_ops); - g_slist_free_1 (tmp_list); + + type = modest_mail_operation_get_type_operation (MODEST_MAIL_OPERATION (pending_ops->data)); + if (type == MODEST_MAIL_OPERATION_TYPE_RECEIVE || type == MODEST_MAIL_OPERATION_TYPE_OPEN) { + modest_mail_operation_cancel (pending_ops->data); } + g_object_unref (G_OBJECT (pending_ops->data)); + tmp_list = pending_ops; + pending_ops = g_slist_next (pending_ops); + g_slist_free_1 (tmp_list); } /* Disconnect the "delete-event" handler, we won't need it anymore */ @@ -819,7 +817,7 @@ modest_window_mgr_unregister_window (ModestWindowMgr *self, gtk_widget_destroy (win->data); /* If there are no more windows registered emit the signal */ - if (priv->window_list == NULL) + if (priv->window_list == NULL && priv->banner_counter == 0) g_signal_emit (self, signals[WINDOW_LIST_EMPTY_SIGNAL], 0); } @@ -981,6 +979,11 @@ modest_window_mgr_set_modal (ModestWindowMgr *self, g_mutex_unlock (priv->queue_lock); if (!old_modal) { + /* make us transient wrt the main window then */ + ModestWindow *main_win = modest_window_mgr_get_main_window (self, FALSE); + if (GTK_WINDOW(main_win) != window) /* they should not be the same */ + gtk_window_set_transient_for (window, GTK_WINDOW(main_win)); + gtk_window_set_modal (window, TRUE); } else { /* un-modalize the old one; the one on top should be the @@ -1181,7 +1184,7 @@ modest_window_mgr_num_windows (ModestWindowMgr *self) if (priv->window_list) num_windows = g_list_length (priv->window_list); - return num_windows; + return num_windows + priv->banner_counter; } GtkWidget * @@ -1226,3 +1229,29 @@ modest_window_mgr_get_msg_view_window (ModestWindowMgr *self) return result; } +void +modest_window_mgr_register_banner (ModestWindowMgr *self) +{ + ModestWindowMgrPrivate *priv; + + g_return_if_fail (MODEST_IS_WINDOW_MGR (self)); + priv = MODEST_WINDOW_MGR_GET_PRIVATE (self); + + priv->banner_counter++; + +} + +void +modest_window_mgr_unregister_banner (ModestWindowMgr *self) +{ + ModestWindowMgrPrivate *priv; + + g_return_if_fail (MODEST_IS_WINDOW_MGR (self)); + priv = MODEST_WINDOW_MGR_GET_PRIVATE (self); + + priv->banner_counter--; + if (priv->window_list == NULL && priv->banner_counter == 0) { + g_signal_emit (self, signals[WINDOW_LIST_EMPTY_SIGNAL], 0); + } + +}