Move mailboxes window to src/widgets
authorJose Dapena Paz <jdapena@igalia.com>
Wed, 25 Nov 2009 12:55:08 +0000 (13:55 +0100)
committerJose Dapena Paz <jdapena@igalia.com>
Wed, 25 Nov 2009 16:01:51 +0000 (17:01 +0100)
src/gtk/modest-gtk-window-mgr.c
src/gtk/modest-shell.c
src/gtk/modest-shell.h
src/hildon2/Makefile.am
src/hildon2/modest-mailboxes-window.c [deleted file]
src/hildon2/modest-mailboxes-window.h [deleted file]
src/widgets/Makefile.am
src/widgets/modest-accounts-window.c
src/widgets/modest-mailboxes-window.c [new file with mode: 0644]
src/widgets/modest-mailboxes-window.h [new file with mode: 0644]

index e673911..a925bd9 100644 (file)
@@ -85,7 +85,7 @@ static gboolean modest_gtk_window_mgr_find_registered_message_uid (ModestWindowM
 static GList *modest_gtk_window_mgr_get_window_list (ModestWindowMgr *self);
 static gboolean modest_gtk_window_mgr_close_all_windows (ModestWindowMgr *self);
 static gboolean modest_gtk_window_mgr_close_all_but_initial (ModestWindowMgr *self);
-static gboolean window_has_modals (ModestWindow *window);
+static gboolean shell_has_modals (ModestShell *window);
 static ModestWindow *modest_gtk_window_mgr_show_initial_window (ModestWindowMgr *self);
 static ModestWindow *modest_gtk_window_mgr_get_current_top (ModestWindowMgr *self);
 static gboolean modest_gtk_window_mgr_screen_is_on (ModestWindowMgr *self);
@@ -263,7 +263,7 @@ modest_gtk_window_mgr_close_all_windows (ModestWindowMgr *self)
 {
        ModestGtkWindowMgrPrivate *priv = NULL;
        gboolean ret_value = FALSE;
-       GtkWidget *window;
+       ModestWindow *window;
        gboolean failed = FALSE;
 
        g_return_val_if_fail (MODEST_IS_GTK_WINDOW_MGR (self), FALSE);
@@ -485,7 +485,7 @@ modest_gtk_window_mgr_register_window (ModestWindowMgr *self,
        if (MODEST_IS_FOLDER_WINDOW (current_top) && MODEST_IS_FOLDER_WINDOW (window)) {
                gboolean retval;
 
-               retval = modest_shell_delete_window (MODEST_SHELL (priv->shell), shell);
+               retval = modest_shell_delete_window (MODEST_SHELL (priv->shell), MODEST_WINDOW (window));
 
                if (retval) {
                        gtk_window_present (GTK_WINDOW (priv->shell));
@@ -540,7 +540,7 @@ modest_gtk_window_mgr_register_window (ModestWindowMgr *self,
                /* If the current view has modal dialogs then
                   we fail to register the new view */
                if ((current_top != NULL) &&
-                   window_has_modals (MODEST_WINDOW (current_top))) {
+                   shell_has_modals (MODEST_SHELL (priv->shell))) {
                        /* Window on top but it has opened dialogs */
                        goto fail;
                }
@@ -600,7 +600,7 @@ cancel_window_operations (ModestWindow *window)
 }
 
 static gboolean
-window_has_modals (ModestWindow *window)
+shell_has_modals (ModestShell *shell)
 {
        GList *toplevels;
        GList *node;
@@ -610,7 +610,7 @@ window_has_modals (ModestWindow *window)
        toplevels = gtk_window_list_toplevels ();
        for (node = toplevels; node != NULL; node = g_list_next (node)) {
                if (GTK_IS_WINDOW (node->data) &&
-                   gtk_window_get_transient_for (GTK_WINDOW (node->data)) == GTK_WINDOW (priv->shell) &&
+                   gtk_window_get_transient_for (GTK_WINDOW (node->data)) == GTK_WINDOW (shell) &&
                    GTK_WIDGET_VISIBLE (node->data)) {
                        retvalue = TRUE;
                        break;
@@ -625,10 +625,13 @@ on_window_destroy (ModestWindow *window,
                   GdkEvent *event,
                   ModestGtkWindowMgr *self)
 {
+       ModestGtkWindowMgrPrivate *priv;
        gboolean no_propagate = FALSE;
 
+       priv = MODEST_GTK_WINDOW_MGR_GET_PRIVATE (self);
+
        /* Do not close the window if it has modals on top */
-       if (!MODEST_IS_MSG_EDIT_WINDOW (window) && window_has_modals (window))
+       if (!MODEST_IS_MSG_EDIT_WINDOW (window) && shell_has_modals (MODEST_SHELL (priv->shell)))
                return TRUE;
 
        if (MODEST_IS_MSG_EDIT_WINDOW (window)) {
@@ -793,7 +796,7 @@ modest_gtk_window_mgr_get_modal (ModestWindowMgr *self)
 {
        ModestGtkWindowMgrPrivate *priv;
        GList *toplevel_list;
-       GtkWidget *current_top, *toplevel;
+       GtkWidget *toplevel;
 
        g_return_val_if_fail (MODEST_IS_GTK_WINDOW_MGR (self), NULL);
        priv = MODEST_GTK_WINDOW_MGR_GET_PRIVATE (self);
@@ -837,15 +840,13 @@ close_all_but_first (gpointer data)
 {
        gint num_windows, i;
        gboolean retval;
-       HildonWindowStack *stack;
-
-       stack = hildon_window_stack_get_default ();
-       g_return_if_fail (stack);
+       ModestGtkWindowMgrPrivate *priv;
 
-       num_windows = hildon_window_stack_size (stack);
+       priv = MODEST_GTK_WINDOW_MGR_GET_PRIVATE(data);
+       num_windows = modest_shell_count_windows (MODEST_SHELL (priv->shell));
 
        for (i = 0; i < (num_windows - 1); i++) {
-               GtkWidget *current_top;
+               ModestWindow *current_top;
 
                /* Close window */
                current_top = modest_shell_peek_window (MODEST_SHELL (priv->shell));
@@ -869,6 +870,9 @@ on_account_removed (TnyAccountStore *acc_store,
                    gpointer user_data)
 {
        ModestWindow *current_top;
+       ModestGtkWindowMgrPrivate *priv;
+
+       priv = MODEST_GTK_WINDOW_MGR_GET_PRIVATE (user_data);
 
        /* Ignore transport account removals */
        if (TNY_IS_TRANSPORT_ACCOUNT (account))
@@ -892,7 +896,7 @@ on_account_removed (TnyAccountStore *acc_store,
                       modal dialog would otherwise, prevent the
                       windows from being closed */
                    if (!strcmp (acc_name, modest_window_get_active_account (current_top)))
-                           g_idle_add (on_idle_close_all_but_first, NULL);
+                           g_idle_add (on_idle_close_all_but_first, (gpointer) priv->shell);
        }
 }
 
@@ -926,7 +930,6 @@ modest_gtk_window_mgr_show_initial_window (ModestWindowMgr *self)
 static ModestWindow *
 modest_gtk_window_mgr_get_current_top (ModestWindowMgr *self)
 {
-       ModestWindow *initial_window = NULL;
        ModestGtkWindowMgrPrivate *priv;
 
        priv = MODEST_GTK_WINDOW_MGR_GET_PRIVATE (self);
@@ -983,6 +986,9 @@ static gboolean
 modest_gtk_window_mgr_close_all_but_initial (ModestWindowMgr *self)
 {
        ModestWindow *top;
+       ModestGtkWindowMgrPrivate *priv;
+
+       priv = MODEST_GTK_WINDOW_MGR_GET_PRIVATE(self);
 
        /* Exit if there are no windows */
        if (!modest_window_mgr_get_num_windows (self)) {
@@ -999,7 +1005,7 @@ modest_gtk_window_mgr_close_all_but_initial (ModestWindowMgr *self)
        /* Close all but first */
        top = modest_window_mgr_get_current_top (self);
        if (!MODEST_IS_ACCOUNTS_WINDOW (top))
-               close_all_but_first (NULL);
+               close_all_but_first ((gpointer) priv->shell);
 
        /* If some cannot be closed return */
        top = modest_window_mgr_get_current_top (self);
index b74e46e..6578312 100644 (file)
@@ -108,10 +108,10 @@ modest_shell_finalize (GObject *obj)
        G_OBJECT_CLASS(parent_class)->finalize (obj);
 }
 
-ModestWindowMgr*
+GtkWidget*
 modest_shell_new (void)
 {
-       return MODEST_WINDOW_MGR(g_object_new(MODEST_TYPE_SHELL, NULL));
+       return (GtkWidget *) g_object_new(MODEST_TYPE_SHELL, NULL);
 }
 
 ModestWindow *
@@ -120,7 +120,7 @@ modest_shell_peek_window (ModestShell *shell)
        ModestShellPrivate *priv;
        gint count;
 
-       priv = MODEST_SHELL_GET_PRIVATE(obj);
+       priv = MODEST_SHELL_GET_PRIVATE (shell);
        count = gtk_notebook_get_n_pages (GTK_NOTEBOOK (priv->notebook));
 
        if (count > 0) {
@@ -136,8 +136,8 @@ modest_shell_delete_window (ModestShell *shell, ModestWindow *window)
        ModestShellPrivate *priv;
        gboolean ret_value;
 
-       priv = MODEST_SHELL_GET_PRIVATE(obj);
-       g_signal_emit (G_OBJECT (window), "delete-event", NULL, &ret_value);
+       priv = MODEST_SHELL_GET_PRIVATE (shell);
+       g_signal_emit_by_name (G_OBJECT (window), "delete-event", NULL, &ret_value);
        if (ret_value == FALSE) {
                gint page_num;
                
@@ -155,6 +155,16 @@ modest_shell_add_window (ModestShell *shell, ModestWindow *window)
 {
        ModestShellPrivate *priv;
 
-       priv = MODEST_SHELL_GET_PRIVATE(obj);
+       priv = MODEST_SHELL_GET_PRIVATE (shell);
        gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), GTK_WIDGET (window), NULL);
 }
+
+gint
+modest_shell_count_windows (ModestShell *shell)
+{
+       ModestShellPrivate *priv;
+
+       priv = MODEST_SHELL_GET_PRIVATE (shell);
+
+       return gtk_notebook_get_n_pages (GTK_NOTEBOOK (priv->notebook));
+}
index e96d34e..4260a57 100644 (file)
@@ -60,11 +60,12 @@ struct _ModestShellClass {
 GType        modest_shell_get_type    (void) G_GNUC_CONST;
 
 /* typical parameter-less _new function */
-GtkWindow*    modest_shell_new  (void);
+GtkWidget*    modest_shell_new  (void);
 
 ModestWindow *modest_shell_peek_window (ModestShell *shell);
 gboolean modest_shell_delete_window (ModestShell *shell, ModestWindow *window);
 void modest_shell_add_window (ModestShell *shell, ModestWindow *window);
+gint modest_shell_count_windows (ModestShell *shell);
 
 
 G_END_DECLS
index eafa3c8..2a50231 100644 (file)
@@ -75,8 +75,6 @@ libmodest_ui_la_SOURCES=              \
        modest-hildon2-sort-dialog.h   \
        modest-hildon2-window.h \
        modest-hildon2-window.c \
-       modest-mailboxes-window.c \
-       modest-mailboxes-window.h \
        modest-platform.c             \
        modest-signature-editor-dialog.c         \
        modest-signature-editor-dialog.h         \
diff --git a/src/hildon2/modest-mailboxes-window.c b/src/hildon2/modest-mailboxes-window.c
deleted file mode 100644 (file)
index 18c7fd7..0000000
+++ /dev/null
@@ -1,643 +0,0 @@
-/* Copyright (c) 2009, Nokia Corporation
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * * Neither the name of the Nokia Corporation nor the names of its
- *   contributors may be used to endorse or promote products derived from
- *   this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include <modest-mailboxes-window.h>
-#include <modest-scrollable.h>
-#include <modest-window-mgr.h>
-#include <modest-signal-mgr.h>
-#include <modest-runtime.h>
-#include <modest-platform.h>
-#include <modest-maemo-utils.h>
-#include <modest-icon-names.h>
-#include <modest-ui-constants.h>
-#include <modest-account-mgr.h>
-#include <modest-account-mgr-helpers.h>
-#include <modest-defs.h>
-#include <modest-ui-actions.h>
-#include <modest-window.h>
-#include <hildon/hildon-program.h>
-#include <hildon/hildon-banner.h>
-#include <hildon/hildon-button.h>
-#include <tny-account-store-view.h>
-#include <modest-header-window.h>
-#include <modest-ui-dimming-rules.h>
-#include <modest-ui-dimming-manager.h>
-#include <modest-window-priv.h>
-#include "modest-text-utils.h"
-#include "modest-tny-account.h"
-#include <modest-folder-window.h>
-
-/* 'private'/'protected' functions */
-static void modest_mailboxes_window_class_init  (ModestMailboxesWindowClass *klass);
-static void modest_mailboxes_window_init        (ModestMailboxesWindow *obj);
-static void modest_mailboxes_window_finalize    (GObject *obj);
-
-static void connect_signals (ModestMailboxesWindow *self);
-static void modest_mailboxes_window_disconnect_signals (ModestWindow *self);
-
-static void on_mailbox_activated (ModestFolderView *mailboxes_view,
-                                 TnyFolder *folder,
-                                 gpointer userdata);
-static void on_progress_list_changed (ModestWindowMgr *mgr,
-                                     ModestMailboxesWindow *self);
-static gboolean on_map_event (GtkWidget *widget,
-                             GdkEvent *event,
-                             gpointer userdata);
-static void update_progress_hint (ModestMailboxesWindow *self);
-static void on_queue_changed    (ModestMailOperationQueue *queue,
-                                ModestMailOperation *mail_op,
-                                ModestMailOperationQueueNotification type,
-                                ModestMailboxesWindow *self);
-static void on_activity_changed (ModestFolderView *view,
-                                gboolean activity,
-                                ModestMailboxesWindow *folder_window);
-static gboolean on_key_press(GtkWidget *widget,
-                               GdkEventKey *event,
-                               gpointer user_data);
-
-typedef struct _ModestMailboxesWindowPrivate ModestMailboxesWindowPrivate;
-struct _ModestMailboxesWindowPrivate {
-
-       GtkWidget *folder_view;
-       GtkWidget *top_vbox;
-       GtkWidget *new_message_button;
-
-       /* signals */
-       GSList *sighandlers;
-
-       gchar *current_store_account;
-       gboolean progress_hint;
-       guint queue_change_handler;
-};
-#define MODEST_MAILBOXES_WINDOW_GET_PRIVATE(o)  (G_TYPE_INSTANCE_GET_PRIVATE((o), \
-                                                                         MODEST_TYPE_MAILBOXES_WINDOW, \
-                                                                         ModestMailboxesWindowPrivate))
-
-/* globals */
-static GtkWindowClass *parent_class = NULL;
-
-/************************************************************************/
-
-GType
-modest_mailboxes_window_get_type (void)
-{
-       static GType my_type = 0;
-       if (!my_type) {
-               static const GTypeInfo my_info = {
-                       sizeof(ModestMailboxesWindowClass),
-                       NULL,           /* base init */
-                       NULL,           /* base finalize */
-                       (GClassInitFunc) modest_mailboxes_window_class_init,
-                       NULL,           /* class finalize */
-                       NULL,           /* class data */
-                       sizeof(ModestMailboxesWindow),
-                       1,              /* n_preallocs */
-                       (GInstanceInitFunc) modest_mailboxes_window_init,
-                       NULL
-               };
-               my_type = g_type_register_static (MODEST_TYPE_HILDON2_WINDOW,
-                                                 "ModestMailboxesWindow",
-                                                 &my_info, 0);
-       }
-       return my_type;
-}
-
-static void
-modest_mailboxes_window_class_init (ModestMailboxesWindowClass *klass)
-{
-       GObjectClass *gobject_class;
-       gobject_class = (GObjectClass*) klass;
-       ModestWindowClass *modest_window_class = (ModestWindowClass *) klass;
-
-       parent_class            = g_type_class_peek_parent (klass);
-       gobject_class->finalize = modest_mailboxes_window_finalize;
-
-       g_type_class_add_private (gobject_class, sizeof(ModestMailboxesWindowPrivate));
-       
-       modest_window_class->disconnect_signals_func = modest_mailboxes_window_disconnect_signals;
-}
-
-static void
-modest_mailboxes_window_init (ModestMailboxesWindow *obj)
-{
-       ModestMailboxesWindowPrivate *priv;
-
-       priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE(obj);
-
-       priv->sighandlers = NULL;
-       
-       priv->folder_view = NULL;
-
-       priv->top_vbox = NULL;
-
-       priv->current_store_account = NULL;
-       priv->progress_hint = FALSE;
-       priv->queue_change_handler = 0;
-}
-
-static void
-modest_mailboxes_window_finalize (GObject *obj)
-{
-       ModestMailboxesWindowPrivate *priv;
-
-       priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE(obj);
-
-       if (priv->current_store_account) {
-               g_free (priv->current_store_account);
-               priv->current_store_account = NULL;
-       }
-
-       /* Sanity check: shouldn't be needed, the window mgr should
-          call this function before */
-       modest_mailboxes_window_disconnect_signals (MODEST_WINDOW (obj));       
-
-       G_OBJECT_CLASS(parent_class)->finalize (obj);
-}
-
-static void
-modest_mailboxes_window_disconnect_signals (ModestWindow *self)
-{
-       ModestMailboxesWindowPrivate *priv;
-       priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE(self);
-
-       if (g_signal_handler_is_connected (G_OBJECT (modest_runtime_get_mail_operation_queue ()), 
-                                          priv->queue_change_handler))
-               g_signal_handler_disconnect (G_OBJECT (modest_runtime_get_mail_operation_queue ()), 
-                                            priv->queue_change_handler);
-
-       modest_signal_mgr_disconnect_all_and_destroy (priv->sighandlers);
-       priv->sighandlers = NULL;
-}
-
-static void
-on_visible_account_changed (ModestFolderView *mailboxes_view,
-                           const gchar *account_id,
-                           gpointer user_data)
-{
-       if (account_id) {
-               TnyAccount *acc = 
-                       modest_tny_account_store_get_tny_account_by (modest_runtime_get_account_store(),
-                                                                    MODEST_TNY_ACCOUNT_STORE_QUERY_ID,
-                                                                    account_id);
-               if (acc) {
-                       const gchar *name;
-                       gchar *title = NULL;
-
-                       name = modest_tny_account_get_parent_modest_account_name_for_server_account (acc);
-                       title = modest_account_mgr_get_display_name (modest_runtime_get_account_mgr(),
-                                                                    name);
-                       if (title) {
-                               modest_window_set_title (MODEST_WINDOW (user_data), title);
-                               g_free (title);
-                       } else {
-                               modest_window_set_title (MODEST_WINDOW (user_data), _("mcen_ap_name"));
-                       }
-                       g_object_unref (acc);
-               }
-       } else {
-               modest_window_set_title (MODEST_WINDOW (user_data), _("mcen_ap_name"));
-       }
-}
-
-static void
-connect_signals (ModestMailboxesWindow *self)
-{
-       ModestMailboxesWindowPrivate *priv;
-
-       priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE(self);
-
-       /* mailboxes view */
-       priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers, 
-                                                      G_OBJECT (priv->folder_view), "folder-activated", 
-                                                      G_CALLBACK (on_mailbox_activated), self);
-
-       priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers,
-                                                      G_OBJECT (modest_runtime_get_window_mgr ()),
-                                                      "progress-list-changed",
-                                                      G_CALLBACK (on_progress_list_changed), self);
-
-       priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers,
-                                                      G_OBJECT (priv->folder_view),
-                                                      "activity-changed",
-                                                      G_CALLBACK (on_activity_changed), self);
-
-       priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers,
-                                                      G_OBJECT (priv->folder_view),
-                                                      "visible-account-changed",
-                                                      G_CALLBACK (on_visible_account_changed), self);
-
-       priv->sighandlers = 
-               modest_signal_mgr_connect (priv->sighandlers,
-                                          G_OBJECT (priv->new_message_button),
-                                          "clicked",
-                                          G_CALLBACK (modest_ui_actions_on_new_msg), self);
-
-       /* connect window keys -> priv->folder_view scroll here? */
-       g_signal_connect(G_OBJECT(self), "key-press-event",
-                       G_CALLBACK(on_key_press), self);
-}
-
-ModestWindow *
-modest_mailboxes_window_new (const gchar *account)
-{
-       ModestMailboxesWindow *self = NULL;     
-       ModestMailboxesWindowPrivate *priv = NULL;
-       HildonProgram *app;
-       GdkPixbuf *window_icon;
-       GtkWidget *scrollable;
-       GtkWidget *action_area_box;
-       GdkPixbuf *new_message_pixbuf;
-       guint accel_key;
-       GdkModifierType accel_mods;
-       GtkAccelGroup *accel_group;
-       GtkWidget *top_alignment;
-       
-       self  = MODEST_MAILBOXES_WINDOW(g_object_new(MODEST_TYPE_MAILBOXES_WINDOW, NULL));
-       priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE(self);
-
-       scrollable = modest_toolkit_factory_create_scrollable (modest_runtime_get_toolkit_factory ());
-       priv->queue_change_handler =
-               g_signal_connect (G_OBJECT (modest_runtime_get_mail_operation_queue ()),
-                                 "queue-changed",
-                                 G_CALLBACK (on_queue_changed),
-                                 self);
-
-       priv->folder_view  = modest_platform_create_folder_view (NULL);
-       modest_folder_view_set_cell_style (MODEST_FOLDER_VIEW (priv->folder_view),
-                                          MODEST_FOLDER_VIEW_CELL_STYLE_COMPACT);
-       modest_folder_view_set_filter (MODEST_FOLDER_VIEW (priv->folder_view), 
-                                      MODEST_FOLDER_VIEW_FILTER_HIDE_ACCOUNTS);
-
-       action_area_box = hildon_tree_view_get_action_area_box (GTK_TREE_VIEW (priv->folder_view));
-       priv->new_message_button = hildon_button_new (0, HILDON_BUTTON_ARRANGEMENT_HORIZONTAL);
-
-       hildon_button_set_title (HILDON_BUTTON (priv->new_message_button), _("mcen_ti_new_message"));
-       new_message_pixbuf = modest_platform_get_icon ("general_add", MODEST_ICON_SIZE_BIG);
-       hildon_button_set_image (HILDON_BUTTON (priv->new_message_button), gtk_image_new_from_pixbuf (new_message_pixbuf));
-       g_object_unref (new_message_pixbuf);
-
-       gtk_box_pack_start (GTK_BOX (action_area_box), priv->new_message_button, TRUE, TRUE, 0);
-       gtk_widget_show_all (priv->new_message_button);
-       hildon_tree_view_set_action_area_visible (GTK_TREE_VIEW (priv->folder_view), TRUE);
-       
-       /* Set account store */
-       tny_account_store_view_set_account_store (TNY_ACCOUNT_STORE_VIEW (priv->folder_view),
-                                                 TNY_ACCOUNT_STORE (modest_runtime_get_account_store ()));
-
-       priv->top_vbox = gtk_vbox_new (0, FALSE);
-       top_alignment = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
-       gtk_alignment_set_padding (GTK_ALIGNMENT (top_alignment), 
-                                  0, 0, 
-                                  MODEST_MARGIN_DOUBLE, MODEST_MARGIN_DOUBLE);
-
-       gtk_container_add (GTK_CONTAINER (scrollable), priv->folder_view);
-       gtk_box_pack_end (GTK_BOX (priv->top_vbox), scrollable, TRUE, TRUE, 0);
-       gtk_container_add (GTK_CONTAINER (top_alignment), priv->top_vbox);
-       gtk_container_add (GTK_CONTAINER (self), top_alignment);
-
-       gtk_widget_show (priv->folder_view);
-       gtk_widget_show (scrollable);
-       gtk_widget_show (top_alignment);
-       gtk_widget_show (priv->top_vbox);
-
-       connect_signals (MODEST_MAILBOXES_WINDOW (self));
-
-       /* Get device name */
-       modest_maemo_utils_get_device_name ();
-
-       app = hildon_program_get_instance ();
-       hildon_program_add_window (app, HILDON_WINDOW (self));
-       
-       /* Set window icon */
-       window_icon = modest_platform_get_icon (MODEST_APP_ICON, MODEST_ICON_SIZE_BIG);
-       if (window_icon) {
-               gtk_window_set_icon (GTK_WINDOW (self), window_icon);
-               g_object_unref (window_icon);
-       }
-
-       /* Dont't restore settings here, 
-        * because it requires a gtk_widget_show(), 
-        * and we don't want to do that until later,
-        * so that the UI is not visible for non-menu D-Bus activation.
-        */
-
-       g_signal_connect (G_OBJECT (self), "map-event",
-                         G_CALLBACK (on_map_event),
-                         G_OBJECT (self));
-       update_progress_hint (self);
-
-       accel_group = gtk_accel_group_new ();
-       gtk_accelerator_parse ("<Control>n", &accel_key, &accel_mods);
-       gtk_widget_add_accelerator (priv->new_message_button, "clicked", accel_group,
-                                   accel_key, accel_mods, 0);
-       gtk_window_add_accel_group (GTK_WINDOW (self), accel_group);
-
-       modest_folder_view_set_filter (MODEST_FOLDER_VIEW (priv->folder_view),
-                                      MODEST_FOLDER_VIEW_FILTER_SHOW_ONLY_MAILBOXES);
-
-       modest_mailboxes_window_set_account (MODEST_MAILBOXES_WINDOW (self), account);
-
-       return MODEST_WINDOW(self);
-}
-
-ModestFolderView *
-modest_mailboxes_window_get_folder_view (ModestMailboxesWindow *self)
-{
-       ModestMailboxesWindowPrivate *priv = NULL;
-
-       g_return_val_if_fail (MODEST_IS_MAILBOXES_WINDOW(self), FALSE);
-
-       priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE (self);
-       
-       return MODEST_FOLDER_VIEW (priv->folder_view);
-}
-
-void
-modest_mailboxes_window_set_account (ModestMailboxesWindow *self,
-                                    const gchar *account_name)
-{
-       ModestMailboxesWindowPrivate *priv = NULL;
-       ModestAccountMgr *mgr;
-       ModestAccountSettings *settings = NULL;
-       ModestServerAccountSettings *store_settings = NULL;
-
-       g_return_if_fail (MODEST_IS_MAILBOXES_WINDOW(self));
-
-       priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE (self);
-
-       /* Get account data */
-       mgr = modest_runtime_get_account_mgr ();
-
-       settings = modest_account_mgr_load_account_settings (mgr, account_name);
-       if (!settings)
-               goto free_refs;
-
-       store_settings = modest_account_settings_get_store_settings (settings);
-       if (!store_settings)
-               goto free_refs;
-
-       if (priv->current_store_account != NULL)
-               g_free (priv->current_store_account);
-       priv->current_store_account = g_strdup (modest_server_account_settings_get_account_name (store_settings));
-
-       modest_folder_view_set_account_id_of_visible_server_account
-               (MODEST_FOLDER_VIEW (priv->folder_view),
-                priv->current_store_account);
-
-       modest_window_set_active_account (MODEST_WINDOW (self), account_name);
-       update_progress_hint (self);
-
-free_refs:
-       if (store_settings)
-               g_object_unref (store_settings);
-       if (settings)
-               g_object_unref (settings);
-
-}
-
-static void
-on_mailbox_activated (ModestFolderView *mailboxes_view,
-                     TnyFolder *folder,
-                     gpointer userdata)
-{
-       ModestMailboxesWindowPrivate *priv = NULL;
-       ModestMailboxesWindow *self = (ModestMailboxesWindow *) userdata;
-       GtkWidget *new_window;
-       gboolean registered;
-       const gchar *active_account;
-
-       g_return_if_fail (MODEST_IS_MAILBOXES_WINDOW(self));
-
-       priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE (self);
-
-       if (!folder)
-               return;
-
-       if (!TNY_IS_FOLDER (folder))
-               return;
-
-       new_window = GTK_WIDGET (modest_folder_window_new (NULL));
-       registered = modest_window_mgr_register_window (modest_runtime_get_window_mgr (), 
-                                                       MODEST_WINDOW (new_window),
-                                                       MODEST_WINDOW (self));
-
-       if (!registered) {
-               gtk_widget_destroy (new_window);
-               new_window = NULL;
-       } else {
-               const gchar *name;
-               active_account = modest_window_get_active_account (MODEST_WINDOW (self));
-               modest_folder_window_set_account (MODEST_FOLDER_WINDOW (new_window), active_account);
-               name = tny_folder_get_name (folder);
-               if (name) {
-                       modest_folder_window_set_mailbox (MODEST_FOLDER_WINDOW (new_window), name);
-               }
-               gtk_widget_show (new_window);
-       }
-       
-}
-
-static gboolean 
-on_map_event (GtkWidget *widget,
-             GdkEvent *event,
-             gpointer userdata)
-{
-       ModestMailboxesWindow *self = (ModestMailboxesWindow *) userdata;
-       ModestMailboxesWindowPrivate *priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE (self);
-
-       if (priv->progress_hint) {
-               hildon_gtk_window_set_progress_indicator (GTK_WINDOW (self), TRUE);
-       }
-
-       return FALSE;
-}
-
-static gboolean
-has_active_operations (ModestMailboxesWindow *self)
-{
-       GSList *operations = NULL, *node;
-       ModestMailOperationQueue *queue;
-       gboolean has_active = FALSE;
-
-       queue = modest_runtime_get_mail_operation_queue ();
-       operations = modest_mail_operation_queue_get_by_source (queue, G_OBJECT (self));
-
-       for (node = operations; node != NULL; node = g_slist_next (node)) {
-               if (!modest_mail_operation_is_finished (MODEST_MAIL_OPERATION (node->data))) {
-                       has_active = TRUE;
-                       break;
-               }
-       }
-
-       if (operations) {
-               g_slist_foreach (operations, (GFunc) g_object_unref, NULL);
-               g_slist_free (operations);
-       }
-
-       return has_active;
-}
-
-static void
-update_progress_hint (ModestMailboxesWindow *self)
-{
-       ModestMailboxesWindowPrivate *priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE (self);
-
-       if (has_active_operations (self)) {
-               priv->progress_hint = TRUE;
-       } else {
-               priv->progress_hint = FALSE;
-       }
-
-       if (!priv->progress_hint && priv->current_store_account) {
-               priv->progress_hint = modest_window_mgr_has_progress_operation_on_account (modest_runtime_get_window_mgr (),
-                                                                                          priv->current_store_account);
-       }
-
-       if (!priv->progress_hint) {
-               priv->progress_hint = modest_folder_view_get_activity (MODEST_FOLDER_VIEW (priv->folder_view));
-       }
-
-       modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (self));
-
-       if (GTK_WIDGET_VISIBLE (self)) {
-               hildon_gtk_window_set_progress_indicator (GTK_WINDOW (self), priv->progress_hint ? 1:0);
-       }
-}
-
-static void
-on_progress_list_changed (ModestWindowMgr *mgr,
-                         ModestMailboxesWindow *self)
-{
-       update_progress_hint (self);
-}
-
-static void 
-on_mail_operation_started (ModestMailOperation *mail_op,
-                          gpointer user_data)
-{
-       ModestMailboxesWindow *self;
-       ModestMailOperationTypeOperation op_type;
-       GObject *source = NULL;
-
-       self = MODEST_MAILBOXES_WINDOW (user_data);
-       op_type = modest_mail_operation_get_type_operation (mail_op);
-       source = modest_mail_operation_get_source(mail_op);
-       if (G_OBJECT (self) == source) {
-               update_progress_hint (self);
-       }
-       g_object_unref (source);
-}
-
-static void 
-on_mail_operation_finished (ModestMailOperation *mail_op,
-                           gpointer user_data)
-{
-       ModestMailboxesWindow *self;
-
-       self = MODEST_MAILBOXES_WINDOW (user_data);
-
-       /* Don't disable the progress hint if there are more pending
-          operations from this window */
-       update_progress_hint (self);
-
-       modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (self));
-}
-
-static void
-on_queue_changed (ModestMailOperationQueue *queue,
-                 ModestMailOperation *mail_op,
-                 ModestMailOperationQueueNotification type,
-                 ModestMailboxesWindow *self)
-{
-       ModestMailboxesWindowPrivate *priv;
-
-       priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE (self);
-
-       /* If this operations was created by another window, do nothing */
-       if (!modest_mail_operation_is_mine (mail_op, G_OBJECT(self))) 
-               return;
-
-       if (type == MODEST_MAIL_OPERATION_QUEUE_OPERATION_ADDED) {
-               priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers,
-                                                              G_OBJECT (mail_op),
-                                                              "operation-started",
-                                                              G_CALLBACK (on_mail_operation_started),
-                                                              self);
-               priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers,
-                                                              G_OBJECT (mail_op),
-                                                              "operation-finished",
-                                                              G_CALLBACK (on_mail_operation_finished),
-                                                              self);
-       } else if (type == MODEST_MAIL_OPERATION_QUEUE_OPERATION_REMOVED) {
-               priv->sighandlers = modest_signal_mgr_disconnect (priv->sighandlers,
-                                                                 G_OBJECT (mail_op),
-                                                                 "operation-started");
-               priv->sighandlers = modest_signal_mgr_disconnect (priv->sighandlers,
-                                                                 G_OBJECT (mail_op),
-                                                                 "operation-finished");
-       }
-}
-
-static void
-on_activity_changed (ModestFolderView *view,
-                    gboolean activity,
-                    ModestMailboxesWindow *self)
-{
-       g_return_if_fail (MODEST_IS_MAILBOXES_WINDOW (self));
-
-       update_progress_hint (self);
-}
-
-
-static gboolean
-on_key_press(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
-{
-       ModestMailboxesWindowPrivate *priv;
-       ModestScrollable *scrollable;
-
-       if (event->type == GDK_KEY_RELEASE)
-               return FALSE;
-
-       priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE(user_data);
-
-       scrollable = MODEST_SCROLLABLE (gtk_widget_get_parent (priv->folder_view));
-
-       switch (event->keyval) {
-
-       case GDK_Up:
-               modest_scrollable_scroll (scrollable, 0, -1);
-               break;
-
-       case GDK_Down:
-               modest_scrollable_scroll (scrollable, 0, 1);
-               break;
-       }
-
-       return FALSE;
-}
diff --git a/src/hildon2/modest-mailboxes-window.h b/src/hildon2/modest-mailboxes-window.h
deleted file mode 100644 (file)
index 02090fb..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-/* Copyright (c) 2009 Nokia Corporation
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are
- * met:
- *
- * * Redistributions of source code must retain the above copyright
- *   notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- *   notice, this list of conditions and the following disclaimer in the
- *   documentation and/or other materials provided with the distribution.
- * * Neither the name of the Nokia Corporation nor the names of its
- *   contributors may be used to endorse or promote products derived from
- *   this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef __MODEST_MAILBOXES_WINDOW_H__
-#define __MODEST_MAILBOXES_WINDOW_H__
-
-#include <modest-hildon2-window.h>
-#include <widgets/modest-folder-view.h>
-
-G_BEGIN_DECLS
-
-/* convenience macros */
-#define MODEST_TYPE_MAILBOXES_WINDOW             (modest_mailboxes_window_get_type())
-#define MODEST_MAILBOXES_WINDOW(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_MAILBOXES_WINDOW,ModestMailboxesWindow))
-#define MODEST_MAILBOXES_WINDOW_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_MAILBOXES_WINDOW,ModestWindow))
-
-#define MODEST_IS_MAILBOXES_WINDOW(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_MAILBOXES_WINDOW))
-#define MODEST_IS_MAILBOXES_WINDOW_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_MAILBOXES_WINDOW))
-#define MODEST_MAILBOXES_WINDOW_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_MAILBOXES_WINDOW,ModestMailboxesWindowClass))
-
-typedef struct _ModestMailboxesWindow      ModestMailboxesWindow;
-typedef struct _ModestMailboxesWindowClass ModestMailboxesWindowClass;
-
-struct _ModestMailboxesWindow {
-       ModestHildon2Window parent;
-};
-
-struct _ModestMailboxesWindowClass {
-       ModestHildon2WindowClass parent_class;
-};
-
-/**
- * modest_mailboxes_window_get_type:
- * 
- * get the GType for the ModestMailboxesWindow class
- *
- * Returns: a GType for ModestMailboxesWindow
- */
-GType modest_mailboxes_window_get_type (void) G_GNUC_CONST;
-
-
-/**
- * modest_mailboxes_window_new:
- * @query: a #TnyMailboxesStoreQuery that specifies the mailboxess to show
- * 
- * instantiates a new ModestMailboxesWindow widget
- *
- * Returns: a new ModestMailboxesWindow, or NULL in case of error
- */
-ModestWindow* modest_mailboxes_window_new (const gchar *account_name);
-
-/**
- * modest_mailboxes_window_get_mailboxes_view:
- * @self: a #ModestMailboxesWindow
- *
- * get the mailboxes view inside the mailboxes window
- */
-ModestFolderView *modest_mailboxes_window_get_folder_view (ModestMailboxesWindow *self);
-
-/**
- * modest_mailboxes_window_set_account:
- * @self: a #ModestMailboxesWindow
- * @account_name: a string
- *
- * Sets the current active account in the mailboxes window.
- */
-void modest_mailboxes_window_set_account (ModestMailboxesWindow *self,
-                                         const gchar *account_name);
-
-G_END_DECLS
-
-#endif
index c0fe066..099a092 100644 (file)
@@ -88,6 +88,8 @@ libmodest_widgets_la_SOURCES=          \
        modest-limit-retrieve-combo-box.c \
        modest-mail-header-view.h \
        modest-mail-header-view.c \
+       modest-mailboxes-window.c \
+       modest-mailboxes-window.h \
        modest-main-window.h           \
        modest-mime-part-view.c        \
        modest-mime-part-view.h        \
index 29d3f8b..61c0154 100644 (file)
 
 #include <modest-accounts-window.h>
 #include <modest-scrollable.h>
-#include <hildon/hildon-banner.h>
-#include <hildon/hildon-helper.h>
 #include <modest-ui-actions.h>
 #include <modest-window-mgr.h>
 #include <modest-signal-mgr.h>
 #include <modest-runtime.h>
 #include <modest-platform.h>
-#include <hildon/hildon-program.h>
-#include <hildon/hildon-button.h>
-#include <modest-maemo-utils.h>
 #include <modest-icon-names.h>
 #include <modest-defs.h>
 #include <modest-folder-window.h>
 #include <modest-ui-constants.h>
 #include <modest-account-mgr-helpers.h>
 #include <modest-mailboxes-window.h>
+#ifdef MODEST_TOOLKIT_HILDON2
+#include <modest-maemo-utils.h>
+#include <hildon/hildon.h>
+#endif
 
 
 /* 'private'/'protected' functions */
diff --git a/src/widgets/modest-mailboxes-window.c b/src/widgets/modest-mailboxes-window.c
new file mode 100644 (file)
index 0000000..18c7fd7
--- /dev/null
@@ -0,0 +1,643 @@
+/* Copyright (c) 2009, Nokia Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Nokia Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived from
+ *   this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <modest-mailboxes-window.h>
+#include <modest-scrollable.h>
+#include <modest-window-mgr.h>
+#include <modest-signal-mgr.h>
+#include <modest-runtime.h>
+#include <modest-platform.h>
+#include <modest-maemo-utils.h>
+#include <modest-icon-names.h>
+#include <modest-ui-constants.h>
+#include <modest-account-mgr.h>
+#include <modest-account-mgr-helpers.h>
+#include <modest-defs.h>
+#include <modest-ui-actions.h>
+#include <modest-window.h>
+#include <hildon/hildon-program.h>
+#include <hildon/hildon-banner.h>
+#include <hildon/hildon-button.h>
+#include <tny-account-store-view.h>
+#include <modest-header-window.h>
+#include <modest-ui-dimming-rules.h>
+#include <modest-ui-dimming-manager.h>
+#include <modest-window-priv.h>
+#include "modest-text-utils.h"
+#include "modest-tny-account.h"
+#include <modest-folder-window.h>
+
+/* 'private'/'protected' functions */
+static void modest_mailboxes_window_class_init  (ModestMailboxesWindowClass *klass);
+static void modest_mailboxes_window_init        (ModestMailboxesWindow *obj);
+static void modest_mailboxes_window_finalize    (GObject *obj);
+
+static void connect_signals (ModestMailboxesWindow *self);
+static void modest_mailboxes_window_disconnect_signals (ModestWindow *self);
+
+static void on_mailbox_activated (ModestFolderView *mailboxes_view,
+                                 TnyFolder *folder,
+                                 gpointer userdata);
+static void on_progress_list_changed (ModestWindowMgr *mgr,
+                                     ModestMailboxesWindow *self);
+static gboolean on_map_event (GtkWidget *widget,
+                             GdkEvent *event,
+                             gpointer userdata);
+static void update_progress_hint (ModestMailboxesWindow *self);
+static void on_queue_changed    (ModestMailOperationQueue *queue,
+                                ModestMailOperation *mail_op,
+                                ModestMailOperationQueueNotification type,
+                                ModestMailboxesWindow *self);
+static void on_activity_changed (ModestFolderView *view,
+                                gboolean activity,
+                                ModestMailboxesWindow *folder_window);
+static gboolean on_key_press(GtkWidget *widget,
+                               GdkEventKey *event,
+                               gpointer user_data);
+
+typedef struct _ModestMailboxesWindowPrivate ModestMailboxesWindowPrivate;
+struct _ModestMailboxesWindowPrivate {
+
+       GtkWidget *folder_view;
+       GtkWidget *top_vbox;
+       GtkWidget *new_message_button;
+
+       /* signals */
+       GSList *sighandlers;
+
+       gchar *current_store_account;
+       gboolean progress_hint;
+       guint queue_change_handler;
+};
+#define MODEST_MAILBOXES_WINDOW_GET_PRIVATE(o)  (G_TYPE_INSTANCE_GET_PRIVATE((o), \
+                                                                         MODEST_TYPE_MAILBOXES_WINDOW, \
+                                                                         ModestMailboxesWindowPrivate))
+
+/* globals */
+static GtkWindowClass *parent_class = NULL;
+
+/************************************************************************/
+
+GType
+modest_mailboxes_window_get_type (void)
+{
+       static GType my_type = 0;
+       if (!my_type) {
+               static const GTypeInfo my_info = {
+                       sizeof(ModestMailboxesWindowClass),
+                       NULL,           /* base init */
+                       NULL,           /* base finalize */
+                       (GClassInitFunc) modest_mailboxes_window_class_init,
+                       NULL,           /* class finalize */
+                       NULL,           /* class data */
+                       sizeof(ModestMailboxesWindow),
+                       1,              /* n_preallocs */
+                       (GInstanceInitFunc) modest_mailboxes_window_init,
+                       NULL
+               };
+               my_type = g_type_register_static (MODEST_TYPE_HILDON2_WINDOW,
+                                                 "ModestMailboxesWindow",
+                                                 &my_info, 0);
+       }
+       return my_type;
+}
+
+static void
+modest_mailboxes_window_class_init (ModestMailboxesWindowClass *klass)
+{
+       GObjectClass *gobject_class;
+       gobject_class = (GObjectClass*) klass;
+       ModestWindowClass *modest_window_class = (ModestWindowClass *) klass;
+
+       parent_class            = g_type_class_peek_parent (klass);
+       gobject_class->finalize = modest_mailboxes_window_finalize;
+
+       g_type_class_add_private (gobject_class, sizeof(ModestMailboxesWindowPrivate));
+       
+       modest_window_class->disconnect_signals_func = modest_mailboxes_window_disconnect_signals;
+}
+
+static void
+modest_mailboxes_window_init (ModestMailboxesWindow *obj)
+{
+       ModestMailboxesWindowPrivate *priv;
+
+       priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE(obj);
+
+       priv->sighandlers = NULL;
+       
+       priv->folder_view = NULL;
+
+       priv->top_vbox = NULL;
+
+       priv->current_store_account = NULL;
+       priv->progress_hint = FALSE;
+       priv->queue_change_handler = 0;
+}
+
+static void
+modest_mailboxes_window_finalize (GObject *obj)
+{
+       ModestMailboxesWindowPrivate *priv;
+
+       priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE(obj);
+
+       if (priv->current_store_account) {
+               g_free (priv->current_store_account);
+               priv->current_store_account = NULL;
+       }
+
+       /* Sanity check: shouldn't be needed, the window mgr should
+          call this function before */
+       modest_mailboxes_window_disconnect_signals (MODEST_WINDOW (obj));       
+
+       G_OBJECT_CLASS(parent_class)->finalize (obj);
+}
+
+static void
+modest_mailboxes_window_disconnect_signals (ModestWindow *self)
+{
+       ModestMailboxesWindowPrivate *priv;
+       priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE(self);
+
+       if (g_signal_handler_is_connected (G_OBJECT (modest_runtime_get_mail_operation_queue ()), 
+                                          priv->queue_change_handler))
+               g_signal_handler_disconnect (G_OBJECT (modest_runtime_get_mail_operation_queue ()), 
+                                            priv->queue_change_handler);
+
+       modest_signal_mgr_disconnect_all_and_destroy (priv->sighandlers);
+       priv->sighandlers = NULL;
+}
+
+static void
+on_visible_account_changed (ModestFolderView *mailboxes_view,
+                           const gchar *account_id,
+                           gpointer user_data)
+{
+       if (account_id) {
+               TnyAccount *acc = 
+                       modest_tny_account_store_get_tny_account_by (modest_runtime_get_account_store(),
+                                                                    MODEST_TNY_ACCOUNT_STORE_QUERY_ID,
+                                                                    account_id);
+               if (acc) {
+                       const gchar *name;
+                       gchar *title = NULL;
+
+                       name = modest_tny_account_get_parent_modest_account_name_for_server_account (acc);
+                       title = modest_account_mgr_get_display_name (modest_runtime_get_account_mgr(),
+                                                                    name);
+                       if (title) {
+                               modest_window_set_title (MODEST_WINDOW (user_data), title);
+                               g_free (title);
+                       } else {
+                               modest_window_set_title (MODEST_WINDOW (user_data), _("mcen_ap_name"));
+                       }
+                       g_object_unref (acc);
+               }
+       } else {
+               modest_window_set_title (MODEST_WINDOW (user_data), _("mcen_ap_name"));
+       }
+}
+
+static void
+connect_signals (ModestMailboxesWindow *self)
+{
+       ModestMailboxesWindowPrivate *priv;
+
+       priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE(self);
+
+       /* mailboxes view */
+       priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers, 
+                                                      G_OBJECT (priv->folder_view), "folder-activated", 
+                                                      G_CALLBACK (on_mailbox_activated), self);
+
+       priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers,
+                                                      G_OBJECT (modest_runtime_get_window_mgr ()),
+                                                      "progress-list-changed",
+                                                      G_CALLBACK (on_progress_list_changed), self);
+
+       priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers,
+                                                      G_OBJECT (priv->folder_view),
+                                                      "activity-changed",
+                                                      G_CALLBACK (on_activity_changed), self);
+
+       priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers,
+                                                      G_OBJECT (priv->folder_view),
+                                                      "visible-account-changed",
+                                                      G_CALLBACK (on_visible_account_changed), self);
+
+       priv->sighandlers = 
+               modest_signal_mgr_connect (priv->sighandlers,
+                                          G_OBJECT (priv->new_message_button),
+                                          "clicked",
+                                          G_CALLBACK (modest_ui_actions_on_new_msg), self);
+
+       /* connect window keys -> priv->folder_view scroll here? */
+       g_signal_connect(G_OBJECT(self), "key-press-event",
+                       G_CALLBACK(on_key_press), self);
+}
+
+ModestWindow *
+modest_mailboxes_window_new (const gchar *account)
+{
+       ModestMailboxesWindow *self = NULL;     
+       ModestMailboxesWindowPrivate *priv = NULL;
+       HildonProgram *app;
+       GdkPixbuf *window_icon;
+       GtkWidget *scrollable;
+       GtkWidget *action_area_box;
+       GdkPixbuf *new_message_pixbuf;
+       guint accel_key;
+       GdkModifierType accel_mods;
+       GtkAccelGroup *accel_group;
+       GtkWidget *top_alignment;
+       
+       self  = MODEST_MAILBOXES_WINDOW(g_object_new(MODEST_TYPE_MAILBOXES_WINDOW, NULL));
+       priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE(self);
+
+       scrollable = modest_toolkit_factory_create_scrollable (modest_runtime_get_toolkit_factory ());
+       priv->queue_change_handler =
+               g_signal_connect (G_OBJECT (modest_runtime_get_mail_operation_queue ()),
+                                 "queue-changed",
+                                 G_CALLBACK (on_queue_changed),
+                                 self);
+
+       priv->folder_view  = modest_platform_create_folder_view (NULL);
+       modest_folder_view_set_cell_style (MODEST_FOLDER_VIEW (priv->folder_view),
+                                          MODEST_FOLDER_VIEW_CELL_STYLE_COMPACT);
+       modest_folder_view_set_filter (MODEST_FOLDER_VIEW (priv->folder_view), 
+                                      MODEST_FOLDER_VIEW_FILTER_HIDE_ACCOUNTS);
+
+       action_area_box = hildon_tree_view_get_action_area_box (GTK_TREE_VIEW (priv->folder_view));
+       priv->new_message_button = hildon_button_new (0, HILDON_BUTTON_ARRANGEMENT_HORIZONTAL);
+
+       hildon_button_set_title (HILDON_BUTTON (priv->new_message_button), _("mcen_ti_new_message"));
+       new_message_pixbuf = modest_platform_get_icon ("general_add", MODEST_ICON_SIZE_BIG);
+       hildon_button_set_image (HILDON_BUTTON (priv->new_message_button), gtk_image_new_from_pixbuf (new_message_pixbuf));
+       g_object_unref (new_message_pixbuf);
+
+       gtk_box_pack_start (GTK_BOX (action_area_box), priv->new_message_button, TRUE, TRUE, 0);
+       gtk_widget_show_all (priv->new_message_button);
+       hildon_tree_view_set_action_area_visible (GTK_TREE_VIEW (priv->folder_view), TRUE);
+       
+       /* Set account store */
+       tny_account_store_view_set_account_store (TNY_ACCOUNT_STORE_VIEW (priv->folder_view),
+                                                 TNY_ACCOUNT_STORE (modest_runtime_get_account_store ()));
+
+       priv->top_vbox = gtk_vbox_new (0, FALSE);
+       top_alignment = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
+       gtk_alignment_set_padding (GTK_ALIGNMENT (top_alignment), 
+                                  0, 0, 
+                                  MODEST_MARGIN_DOUBLE, MODEST_MARGIN_DOUBLE);
+
+       gtk_container_add (GTK_CONTAINER (scrollable), priv->folder_view);
+       gtk_box_pack_end (GTK_BOX (priv->top_vbox), scrollable, TRUE, TRUE, 0);
+       gtk_container_add (GTK_CONTAINER (top_alignment), priv->top_vbox);
+       gtk_container_add (GTK_CONTAINER (self), top_alignment);
+
+       gtk_widget_show (priv->folder_view);
+       gtk_widget_show (scrollable);
+       gtk_widget_show (top_alignment);
+       gtk_widget_show (priv->top_vbox);
+
+       connect_signals (MODEST_MAILBOXES_WINDOW (self));
+
+       /* Get device name */
+       modest_maemo_utils_get_device_name ();
+
+       app = hildon_program_get_instance ();
+       hildon_program_add_window (app, HILDON_WINDOW (self));
+       
+       /* Set window icon */
+       window_icon = modest_platform_get_icon (MODEST_APP_ICON, MODEST_ICON_SIZE_BIG);
+       if (window_icon) {
+               gtk_window_set_icon (GTK_WINDOW (self), window_icon);
+               g_object_unref (window_icon);
+       }
+
+       /* Dont't restore settings here, 
+        * because it requires a gtk_widget_show(), 
+        * and we don't want to do that until later,
+        * so that the UI is not visible for non-menu D-Bus activation.
+        */
+
+       g_signal_connect (G_OBJECT (self), "map-event",
+                         G_CALLBACK (on_map_event),
+                         G_OBJECT (self));
+       update_progress_hint (self);
+
+       accel_group = gtk_accel_group_new ();
+       gtk_accelerator_parse ("<Control>n", &accel_key, &accel_mods);
+       gtk_widget_add_accelerator (priv->new_message_button, "clicked", accel_group,
+                                   accel_key, accel_mods, 0);
+       gtk_window_add_accel_group (GTK_WINDOW (self), accel_group);
+
+       modest_folder_view_set_filter (MODEST_FOLDER_VIEW (priv->folder_view),
+                                      MODEST_FOLDER_VIEW_FILTER_SHOW_ONLY_MAILBOXES);
+
+       modest_mailboxes_window_set_account (MODEST_MAILBOXES_WINDOW (self), account);
+
+       return MODEST_WINDOW(self);
+}
+
+ModestFolderView *
+modest_mailboxes_window_get_folder_view (ModestMailboxesWindow *self)
+{
+       ModestMailboxesWindowPrivate *priv = NULL;
+
+       g_return_val_if_fail (MODEST_IS_MAILBOXES_WINDOW(self), FALSE);
+
+       priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE (self);
+       
+       return MODEST_FOLDER_VIEW (priv->folder_view);
+}
+
+void
+modest_mailboxes_window_set_account (ModestMailboxesWindow *self,
+                                    const gchar *account_name)
+{
+       ModestMailboxesWindowPrivate *priv = NULL;
+       ModestAccountMgr *mgr;
+       ModestAccountSettings *settings = NULL;
+       ModestServerAccountSettings *store_settings = NULL;
+
+       g_return_if_fail (MODEST_IS_MAILBOXES_WINDOW(self));
+
+       priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE (self);
+
+       /* Get account data */
+       mgr = modest_runtime_get_account_mgr ();
+
+       settings = modest_account_mgr_load_account_settings (mgr, account_name);
+       if (!settings)
+               goto free_refs;
+
+       store_settings = modest_account_settings_get_store_settings (settings);
+       if (!store_settings)
+               goto free_refs;
+
+       if (priv->current_store_account != NULL)
+               g_free (priv->current_store_account);
+       priv->current_store_account = g_strdup (modest_server_account_settings_get_account_name (store_settings));
+
+       modest_folder_view_set_account_id_of_visible_server_account
+               (MODEST_FOLDER_VIEW (priv->folder_view),
+                priv->current_store_account);
+
+       modest_window_set_active_account (MODEST_WINDOW (self), account_name);
+       update_progress_hint (self);
+
+free_refs:
+       if (store_settings)
+               g_object_unref (store_settings);
+       if (settings)
+               g_object_unref (settings);
+
+}
+
+static void
+on_mailbox_activated (ModestFolderView *mailboxes_view,
+                     TnyFolder *folder,
+                     gpointer userdata)
+{
+       ModestMailboxesWindowPrivate *priv = NULL;
+       ModestMailboxesWindow *self = (ModestMailboxesWindow *) userdata;
+       GtkWidget *new_window;
+       gboolean registered;
+       const gchar *active_account;
+
+       g_return_if_fail (MODEST_IS_MAILBOXES_WINDOW(self));
+
+       priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE (self);
+
+       if (!folder)
+               return;
+
+       if (!TNY_IS_FOLDER (folder))
+               return;
+
+       new_window = GTK_WIDGET (modest_folder_window_new (NULL));
+       registered = modest_window_mgr_register_window (modest_runtime_get_window_mgr (), 
+                                                       MODEST_WINDOW (new_window),
+                                                       MODEST_WINDOW (self));
+
+       if (!registered) {
+               gtk_widget_destroy (new_window);
+               new_window = NULL;
+       } else {
+               const gchar *name;
+               active_account = modest_window_get_active_account (MODEST_WINDOW (self));
+               modest_folder_window_set_account (MODEST_FOLDER_WINDOW (new_window), active_account);
+               name = tny_folder_get_name (folder);
+               if (name) {
+                       modest_folder_window_set_mailbox (MODEST_FOLDER_WINDOW (new_window), name);
+               }
+               gtk_widget_show (new_window);
+       }
+       
+}
+
+static gboolean 
+on_map_event (GtkWidget *widget,
+             GdkEvent *event,
+             gpointer userdata)
+{
+       ModestMailboxesWindow *self = (ModestMailboxesWindow *) userdata;
+       ModestMailboxesWindowPrivate *priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE (self);
+
+       if (priv->progress_hint) {
+               hildon_gtk_window_set_progress_indicator (GTK_WINDOW (self), TRUE);
+       }
+
+       return FALSE;
+}
+
+static gboolean
+has_active_operations (ModestMailboxesWindow *self)
+{
+       GSList *operations = NULL, *node;
+       ModestMailOperationQueue *queue;
+       gboolean has_active = FALSE;
+
+       queue = modest_runtime_get_mail_operation_queue ();
+       operations = modest_mail_operation_queue_get_by_source (queue, G_OBJECT (self));
+
+       for (node = operations; node != NULL; node = g_slist_next (node)) {
+               if (!modest_mail_operation_is_finished (MODEST_MAIL_OPERATION (node->data))) {
+                       has_active = TRUE;
+                       break;
+               }
+       }
+
+       if (operations) {
+               g_slist_foreach (operations, (GFunc) g_object_unref, NULL);
+               g_slist_free (operations);
+       }
+
+       return has_active;
+}
+
+static void
+update_progress_hint (ModestMailboxesWindow *self)
+{
+       ModestMailboxesWindowPrivate *priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE (self);
+
+       if (has_active_operations (self)) {
+               priv->progress_hint = TRUE;
+       } else {
+               priv->progress_hint = FALSE;
+       }
+
+       if (!priv->progress_hint && priv->current_store_account) {
+               priv->progress_hint = modest_window_mgr_has_progress_operation_on_account (modest_runtime_get_window_mgr (),
+                                                                                          priv->current_store_account);
+       }
+
+       if (!priv->progress_hint) {
+               priv->progress_hint = modest_folder_view_get_activity (MODEST_FOLDER_VIEW (priv->folder_view));
+       }
+
+       modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (self));
+
+       if (GTK_WIDGET_VISIBLE (self)) {
+               hildon_gtk_window_set_progress_indicator (GTK_WINDOW (self), priv->progress_hint ? 1:0);
+       }
+}
+
+static void
+on_progress_list_changed (ModestWindowMgr *mgr,
+                         ModestMailboxesWindow *self)
+{
+       update_progress_hint (self);
+}
+
+static void 
+on_mail_operation_started (ModestMailOperation *mail_op,
+                          gpointer user_data)
+{
+       ModestMailboxesWindow *self;
+       ModestMailOperationTypeOperation op_type;
+       GObject *source = NULL;
+
+       self = MODEST_MAILBOXES_WINDOW (user_data);
+       op_type = modest_mail_operation_get_type_operation (mail_op);
+       source = modest_mail_operation_get_source(mail_op);
+       if (G_OBJECT (self) == source) {
+               update_progress_hint (self);
+       }
+       g_object_unref (source);
+}
+
+static void 
+on_mail_operation_finished (ModestMailOperation *mail_op,
+                           gpointer user_data)
+{
+       ModestMailboxesWindow *self;
+
+       self = MODEST_MAILBOXES_WINDOW (user_data);
+
+       /* Don't disable the progress hint if there are more pending
+          operations from this window */
+       update_progress_hint (self);
+
+       modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (self));
+}
+
+static void
+on_queue_changed (ModestMailOperationQueue *queue,
+                 ModestMailOperation *mail_op,
+                 ModestMailOperationQueueNotification type,
+                 ModestMailboxesWindow *self)
+{
+       ModestMailboxesWindowPrivate *priv;
+
+       priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE (self);
+
+       /* If this operations was created by another window, do nothing */
+       if (!modest_mail_operation_is_mine (mail_op, G_OBJECT(self))) 
+               return;
+
+       if (type == MODEST_MAIL_OPERATION_QUEUE_OPERATION_ADDED) {
+               priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers,
+                                                              G_OBJECT (mail_op),
+                                                              "operation-started",
+                                                              G_CALLBACK (on_mail_operation_started),
+                                                              self);
+               priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers,
+                                                              G_OBJECT (mail_op),
+                                                              "operation-finished",
+                                                              G_CALLBACK (on_mail_operation_finished),
+                                                              self);
+       } else if (type == MODEST_MAIL_OPERATION_QUEUE_OPERATION_REMOVED) {
+               priv->sighandlers = modest_signal_mgr_disconnect (priv->sighandlers,
+                                                                 G_OBJECT (mail_op),
+                                                                 "operation-started");
+               priv->sighandlers = modest_signal_mgr_disconnect (priv->sighandlers,
+                                                                 G_OBJECT (mail_op),
+                                                                 "operation-finished");
+       }
+}
+
+static void
+on_activity_changed (ModestFolderView *view,
+                    gboolean activity,
+                    ModestMailboxesWindow *self)
+{
+       g_return_if_fail (MODEST_IS_MAILBOXES_WINDOW (self));
+
+       update_progress_hint (self);
+}
+
+
+static gboolean
+on_key_press(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
+{
+       ModestMailboxesWindowPrivate *priv;
+       ModestScrollable *scrollable;
+
+       if (event->type == GDK_KEY_RELEASE)
+               return FALSE;
+
+       priv = MODEST_MAILBOXES_WINDOW_GET_PRIVATE(user_data);
+
+       scrollable = MODEST_SCROLLABLE (gtk_widget_get_parent (priv->folder_view));
+
+       switch (event->keyval) {
+
+       case GDK_Up:
+               modest_scrollable_scroll (scrollable, 0, -1);
+               break;
+
+       case GDK_Down:
+               modest_scrollable_scroll (scrollable, 0, 1);
+               break;
+       }
+
+       return FALSE;
+}
diff --git a/src/widgets/modest-mailboxes-window.h b/src/widgets/modest-mailboxes-window.h
new file mode 100644 (file)
index 0000000..f933f90
--- /dev/null
@@ -0,0 +1,109 @@
+/* Copyright (c) 2009 Nokia Corporation
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * * Neither the name of the Nokia Corporation nor the names of its
+ *   contributors may be used to endorse or promote products derived from
+ *   this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __MODEST_MAILBOXES_WINDOW_H__
+#define __MODEST_MAILBOXES_WINDOW_H__
+
+#ifdef MODEST_TOOLKIT_HILDON2
+#include <modest-hildon2-window.h>
+#endif
+#include <widgets/modest-window.h>
+#include <widgets/modest-folder-view.h>
+
+G_BEGIN_DECLS
+
+/* convenience macros */
+#define MODEST_TYPE_MAILBOXES_WINDOW             (modest_mailboxes_window_get_type())
+#define MODEST_MAILBOXES_WINDOW(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_MAILBOXES_WINDOW,ModestMailboxesWindow))
+#define MODEST_MAILBOXES_WINDOW_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_MAILBOXES_WINDOW,ModestWindow))
+
+#define MODEST_IS_MAILBOXES_WINDOW(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_MAILBOXES_WINDOW))
+#define MODEST_IS_MAILBOXES_WINDOW_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_MAILBOXES_WINDOW))
+#define MODEST_MAILBOXES_WINDOW_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_MAILBOXES_WINDOW,ModestMailboxesWindowClass))
+
+typedef struct _ModestMailboxesWindow      ModestMailboxesWindow;
+typedef struct _ModestMailboxesWindowClass ModestMailboxesWindowClass;
+
+struct _ModestMailboxesWindow {
+#ifdef MODEST_TOOLKIT_HILDON2
+       ModestHildon2Window parent;
+#else
+       ModestWindow parent;
+#endif
+};
+
+struct _ModestMailboxesWindowClass {
+#ifdef MODEST_TOOLKIT_HILDON2
+       ModestHildon2WindowClass parent_class;
+#else
+       ModestWindowClass parent_class;
+#endif
+};
+
+/**
+ * modest_mailboxes_window_get_type:
+ * 
+ * get the GType for the ModestMailboxesWindow class
+ *
+ * Returns: a GType for ModestMailboxesWindow
+ */
+GType modest_mailboxes_window_get_type (void) G_GNUC_CONST;
+
+
+/**
+ * modest_mailboxes_window_new:
+ * @query: a #TnyMailboxesStoreQuery that specifies the mailboxess to show
+ * 
+ * instantiates a new ModestMailboxesWindow widget
+ *
+ * Returns: a new ModestMailboxesWindow, or NULL in case of error
+ */
+ModestWindow* modest_mailboxes_window_new (const gchar *account_name);
+
+/**
+ * modest_mailboxes_window_get_mailboxes_view:
+ * @self: a #ModestMailboxesWindow
+ *
+ * get the mailboxes view inside the mailboxes window
+ */
+ModestFolderView *modest_mailboxes_window_get_folder_view (ModestMailboxesWindow *self);
+
+/**
+ * modest_mailboxes_window_set_account:
+ * @self: a #ModestMailboxesWindow
+ * @account_name: a string
+ *
+ * Sets the current active account in the mailboxes window.
+ */
+void modest_mailboxes_window_set_account (ModestMailboxesWindow *self,
+                                         const gchar *account_name);
+
+G_END_DECLS
+
+#endif