-
- /* Add to list. Keep a reference to the window */
- g_object_ref (window);
- priv->window_list = g_list_prepend (priv->window_list, window);
-
- /* Listen to object destruction */
- handler_id = g_malloc0 (sizeof (gint));
- *handler_id = g_signal_connect (window, "delete-event", G_CALLBACK (on_window_destroy), self);
- g_hash_table_insert (priv->destroy_handlers, window, handler_id);
-
- /* If there is a msg view window, let the main window listen the msg-changed signal */
- if (MODEST_IS_MSG_VIEW_WINDOW(window) && priv->main_window) {
- gulong *handler;
- handler = g_malloc0 (sizeof (gulong));
- *handler = g_signal_connect (window, "msg-changed",
- G_CALLBACK (modest_main_window_on_msg_view_window_msg_changed),
- priv->main_window);
- g_hash_table_insert (priv->viewer_handlers, window, handler);
- }
-
- /* Put into fullscreen if needed */
- if (priv->fullscreen_mode)
- gtk_window_fullscreen (GTK_WINDOW (window));
-
- /* Show/hide toolbar & fullscreen */
- key = get_show_toolbar_key (G_TYPE_FROM_INSTANCE (window), priv->fullscreen_mode);
- modest_window_show_toolbar (window, modest_conf_get_bool (modest_runtime_get_conf (), key, NULL));
-}
-
-static gboolean
-on_window_destroy (ModestWindow *window,
- GdkEvent *event,
- ModestWindowMgr *self)
-{
- gint dialog_response = GTK_RESPONSE_NONE;
-
- /* Specific stuff first */
- if (MODEST_IS_MAIN_WINDOW (window)) {
- ModestWindowMgrPrivate *priv;
- priv = MODEST_WINDOW_MGR_GET_PRIVATE (self);
-
- /* If more than one window already opened */
- if (g_list_length (priv->window_list) > 1) {
-
- /* Present the window if it's not visible now */
- if (!gtk_window_has_toplevel_focus (GTK_WINDOW (window)))
- gtk_window_present (GTK_WINDOW (window));
- /* Create the confirmation dialog MSG-NOT308 */
- dialog_response = modest_platform_run_confirmation_dialog (
- GTK_WINDOW (window), _("emev_nc_close_windows"));
-
- /* 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))
- {
- GList *iter = priv->window_list;
- do {
- if (iter->data != window) {
- GList *tmp = iter->next;
- on_window_destroy (MODEST_WINDOW (iter->data),
- event,
- self);
- iter = tmp;
- } else {
- iter = g_list_next (iter);
- }
- } while (iter);
- }
- else
- {
- return TRUE;
- }
- }
- }
- else {
- if (MODEST_IS_MSG_EDIT_WINDOW (window)) {
- gboolean sent = FALSE;
- gint response = GTK_RESPONSE_ACCEPT;
- sent = modest_msg_edit_window_get_sent (MODEST_MSG_EDIT_WINDOW (window));
- /* Save currently edited message to Drafts if it was not sent */
- if (!sent && modest_msg_edit_window_is_modified (MODEST_MSG_EDIT_WINDOW (window))) {
-
- /* Raise the window if it's minimized */
- if (!gtk_window_has_toplevel_focus (GTK_WINDOW (window)))
- gtk_window_present (GTK_WINDOW (window));
-
- response =
- 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));
- }
- }
- }