Updated the account window management to the Fremantle style
authorSergio Villar Senin <svillar@igalia.com>
Wed, 26 Nov 2008 16:35:03 +0000 (16:35 +0000)
committerSergio Villar Senin <svillar@igalia.com>
Wed, 26 Nov 2008 16:35:03 +0000 (16:35 +0000)
pmo-drop-split-view-r6426

16 files changed:
src/hildon2/modest-default-account-settings-dialog.c
src/hildon2/modest-hildon2-window-mgr.c
src/hildon2/modest-hildon2-window-mgr.h
src/hildon2/modest-platform.c
src/maemo/modest-platform.c
src/modest-mail-operation-queue.c
src/modest-main.c
src/modest-platform.h
src/modest-runtime.c
src/modest-runtime.h
src/modest-tny-account-store.c
src/modest-tny-account-store.h
src/widgets/modest-folder-view.c
src/widgets/modest-hildon1-window-mgr.c
src/widgets/modest-window-mgr.c
src/widgets/modest-window-mgr.h

index 857d8f6..95317cf 100644 (file)
@@ -1030,7 +1030,7 @@ on_response (GtkDialog *wizard_dialog,
                                        transport_settings = modest_account_settings_get_transport_settings (priv->settings);
                                        store_account_name = modest_server_account_settings_get_account_name (store_settings);
                                        transport_account_name = modest_server_account_settings_get_account_name (transport_settings);
-                                       
+
                                        if (store_account_name) {
                                                modest_account_mgr_notify_account_update (priv->account_manager, 
                                                                                          store_account_name);
@@ -1041,7 +1041,7 @@ on_response (GtkDialog *wizard_dialog,
                                        }
                                        g_object_unref (store_settings);
                                        g_object_unref (transport_settings);
-                                       
+
                                        modest_platform_information_banner(NULL, NULL, _("mcen_ib_advsetup_settings_saved"));
                                }
                        } else {
index d79fcc4..85c74d8 100644 (file)
@@ -166,10 +166,10 @@ modest_hildon2_window_mgr_instance_init (ModestHildon2WindowMgr *obj)
 
        priv->modal_windows = g_queue_new ();
        priv->queue_lock = g_mutex_new ();
-       
+
        /* Could not initialize it from gconf, singletons are not
           ready yet */
-       priv->destroy_handlers = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free);   
+       priv->destroy_handlers = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free);
        priv->viewer_handlers = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free);
 
        priv->closing_time = 0;
@@ -218,11 +218,10 @@ modest_hildon2_window_mgr_finalize (GObject *obj)
                g_mutex_unlock (priv->queue_lock);
        }
        g_mutex_free (priv->queue_lock);
-       
+
        /* Do not unref priv->main_window because it does not hold a
           new reference */
 
-       
        G_OBJECT_CLASS(parent_class)->finalize (obj);
 }
 
@@ -353,10 +352,10 @@ modest_hildon2_window_mgr_register_window (ModestWindowMgr *self,
                gtk_window_present (GTK_WINDOW (win));
                return TRUE;
        }
-       
+
        if (!MODEST_WINDOW_MGR_CLASS (parent_class)->register_window (self, window, parent))
                goto fail;
-       
+
        /* Add to list. Keep a reference to the window */
        g_object_ref (window);
        priv->window_list = g_list_prepend (priv->window_list, window);
@@ -368,7 +367,7 @@ modest_hildon2_window_mgr_register_window (ModestWindowMgr *self,
        if (!parent || ((GtkWidget *) parent != current_top)) {
                gboolean close_canceled = FALSE;
 
-               if ((current_top != NULL) && 
+               if ((current_top != NULL) &&
                    window_has_modals (MODEST_WINDOW (current_top))) {
                        /* Window on top but it has opened dialogs */
                        goto fail;
@@ -392,7 +391,7 @@ modest_hildon2_window_mgr_register_window (ModestWindowMgr *self,
        *handler_id = g_signal_connect (window, "delete-event", G_CALLBACK (on_window_destroy), self);
        g_hash_table_insert (priv->destroy_handlers, window, handler_id);
 
-       /* Show toolbar always */       
+       /* Show toolbar always */
        modest_window_show_toolbar (window, TRUE);
 
        return TRUE;
@@ -467,73 +466,36 @@ on_window_destroy (ModestWindow *window,
 {
        gboolean no_propagate = FALSE;
 
-       if (!window_can_close (window)) {
+       if (!window_can_close (window))
                return TRUE;
-       }
-       /* Specific stuff first */
-       if (MODEST_IS_MAIN_WINDOW (window)) {
-               ModestHildon2WindowMgrPrivate *priv;
-               ModestMainWindowContentsStyle style;
-               priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
-
-               /* If we're on header view, then just go to folder view and don't close */
-               style = modest_main_window_get_contents_style (MODEST_MAIN_WINDOW (window));
-               if (style == MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS) {
-                       modest_main_window_set_contents_style (MODEST_MAIN_WINDOW (window),
-                                                              MODEST_MAIN_WINDOW_CONTENTS_STYLE_FOLDERS);
-                       return TRUE;
-               }
-
-               /* Do not unregister it, just hide */
-               gtk_widget_hide_all (GTK_WIDGET (window));
-
-               /* Cancel pending operations */
-               cancel_window_operations (window);
 
-               /* Fake the window system, make it think that there is no window */
-               if (modest_window_mgr_num_windows (MODEST_WINDOW_MGR (self)) == 0)
-                       g_signal_emit_by_name (self, "window-list-empty");
+       if (MODEST_IS_MSG_EDIT_WINDOW (window)) {
+               gboolean sent = FALSE;
+               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))) {
 
-               no_propagate = TRUE;
-       }
-       else {
-               if (MODEST_IS_MSG_EDIT_WINDOW (window)) {
-                       gboolean sent = FALSE;
-                       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))) {
-
-                         if (!modest_ui_actions_on_save_to_drafts (NULL, MODEST_MSG_EDIT_WINDOW (window)))
-                                 return TRUE;
-                       }
+                       if (!modest_ui_actions_on_save_to_drafts (NULL, MODEST_MSG_EDIT_WINDOW (window)))
+                               return TRUE;
                }
-               /* Unregister window */
-               modest_window_mgr_unregister_window (MODEST_WINDOW_MGR (self), window);
-               no_propagate = FALSE;
        }
 
+       /* Unregister window */
+       modest_window_mgr_unregister_window (MODEST_WINDOW_MGR (self), window);
+       no_propagate = FALSE;
+
        return no_propagate;
 }
 
 static void
-disconnect_msg_changed (gpointer key, 
-                       gpointer value, 
-                       gpointer user_data)
-{
-       guint handler_id;
-       handler_id = GPOINTER_TO_UINT(value);
-       
-       if (key && G_IS_OBJECT(key))
-               g_signal_handler_disconnect (G_OBJECT (key), handler_id);
-}
-
-static void 
 modest_hildon2_window_mgr_unregister_window (ModestWindowMgr *self, 
                                             ModestWindow *window)
 {
        GList *win;
        ModestHildon2WindowMgrPrivate *priv;
        gulong *tmp, handler_id;
+       gboolean check_close_all = FALSE;
+       guint num_windows;
 
        g_return_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self));
        g_return_if_fail (MODEST_IS_WINDOW (window));
@@ -546,19 +508,9 @@ modest_hildon2_window_mgr_unregister_window (ModestWindowMgr *self,
                return;
        }
 
-       /* If it's the main window unset it */
-       if (MODEST_IS_MAIN_WINDOW (window)) {
-               modest_window_mgr_set_main_window (self, NULL);
-
-               /* Disconnect all emissions of msg-changed */
-               if (priv->viewer_handlers) {
-                       g_hash_table_foreach (priv->viewer_handlers, 
-                                             disconnect_msg_changed, 
-                                             NULL);
-                       g_hash_table_destroy (priv->viewer_handlers);
-                       priv->viewer_handlers = NULL;
-               }
-       }
+       /* Remember this for the end of the method */
+       if (MODEST_IS_FOLDER_WINDOW (window))
+               check_close_all = TRUE;
 
        /* Remove the viewer window handler from the hash table. The
           HashTable could not exist if the main window was closed
@@ -593,35 +545,40 @@ modest_hildon2_window_mgr_unregister_window (ModestWindowMgr *self,
 
        /* Disconnect the "window-state-event" handler, we won't need it anymore */
        if (priv->window_state_uids) {
-#ifndef MODEST_TOOLKIT_GTK
                priv->window_state_uids = 
                        modest_signal_mgr_disconnect (priv->window_state_uids, 
                                                      G_OBJECT (window), 
                                                      "notify::is-topmost");
-#else
-               priv->window_state_uids = 
-                       modest_signal_mgr_disconnect (priv->window_state_uids, 
-                                                     G_OBJECT (window), 
-                                                     "window-state-event");
-#endif
        }
-       
+
        /* Disconnect the "delete-event" handler, we won't need it anymore */
        g_signal_handler_disconnect (window, handler_id);
 
        /* Destroy the window */
        g_object_unref (win->data);
        g_list_free (win);
-       
+
        MODEST_WINDOW_MGR_CLASS (parent_class)->unregister_window (self, window);
 
+       /* We have to get the number of windows here in order not to
+          emit the signal too many times */
+       num_windows = modest_window_mgr_get_num_windows (self);
+
+       /* Check if we have to destroy the accounts window as
+          well. This happens if we only have one or none remote
+          accounts */
+       if (check_close_all) {
+               ModestTnyAccountStore *acc_store = modest_runtime_get_account_store ();
+               if (modest_tny_account_store_get_num_remote_accounts (acc_store) < 2)
+                       modest_window_mgr_close_all_windows (self);
+       }
+
        /* If there are no more windows registered emit the signal */
-       if (modest_window_mgr_num_windows (self) == 0)
+       if (num_windows == 0)
                g_signal_emit_by_name (self, "window-list-empty");
 }
 
 
-
 static void
 modest_hildon2_window_mgr_set_fullscreen_mode (ModestWindowMgr *self,
                                               gboolean on)
@@ -653,12 +610,12 @@ modest_hildon2_window_mgr_get_main_window (ModestWindowMgr *self, gboolean show)
 {
        ModestHildon2WindowMgrPrivate *priv;
        ModestWindow *result;
-       
+
        g_return_val_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self), NULL);
        priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
 
        /* TODO: make this return NULL always */
-       
+
        result = MODEST_WINDOW_MGR_CLASS (parent_class)->get_main_window (self, FALSE);
        /* create the main window, if it hasn't been created yet */
        if (!result && show) {
@@ -726,25 +683,34 @@ modest_hildon2_window_mgr_set_modal (ModestWindowMgr *self,
 static ModestWindow *
 modest_hildon2_window_mgr_show_initial_window (ModestWindowMgr *self)
 {
-       ModestWindow *window = NULL;
-       ModestAccountMgr *mgr;
-       GSList *account_names;
-       gint count;
-
-       mgr = modest_runtime_get_account_mgr ();
-       account_names = modest_account_mgr_account_names (mgr, TRUE);
-       count = g_slist_length (account_names);
-
-       if (count > 1) {
-               window = MODEST_WINDOW (modest_accounts_window_new ());
-       } else {
-               window = MODEST_WINDOW (modest_folder_window_new (NULL));
-               if (count == 1)
-                       modest_folder_window_set_account (MODEST_FOLDER_WINDOW (window),
-                                                         account_names->data);
+       ModestWindow *initial_window = NULL;
+       ModestTnyAccountStore *acc_store;
+
+       /* Always create accounts window. We'll decide later if we
+          want to show it or not, depending the number of accounts */
+       initial_window = MODEST_WINDOW (modest_accounts_window_new ());
+       modest_window_mgr_register_window (self, initial_window, NULL);
+
+       /* If there are less than 2 remote accounts then directly show
+          the folder window and do not show the accounts window */
+       acc_store = modest_runtime_get_account_store ();
+       if (modest_tny_account_store_get_num_remote_accounts (acc_store) < 2) {
+               ModestAccountMgr *mgr;
+
+               /* Show first the accounts window to add it to the
+                  stack. This has to be changed when the new
+                  stackable API is available. There will be a method
+                  to show all the windows that will only show the
+                  last one to the user. The current code shows both
+                  windows, one after the other */
+               gtk_widget_show (GTK_WIDGET (initial_window));
+
+               initial_window = MODEST_WINDOW (modest_folder_window_new (NULL));
+               mgr = modest_runtime_get_account_mgr ();
+               modest_folder_window_set_account (MODEST_FOLDER_WINDOW (initial_window),
+                                                 modest_account_mgr_get_default_account (mgr));
+               modest_window_mgr_register_window (self, initial_window, NULL);
        }
-       modest_account_mgr_free_account_names (account_names);
-       modest_window_mgr_register_window (self, window, NULL);
 
-       return window;
+       return initial_window;
 }
index 706079f..b7d1cfd 100644 (file)
@@ -61,8 +61,21 @@ struct _ModestHildon2WindowMgrClass {
 GType        modest_hildon2_window_mgr_get_type    (void) G_GNUC_CONST;
 
 /* typical parameter-less _new function */
-ModestWindowMgr*    modest_hildon2_window_mgr_new         (void);
-       
+ModestWindowMgr*    modest_hildon2_window_mgr_new  (void);
+
+/**
+ * modest_hildon2_window_mgr_set_account_store:
+ * @self: a #ModestHildon2WindowMgr
+ * @acc_store: a #TnyAccountStore
+ *
+ * The window manager will use this function to connect itself to the
+ * account-created and account-removed signals of the
+ * #TnyAccountStore, because it ill create/destroy the accounts window
+ * depending on the existence of 0, 1 or more accounts.
+ **/
+void modest_hildon2_window_mgr_set_account_store   (ModestHildon2WindowMgr *self,
+                                                   TnyAccountStore *acc_store);
+
 G_END_DECLS
 
 #endif /* __MODEST_HILDON2_WINDOW_MGR_H__ */
index 17e9212..adc97f5 100644 (file)
@@ -59,6 +59,7 @@
 #include <hildon/hildon-sound.h>
 #include <osso-mem.h>
 #include "hildon2/modest-hildon2-details-dialog.h"
+#include "hildon2/modest-hildon2-window-mgr.h"
 
 #ifdef MODEST_HAVE_MCE
 #include <mce/dbus-names.h>
@@ -1450,7 +1451,7 @@ modest_platform_information_banner (GtkWidget *parent,
        GtkWidget *banner, *banner_parent = NULL;
        ModestWindowMgr *mgr = modest_runtime_get_window_mgr ();
 
-       if (modest_window_mgr_num_windows (mgr) == 0)
+       if (modest_window_mgr_get_num_windows (mgr) == 0)
                return;
 
        if (parent && GTK_IS_WINDOW (parent)) {
@@ -1486,7 +1487,7 @@ modest_platform_information_banner_with_timeout (GtkWidget *parent,
 {
        GtkWidget *banner;
 
-       if (modest_window_mgr_num_windows (modest_runtime_get_window_mgr ()) == 0)
+       if (modest_window_mgr_get_num_windows (modest_runtime_get_window_mgr ()) == 0)
                return;
 
        banner = hildon_banner_show_information (parent, icon_name, text);
@@ -1502,7 +1503,7 @@ modest_platform_animation_banner (GtkWidget *parent,
 
        g_return_val_if_fail (text != NULL, NULL);
 
-       if (modest_window_mgr_num_windows (modest_runtime_get_window_mgr ()) == 0)
+       if (modest_window_mgr_get_num_windows (modest_runtime_get_window_mgr ()) == 0)
                return NULL;
 
        /* If the parent is not visible then do not show */
@@ -2117,7 +2118,7 @@ modest_platform_run_header_details_dialog (GtkWindow *parent_window,
                                           TnyHeader *header)
 {
        GtkWidget *dialog;
-       
+
        /* Create dialog */
        dialog = modest_hildon2_details_dialog_new_with_header (parent_window, header);
 
index 24cd4bb..3a77873 100644 (file)
@@ -1460,7 +1460,7 @@ banner_finish (gpointer data, GObject *object)
        g_object_unref (mgr);
 }
 
-void 
+void
 modest_platform_information_banner (GtkWidget *parent,
                                    const gchar *icon_name,
                                    const gchar *text)
@@ -1468,7 +1468,7 @@ modest_platform_information_banner (GtkWidget *parent,
        GtkWidget *banner, *banner_parent = NULL;
        ModestWindowMgr *mgr = modest_runtime_get_window_mgr ();
 
-       if (modest_window_mgr_num_windows (mgr) == 0)
+       if (modest_window_mgr_get_num_windows (mgr) == 0)
                return;
 
        if (parent && GTK_IS_WINDOW (parent)) {
@@ -1478,7 +1478,7 @@ modest_platform_information_banner (GtkWidget *parent,
                        banner_parent = parent;
                /* If the window is not the topmost but it's visible
                   (it's minimized for example) then show the banner
-                  with no parent */ 
+                  with no parent */
                else if (GTK_WIDGET_VISIBLE (parent))
                        banner_parent = NULL;
                /* If the window is hidden (like the main window when
@@ -1504,7 +1504,7 @@ modest_platform_information_banner_with_timeout (GtkWidget *parent,
 {
        GtkWidget *banner;
 
-       if (modest_window_mgr_num_windows (modest_runtime_get_window_mgr ()) == 0)
+       if (modest_window_mgr_get_num_windows (modest_runtime_get_window_mgr ()) == 0)
                return;
 
        banner = hildon_banner_show_information (parent, icon_name, text);
@@ -1520,7 +1520,7 @@ modest_platform_animation_banner (GtkWidget *parent,
 
        g_return_val_if_fail (text != NULL, NULL);
 
-       if (modest_window_mgr_num_windows (modest_runtime_get_window_mgr ()) == 0)
+       if (modest_window_mgr_get_num_windows (modest_runtime_get_window_mgr ()) == 0)
                return NULL;
 
        /* If the parent is not visible then do not show */
index 1ca4450..720e668 100644 (file)
@@ -180,7 +180,7 @@ on_finalize_foreach(gpointer op,
        g_signal_handlers_disconnect_by_func (mail_op, G_CALLBACK (on_operation_finished), user_data);
 
        MODEST_DEBUG_BLOCK (print_queue_item (mail_op, "cancel/remove"););
-       
+
        modest_mail_operation_cancel (mail_op);
        g_queue_remove (priv->op_queue, mail_op);
        g_object_unref (G_OBJECT (mail_op));
@@ -245,7 +245,7 @@ modest_mail_operation_queue_add (ModestMailOperationQueue *self,
 
        g_return_if_fail (MODEST_IS_MAIL_OPERATION_QUEUE (self));
        g_return_if_fail (MODEST_IS_MAIL_OPERATION (mail_op));
-       
+
        priv = MODEST_MAIL_OPERATION_QUEUE_GET_PRIVATE(self);
 
        priv->running_final_sync = (modest_mail_operation_get_type_operation (mail_op) == MODEST_MAIL_OPERATION_TYPE_SHUTDOWN);
@@ -253,7 +253,7 @@ modest_mail_operation_queue_add (ModestMailOperationQueue *self,
        g_mutex_lock (priv->queue_lock);
        g_queue_push_tail (priv->op_queue, g_object_ref (mail_op));
        g_mutex_unlock (priv->queue_lock);
-       
+
        MODEST_DEBUG_BLOCK (print_queue_item (mail_op, "add"););
 
        /* Get notified when the operation ends to remove it from the
@@ -302,7 +302,7 @@ notify_queue_empty (gpointer user_data)
 }
 
 
-void 
+void
 modest_mail_operation_queue_remove (ModestMailOperationQueue *self,
                                    ModestMailOperation *mail_op)
 {
@@ -367,14 +367,14 @@ modest_mail_operation_queue_remove (ModestMailOperationQueue *self,
        }
 }
 
-guint 
+guint
 modest_mail_operation_queue_num_elements (ModestMailOperationQueue *self)
 {
        ModestMailOperationQueuePrivate *priv;
        guint length = 0;
 
        g_return_val_if_fail (MODEST_IS_MAIL_OPERATION_QUEUE (self), 0);
-       
+
        priv = MODEST_MAIL_OPERATION_QUEUE_GET_PRIVATE(self);
 
        g_mutex_lock (priv->queue_lock);
@@ -513,7 +513,7 @@ modest_mail_operation_queue_to_string (ModestMailOperationQueue *self)
                g_queue_foreach (priv->op_queue, (GFunc)accumulate_mail_op_strings, &str);
                g_mutex_unlock (priv->queue_lock);
        }
-               
+
        return str;
 }
 
@@ -521,9 +521,9 @@ gboolean
 modest_mail_operation_queue_running_shutdown (ModestMailOperationQueue *self)
 {
        ModestMailOperationQueuePrivate *priv;
-       
+
        g_return_val_if_fail (MODEST_IS_MAIL_OPERATION_QUEUE (self), FALSE);
-       
+
        priv = MODEST_MAIL_OPERATION_QUEUE_GET_PRIVATE(self);
        return priv->running_final_sync;
 }
@@ -532,9 +532,9 @@ void
 modest_mail_operation_queue_set_running_shutdown (ModestMailOperationQueue *self)
 {
        ModestMailOperationQueuePrivate *priv;
-       
+
        g_return_if_fail (MODEST_IS_MAIL_OPERATION_QUEUE (self));
-       
+
        priv = MODEST_MAIL_OPERATION_QUEUE_GET_PRIVATE(self);
        priv->running_final_sync = TRUE;
 }
index 552a62d..f84edf3 100644 (file)
 #include <gdk/gdk.h>
 #include <string.h>
 #include <glib.h>
-#include <modest-runtime.h>
-#include <modest-init.h>
+#include "modest-runtime.h"
+#include "modest-init.h"
 #include "modest-platform.h"
 #include "modest-ui-actions.h"
-#include <widgets/modest-main-window.h>
-#ifdef MODEST_TOOLKIT_HILDON2
-#include <modest-accounts-window.h>
-#include <modest-folder-window.h>
-#endif
 
 typedef struct {
        gulong queue_handler;
@@ -96,7 +91,7 @@ on_queue_empty (ModestMailOperationQueue *queue,
        /* Exit if the queue is empty and there are no more
           windows. We can exit as well if the main window is hidden
           and it's the only one */
-       if (modest_window_mgr_num_windows (mgr) == 0)
+       if (modest_window_mgr_get_num_windows (mgr) == 0)
                g_idle_add_full (G_PRIORITY_LOW, on_idle_exit_modest, user_data, NULL);
 }
 
@@ -114,9 +109,9 @@ on_window_list_empty (ModestWindowMgr *window_mgr,
 int
 main (int argc, char *argv[])
 {
-       /* Usually we don't show the application at first, 
-        * because we wait for the top_application D-Bus method to 
-        * be called. But that's annoying when starting from the 
+       /* Usually we don't show the application at first,
+        * because we wait for the top_application D-Bus method to
+        * be called. But that's annoying when starting from the
         * command line.: */
        gboolean show_ui_without_top_application_method = FALSE;
        int retval  = 0;
index 3a88865..386b99c 100644 (file)
@@ -502,7 +502,7 @@ gboolean modest_platform_check_memory_low (ModestWindow *win,
  * modest_platform_run_folder_details_dialog:
  * @parent_window: the parent #GtkWindow for the new dialog
  * @folder: the #TnyFolder whose details will be shown
- * 
+ *
  * Shows the folder details dialog
  **/
 void     modest_platform_run_folder_details_dialog (GtkWindow *parent_window,
@@ -512,14 +512,21 @@ void     modest_platform_run_folder_details_dialog (GtkWindow *parent_window,
  * modest_platform_run_header_details_dialog:
  * @parent_window: the parent #GtkWindow for the new dialog
  * @header: the #TnyHeader whose details will be shown
- * 
+ *
  * Shows the header details dialog
  **/
 void     modest_platform_run_header_details_dialog (GtkWindow *parent_window,
                                                    TnyHeader *header);
 
+/**
+ * modest_platform_on_runtime_initialized:
+ *
+ * This function will be used by platforms to connect objects between
+ * themselves once all the singletons have been created. So this
+ * function MUST be called *before* modest_init
+ **/
+void     modest_platform_on_runtime_initialized ();
 
 G_END_DECLS
 
 #endif /* __MODEST_PLATFORM_UTILS_H__ */
-
index 2097db5..890b8db 100644 (file)
@@ -69,13 +69,13 @@ modest_runtime_init (void)
                g_printerr ("modest: modest_runtime_init can only be run once\n");
                return FALSE;
        }
-       
+
        _singletons = modest_singletons_new ();
        if (!_singletons) {
                g_printerr ("modest: failed to create singletons\n");
                return FALSE;
        }
-       
+
        return TRUE;
 }
 
@@ -143,9 +143,10 @@ modest_runtime_get_email_clipboard   (void)
 ModestTnyAccountStore*
 modest_runtime_get_account_store   (void)
 {
-       // we get the account store here instead of in Singletons
-        // as it leads to various chicken & problems with initialization
-       g_return_val_if_fail (_singletons, NULL);       
+       g_return_val_if_fail (_singletons, NULL);
+       /* we get the account store here instead of in Singletons as
+          it leads to various chicken & egg problems with
+          initialization */
        if (!_account_store) {
                _account_store  = modest_tny_account_store_new (modest_runtime_get_account_mgr(),
                                                                modest_runtime_get_device());
index c2177d8..c07baf2 100644 (file)
@@ -66,7 +66,7 @@ typedef enum {
  * environment, instantiates singletons and so on)
  * modest_runtime_init should only be called once, and
  * when done with it, modest_runtime_uninit should be called
- *  
+ *
  * TRUE if this succeeded, FALSE otherwise.
  */
 gboolean modest_runtime_init (void);
@@ -81,10 +81,10 @@ gboolean modest_runtime_init (void);
  * TRUE if this succeeded, FALSE otherwise
  */
 gboolean modest_runtime_uninit (void);
-       
+
 
 /**
- * modest_runtime_get_debug_flags 
+ * modest_runtime_get_debug_flags
  *
  * get the debug flags for modest; they are read from the MODEST_DEBUG
  * environment variable; the flags specified as strings, separated by ':'.
index d674e75..928c198 100644 (file)
@@ -116,7 +116,7 @@ static void    connection_status_changed   (TnyAccount *account,
                                            TnyConnectionStatus status, 
                                            gpointer data);
 
-static gboolean only_local_accounts        (ModestTnyAccountStore *self);
+static inline gboolean only_local_accounts        (ModestTnyAccountStore *self);
 
 /* list my signals */
 enum {
@@ -1706,27 +1706,10 @@ insert_account (ModestTnyAccountStore *self,
        g_object_unref (transport_account);
 }
 
-static gboolean
+static inline gboolean
 only_local_accounts (ModestTnyAccountStore *self)
 {
-       ModestTnyAccountStorePrivate *priv = NULL;
-       gboolean only_local = TRUE;
-       TnyIterator *iter;
-
-       /* Check if this is the first remote account we add */
-       priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE (self);
-       iter = tny_list_create_iterator (priv->store_accounts);
-
-       while (!tny_iterator_is_done (iter) && only_local) {
-               TnyAccount *account = (TnyAccount *) tny_iterator_get_current (iter);
-               if (modest_tny_folder_store_is_remote (TNY_FOLDER_STORE (account)))
-                       only_local = FALSE;
-               g_object_unref (account);
-               tny_iterator_next (iter);
-       }
-       g_object_unref (iter);
-
-       return only_local;
+       return (modest_tny_account_store_get_num_remote_accounts (self) > 0) ? FALSE : TRUE;
 }
 
 static void
@@ -2247,3 +2230,25 @@ modest_tny_account_store_set_send_mail_blocked (ModestTnyAccountStore *self,
 
        priv->send_mail_blocked = blocked;
 }
+
+static void
+count_remote_accounts (gpointer data, gpointer user_data)
+{
+       TnyFolderStore *account = TNY_FOLDER_STORE (data);
+       gint *count = (gint *) user_data;
+
+       if (modest_tny_folder_store_is_remote (account))
+               (*count)++;
+}
+
+guint
+modest_tny_account_store_get_num_remote_accounts (ModestTnyAccountStore *self)
+{
+       ModestTnyAccountStorePrivate *priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE (self);
+       gint count = 0;
+
+       /* Count remote accounts */
+       tny_list_foreach (priv->store_accounts, (GFunc) count_remote_accounts, &count);
+
+       return count;
+}
index 8031fe5..239deb4 100644 (file)
@@ -271,6 +271,7 @@ gboolean modest_tny_account_store_is_send_mail_blocked (ModestTnyAccountStore *s
  */
 void modest_tny_account_store_set_send_mail_blocked (ModestTnyAccountStore *self, gboolean blocked);
 
+guint modest_tny_account_store_get_num_remote_accounts (ModestTnyAccountStore *self);
 
 G_END_DECLS
 
index 232959f..d1cc82b 100644 (file)
@@ -38,6 +38,7 @@
 #include <tny-gtk-folder-store-tree-model.h>
 #endif
 #include <tny-gtk-header-list-model.h>
+#include <tny-merge-folder.h>
 #include <tny-folder.h>
 #include <tny-folder-store-observer.h>
 #include <tny-account-store.h>
@@ -1409,11 +1410,11 @@ filter_row (GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
                if (priv->style == MODEST_FOLDER_VIEW_STYLE_SHOW_ONE &&
                    !gtk_tree_model_iter_parent (model, iter, &parent)) {
                        /* Only show special folders for current account if needed */
-                       if (TNY_IS_FOLDER (instance)) {
+                       if (TNY_IS_FOLDER (instance) && !TNY_IS_MERGE_FOLDER (instance)) {
                                TnyAccount *account;
 
                                account = tny_folder_get_account (TNY_FOLDER (instance));
-                               
+
                                if (TNY_IS_ACCOUNT (account)) {
                                        const gchar *account_id = tny_account_get_id (account);
 
@@ -1428,7 +1429,7 @@ filter_row (GtkTreeModel *model, GtkTreeIter *iter, gpointer data)
                                                g_object_unref (account);
                                }
                        }
-                       
+
                }
        }
 
index 87b779b..a7da42e 100644 (file)
@@ -579,7 +579,7 @@ on_window_destroy (ModestWindow *window,
                cancel_window_operations (window);
 
                /* Fake the window system, make it think that there is no window */
-               if (modest_window_mgr_num_windows (MODEST_WINDOW_MGR (self)) == 0)
+               if (modest_window_mgr_get_num_windows (MODEST_WINDOW_MGR (self)) == 0)
                        g_signal_emit_by_name (self, "window-list-empty");
 
                no_propagate = TRUE;
@@ -714,7 +714,7 @@ modest_hildon1_window_mgr_unregister_window (ModestWindowMgr *self,
        MODEST_WINDOW_MGR_CLASS (parent_class)->unregister_window (self, window);
 
        /* If there are no more windows registered emit the signal */
-       if (modest_window_mgr_num_windows (self) == 0)
+       if (modest_window_mgr_get_num_windows (self) == 0)
                g_signal_emit_by_name (self, "window-list-empty");
 }
 
index 39ff23f..d970434 100644 (file)
@@ -733,33 +733,33 @@ modest_window_mgr_save_state_for_all_windows (ModestWindowMgr *self)
                        /* This calls the vfunc, 
                         * so each window can do its own thing: */
                        modest_window_save_state (window);
-               }       
-               
+               }
+
                node = g_list_next (node);
        }
        g_list_free (window_list);
 }
 
-gint 
-modest_window_mgr_num_windows (ModestWindowMgr *self)
+guint
+modest_window_mgr_get_num_windows (ModestWindowMgr *self)
 {
        ModestWindowMgrPrivate *priv;
        gint num_windows = 0;
        GList *window_list;
 
        g_return_val_if_fail (self && MODEST_IS_WINDOW_MGR(self), -1);
-       
+
        priv =  MODEST_WINDOW_MGR_GET_PRIVATE(self);
 
        window_list = modest_window_mgr_get_window_list (self);
-       
+
        if (window_list) {
                num_windows = g_list_length (window_list);
                g_list_free (window_list);
        }
 
        /* Do not take into account the main window if it was hidden */
-       if (priv->main_window && !GTK_WIDGET_VISIBLE (priv->main_window))
+       if (num_windows && priv->main_window && !GTK_WIDGET_VISIBLE (priv->main_window))
                num_windows--;
 
        return num_windows + priv->banner_counter;
@@ -827,7 +827,7 @@ modest_window_mgr_unregister_banner (ModestWindowMgr *self)
        priv = MODEST_WINDOW_MGR_GET_PRIVATE (self);
 
        priv->banner_counter--;
-       if (modest_window_mgr_num_windows (self) == 0)
+       if (modest_window_mgr_get_num_windows (self) == 0)
                g_signal_emit (self, signals[WINDOW_LIST_EMPTY_SIGNAL], 0);
 }
 
index 6c555b4..2398be2 100644 (file)
@@ -349,14 +349,14 @@ gboolean modest_window_mgr_get_hibernation_is_prevented (ModestWindowMgr *self);
 void modest_window_mgr_save_state_for_all_windows (ModestWindowMgr *self);
 
 /**
- * modest_window_mgr_num_windows:
+ * modest_window_mgr_get_num_windows:
  * @self: a #ModestWindowMgr
  * 
  * Gets the number of already registered windows, and pending banners
  *
  * Returns: the number of already registered windows, and pending banners
  **/
-gint modest_window_mgr_num_windows (ModestWindowMgr *self);
+guint modest_window_mgr_get_num_windows (ModestWindowMgr *self);
 
 /**
  * modest_window_mgr_get_msg_view_window: