* Added the show_initial_window method
[modest] / src / hildon2 / modest-hildon2-window-mgr.c
index f7251f7..d79fcc4 100644 (file)
@@ -28,6 +28,7 @@
  */
 
 #include <string.h>
+#include <hildon/hildon-program.h>
 #include "modest-hildon2-window-mgr.h"
 #include "modest-msg-edit-window.h"
 #include "modest-main-window.h"
@@ -39,7 +40,8 @@
 #include "modest-ui-actions.h"
 #include "modest-debug.h"
 #include "modest-tny-folder.h"
-#include <hildon/hildon-program.h>
+#include "modest-folder-window.h"
+#include "modest-accounts-window.h"
 
 /* 'private'/'protected' functions */
 static void modest_hildon2_window_mgr_class_init (ModestHildon2WindowMgrClass *klass);
@@ -74,19 +76,20 @@ static GList *modest_hildon2_window_mgr_get_window_list (ModestWindowMgr *self);
 static gboolean modest_hildon2_window_mgr_close_all_windows (ModestWindowMgr *self);
 static gboolean window_can_close (ModestWindow *window);
 static gboolean window_has_modals (ModestWindow *window);
+static ModestWindow *modest_hildon2_window_mgr_show_initial_window (ModestWindowMgr *self);
 
 typedef struct _ModestHildon2WindowMgrPrivate ModestHildon2WindowMgrPrivate;
 struct _ModestHildon2WindowMgrPrivate {
        GList        *window_list;
        GMutex       *queue_lock;
        GQueue       *modal_windows;
-       
+
        gboolean     fullscreen_mode;
-       
+
        GHashTable   *destroy_handlers;
        GHashTable   *viewer_handlers;
        GSList       *window_state_uids;
-       
+
        guint        closing_time;
 
        GSList       *modal_handler_uids;
@@ -144,6 +147,7 @@ modest_hildon2_window_mgr_class_init (ModestHildon2WindowMgrClass *klass)
        mgr_class->find_registered_header = modest_hildon2_window_mgr_find_registered_header;
        mgr_class->get_window_list = modest_hildon2_window_mgr_get_window_list;
        mgr_class->close_all_windows = modest_hildon2_window_mgr_close_all_windows;
+       mgr_class->show_initial_window = modest_hildon2_window_mgr_show_initial_window;
 
        g_type_class_add_private (gobject_class, sizeof(ModestHildon2WindowMgrPrivate));
 
@@ -719,3 +723,28 @@ modest_hildon2_window_mgr_set_modal (ModestWindowMgr *self,
        gtk_window_set_destroy_with_parent (window, TRUE);
 }
 
+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);
+       }
+       modest_account_mgr_free_account_names (account_names);
+       modest_window_mgr_register_window (self, window, NULL);
+
+       return window;
+}