Removed some dependencies with main window
authorSergio Villar Senin <svillar@igalia.com>
Thu, 29 Jan 2009 11:14:39 +0000 (11:14 +0000)
committerSergio Villar Senin <svillar@igalia.com>
Thu, 29 Jan 2009 11:14:39 +0000 (11:14 +0000)
pmo-trunk-r7344

src/dbus_api/modest-dbus-callbacks.c
src/hildon2/modest-folder-window.c
src/hildon2/modest-msg-view-window.c
src/modest-tny-account-store.c
src/modest-ui-actions.c
src/modest-ui-dimming-rules.c

index d8d2abb..8f037cc 100644 (file)
@@ -611,19 +611,20 @@ on_open_message_performer (gboolean canceled,
 static gboolean
 on_idle_open_message_performer (gpointer user_data)
 {
 static gboolean
 on_idle_open_message_performer (gpointer user_data)
 {
-       ModestWindow *main_win = NULL;
+       ModestWindow *top_win = NULL;
        OpenMsgPerformerInfo *info = (OpenMsgPerformerInfo *) user_data;
 
        OpenMsgPerformerInfo *info = (OpenMsgPerformerInfo *) user_data;
 
-       main_win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr(),
-                                                     FALSE); /* don't create */
+       top_win = modest_window_mgr_get_current_top (modest_runtime_get_window_mgr());
 
        /* Lock before the call as we're in an idle handler */
        gdk_threads_enter ();
        if (info->connect) {
 
        /* Lock before the call as we're in an idle handler */
        gdk_threads_enter ();
        if (info->connect) {
-               modest_platform_connect_and_perform (GTK_WINDOW (main_win), TRUE, info->account, 
+               modest_platform_connect_and_perform (GTK_WINDOW (top_win), TRUE, 
+                                                    info->account, 
                                                     on_open_message_performer, info);
        } else {
                                                     on_open_message_performer, info);
        } else {
-               on_open_message_performer (FALSE, NULL, GTK_WINDOW (main_win), info->account, info);
+               on_open_message_performer (FALSE, NULL, GTK_WINDOW (top_win), 
+                                          info->account, info);
        }
        gdk_threads_leave ();
 
        }
        gdk_threads_leave ();
 
@@ -718,14 +719,13 @@ on_remove_msgs_finished (ModestMailOperation *mail_op,
                         gpointer user_data)
 {      
        TnyHeader *header;
                         gpointer user_data)
 {      
        TnyHeader *header;
-       ModestWindow *main_win = NULL, *msg_view = NULL;
+       ModestWindow *top_win = NULL, *msg_view = NULL;
 
        header = (TnyHeader *) user_data;
 
        /* Get the main window if exists */
 
        header = (TnyHeader *) user_data;
 
        /* Get the main window if exists */
-       main_win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr(),
-                                                     FALSE); /* don't create */
-       if (!main_win) {
+       top_win = modest_window_mgr_get_current_top (modest_runtime_get_window_mgr());
+       if (!top_win) {
                g_object_unref (header);
                return;
        }
                g_object_unref (header);
                return;
        }
@@ -755,7 +755,7 @@ thread_prepare_delete_message (gpointer userdata)
        char *uri;
        gchar *uid = NULL;
        ModestMailOperation *mail_op = NULL;
        char *uri;
        gchar *uid = NULL;
        ModestMailOperation *mail_op = NULL;
-       ModestWindow *main_win = NULL;
+       ModestWindow *top_win = NULL;
 
        uri = (char *) userdata;
 
 
        uri = (char *) userdata;
 
@@ -769,10 +769,9 @@ thread_prepare_delete_message (gpointer userdata)
                g_free (uri);
                return FALSE; 
        }
                g_free (uri);
                return FALSE; 
        }
-       
-       main_win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr(),
-                                                     FALSE); /* don't create */
-       
+
+       top_win = modest_window_mgr_get_current_top (modest_runtime_get_window_mgr());
+
        folder = tny_msg_get_folder (msg);
        if (!folder) {
                g_warning ("%s: Could not find folder (uri:'%s')", __FUNCTION__, uri);
        folder = tny_msg_get_folder (msg);
        if (!folder) {
                g_warning ("%s: Could not find folder (uri:'%s')", __FUNCTION__, uri);
@@ -829,7 +828,7 @@ thread_prepare_delete_message (gpointer userdata)
         * the code below is or does Gtk+ code */
        gdk_threads_enter (); /* CHECKED */
 
         * the code below is or does Gtk+ code */
        gdk_threads_enter (); /* CHECKED */
 
-       mail_op = modest_mail_operation_new (main_win ? G_OBJECT(main_win) : NULL);
+       mail_op = modest_mail_operation_new (top_win ? G_OBJECT(top_win) : NULL);
        modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
 
        g_signal_connect (G_OBJECT (mail_op),
        modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (), mail_op);
 
        g_signal_connect (G_OBJECT (mail_op),
index 1e02185..05be38f 100644 (file)
@@ -380,6 +380,7 @@ static void setup_menu (ModestFolderWindow *self)
                                           NULL,
                                           APP_MENU_CALLBACK (modest_ui_actions_on_send_receive),
                                           MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_send_receive));
                                           NULL,
                                           APP_MENU_CALLBACK (modest_ui_actions_on_send_receive),
                                           MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_send_receive));
+
        modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_outbox_cancelsend"), NULL,
                                           APP_MENU_CALLBACK (modest_ui_actions_cancel_send),
                                           MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_cancel_sending_all));
        modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_outbox_cancelsend"), NULL,
                                           APP_MENU_CALLBACK (modest_ui_actions_cancel_send),
                                           MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_cancel_sending_all));
index 66df0c9..b2468ba 100644 (file)
@@ -3129,21 +3129,21 @@ setup_menu (ModestMsgViewWindow *self)
        modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_inbox_forward"), "<Control>d",
                                           APP_MENU_CALLBACK (modest_ui_actions_on_forward),
                                           MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_reply_msg));
        modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_inbox_forward"), "<Control>d",
                                           APP_MENU_CALLBACK (modest_ui_actions_on_forward),
                                           MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_reply_msg));
-       
+
        modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_inbox_mark_as_read"), NULL,
                                           APP_MENU_CALLBACK (modest_ui_actions_on_mark_as_read),
                                           MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_mark_as_read_msg_in_view));
        modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_inbox_mark_as_unread"), NULL,
                                           APP_MENU_CALLBACK (modest_ui_actions_on_mark_as_unread),
                                           MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_mark_as_unread_msg_in_view));
        modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_inbox_mark_as_read"), NULL,
                                           APP_MENU_CALLBACK (modest_ui_actions_on_mark_as_read),
                                           MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_mark_as_read_msg_in_view));
        modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_inbox_mark_as_unread"), NULL,
                                           APP_MENU_CALLBACK (modest_ui_actions_on_mark_as_unread),
                                           MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_mark_as_unread_msg_in_view));
-       
+
        modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_viewer_save_attachments"), NULL,
                                           APP_MENU_CALLBACK (modest_ui_actions_save_attachments),
                                           MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_save_attachments));
        modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_inbox_remove_attachments"), NULL,
                                           APP_MENU_CALLBACK (modest_ui_actions_remove_attachments),
                                           MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_remove_attachments));
        modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_viewer_save_attachments"), NULL,
                                           APP_MENU_CALLBACK (modest_ui_actions_save_attachments),
                                           MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_save_attachments));
        modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_inbox_remove_attachments"), NULL,
                                           APP_MENU_CALLBACK (modest_ui_actions_remove_attachments),
                                           MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_remove_attachments));
-       
+
        modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_new_message"), "<Control>n",
                                           APP_MENU_CALLBACK (modest_ui_actions_on_new_msg),
                                           MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_new_msg));
        modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_new_message"), "<Control>n",
                                           APP_MENU_CALLBACK (modest_ui_actions_on_new_msg),
                                           MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_new_msg));
index af2598f..47e6b81 100644 (file)
@@ -493,11 +493,8 @@ on_account_changed (ModestAccountMgr *acc_mgr,
 static void 
 show_password_warning_only (const gchar *msg)
 {
 static void 
 show_password_warning_only (const gchar *msg)
 {
-       ModestWindow *main_window = 
-               modest_window_mgr_get_main_window (modest_runtime_get_window_mgr (), FALSE); /* don't create */
-       
        /* Show an explanatory temporary banner: */
        /* Show an explanatory temporary banner: */
-       if (main_window) 
+       if (modest_window_mgr_get_num_windows (modest_runtime_get_window_mgr ()))
                modest_platform_information_banner (NULL, NULL, msg);
 }
 
                modest_platform_information_banner (NULL, NULL, msg);
 }
 
@@ -584,10 +581,10 @@ get_password (TnyAccount *account, const gchar * prompt_not_used, gboolean *canc
                           __FUNCTION__, server_account_name ? server_account_name : "<NULL>");
                if (cancel)
                        *cancel = TRUE;
                           __FUNCTION__, server_account_name ? server_account_name : "<NULL>");
                if (cancel)
                        *cancel = TRUE;
-               
+
                return NULL;
        }
                return NULL;
        }
-       
+
        /* This hash map stores passwords, including passwords that are not stored in gconf. */
        /* Is it in the hash? if it's already there, it must be wrong... */
        pwd_ptr = (gpointer)&pwd; /* pwd_ptr so the compiler does not complained about
        /* This hash map stores passwords, including passwords that are not stored in gconf. */
        /* Is it in the hash? if it's already there, it must be wrong... */
        pwd_ptr = (gpointer)&pwd; /* pwd_ptr so the compiler does not complained about
@@ -600,7 +597,7 @@ get_password (TnyAccount *account, const gchar * prompt_not_used, gboolean *canc
        MODEST_DEBUG_BLOCK(
                g_debug ("%s: Already asked = %d\n", __FUNCTION__, already_asked);
        );
        MODEST_DEBUG_BLOCK(
                g_debug ("%s: Already asked = %d\n", __FUNCTION__, already_asked);
        );
-               
+
        /* If the password is not already there, try ModestConf */
        if (!already_asked) {
                pwd  = modest_account_mgr_get_server_account_password (priv->account_mgr,
        /* If the password is not already there, try ModestConf */
        if (!already_asked) {
                pwd  = modest_account_mgr_get_server_account_password (priv->account_mgr,
@@ -657,18 +654,18 @@ get_password (TnyAccount *account, const gchar * prompt_not_used, gboolean *canc
                if (settings_have_password) {
                        /* The password must be wrong, so show the account settings dialog so it can be corrected: */
                        show_wrong_password_dialog (account);
                if (settings_have_password) {
                        /* The password must be wrong, so show the account settings dialog so it can be corrected: */
                        show_wrong_password_dialog (account);
-                       
+
                        if (cancel)
                                *cancel = TRUE;
                        if (cancel)
                                *cancel = TRUE;
-                               
+
                        return NULL;
                }
                        return NULL;
                }
-       
+
                /* we don't have it yet. Get the password from the user */
                const gchar* account_id = tny_account_get_id (account);
                gboolean remember = FALSE;
                pwd = NULL;
                /* we don't have it yet. Get the password from the user */
                const gchar* account_id = tny_account_get_id (account);
                gboolean remember = FALSE;
                pwd = NULL;
-               
+
                if (already_asked) {
                        const gchar *msg;
                        gboolean username_known = 
                if (already_asked) {
                        const gchar *msg;
                        gboolean username_known = 
index b998952..aae883c 100644 (file)
@@ -5805,14 +5805,15 @@ modest_ui_actions_on_move_to (GtkAction *action,
 gboolean 
 modest_ui_actions_on_edit_mode_move_to (ModestWindow *win)
 {
 gboolean 
 modest_ui_actions_on_edit_mode_move_to (ModestWindow *win)
 {
-       GtkWidget *dialog = NULL, *folder_view = NULL;
-       ModestMainWindow *main_window;
+       GtkWidget *dialog = NULL;
        MoveToInfo *helper = NULL;
        TnyList *list_to_move;
 
        g_return_val_if_fail (MODEST_IS_WINDOW (win), FALSE);
 
        MoveToInfo *helper = NULL;
        TnyList *list_to_move;
 
        g_return_val_if_fail (MODEST_IS_WINDOW (win), FALSE);
 
+#ifndef MODEST_TOOLKIT_HILDON2
        /* Get the main window if exists */
        /* Get the main window if exists */
+       ModestMainWindow *main_window;
        if (MODEST_IS_MAIN_WINDOW (win))
                main_window = MODEST_MAIN_WINDOW (win);
        else
        if (MODEST_IS_MAIN_WINDOW (win))
                main_window = MODEST_MAIN_WINDOW (win);
        else
@@ -5826,6 +5827,7 @@ modest_ui_actions_on_edit_mode_move_to (ModestWindow *win)
                                                                   MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW);
        else
                folder_view = NULL;
                                                                   MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW);
        else
                folder_view = NULL;
+#endif
 
        list_to_move = modest_platform_get_list_to_move (MODEST_WINDOW (win));
 
 
        list_to_move = modest_platform_get_list_to_move (MODEST_WINDOW (win));
 
@@ -5838,14 +5840,14 @@ modest_ui_actions_on_edit_mode_move_to (ModestWindow *win)
        }
 
        /* Create and run the dialog */
        }
 
        /* Create and run the dialog */
-       dialog = create_move_to_dialog (GTK_WINDOW (win), folder_view);
+       dialog = create_move_to_dialog (GTK_WINDOW (win), NULL);
        modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), 
                                     GTK_WINDOW (dialog), 
                                     (GtkWindow *) win);
 
        /* Create helper */
        helper = g_slice_new0 (MoveToInfo);
        modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), 
                                     GTK_WINDOW (dialog), 
                                     (GtkWindow *) win);
 
        /* Create helper */
        helper = g_slice_new0 (MoveToInfo);
-       helper->list = modest_platform_get_list_to_move (MODEST_WINDOW (win));
+       helper->list = list_to_move;
        helper->win = win;
 
        /* Listen to response signal */
        helper->win = win;
 
        /* Listen to response signal */
@@ -6359,6 +6361,8 @@ modest_ui_actions_on_send_queue_status_changed (ModestTnySendQueue *send_queue,
        TnyFolderStore *selected_folder = NULL;
        TnyFolderType folder_type;
 
        TnyFolderStore *selected_folder = NULL;
        TnyFolderType folder_type;
 
+
+       /* TODO: this does not work in Fremantle */
        mgr = modest_runtime_get_window_mgr ();
        main_window = MODEST_MAIN_WINDOW (modest_window_mgr_get_main_window (mgr,
                                                                             FALSE));/* don't create */
        mgr = modest_runtime_get_window_mgr ();
        main_window = MODEST_MAIN_WINDOW (modest_window_mgr_get_main_window (mgr,
                                                                             FALSE));/* don't create */
index 2857cf7..143a6f9 100644 (file)
@@ -2903,12 +2903,12 @@ _msgs_send_in_progress (void)
        cache_mgr = modest_runtime_get_cache_mgr ();
        send_queue_cache = modest_cache_mgr_get_cache (cache_mgr,
                                                       MODEST_CACHE_MGR_CACHE_TYPE_SEND_QUEUE);
        cache_mgr = modest_runtime_get_cache_mgr ();
        send_queue_cache = modest_cache_mgr_get_cache (cache_mgr,
                                                       MODEST_CACHE_MGR_CACHE_TYPE_SEND_QUEUE);
-       
+
        g_hash_table_foreach (send_queue_cache, (GHFunc) fill_list_of_caches, &send_queues);
        g_hash_table_foreach (send_queue_cache, (GHFunc) fill_list_of_caches, &send_queues);
-               
+
        for (node = send_queues; node != NULL && !found; node = g_slist_next (node)) {
                send_queue = MODEST_TNY_SEND_QUEUE (node->data);
        for (node = send_queues; node != NULL && !found; node = g_slist_next (node)) {
                send_queue = MODEST_TNY_SEND_QUEUE (node->data);
-               
+
                /* Check if msg uid is being processed inside send queue */
                if (modest_tny_send_queue_sending_in_progress (send_queue)) {
                        found = TRUE;
                /* Check if msg uid is being processed inside send queue */
                if (modest_tny_send_queue_sending_in_progress (send_queue)) {
                        found = TRUE;