* Changes in the autotools stuff affecting a lot of platform dependent
[modest] / src / widgets / modest-window-mgr.c
index 741b5c5..fb88abf 100644 (file)
@@ -255,9 +255,9 @@ modest_window_mgr_finalize (GObject *obj)
                GList *iter = priv->window_list;
                /* unregister pending windows */
                while (iter) {
-                       modest_window_mgr_unregister_window (MODEST_WINDOW_MGR (obj), 
-                                                            MODEST_WINDOW (iter->data));
+                       ModestWindow *window = (ModestWindow *) iter->data;
                        iter = g_list_next (iter);
+                       modest_window_mgr_unregister_window (MODEST_WINDOW_MGR (obj), window);
                }
                g_list_free (priv->window_list);
                priv->window_list = NULL;
@@ -330,7 +330,7 @@ remove_uid (GSList *list, const gchar *uid)
        GSList *cursor = list, *start = list;
        
        if (!uid)
-               return FALSE;
+               return list;
        
        while (cursor) {
                GSList *next = g_slist_next (cursor);
@@ -425,37 +425,11 @@ modest_window_mgr_register_help_id (ModestWindowMgr *self, GtkWindow *win, const
 const gchar*
 modest_window_mgr_get_help_id (ModestWindowMgr *self, GtkWindow *win)
 {
-       const gchar* help_id = NULL;
-
        /* we don't need 'self', but for API consistency... */
-       g_return_val_if_fail (self && MODEST_IS_WINDOW_MGR(self), NULL);
-       
+       g_return_val_if_fail (self && MODEST_IS_WINDOW_MGR (self), NULL);
        g_return_val_if_fail (win, NULL);
-       g_return_val_if_fail (GTK_IS_WINDOW(win), NULL);
-       
-       if (MODEST_IS_MAIN_WINDOW (win)) {
-               GtkWidget *folder_view;
-               TnyFolderStore *folder_store;
-               
-               /* Get selected folder */
-               folder_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (win),
-                                                                  MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW);
-               folder_store = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
-
-               /* Switch help_id */
-               if (folder_store && TNY_IS_FOLDER (folder_store)) {
-                       help_id = modest_tny_folder_get_help_id (TNY_FOLDER (folder_store));
-                       if (!help_id)
-                               g_warning ("%s: BUG: did not get a valid help_id", __FUNCTION__);
-               }
-               if (folder_store)
-                       g_object_unref (folder_store);
-       }
 
-       if (!help_id)
-               help_id = g_object_get_data (G_OBJECT(win), MODEST_WINDOW_HELP_ID_PARAM);
-               
-       return help_id;
+       return g_object_get_data (G_OBJECT(win), MODEST_WINDOW_HELP_ID_PARAM);
 }
 
 static gint
@@ -572,7 +546,7 @@ get_show_toolbar_key (GType window_type,
        return key;
 }
 
-#ifdef MODEST_PLATFORM_MAEMO
+#ifndef MODEST_TOOLKIT_GTK
 static void
 on_window_is_topmost (GObject    *gobject,
                      GParamSpec *arg1,
@@ -698,7 +672,7 @@ modest_window_mgr_register_window (ModestWindowMgr *self,
        /* Listen to window state changes. Unfortunately
           window-state-event does not properly work for the Maemo
           version, so we need to use is-topmost and the ifdef */
-#ifdef MODEST_PLATFORM_MAEMO
+#ifndef MODEST_TOOLKIT_GTK
        priv->window_state_uids = 
                modest_signal_mgr_connect (priv->window_state_uids, 
                                           G_OBJECT (window), 
@@ -779,8 +753,10 @@ on_window_destroy (ModestWindow *window,
                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)))
+                       if (!gtk_window_has_toplevel_focus (GTK_WINDOW (window))) {
                                gtk_window_present (GTK_WINDOW (window));
+                               priv->current_top = window;
+                       }
                        /* Create the confirmation dialog MSG-NOT308 */
                        dialog_response = modest_platform_run_confirmation_dialog (
                                        GTK_WINDOW (window), _("emev_nc_close_windows"));
@@ -841,7 +817,7 @@ on_window_destroy (ModestWindow *window,
                }
                /* Unregister window */
                modest_window_mgr_unregister_window (self, window);
-               no_propagate = FALSE;
+               no_propagate = TRUE;
        }
 
        return no_propagate;
@@ -913,6 +889,7 @@ modest_window_mgr_unregister_window (ModestWindowMgr *self,
        priv->window_list = g_list_remove_link (priv->window_list, win);
        tmp = g_hash_table_lookup (priv->destroy_handlers, window);
        handler_id = *tmp;
+
        g_hash_table_remove (priv->destroy_handlers, window);
 
        /* cancel open and receive operations */
@@ -927,7 +904,7 @@ modest_window_mgr_unregister_window (ModestWindowMgr *self,
 
        /* Disconnect the "window-state-event" handler, we won't need it anymore */
        if (priv->window_state_uids) {
-#ifdef MODEST_PLATFORM_MAEMO
+#ifndef MODEST_TOOLKIT_GTK
                priv->window_state_uids = 
                        modest_signal_mgr_disconnect (priv->window_state_uids, 
                                                      G_OBJECT (window), 
@@ -947,7 +924,9 @@ modest_window_mgr_unregister_window (ModestWindowMgr *self,
        modest_window_disconnect_signals (window);
        
        /* Destroy the window */
+       g_object_unref (win->data);
        gtk_widget_destroy (win->data);
+       g_list_free (win);
        
        /* If there are no more windows registered emit the signal */
        if (modest_window_mgr_num_windows (self) == 0)
@@ -1258,6 +1237,10 @@ idle_top_modal (gpointer data)
        if (topmost) {
                gdk_threads_enter ();
                gtk_window_present (topmost);
+               /* It seems that the window looses modality if some
+                  other is shown on top of it after set_transient_for
+                  and set_parent */
+               gtk_window_set_modal (topmost, TRUE);
                gdk_threads_leave ();
        }