New accounts window, that's shown as top main view for modest.
authorJose Dapena Paz <jdapena@igalia.com>
Fri, 21 Nov 2008 09:44:23 +0000 (09:44 +0000)
committerJose Dapena Paz <jdapena@igalia.com>
Fri, 21 Nov 2008 09:44:23 +0000 (09:44 +0000)
* src/modest-main.c:
        * In hildon2, show the accounts window as top window instead of
          any other type of account.
* src/widgets/modest-header-view.[ch]:
        * Now set folder accepts a parameter for the window where we
          show the notification about the progress.
* src/modest-ui-actions.c:
        * Take into account in send receive that sending/receiving on
          accounts window should refresh all.
* src/dbus_api/modest-dbus-callbacks.c:
        * Start with accounts window in hildon 2.2 modest.
* src/hildon2/modest-platform.c:
        * Remove dependency on main window.
* src/hildon2/modest-hildon2-window-mgr.c:
        * Improvements on window manager to cope with accounts window
          (and lots of other generic window stacks).
* src/hildon2/modest-main-window.c:
        * Update to build properly with header view api change.
* src/hildon2/modest-msg-view-window.c:
        * Now it connects with the header window instead of main window.
* src/hildon2/modest-header-window.c:
        * Allow passing properly progress window to header view for
          reload information.

pmo-drop-split-view-r6365

src/dbus_api/Makefile.am
src/dbus_api/modest-dbus-callbacks.c
src/hildon2/modest-header-window.c
src/hildon2/modest-hildon2-window-mgr.c
src/hildon2/modest-main-window.c
src/hildon2/modest-msg-view-window.c
src/hildon2/modest-platform.c
src/modest-main.c
src/modest-ui-actions.c
src/widgets/modest-header-view.c
src/widgets/modest-header-view.h

index 9740138..1ec36dd 100644 (file)
@@ -35,6 +35,7 @@ INCLUDES=\
        $(MODEST_OGS_CFLAGS) \
        -I ${top_srcdir}/src/widgets  \
        -I ${top_srcdir}/src  \
+       -I ${top_srcdir}/src/$(MODEST_TOOLKIT_DIR) \
        -DPREFIX=\"@prefix@\" \
        -DMAEMO_CHANGES \
        -DPIXMAP_PREFIX=\"${datadir}/pixmaps/modest/\" \
index 0289eb6..758fed6 100644 (file)
 #include <string.h>
 #include <glib/gstdio.h>
 #ifdef MODEST_HAVE_HILDON0_WIDGETS
+#include <hildon-widgets/hildon-program.h>
 #include <libgnomevfs/gnome-vfs-mime-utils.h>
 #else
+#include <hildon/hildon-program.h>
 #include <libgnomevfs/gnome-vfs-mime.h>
 #endif
 #include <tny-fs-stream.h>
 
+#ifdef MODEST_TOOLKIT_HILDON2
+#include <modest-accounts-window.h>
+#include <modest-folder-window.h>
+#endif
+
+
 #include <tny-list.h>
 #include <tny-iterator.h>
 #include <tny-simple-list.h>
@@ -708,7 +716,6 @@ on_remove_msgs_finished (ModestMailOperation *mail_op,
 {      
        TnyHeader *header;
        ModestWindow *main_win = NULL, *msg_view = NULL;
-       ModestHeaderView *header_view;
 
        header = (TnyHeader *) user_data;
 
@@ -727,12 +734,10 @@ on_remove_msgs_finished (ModestMailOperation *mail_op,
        }       
        g_object_unref (header);
 
-       /* Refilter the header view explicitly */
-       header_view = (ModestHeaderView *)
-               modest_main_window_get_child_widget (MODEST_MAIN_WINDOW(main_win),
-                                                    MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW);
-       if (header_view && MODEST_IS_HEADER_VIEW (header_view))
-               modest_header_view_refilter (header_view);
+       /* Refilter the header views explicitely */
+
+       /* TODO: call modest_window_mgr_refilter_header_views */
+       /* this call will go through all the windows, get the header views and refilter them */
 }
 
 static gpointer
@@ -1149,7 +1154,50 @@ on_open_default_inbox(GArray * arguments, gpointer data, osso_rpc_t * retval)
        return OSSO_OK;
 }
 
+#ifdef MODEST_TOOLKIT_HILDON2
+static gboolean 
+on_idle_top_application (gpointer user_data)
+{
+       HildonProgram *program;
+       GtkWidget *window;
+       
+       /* This is a GDK lock because we are an idle callback and
+        * the code below is or does Gtk+ code */
+
+       gdk_threads_enter (); /* CHECKED */
+
+       program = hildon_program_get_instance ();
+       window = GTK_WIDGET (hildon_program_peek_window_stack (program));
+
+       if (window) {
+               gtk_window_present (GTK_WINDOW (window));
+       } else {
+               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 = GTK_WIDGET (modest_accounts_window_new ());
+               } else {
+                       window = GTK_WIDGET (modest_folder_window_new (NULL));
+                       modest_folder_window_set_account (MODEST_FOLDER_WINDOW (window),
+                                                         account_names->data);
+               }
+
+               modest_account_mgr_free_account_names (account_names);
+               gtk_widget_show (window);
+       }
+
+       gdk_threads_leave (); /* CHECKED */
+       
+       return FALSE; /* Do not call this callback again. */
+}
+#else
 static gboolean 
 on_idle_top_application (gpointer user_data)
 {
@@ -1161,11 +1209,6 @@ on_idle_top_application (gpointer user_data)
 
        gdk_threads_enter (); /* CHECKED */
        
-#ifdef MODEST_TOOLKIT_HILDON2
-       main_win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr (),
-                                                     TRUE);
-       new_window = TRUE;
-#else
        main_win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr (),
                                                      FALSE);
 
@@ -1174,7 +1217,6 @@ on_idle_top_application (gpointer user_data)
                                                              TRUE);
                new_window = TRUE;
        }
-#endif
 
        if (main_win) {
                /* If we're showing an already existing window then
@@ -1187,17 +1229,16 @@ on_idle_top_application (gpointer user_data)
                }
        }
 
-#ifndef MODEST_TOOLKIT_HILDON2
        if (main_win) {
                gtk_widget_show_all (GTK_WIDGET (main_win));
                gtk_window_present (GTK_WINDOW (main_win));
        }
-#endif
 
        gdk_threads_leave (); /* CHECKED */
        
        return FALSE; /* Do not call this callback again. */
 }
+#endif
 
 static gint 
 on_top_application(GArray * arguments, gpointer data, osso_rpc_t * retval)
index 6a37490..d30533a 100644 (file)
@@ -96,7 +96,8 @@ static void add_to_menu (ModestHeaderWindow *self,
                         GCallback callback);
 static void setup_menu (ModestHeaderWindow *self);
 static GtkWidget *create_empty_view (void);
-static GtkWidget *create_header_view (TnyFolder *folder);
+static GtkWidget *create_header_view (ModestWindow *progress_window,
+                                     TnyFolder *folder);
 
 static void update_view (ModestHeaderWindow *self,
                         TnyFolderChange *change);
@@ -282,13 +283,13 @@ osso_display_event_cb (osso_display_state_t state,
 }
 
 static GtkWidget *
-create_header_view (TnyFolder *folder)
+create_header_view (ModestWindow *progress_window, TnyFolder *folder)
 {
        GtkWidget *header_view;
 
        header_view  = modest_header_view_new (NULL, MODEST_HEADER_VIEW_STYLE_TWOLINES);
        modest_header_view_set_folder (MODEST_HEADER_VIEW (header_view), folder, 
-                                      TRUE, NULL, NULL);
+                                      TRUE, progress_window, NULL, NULL);
        modest_widget_memory_restore (modest_runtime_get_conf (), G_OBJECT(header_view),
                                      MODEST_CONF_HEADER_VIEW_KEY);
 
@@ -326,7 +327,7 @@ modest_header_window_new (TnyFolder *folder)
 
        pannable = hildon_pannable_area_new ();
 
-       priv->header_view  = create_header_view (folder);
+       priv->header_view  = create_header_view (MODEST_WINDOW (self), folder);
        priv->empty_view = create_empty_view ();
        g_object_ref (priv->header_view);
        g_object_ref (priv->empty_view);
index 9ecc4ca..f7251f7 100644 (file)
@@ -332,7 +332,6 @@ modest_hildon2_window_mgr_register_window (ModestWindowMgr *self,
        GList *win;
        ModestHildon2WindowMgrPrivate *priv;
        gint *handler_id;
-       ModestWindow *main_window;
        HildonProgram *program;
        GtkWidget *current_top;
 
@@ -389,17 +388,6 @@ 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);
 
-       main_window = modest_window_mgr_get_main_window (self, FALSE);
-       /* If there is a msg view window, let the main window listen the msg-changed signal */
-       if (MODEST_IS_MSG_VIEW_WINDOW(window) && 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), 
-                                            main_window);
-               g_hash_table_insert (priv->viewer_handlers, window, handler);
-       }
-
        /* Show toolbar always */       
        modest_window_show_toolbar (window, TRUE);
 
@@ -664,6 +652,8 @@ modest_hildon2_window_mgr_get_main_window (ModestWindowMgr *self, gboolean show)
        
        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 */
index 4fd78b2..16203c0 100644 (file)
@@ -2537,7 +2537,7 @@ static void on_folder_view_row_activated (GtkTreeView *tree_view,
                                    -1);
                if (folder_store && TNY_IS_FOLDER (folder_store)) {
                        modest_header_view_set_folder (MODEST_HEADER_VIEW (priv->header_view), 
-                                                      TNY_FOLDER (folder_store), TRUE,
+                                                      TNY_FOLDER (folder_store), TRUE, MODEST_WINDOW (self),
                                                       NULL, NULL);
                        modest_main_window_set_contents_style (MODEST_MAIN_WINDOW (self),
                                                               MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS);
index 0e2d58c..d7c6848 100644 (file)
@@ -61,6 +61,7 @@
 #include <errno.h>
 #include <glib/gstdio.h>
 #include <modest-debug.h>
+#include <modest-header-window.h>
 
 #define DEFAULT_FOLDER "MyDocs/.documents"
 
@@ -562,8 +563,8 @@ static void
 modest_msg_view_window_disconnect_signals (ModestWindow *self)
 {
        ModestMsgViewWindowPrivate *priv;
-       ModestHeaderView *header_view = NULL;
-       ModestWindow *main_window = NULL;
+       GtkWidget *header_view = NULL;
+       GtkWindow *parent_window = NULL;
        
        priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (self);
 
@@ -607,21 +608,15 @@ modest_msg_view_window_disconnect_signals (ModestWindow *self)
 
        modest_signal_mgr_disconnect_all_and_destroy (priv->sighandlers);
        priv->sighandlers = NULL;
-       
-       main_window = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr(),
-                                                        FALSE); /* don't create */
-       if (!main_window)
-               return;
-       
-       header_view = MODEST_HEADER_VIEW(
-                       modest_main_window_get_child_widget(
-                               MODEST_MAIN_WINDOW(main_window),
-                               MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW));
-       if (header_view == NULL)
-               return;
-       
-       modest_header_view_remove_observer(header_view,
-                       MODEST_HEADER_VIEW_OBSERVER(self));
+
+       parent_window = gtk_window_get_transient_for (GTK_WINDOW (self));
+       if (parent_window && MODEST_IS_HEADER_WINDOW (parent_window)) {
+               header_view = GTK_WIDGET (modest_header_window_get_header_view (MODEST_HEADER_WINDOW (parent_window)));
+               if (header_view) {
+                       modest_header_view_remove_observer(MODEST_HEADER_VIEW (header_view),
+                                                          MODEST_HEADER_VIEW_OBSERVER(self));
+               }
+       }
 }      
 
 static void
index bea330b..17e9212 100644 (file)
@@ -1152,7 +1152,6 @@ void
 modest_platform_push_email_notification(void)
 {
        gboolean play_sound;
-       ModestWindow *main_window;
        gboolean screen_on = TRUE, app_in_foreground;
 
        /* Check whether or not we should play a sound */
@@ -1161,9 +1160,7 @@ modest_platform_push_email_notification(void)
                                           NULL);
 
        /* Get the screen status */
-       main_window = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr (), FALSE);
-       if (main_window)
-               screen_on = modest_main_window_screen_is_on (MODEST_MAIN_WINDOW (main_window));
+       /* TODO :obtain properly the screen_is_on status */
 
        /* Get the window status */
        app_in_foreground = hildon_program_get_is_topmost (hildon_program_get_instance ());
@@ -1658,19 +1655,16 @@ modest_platform_run_certificate_confirmation_dialog (const gchar* server_name,
 {
        GtkWidget *note;
        gint response;
-       ModestWindow *main_win;
-       
-       if (!modest_window_mgr_main_window_exists (modest_runtime_get_window_mgr())) {
-               g_warning ("%s: don't show dialogs if there's no main window; assuming 'Cancel'",
+       ModestWindow *win;
+
+       win = MODEST_WINDOW (hildon_program_peek_window_stack (hildon_program_get_instance ()));
+
+       if (!win) {
+         g_warning ("%s: don't show dialogs if there's no window shown; assuming 'Cancel'",
                           __FUNCTION__);
                return FALSE;
        }
 
-       /* don't create it */
-       main_win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr(), FALSE);
-       g_return_val_if_fail (main_win, FALSE); /* should not happen */
-       
-       
        gchar *question = g_strdup_printf (_("mcen_nc_unknown_certificate"),
                                           server_name);
        
@@ -1679,7 +1673,7 @@ modest_platform_run_certificate_confirmation_dialog (const gchar* server_name,
           example. With GTK_RESPONSE_HELP the view button is aligned
           to the left while the other two to the right */
        note = hildon_note_new_confirmation_add_buttons  (
-               GTK_WINDOW(main_win),
+               NULL,
                question,
                _("mcen_bd_dialog_ok"),     GTK_RESPONSE_OK,
                _("mcen_bd_view"),          GTK_RESPONSE_APPLY,   /* abusing this... */
@@ -1690,8 +1684,6 @@ modest_platform_run_certificate_confirmation_dialog (const gchar* server_name,
                          G_CALLBACK(on_cert_dialog_response),
                          (gpointer) certificate);
        
-       modest_window_mgr_set_modal (modest_runtime_get_window_mgr (),
-                                    GTK_WINDOW (note), GTK_WINDOW (main_win));
        response = gtk_dialog_run(GTK_DIALOG(note));
 
        on_destroy_dialog (note);
index 19cebd6..5e3a9c8 100644 (file)
 #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;
@@ -180,17 +184,39 @@ main (int argc, char *argv[])
         * when we receive the "top_application" D-Bus method.
         */
        if (show_ui_without_top_application_method) {
-               ModestWindow *main_win;
+               ModestWindow *window;
+
+#ifdef MODEST_TOOLKIT_HILDON2
+               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 (modest_runtime_get_window_mgr (), window, NULL);
+               gtk_widget_show (GTK_WIDGET (window));
+#else
 
                /* this will create & register the window */
-               main_win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr(), 
-                                                             TRUE);
-               if (!main_win) {
+               window = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr(), 
+                                                           TRUE);
+               if (!window) {
                        g_printerr ("modest: failed to get main window instance\n");
                        retval = 1;
                        goto cleanup;
                }
-       
+#endif
                /* Remove new mail notifications if exist */
                modest_platform_remove_new_mail_notifications (FALSE);
        }
index a16034b..6750eb6 100644 (file)
@@ -2225,11 +2225,16 @@ modest_ui_actions_on_send_receive (GtkAction *action, ModestWindow *win)
        
                if (folder_store)
                        g_object_unref (folder_store);
-       }       
+               /* Refresh the active account. Force the connection if needed
+                  and poke the status of all folders */
+               modest_ui_actions_do_send_receive (NULL, TRUE, TRUE, TRUE, win);
+       } else {
+               const gchar *active_account;
+               active_account = modest_window_get_active_account (MODEST_WINDOW (win));
+
+               modest_ui_actions_do_send_receive (active_account, TRUE, TRUE, TRUE, win);
+       } 
        
-       /* Refresh the active account. Force the connection if needed
-          and poke the status of all folders */
-       modest_ui_actions_do_send_receive (NULL, TRUE, TRUE, TRUE, win);
 }
 
 
@@ -2470,6 +2475,7 @@ modest_ui_actions_on_folder_selection_changed (ModestFolderView *folder_view,
                        modest_header_view_set_folder (MODEST_HEADER_VIEW(header_view),
                                                       TNY_FOLDER (folder_store),
                                                       TRUE,
+                                                      MODEST_WINDOW (main_window),
                                                       folder_refreshed_cb,
                                                       main_window);
                        
@@ -2598,6 +2604,9 @@ on_save_to_drafts_cb (ModestMailOperation *mail_op,
                      gpointer user_data)
 {
        ModestMsgEditWindow *edit_window;
+
+       /* TODO: in hildon 2 we have to dim and undim the header views while we're saving */
+#ifndef MODEST_TOOLKIT_HILDON2
        ModestMainWindow *win;
 
        /* FIXME. Make the header view sensitive again. This is a
@@ -2610,6 +2619,7 @@ on_save_to_drafts_cb (ModestMailOperation *mail_op,
                        win, MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW);
                if (hdrview) gtk_widget_set_sensitive(hdrview, TRUE);
        }
+#endif
 
        edit_window = MODEST_MSG_EDIT_WINDOW (user_data);
 
index 2a68e09..4670b9a 100644 (file)
@@ -1295,23 +1295,16 @@ void
 modest_header_view_set_folder (ModestHeaderView *self, 
                               TnyFolder *folder,
                               gboolean refresh,
+                              ModestWindow *progress_window,
                               RefreshAsyncUserCallback callback,
                               gpointer user_data)
 {
        ModestHeaderViewPrivate *priv;
-       ModestWindow *main_win;
        
        g_return_if_fail (self);
 
        priv =     MODEST_HEADER_VIEW_GET_PRIVATE(self);
 
-       main_win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr (),
-                                                     FALSE); /* don't create */
-       if (!main_win) {
-               g_warning ("%s: BUG: no main window", __FUNCTION__);
-               return;
-       }
-                                                     
        if (priv->folder) {
                if (priv->status_timeout) {
                        g_source_remove (priv->status_timeout);
@@ -1355,9 +1348,10 @@ modest_header_view_set_folder (ModestHeaderView *self,
                info->user_data = user_data;
 
                /* Create the mail operation (source will be the parent widget) */
-               mail_op = modest_mail_operation_new_with_error_handling (G_OBJECT(main_win),
-                                                                        refresh_folder_error_handler,
-                                                                        NULL, NULL);
+               if (progress_window)
+                       mail_op = modest_mail_operation_new_with_error_handling (G_OBJECT(progress_window),
+                                                                                refresh_folder_error_handler,
+                                                                                NULL, NULL);
                if (refresh) {                  
                        modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
                                                         mail_op);
@@ -1942,7 +1936,7 @@ modest_header_view_clear (ModestHeaderView *self)
 {
        g_return_if_fail (self && MODEST_IS_HEADER_VIEW(self));
        
-       modest_header_view_set_folder (self, NULL, FALSE, NULL, NULL);
+       modest_header_view_set_folder (self, NULL, FALSE, NULL, NULL, NULL);
 }
 
 void 
index 2ff48c4..3ff7c81 100644 (file)
@@ -161,6 +161,7 @@ GtkWidget*   modest_header_view_new        (TnyFolder *folder,
 void         modest_header_view_set_folder (ModestHeaderView *self,
                                            TnyFolder *folder,
                                            gboolean refresh,
+                                           ModestWindow *progress_window,
                                            RefreshAsyncUserCallback callback,
                                            gpointer user_data);