This is a manual merge of branch drop split view intro trunk.
authorJose Dapena Paz <jdapena@igalia.com>
Fri, 19 Dec 2008 14:35:43 +0000 (14:35 +0000)
committerJose Dapena Paz <jdapena@igalia.com>
Fri, 19 Dec 2008 14:35:43 +0000 (14:35 +0000)
This should be the final work to make trunk release with the new ui
from now on (and then making drop-split-view branch deprecated). It's
based on drop-split-view r6953.

pmo-trunk-r6954

69 files changed:
configure.ac
debian/control
src/dbus_api/Makefile.am
src/dbus_api/modest-dbus-callbacks.c
src/gnome/modest-platform.c
src/hildon2/Makefile.am
src/hildon2/modest-account-view-window.c
src/hildon2/modest-accounts-window.c [new file with mode: 0644]
src/hildon2/modest-accounts-window.h [new file with mode: 0644]
src/hildon2/modest-address-book.c
src/hildon2/modest-connection-specific-smtp-edit-window.c
src/hildon2/modest-connection-specific-smtp-window.c
src/hildon2/modest-default-account-settings-dialog.c
src/hildon2/modest-easysetup-wizard-dialog.c
src/hildon2/modest-folder-window.c
src/hildon2/modest-header-window.c
src/hildon2/modest-header-window.h
src/hildon2/modest-hildon-includes.h
src/hildon2/modest-hildon2-global-settings-dialog.c
src/hildon2/modest-hildon2-window-mgr.c
src/hildon2/modest-hildon2-window-mgr.h
src/hildon2/modest-icon-names.h
src/hildon2/modest-maemo-security-options-view.c
src/hildon2/modest-main-window.c
src/hildon2/modest-msg-edit-window.c
src/hildon2/modest-msg-view-window.c
src/hildon2/modest-number-editor.c [new file with mode: 0644]
src/hildon2/modest-number-editor.h [new file with mode: 0644]
src/hildon2/modest-platform.c
src/hildon2/modest-signature-editor-dialog.c
src/hildon2/ui/modest-msg-edit-window-ui.xml
src/maemo/modest-main-window-ui.h
src/maemo/modest-main-window.c
src/maemo/modest-msg-view-window.c
src/maemo/modest-platform.c
src/modest-dimming-rule.c
src/modest-init.c
src/modest-mail-operation-queue.c
src/modest-main.c
src/modest-marshal.list
src/modest-platform.h
src/modest-runtime.c
src/modest-runtime.h
src/modest-text-utils.c
src/modest-tny-account-store.c
src/modest-tny-account-store.h
src/modest-ui-actions.c
src/modest-ui-actions.h
src/modest-ui-dimming-rules.c
src/modest-ui-dimming-rules.h
src/modest-utils.c
src/widgets/modest-account-view.c
src/widgets/modest-attachment-view.c
src/widgets/modest-compact-mail-header-view.c
src/widgets/modest-expander-mail-header-view.c
src/widgets/modest-folder-view.c
src/widgets/modest-global-settings-dialog.c
src/widgets/modest-gtkhtml-msg-view.c
src/widgets/modest-header-view.c
src/widgets/modest-header-view.h
src/widgets/modest-hildon1-window-mgr.c
src/widgets/modest-msg-edit-window-ui.h
src/widgets/modest-recpt-editor.c
src/widgets/modest-ui-constants.h
src/widgets/modest-validating-entry.c
src/widgets/modest-validating-entry.h
src/widgets/modest-window-mgr.c
src/widgets/modest-window-mgr.h
src/widgets/modest-wizard-dialog.c

index 7c86bbc..933fdf6 100644 (file)
@@ -162,6 +162,8 @@ if test "$have_hildon1" = "true"; then
    if test "$have_hildon2" = "true"; then
       echo "DETECTED HILDON 2 $have_hildon2."
       detected_toolkit=hildon2
+      hildonpkgs="$hildonpkgs libcanberra profile"
+      echo "HILDON 2 PACKAGES $hildonpkgs"
    fi
 else
    hildonpkgs="hildon-libs hildon-fm"
index 65f7e28..578d047 100644 (file)
@@ -4,10 +4,10 @@ Priority: optional
 Maintainer: Dirk-Jan C. Binnema <dirk-jan.binnema@nokia.com> 
 Build-Depends: debhelper (>= 4.0.0), cdbs, gnome-common, gtkhtml-dev, libconic0-dev, libhildon1-dev, libdbus-1-dev,
  libdbus-glib-1-dev, libebook-dev, osso-af-settings, libedataserver-dev, libhildonnotify-dev, libgconf2-dev,
- libglib2.0-dev, libosso-abook-dev, libosso-gnomevfs2-dev, libhildonmime-dev,libtinymail-1.0-0-dev, libtinymail-camel-1.0-0-dev,
+ libglib2.0-dev, libosso-abook-dev, libosso-gnomevfs2-dev, libhildonmime-dev, libprofile-dev, libtinymail-1.0-0-dev, libtinymail-camel-1.0-0-dev,
  libtinymail-maemo-1.0-0-dev, libtinymailui-1.0-0-dev, libtinymail-gnomevfs-1.0-0-dev, libtinymailui-gtk-1.0-0-dev, wpeditor0,
  wpeditor-dev, libhildonhelp-dev, modest-providers-data, libalarm-dev, gtk-doc-tools, libhildonnotify-dev, libnotify-dev,
- libogs1.2-dev, microb-engine-dev, mce-dev, maemo-launcher-dev
+ libogs1.2-dev, microb-engine-dev, mce-dev, maemo-launcher-dev, profile-data-dev
 Standards-Version: 3.6.0
 
 Package: modest
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..549a769 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 <hildon/hildon.h>
+#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,40 @@ 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)
+{
+       HildonWindowStack *stack;
+       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 */
+
+       stack = hildon_window_stack_get_default ();
+       window = GTK_WIDGET (hildon_window_stack_peek (stack));
+
+       if (window) {
+               gtk_window_present (GTK_WINDOW (window));
+       } else {
+               ModestWindowMgr *mgr;
 
+               mgr = modest_runtime_get_window_mgr ();
+               window = (GtkWidget *) modest_window_mgr_show_initial_window (mgr);
+               if (window) {
+                       modest_platform_remove_new_mail_notifications (FALSE);
+               } else {
+                       g_printerr ("modest: failed to get main window instance\n");
+               }
+       }
+
+       gdk_threads_leave (); /* CHECKED */
+       
+       return FALSE; /* Do not call this callback again. */
+}
+#else
 static gboolean 
 on_idle_top_application (gpointer user_data)
 {
@@ -1161,11 +1199,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 +1207,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 +1219,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 28885ee..bda9c2c 100644 (file)
@@ -552,3 +552,34 @@ modest_platform_run_header_details_dialog (GtkWindow *parent_window,
                                  G_CALLBACK (gtk_widget_destroy),
                                  dialog);
 }
+
+GtkWidget* 
+modest_platform_create_move_to_dialog (GtkWindow *parent_window,
+                                      GtkWidget **folder_view)
+{
+       GtkWidget *dialog, *folder_view_container;
+
+       dialog = gtk_dialog_new_with_buttons (_("mcen_ti_moveto_folders_title"),
+                                             GTK_WINDOW (parent_window),
+                                             GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR |
+                                             GTK_DIALOG_DESTROY_WITH_PARENT,
+                                             _("mcen_bd_dialog_ok"), GTK_RESPONSE_OK,
+                                             _("mcen_bd_new"), MODEST_GTK_RESPONSE_NEW_FOLDER,
+                                             _("mcen_bd_dialog_cancel"), GTK_RESPONSE_CANCEL,
+                                             NULL);
+
+       /* Create folder view */
+       *folder_view = modest_platform_create_folder_view (NULL);
+
+       /* Create pannable and add it to the dialog */
+       folder_view_container = gtk_scrolled_window_new (NULL, NULL);
+       gtk_scrolled_window_set_policy  (GTK_SCROLLED_WINDOW (*folder_view_container),
+                                        GTK_POLICY_AUTOMATIC,
+                                        GTK_POLICY_AUTOMATIC);
+       gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), folder_view_container);
+       gtk_container_add (GTK_CONTAINER (folder_view_container), *folder_view);
+
+       gtk_window_set_default_size (GTK_WINDOW (dialog), 300, 300);
+
+       return dialog;
+}
index d6424b4..88f6010 100644 (file)
@@ -50,6 +50,8 @@ noinst_LTLIBRARIES=\
 
 libmodest_ui_la_SOURCES=              \
        modest-account-view-window.c  \
+       modest-accounts-window.c \
+       modest-accounts-window.h \
        modest-default-account-settings-dialog.c \
        modest-easysetup-wizard-dialog.h modest-easysetup-wizard-dialog.c \
        modest-country-picker.h modest-country-picker.c \
@@ -77,6 +79,8 @@ libmodest_ui_la_SOURCES=              \
        modest-msg-view-window.c      \
        modest-msg-edit-window.c      \
        modest-maemo-utils.c          \
+       modest-number-editor.c        \
+       modest-number-editor.h        \
        modest-connection-specific-smtp-window.h \
        modest-connection-specific-smtp-window.c \
        modest-connection-specific-smtp-edit-window.h \
index 5cdfea1..9cbfed1 100644 (file)
@@ -321,6 +321,8 @@ setup_button_box (ModestAccountViewWindow *self, GtkButtonBox *box)
        ModestAccountViewWindowPrivate *priv = MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE(self);
 
        priv->new_button     = gtk_button_new_from_stock(_HL("wdgt_bd_new"));
+       hildon_gtk_widget_set_theme_size (priv->new_button,
+                                         HILDON_SIZE_FINGER_HEIGHT);
 
        g_signal_connect (G_OBJECT(priv->new_button), "clicked",
                          G_CALLBACK(on_new_button_clicked),
diff --git a/src/hildon2/modest-accounts-window.c b/src/hildon2/modest-accounts-window.c
new file mode 100644 (file)
index 0000000..65c9eb7
--- /dev/null
@@ -0,0 +1,432 @@
+/* Copyright (c) 2008, 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-accounts-window.h>
+#include <modest-osso-state-saving.h>
+#include <libosso.h>
+#include <hildon/hildon-pannable-area.h>
+#include <hildon/hildon-banner.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 <modest-maemo-utils.h>
+#include <modest-icon-names.h>
+#include <modest-defs.h>
+#include <modest-folder-window.h>
+#include <modest-ui-dimming-rules.h>
+#include <modest-ui-dimming-manager.h>
+#include <modest-window-priv.h>
+
+
+/* 'private'/'protected' functions */
+static void modest_accounts_window_class_init  (ModestAccountsWindowClass *klass);
+static void modest_accounts_window_instance_init (ModestAccountsWindow *obj);
+static void modest_accounts_window_finalize    (GObject *obj);
+
+static void connect_signals (ModestAccountsWindow *self);
+static void modest_accounts_window_disconnect_signals (ModestWindow *self);
+
+static gboolean on_zoom_minus_plus_not_implemented (ModestWindow *window);
+static void on_account_activated (GtkTreeView *treeview,
+                                 GtkTreePath *path,
+                                 GtkTreeViewColumn *column,
+                                 ModestAccountsWindow *accounts_window);
+static void add_to_menu (ModestAccountsWindow *self,
+                        HildonAppMenu *menu,
+                        gchar *label,
+                        GCallback callback,
+                        ModestDimmingRulesGroup *group,
+                        GCallback dimming_callback);
+static void setup_menu (ModestAccountsWindow *self,
+                       ModestDimmingRulesGroup *group);
+
+static void modest_accounts_window_show_toolbar (ModestWindow *self,
+                                                gboolean show_toolbar);
+static gboolean modest_accounts_window_toggle_menu (HildonWindow *window,
+                                                   guint button,
+                                                   guint32 time);
+
+typedef struct _ModestAccountsWindowPrivate ModestAccountsWindowPrivate;
+struct _ModestAccountsWindowPrivate {
+
+       GtkWidget *account_view;
+       GtkWidget *app_menu;
+
+       /* signals */
+       GSList *sighandlers;
+
+       /* Display state */
+       osso_display_state_t display_state;
+};
+#define MODEST_ACCOUNTS_WINDOW_GET_PRIVATE(o)  (G_TYPE_INSTANCE_GET_PRIVATE((o), \
+                                                                           MODEST_TYPE_ACCOUNTS_WINDOW, \
+                                                                           ModestAccountsWindowPrivate))
+
+/* globals */
+static GtkWindowClass *parent_class = NULL;
+
+/************************************************************************/
+
+GType
+modest_accounts_window_get_type (void)
+{
+       static GType my_type = 0;
+       if (!my_type) {
+               static const GTypeInfo my_info = {
+                       sizeof(ModestAccountsWindowClass),
+                       NULL,           /* base init */
+                       NULL,           /* base finalize */
+                       (GClassInitFunc) modest_accounts_window_class_init,
+                       NULL,           /* class finalize */
+                       NULL,           /* class data */
+                       sizeof(ModestAccountsWindow),
+                       1,              /* n_preallocs */
+                       (GInstanceInitFunc) modest_accounts_window_instance_init,
+                       NULL
+               };
+               my_type = g_type_register_static (MODEST_TYPE_WINDOW,
+                                                 "ModestAccountsWindow",
+                                                 &my_info, 0);
+       }
+       return my_type;
+}
+
+static void
+modest_accounts_window_class_init (ModestAccountsWindowClass *klass)
+{
+       GObjectClass *gobject_class;
+       gobject_class = (GObjectClass*) klass;
+       ModestWindowClass *modest_window_class = (ModestWindowClass *) klass;
+       HildonWindowClass *hildon_window_class = (HildonWindowClass *) klass;
+
+       parent_class            = g_type_class_peek_parent (klass);
+       gobject_class->finalize = modest_accounts_window_finalize;
+
+       g_type_class_add_private (gobject_class, sizeof(ModestAccountsWindowPrivate));
+       
+       hildon_window_class->toggle_menu = modest_accounts_window_toggle_menu;
+
+       modest_window_class->zoom_minus_func = on_zoom_minus_plus_not_implemented;
+       modest_window_class->zoom_plus_func = on_zoom_minus_plus_not_implemented;
+       modest_window_class->show_toolbar_func = modest_accounts_window_show_toolbar;
+       modest_window_class->disconnect_signals_func = modest_accounts_window_disconnect_signals;
+}
+
+static void
+modest_accounts_window_instance_init (ModestAccountsWindow *obj)
+{
+       ModestAccountsWindowPrivate *priv;
+
+       priv = MODEST_ACCOUNTS_WINDOW_GET_PRIVATE(obj);
+
+       priv->sighandlers = NULL;
+       priv->display_state = OSSO_DISPLAY_ON;
+       
+       priv->account_view = NULL;
+       
+       modest_window_mgr_register_help_id (modest_runtime_get_window_mgr(),
+                                           GTK_WINDOW(obj),
+                                           "applications_email_accountsview");
+}
+
+static void
+modest_accounts_window_finalize (GObject *obj)
+{
+       ModestAccountsWindowPrivate *priv;
+
+       priv = MODEST_ACCOUNTS_WINDOW_GET_PRIVATE(obj);
+
+       /* Sanity check: shouldn't be needed, the window mgr should
+          call this function before */
+       modest_accounts_window_disconnect_signals (MODEST_WINDOW (obj));        
+
+       G_OBJECT_CLASS(parent_class)->finalize (obj);
+}
+
+static void
+modest_accounts_window_disconnect_signals (ModestWindow *self)
+{      
+       ModestAccountsWindowPrivate *priv;      
+       priv = MODEST_ACCOUNTS_WINDOW_GET_PRIVATE(self);
+
+       modest_signal_mgr_disconnect_all_and_destroy (priv->sighandlers);
+       priv->sighandlers = NULL;       
+}
+
+static void
+connect_signals (ModestAccountsWindow *self)
+{      
+       ModestAccountsWindowPrivate *priv;
+       
+       priv = MODEST_ACCOUNTS_WINDOW_GET_PRIVATE(self);
+
+       /* accounts view */
+       priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers, 
+                                                      G_OBJECT (priv->account_view), "row-activated", 
+                                                      G_CALLBACK (on_account_activated), self);
+
+       /* window */
+
+       /* we don't register this in sighandlers, as it should be run after disconnecting all signals,
+        * in destroy stage */
+
+       
+}
+
+static void 
+osso_display_event_cb (osso_display_state_t state, 
+                      gpointer data)
+{
+       ModestAccountsWindowPrivate *priv = MODEST_ACCOUNTS_WINDOW_GET_PRIVATE (data);
+
+       priv->display_state = state;
+
+       /* Stop blinking if the screen becomes on */
+       if (priv->display_state == OSSO_DISPLAY_ON)
+               modest_platform_remove_new_mail_notifications (TRUE);
+}
+
+ModestWindow *
+modest_accounts_window_new (void)
+{
+       ModestAccountsWindow *self = NULL;      
+       ModestAccountsWindowPrivate *priv = NULL;
+       HildonProgram *app;
+       GdkPixbuf *window_icon;
+       GtkWidget *pannable;
+       ModestWindowPrivate *parent_priv = NULL;
+       ModestDimmingRulesGroup *menu_rules_group = NULL;
+       
+       self  = MODEST_ACCOUNTS_WINDOW(g_object_new(MODEST_TYPE_ACCOUNTS_WINDOW, NULL));
+       priv = MODEST_ACCOUNTS_WINDOW_GET_PRIVATE(self);
+       parent_priv = MODEST_WINDOW_GET_PRIVATE(self);
+
+       parent_priv->ui_dimming_manager = modest_ui_dimming_manager_new();
+       menu_rules_group = modest_dimming_rules_group_new (MODEST_DIMMING_RULES_MENU, FALSE);
+
+       pannable = hildon_pannable_area_new ();
+       priv->account_view  = GTK_WIDGET (modest_account_view_new (modest_runtime_get_account_mgr ()));
+
+       setup_menu (self, menu_rules_group);
+
+       modest_ui_dimming_manager_insert_rules_group (parent_priv->ui_dimming_manager, menu_rules_group);
+       g_object_unref (menu_rules_group);
+
+       gtk_container_add (GTK_CONTAINER (pannable), priv->account_view);
+       gtk_container_add (GTK_CONTAINER (self), pannable);
+
+       gtk_widget_show (priv->account_view);
+       gtk_widget_show (pannable);
+
+       connect_signals (MODEST_ACCOUNTS_WINDOW (self));
+
+       /* Load previous osso state, for instance if we are being restored from 
+        * hibernation:  */
+       modest_osso_load_state ();
+
+       /* 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);
+       }
+
+       /* Listen for changes in the screen, we don't want to show a
+          led pattern when the display is on for example */
+       osso_hw_set_display_event_cb (modest_maemo_utils_get_osso_context (),
+                                     osso_display_event_cb,
+                                     self); 
+
+       /* 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.
+        */
+
+       return MODEST_WINDOW(self);
+}
+
+static gboolean
+on_zoom_minus_plus_not_implemented (ModestWindow *window)
+{
+       g_return_val_if_fail (MODEST_IS_ACCOUNTS_WINDOW (window), FALSE);
+
+       hildon_banner_show_information (NULL, NULL, dgettext("hildon-common-strings", "ckct_ib_cannot_zoom_here"));
+       return FALSE;
+
+}
+
+gboolean
+modest_accounts_window_screen_is_on (ModestAccountsWindow *self)
+{
+       ModestAccountsWindowPrivate *priv = NULL;
+
+       g_return_val_if_fail (MODEST_IS_ACCOUNTS_WINDOW(self), FALSE);
+
+       priv = MODEST_ACCOUNTS_WINDOW_GET_PRIVATE (self);
+       
+       return (priv->display_state == OSSO_DISPLAY_ON) ? TRUE : FALSE;
+}
+
+ModestAccountView *
+modest_accounts_window_get_account_view (ModestAccountsWindow *self)
+{
+       ModestAccountsWindowPrivate *priv = NULL;
+
+       g_return_val_if_fail (MODEST_IS_ACCOUNTS_WINDOW(self), FALSE);
+
+       priv = MODEST_ACCOUNTS_WINDOW_GET_PRIVATE (self);
+       
+       return MODEST_ACCOUNT_VIEW (priv->account_view);
+}
+
+static void add_to_menu (ModestAccountsWindow *self,
+                        HildonAppMenu *menu,
+                        gchar *label,
+                        GCallback callback,
+                        ModestDimmingRulesGroup *group,
+                        GCallback dimming_callback)
+{
+       GtkWidget *button;
+
+       button = gtk_button_new_with_label (label);
+       g_signal_connect_after (G_OBJECT (button), "clicked",
+                               callback, (gpointer) self);
+       if (dimming_callback)
+               modest_dimming_rules_group_add_widget_rule (group,
+                                                           button,
+                                                           dimming_callback,
+                                                           MODEST_WINDOW (self));
+       hildon_app_menu_append (menu, GTK_BUTTON (button));
+}
+
+static void
+on_new_account (GtkAction *action,
+               ModestWindow *window)
+{
+       modest_ui_actions_run_account_setup_wizard (window);
+}
+
+static void setup_menu (ModestAccountsWindow *self, ModestDimmingRulesGroup *group)
+{
+       ModestAccountsWindowPrivate *priv = NULL;
+
+       g_return_if_fail (MODEST_IS_ACCOUNTS_WINDOW(self));
+
+       priv = MODEST_ACCOUNTS_WINDOW_GET_PRIVATE (self);
+
+       priv->app_menu = hildon_app_menu_new ();
+
+       /* Settings menu buttons */
+       add_to_menu (self, HILDON_APP_MENU (priv->app_menu), _("TODO: new account"),
+                    G_CALLBACK (on_new_account),
+                    group, NULL);
+       add_to_menu (self, HILDON_APP_MENU (priv->app_menu), _("TODO: edit accounts"),
+                    G_CALLBACK (modest_ui_actions_on_accounts),
+                    group, NULL);
+       add_to_menu (self, HILDON_APP_MENU (priv->app_menu), _("mcen_me_inbox_options"),
+                    G_CALLBACK (modest_ui_actions_on_settings),
+                    group, NULL);
+       add_to_menu (self, HILDON_APP_MENU (priv->app_menu), _("mcen_me_inbox_globalsmtpservers"),
+                    G_CALLBACK (modest_ui_actions_on_smtp_servers),
+                    group, G_CALLBACK (modest_ui_dimming_rules_on_tools_smtp_servers));
+       add_to_menu (self, HILDON_APP_MENU (priv->app_menu), _("mcen_me_viewer_newemail"),
+                    G_CALLBACK (modest_ui_actions_on_new_msg),
+                    group, G_CALLBACK (modest_ui_dimming_rules_on_new_msg));
+       add_to_menu (self, HILDON_APP_MENU (priv->app_menu), _("mcen_me_inbox_sendandreceive"),
+                    G_CALLBACK (modest_ui_actions_on_send_receive),
+                    group, G_CALLBACK (modest_ui_dimming_rules_on_send_receive_all));
+       add_to_menu (self, HILDON_APP_MENU (priv->app_menu), _("mcen_me_outbox_cancelsend"),
+                    G_CALLBACK (modest_ui_actions_cancel_send),
+                    group, G_CALLBACK (modest_ui_dimming_rules_on_cancel_sending_all));
+       
+       hildon_stackable_window_set_main_menu (HILDON_STACKABLE_WINDOW (self), 
+                                              HILDON_APP_MENU (priv->app_menu));
+}
+
+static gboolean 
+modest_accounts_window_toggle_menu (HildonWindow *window,
+                                   guint button,
+                                   guint32 time)
+{
+       ModestAccountsWindowPrivate *priv = NULL;
+
+       priv = MODEST_ACCOUNTS_WINDOW_GET_PRIVATE (window);
+
+       modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (window));
+
+       gtk_widget_queue_resize (priv->app_menu);
+
+       return HILDON_WINDOW_CLASS (parent_class)->toggle_menu (window, button, time);
+}
+
+
+
+static void
+on_account_activated (GtkTreeView *account_view,
+                     GtkTreePath *path,
+                     GtkTreeViewColumn *column,
+                     ModestAccountsWindow *self)
+{
+       ModestAccountsWindowPrivate *priv;
+       gchar* account_name; 
+       GtkWidget *folder_window;
+
+       priv = MODEST_ACCOUNTS_WINDOW_GET_PRIVATE (self);
+       
+       account_name = modest_account_view_get_path_account (MODEST_ACCOUNT_VIEW (priv->account_view), path);
+       if (!account_name)
+               return;
+
+       folder_window = GTK_WIDGET (modest_folder_window_new (NULL));
+       modest_window_mgr_register_window (modest_runtime_get_window_mgr (), 
+                                          MODEST_WINDOW (folder_window),
+                                          MODEST_WINDOW (self));
+       modest_folder_window_set_account (MODEST_FOLDER_WINDOW (folder_window), account_name);
+       gtk_widget_show (folder_window);
+       g_free (account_name);
+
+}
+
+static void
+modest_accounts_window_show_toolbar (ModestWindow *self,
+                                    gboolean show_toolbar)
+{
+       /* Empty implementation, this view does not show any
+          toolbar */
+}
diff --git a/src/hildon2/modest-accounts-window.h b/src/hildon2/modest-accounts-window.h
new file mode 100644 (file)
index 0000000..95ba4cf
--- /dev/null
@@ -0,0 +1,87 @@
+/* Copyright (c) 2008 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_ACCOUNTS_WINDOW_H__
+#define __MODEST_ACCOUNTS_WINDOW_H__
+
+#include <widgets/modest-window.h>
+#include <widgets/modest-account-view.h>
+
+G_BEGIN_DECLS
+
+/* convenience macros */
+#define MODEST_TYPE_ACCOUNTS_WINDOW             (modest_accounts_window_get_type())
+#define MODEST_ACCOUNTS_WINDOW(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj),MODEST_TYPE_ACCOUNTS_WINDOW,ModestAccountsWindow))
+#define MODEST_ACCOUNTS_WINDOW_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass),MODEST_TYPE_ACCOUNTS_WINDOW,ModestWindow))
+
+#define MODEST_IS_ACCOUNTS_WINDOW(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj),MODEST_TYPE_ACCOUNTS_WINDOW))
+#define MODEST_IS_ACCOUNTS_WINDOW_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE((klass),MODEST_TYPE_ACCOUNTS_WINDOW))
+#define MODEST_ACCOUNTS_WINDOW_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS((obj),MODEST_TYPE_ACCOUNTS_WINDOW,ModestAccountsWindowClass))
+
+typedef struct _ModestAccountsWindow      ModestAccountsWindow;
+typedef struct _ModestAccountsWindowClass ModestAccountsWindowClass;
+
+struct _ModestAccountsWindow {
+       ModestWindow parent;
+};
+
+struct _ModestAccountsWindowClass {
+       ModestWindowClass parent_class;
+};
+
+/**
+ * modest_accounts_window_get_type:
+ * 
+ * get the GType for the ModestAccountsWindow class
+ *
+ * Returns: a GType for ModestAccountsWindow
+ */
+GType modest_accounts_window_get_type (void) G_GNUC_CONST;
+
+
+/**
+ * modest_accounts_window_new:
+ * 
+ * instantiates a new ModestAccountsWindow widget
+ *
+ * Returns: a new ModestAccountsWindow, or NULL in case of error
+ */
+ModestWindow* modest_accounts_window_new ();
+
+/**
+ * modest_accounts_window_get_accounts_view:
+ * @self: a #ModestAccountsWindow
+ *
+ * get the account view inside the accounts window
+ */
+ModestAccountView *modest_accounts_window_get_account_view (ModestAccountsWindow *self);
+
+G_END_DECLS
+
+#endif
index 5baae04..7377e4e 100644 (file)
@@ -899,7 +899,6 @@ select_contacts_for_name_dialog (const gchar *name)
                                                                                   _AB("addr_ti_dia_select_contacts"),
                                                                                   OSSO_ABOOK_CAPS_EMAIL,
                                                                                   OSSO_ABOOK_CONTACT_ORDER_NAME);
-
                osso_abook_contact_chooser_set_model (OSSO_ABOOK_CONTACT_CHOOSER (contact_dialog),
                                                      contact_model);
 
index 786b31b..d2c0f4e 100644 (file)
@@ -36,6 +36,8 @@
 #include "modest-secureauth-picker.h"
 #include "widgets/modest-validating-entry.h"
 #include <hildon/hildon-pannable-area.h>
+#include <hildon/hildon-entry.h>
+#include <modest-ui-constants.h>
 #include <gtk/gtkbutton.h>
 #include <gtk/gtkhbox.h>
 #include <gtk/gtkvbox.h>
@@ -158,7 +160,7 @@ on_value_changed(GtkWidget* widget, GValue* value, ModestConnectionSpecificSmtpE
 }
 
 static gboolean
-on_range_error (GtkWidget *widget, HildonNumberEditorErrorType type, gpointer user_data)
+on_range_error (GtkWidget *widget, ModestNumberEditorErrorType type, gpointer user_data)
 {
        gchar *msg;
        ModestConnectionSpecificSmtpEditWindow *self = user_data;
@@ -170,9 +172,9 @@ on_range_error (GtkWidget *widget, HildonNumberEditorErrorType type, gpointer us
         * remember that such an error occured. */
        priv->range_error_occured = TRUE;
 
-       if (type == HILDON_NUMBER_EDITOR_ERROR_MAXIMUM_VALUE_EXCEED) {
+       if (type == MODEST_NUMBER_EDITOR_ERROR_MAXIMUM_VALUE_EXCEED) {
                msg = g_strdup_printf (dgettext ("hildon-libs", "ckct_ib_maximum_value"), 65535);
-       } else if (type == HILDON_NUMBER_EDITOR_ERROR_MINIMUM_VALUE_EXCEED) {
+       } else if (type == MODEST_NUMBER_EDITOR_ERROR_MINIMUM_VALUE_EXCEED) {
                msg = g_strdup_printf (dgettext ("hildon-libs", "ckct_ib_minimum_value"), 1);
        } else {
                msg = g_strdup_printf (_HL("ckct_ib_set_a_value_within_range"), PORT_RANGE_MIN, PORT_RANGE_MAX);
@@ -207,7 +209,7 @@ on_response (GtkDialog *dialog, int response_id, gpointer user_data)
        ModestConnectionSpecificSmtpEditWindowPrivate *priv =
                        CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW_GET_PRIVATE (self);
 
-       hostname = gtk_entry_get_text (GTK_ENTRY (priv->entry_outgoingserver));
+       hostname = hildon_entry_get_text (HILDON_ENTRY (priv->entry_outgoingserver));
 
        /* Don't close the dialog if a range error occured */
        if(response_id == GTK_RESPONSE_OK && priv->range_error_occured)
@@ -262,8 +264,8 @@ security_picker_set_port (ModestConnectionSpecificSmtpEditWindowPrivate *priv)
                        MODEST_SERVERSECURITY_PICKER (priv->outgoing_security_picker));
 
        if(port_number != 0) {
-               hildon_number_editor_set_value (
-                       HILDON_NUMBER_EDITOR (priv->entry_port), port_number);
+               modest_number_editor_set_value (
+                       MODEST_NUMBER_EDITOR (priv->entry_port), port_number);
        }
 }
 
@@ -338,7 +340,7 @@ modest_connection_specific_smtp_edit_window_init (ModestConnectionSpecificSmtpEd
         
        /* The outgoing server widgets: */
        if (!priv->entry_outgoingserver)
-               priv->entry_outgoingserver = gtk_entry_new ();
+               priv->entry_outgoingserver = hildon_entry_new (MODEST_EDITABLE_SIZE);
        /* Auto-capitalization is the default, so let's turn it off: */
        hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_outgoingserver), HILDON_GTK_INPUT_MODE_FULL);
        g_signal_connect(G_OBJECT(priv->entry_outgoingserver), "changed", G_CALLBACK(on_change), self);
@@ -385,7 +387,7 @@ modest_connection_specific_smtp_edit_window_init (ModestConnectionSpecificSmtpEd
        gtk_entry_set_max_length (GTK_ENTRY (priv->entry_user_username), 64);
        
        /* The password widgets: */     
-       priv->entry_user_password = gtk_entry_new ();
+       priv->entry_user_password = hildon_entry_new (MODEST_EDITABLE_SIZE);
        /* Auto-capitalization is the default, so let's turn it off: */
        hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_user_password), 
                HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
@@ -415,7 +417,7 @@ modest_connection_specific_smtp_edit_window_init (ModestConnectionSpecificSmtpEd
        
        /* The port number widgets: */
        if (!priv->entry_port)
-               priv->entry_port = GTK_WIDGET (hildon_number_editor_new (PORT_RANGE_MIN, PORT_RANGE_MAX));
+               priv->entry_port = GTK_WIDGET (modest_number_editor_new (PORT_RANGE_MIN, PORT_RANGE_MAX));
        captioned = modest_maemo_utils_create_captioned (title_sizegroup, value_sizegroup,
                                                         _("mcen_fi_emailsetup_port"), priv->entry_port);
        gtk_widget_add_events(GTK_WIDGET(priv->entry_port), GDK_FOCUS_CHANGE_MASK);
@@ -503,12 +505,12 @@ modest_connection_specific_smtp_edit_window_set_connection (
                if (priv->account_name)
                        g_free (priv->account_name);
                priv->account_name = g_strdup (modest_server_account_settings_get_account_name (server_settings));
-               gtk_entry_set_text (GTK_ENTRY (priv->entry_outgoingserver), 
-                                   modest_server_account_settings_get_hostname (server_settings));
-               gtk_entry_set_text (GTK_ENTRY (priv->entry_user_username),
-                                   modest_server_account_settings_get_username (server_settings));     
-               gtk_entry_set_text (GTK_ENTRY (priv->entry_user_password), 
-                                   modest_server_account_settings_get_password (server_settings));
+               hildon_entry_set_text (HILDON_ENTRY (priv->entry_outgoingserver), 
+                                      modest_server_account_settings_get_hostname (server_settings));
+               hildon_entry_set_text (HILDON_ENTRY (priv->entry_user_username),
+                                      modest_server_account_settings_get_username (server_settings));  
+               hildon_entry_set_text (HILDON_ENTRY (priv->entry_user_password), 
+                                      modest_server_account_settings_get_password (server_settings));
        
                modest_serversecurity_picker_set_active_serversecurity (
                MODEST_SERVERSECURITY_PICKER (priv->outgoing_security_picker), 
@@ -519,8 +521,8 @@ modest_connection_specific_smtp_edit_window_set_connection (
                modest_server_account_settings_get_auth_protocol (server_settings));
                
                /* port: */
-               hildon_number_editor_set_value (
-                       HILDON_NUMBER_EDITOR (priv->entry_port), 
+               modest_number_editor_set_value (
+                       MODEST_NUMBER_EDITOR (priv->entry_port), 
                        modest_server_account_settings_get_port (server_settings));
                
                
@@ -537,7 +539,7 @@ modest_connection_specific_smtp_edit_window_get_settings (ModestConnectionSpecif
        const gchar *outgoing_server = NULL;
 
        priv =  CONNECTION_SPECIFIC_SMTP_EDIT_WINDOW_GET_PRIVATE (window);
-       outgoing_server = gtk_entry_get_text (GTK_ENTRY (priv->entry_outgoingserver));
+       outgoing_server = hildon_entry_get_text (HILDON_ENTRY (priv->entry_outgoingserver));
 
        /* If the outgoing server is NULL, we are removing the connection specific
         * settings */
@@ -548,13 +550,13 @@ modest_connection_specific_smtp_edit_window_get_settings (ModestConnectionSpecif
        server_settings = modest_server_account_settings_new ();
        
        modest_server_account_settings_set_hostname (server_settings, 
-                                                    gtk_entry_get_text (GTK_ENTRY (priv->entry_outgoingserver)));
+                                                    hildon_entry_get_text (HILDON_ENTRY (priv->entry_outgoingserver)));
        modest_server_account_settings_set_protocol (server_settings,
                                                     MODEST_PROTOCOLS_TRANSPORT_SMTP);
        modest_server_account_settings_set_username (server_settings,
-                                                    gtk_entry_get_text (GTK_ENTRY (priv->entry_user_username)));
+                                                    hildon_entry_get_text (HILDON_ENTRY (priv->entry_user_username)));
        modest_server_account_settings_set_password (server_settings,
-                                                    gtk_entry_get_text (GTK_ENTRY (priv->entry_user_password)));
+                                                    hildon_entry_get_text (HILDON_ENTRY (priv->entry_user_password)));
        
        modest_server_account_settings_set_security_protocol (server_settings, 
                                                     modest_serversecurity_picker_get_active_serversecurity (
@@ -567,7 +569,7 @@ modest_connection_specific_smtp_edit_window_get_settings (ModestConnectionSpecif
        
        /* port: */
        modest_server_account_settings_set_port (server_settings,
-                                                hildon_number_editor_get_value (HILDON_NUMBER_EDITOR (priv->entry_port)));
+                                                modest_number_editor_get_value (MODEST_NUMBER_EDITOR (priv->entry_port)));
                        
        return server_settings;
 }
index 2de4896..909d00d 100644 (file)
@@ -39,6 +39,7 @@
 #include <gtk/gtkcellrenderertext.h>
 #include <gtk/gtkliststore.h>
 #include <hildon/hildon-pannable-area.h>
+#include <hildon/hildon-gtk.h>
 #include <gtk/gtkbutton.h>
 #include <gtk/gtkhbox.h>
 #include <gtk/gtkvbox.h>
index a8a1a09..048da3d 100644 (file)
@@ -212,16 +212,16 @@ on_modified_checkbutton_toggled (GtkButton *button, gpointer user_data)
 }
 
 static void
-on_modified_number_editor_changed (HildonNumberEditor *number_editor, gint new_value, gpointer user_data)
+on_modified_number_editor_changed (ModestNumberEditor *number_editor, gint new_value, gpointer user_data)
 {
        set_modified (MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG (user_data), TRUE);
 }
 
 static void       
-on_number_editor_notify (HildonNumberEditor *editor, GParamSpec *arg1, gpointer user_data)
+on_number_editor_notify (ModestNumberEditor *editor, GParamSpec *arg1, gpointer user_data)
 {
        ModestDefaultAccountSettingsDialog *dialog = MODEST_DEFAULT_ACCOUNT_SETTINGS_DIALOG (user_data);
-       gint value = hildon_number_editor_get_value (editor);
+       gint value = modest_number_editor_get_value (editor);
 
        gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, value > 0);
 }
@@ -232,7 +232,7 @@ on_number_editor_notify (HildonNumberEditor *editor, GParamSpec *arg1, gpointer
 static void
 connect_for_modified (ModestDefaultAccountSettingsDialog *self, GtkWidget *widget)
 {
-       if (HILDON_IS_NUMBER_EDITOR (widget)) {
+       if (MODEST_IS_NUMBER_EDITOR (widget)) {
                g_signal_connect (G_OBJECT (widget), "notify::value",
                        G_CALLBACK (on_modified_number_editor_changed), self);
                g_signal_connect (G_OBJECT (widget), "notify", G_CALLBACK (on_number_editor_notify), self);
index 58129d6..8670ead 100644 (file)
@@ -342,7 +342,7 @@ update_user_email_from_provider (ModestEasysetupWizardDialog *self)
                domain_name = g_strdup (MODEST_EXAMPLE_EMAIL_ADDRESS);
                
        if (priv->entry_user_email)
-               gtk_entry_set_text (GTK_ENTRY (priv->entry_user_email), domain_name);
+               hildon_entry_set_text (HILDON_ENTRY (priv->entry_user_email), domain_name);
                
        g_free (domain_name);
        
@@ -428,7 +428,7 @@ create_page_account_details (ModestEasysetupWizardDialog *self)
        g_free (default_account_name_start);
        default_account_name_start = NULL;
        
-       gtk_entry_set_text( GTK_ENTRY (priv->entry_account_title), default_account_name);
+       hildon_entry_set_text (HILDON_ENTRY (priv->entry_account_title), default_account_name);
        g_free (default_account_name);
        default_account_name = NULL;
 
@@ -546,7 +546,7 @@ create_page_user_details (ModestEasysetupWizardDialog *self)
                                              on_entry_max, self);
        
        /* The password widgets: */     
-       priv->entry_user_password = gtk_entry_new ();
+       priv->entry_user_password = hildon_entry_new (MODEST_EDITABLE_SIZE);
        /* Auto-capitalization is the default, so let's turn it off: */
        hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_user_password), 
                                         HILDON_GTK_INPUT_MODE_FULL | HILDON_GTK_INPUT_MODE_INVISIBLE);
@@ -739,7 +739,7 @@ create_page_custom_incoming (ModestEasysetupWizardDialog *self)
        gtk_box_pack_start (GTK_BOX (box), priv->incoming_servertype_picker, FALSE, FALSE, MODEST_MARGIN_HALF);
        gtk_widget_show (priv->incoming_servertype_picker);
        
-       priv->entry_incomingserver = gtk_entry_new ();
+       priv->entry_incomingserver = hildon_entry_new (MODEST_EDITABLE_SIZE);
        g_signal_connect(G_OBJECT(priv->entry_incomingserver), "changed", G_CALLBACK(on_easysetup_changed), self);
        /* Auto-capitalization is the default, so let's turn it off: */
        hildon_gtk_entry_set_input_mode (GTK_ENTRY (priv->entry_incomingserver), HILDON_GTK_INPUT_MODE_FULL);
@@ -856,7 +856,7 @@ create_page_custom_outgoing (ModestEasysetupWizardDialog *self)
         
        /* The outgoing server widgets: */
        priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE (self);
-       priv->entry_outgoingserver = gtk_entry_new ();
+       priv->entry_outgoingserver = hildon_entry_new (MODEST_EDITABLE_SIZE);
        g_signal_connect (G_OBJECT (priv->entry_outgoingserver), "changed",
                   G_CALLBACK (on_easysetup_changed), self);
        /* Auto-capitalization is the default, so let's turn it off: */
@@ -1527,13 +1527,13 @@ set_default_custom_servernames (ModestEasysetupWizardDialog *self)
 
                /* This could happen when the combo box has still no active iter */
                if (protocol_type != MODEST_PROTOCOL_REGISTRY_TYPE_INVALID) {
-                       const gchar* email_address = gtk_entry_get_text (GTK_ENTRY(priv->entry_user_email));    
+                       const gchar* email_address = hildon_entry_get_text (HILDON_ENTRY(priv->entry_user_email));      
                        gchar* servername = util_get_default_servername_from_email_address (email_address, 
                                                                                            protocol_type);
 
                        /* Do not set the INCOMING_CHANGED flag because of this edit */
                        g_signal_handlers_block_by_func (G_OBJECT (priv->entry_incomingserver), G_CALLBACK (on_entry_incoming_servername_changed), self);
-                       gtk_entry_set_text (GTK_ENTRY (priv->entry_incomingserver), servername);
+                       hildon_entry_set_text (HILDON_ENTRY (priv->entry_incomingserver), servername);
                        g_signal_handlers_unblock_by_func (G_OBJECT (priv->entry_incomingserver), G_CALLBACK (on_entry_incoming_servername_changed), self);
                        
                        g_free (servername);
@@ -1548,13 +1548,13 @@ set_default_custom_servernames (ModestEasysetupWizardDialog *self)
                
        if (priv->entry_user_email
            && ((priv->server_changes & MODEST_EASYSETUP_WIZARD_DIALOG_OUTGOING_CHANGED) == 0)) {
-               const gchar* email_address = gtk_entry_get_text (GTK_ENTRY(priv->entry_user_email));
+               const gchar* email_address = hildon_entry_get_text (HILDON_ENTRY(priv->entry_user_email));
                
                gchar* servername = util_get_default_servername_from_email_address (email_address, MODEST_PROTOCOLS_TRANSPORT_SMTP);
 
                /* Do not set the OUTGOING_CHANGED flag because of this edit */
                g_signal_handlers_block_by_func (G_OBJECT (priv->entry_outgoingserver), G_CALLBACK (on_entry_outgoing_servername_changed), self);
-               gtk_entry_set_text (GTK_ENTRY (priv->entry_outgoingserver), servername);
+               hildon_entry_set_text (HILDON_ENTRY (priv->entry_outgoingserver), servername);
                g_signal_handlers_unblock_by_func (G_OBJECT (priv->entry_outgoingserver), G_CALLBACK (on_entry_outgoing_servername_changed), self);
 
                g_free (servername);
@@ -1568,7 +1568,7 @@ get_entered_account_title (ModestEasysetupWizardDialog *self)
        const gchar* account_title;
 
        priv = MODEST_EASYSETUP_WIZARD_DIALOG_GET_PRIVATE(self);
-       account_title = gtk_entry_get_text (GTK_ENTRY (priv->entry_account_title));
+       account_title = hildon_entry_get_text (HILDON_ENTRY (priv->entry_account_title));
 
        if (!account_title || (g_utf8_strlen (account_title, -1) == 0)) {
                return NULL;
@@ -1630,7 +1630,7 @@ on_before_next (ModestWizardDialog *dialog, GtkWidget *current_page, GtkWidget *
 
        } else if (current_page == priv->page_user_details) {
                /* Check that the email address is valud: */
-               const gchar* email_address = gtk_entry_get_text (GTK_ENTRY (priv->entry_user_email));
+               const gchar* email_address = hildon_entry_get_text (HILDON_ENTRY (priv->entry_user_email));
                if ((!email_address) || (g_utf8_strlen (email_address, -1) == 0))
                        return FALSE;
                        
@@ -1686,7 +1686,7 @@ static gboolean entry_is_empty (GtkWidget *entry)
        if (!entry)
                return FALSE;
                
-       const gchar* text = gtk_entry_get_text (GTK_ENTRY (entry));
+       const gchar* text = hildon_entry_get_text (HILDON_ENTRY (entry));
        if ((!text) || (g_utf8_strlen (text, -1) == 0))
                return TRUE;
        else {
@@ -1860,8 +1860,8 @@ save_to_settings (ModestEasysetupWizardDialog *self)
        }
 
        /* username and password (for both incoming and outgoing): */
-       username = gtk_entry_get_text (GTK_ENTRY (priv->entry_user_username));
-       password = gtk_entry_get_text (GTK_ENTRY (priv->entry_user_password));
+       username = hildon_entry_get_text (HILDON_ENTRY (priv->entry_user_username));
+       password = hildon_entry_get_text (HILDON_ENTRY (priv->entry_user_password));
 
        store_settings = modest_account_settings_get_store_settings (priv->settings);
        transport_settings = modest_account_settings_get_transport_settings (priv->settings);
@@ -1920,7 +1920,7 @@ save_to_settings (ModestEasysetupWizardDialog *self)
                        modest_server_account_settings_set_port (store_settings, store_port);
        } else {
                /* Use custom pages because no preset was specified: */
-               store_hostname = g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->entry_incomingserver) ));               
+               store_hostname = g_strdup (hildon_entry_get_text (HILDON_ENTRY (priv->entry_incomingserver) ));         
                store_protocol = modest_servertype_picker_get_active_servertype (
                        MODEST_SERVERTYPE_PICKER (priv->incoming_servertype_picker));           
 
@@ -1991,7 +1991,7 @@ save_to_settings (ModestEasysetupWizardDialog *self)
 
                registry = modest_runtime_get_protocol_registry ();
                /* Use custom pages because no preset was specified: */
-               transport_hostname = g_strdup (gtk_entry_get_text (GTK_ENTRY (priv->entry_outgoingserver) ));
+               transport_hostname = g_strdup (hildon_entry_get_text (HILDON_ENTRY (priv->entry_outgoingserver) ));
 
                store_proto = modest_protocol_registry_get_protocol_by_type (registry, 
                                                                             store_protocol);
@@ -2018,8 +2018,8 @@ save_to_settings (ModestEasysetupWizardDialog *self)
        g_object_unref (transport_settings);
        g_free (transport_hostname);
        
-       fullname = gtk_entry_get_text (GTK_ENTRY (priv->entry_user_name));
-       email_address = gtk_entry_get_text (GTK_ENTRY (priv->entry_user_email));
+       fullname = hildon_entry_get_text (HILDON_ENTRY (priv->entry_user_name));
+       email_address = hildon_entry_get_text (HILDON_ENTRY (priv->entry_user_email));
        modest_account_settings_set_fullname (priv->settings, fullname);
        modest_account_settings_set_email_address (priv->settings, email_address);
        /* we don't set retrieve type to preserve advanced settings if
index a1295ab..54cc733 100644 (file)
@@ -42,6 +42,7 @@
 #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 <tny-account-store-view.h>
@@ -395,6 +396,9 @@ on_folder_activated (ModestFolderView *folder_view,
        if (!folder)
                return;
 
+       if (!TNY_IS_FOLDER (folder))
+               return;
+
        headerwin = modest_header_window_new (folder);
        modest_window_mgr_register_window (modest_runtime_get_window_mgr (), 
                                           MODEST_WINDOW (headerwin),
index b0ebd6f..d592e40 100644 (file)
@@ -31,7 +31,9 @@
 #include <modest-osso-state-saving.h>
 #include <libosso.h>
 #include <hildon/hildon-pannable-area.h>
+#include <hildon/hildon-edit-toolbar.h>
 #include <modest-window-mgr.h>
+#include <modest-window-priv.h>
 #include <modest-signal-mgr.h>
 #include <modest-runtime.h>
 #include <modest-platform.h>
@@ -48,6 +50,8 @@
 #include <hildon/hildon-button.h>
 #include <hildon/hildon-program.h>
 #include <hildon/hildon-banner.h>
+#include "modest-ui-dimming-rules.h"
+#include "modest-ui-dimming-manager.h"
 
 typedef enum {
        CONTENTS_STATE_NONE = 0,
@@ -55,27 +59,44 @@ typedef enum {
        CONTENTS_STATE_HEADERS = 2
 } ContentsState;
 
+typedef enum {
+       EDIT_MODE_COMMAND_NONE = 0,
+       EDIT_MODE_COMMAND_MOVE = 1,
+       EDIT_MODE_COMMAND_DELETE = 2,
+} EditModeCommand;
+
 typedef struct _ModestHeaderWindowPrivate ModestHeaderWindowPrivate;
 struct _ModestHeaderWindowPrivate {
 
        GtkWidget *header_view;
        GtkWidget *empty_view;
        GtkWidget *contents_view;
-       GtkWidget *new_message_button;
+       GtkWidget *top_vbox;
+       GtkWidget *edit_toolbar;
 
+       /* state bar */
        ContentsState contents_state;
+       gboolean edit_mode;
+       EditModeCommand edit_command;
 
        TnyFolder *folder;
 
+       /* autoscroll */
+       gboolean autoscroll;
+
        /* banners */
        GtkWidget *updating_banner;
        guint updating_banner_timeout;
 
        /* signals */
        GSList *sighandlers;
+       gulong queue_change_handler;
 
        /* Display state */
        osso_display_state_t display_state;
+
+       /* progress hint */
+       gboolean progress_hint;
 };
 #define MODEST_HEADER_WINDOW_GET_PRIVATE(o)  (G_TYPE_INSTANCE_GET_PRIVATE((o), \
                                                                          MODEST_TYPE_HEADER_WINDOW, \
@@ -90,13 +111,20 @@ static void connect_signals (ModestHeaderWindow *self);
 static void modest_header_window_disconnect_signals (ModestWindow *self);
 
 static gboolean on_zoom_minus_plus_not_implemented (ModestWindow *window);
+static gboolean modest_header_window_toggle_menu (HildonWindow *window,
+                                                 guint button,
+                                                 guint32 time);
 static void add_to_menu (ModestHeaderWindow *self,
                         HildonAppMenu *menu,
                         gchar *label,
-                        GCallback callback);
-static void setup_menu (ModestHeaderWindow *self);
+                        GCallback callback,
+                        ModestDimmingRulesGroup *group,
+                        GCallback dimming_callback);
+static void setup_menu (ModestHeaderWindow *self,
+                       ModestDimmingRulesGroup *group);
 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);
@@ -114,6 +142,30 @@ static void on_header_activated (ModestHeaderView *header_view,
 static void on_updating_msg_list (ModestHeaderView *header_view,
                                  gboolean starting,
                                  gpointer user_data);
+static void set_edit_mode (ModestHeaderWindow *self,
+                          EditModeCommand command);
+static void edit_toolbar_button_clicked (HildonEditToolbar *toolbar,
+                                        ModestHeaderWindow *self);
+static void edit_toolbar_arrow_clicked (HildonEditToolbar *toolbar,
+                                       ModestHeaderWindow *self);
+static void set_delete_edit_mode (GtkButton *button,
+                                 ModestHeaderWindow *self);
+static void set_moveto_edit_mode (GtkButton *button,
+                                 ModestHeaderWindow *self);
+static gboolean on_expose_event(GtkTreeView *header_view,
+                               GdkEventExpose *event,
+                               gpointer user_data);
+static void on_vertical_movement (HildonPannableArea *area,
+                                 HildonMovementDirection direction,
+                                 gdouble x, gdouble y, gpointer user_data);
+static void set_progress_hint    (ModestHeaderWindow *self, 
+                                 gboolean enabled);
+static void on_queue_changed    (ModestMailOperationQueue *queue,
+                                ModestMailOperation *mail_op,
+                                ModestMailOperationQueueNotification type,
+                                ModestHeaderWindow *self);
+static void modest_header_window_show_toolbar   (ModestWindow *window,
+                                                gboolean show_toolbar);
 
 
 /* globals */
@@ -158,14 +210,18 @@ modest_header_window_class_init (ModestHeaderWindowClass *klass)
        GObjectClass *gobject_class;
        gobject_class = (GObjectClass*) klass;
        ModestWindowClass *modest_window_class = (ModestWindowClass *) klass;
+       HildonWindowClass *hildon_window_class = (HildonWindowClass *) klass;
 
        parent_class            = g_type_class_peek_parent (klass);
        gobject_class->finalize = modest_header_window_finalize;
 
        g_type_class_add_private (gobject_class, sizeof(ModestHeaderWindowPrivate));
        
+       hildon_window_class->toggle_menu = modest_header_window_toggle_menu;
+
        modest_window_class->zoom_minus_func = on_zoom_minus_plus_not_implemented;
        modest_window_class->zoom_plus_func = on_zoom_minus_plus_not_implemented;
+       modest_window_class->show_toolbar_func = modest_header_window_show_toolbar;
        modest_window_class->disconnect_signals_func = modest_header_window_disconnect_signals;
 }
 
@@ -181,11 +237,18 @@ modest_header_window_init (ModestHeaderWindow *obj)
        
        priv->header_view = NULL;
        priv->empty_view = NULL;
+       priv->top_vbox = NULL;
+       priv->edit_mode = FALSE;
+       priv->edit_command = EDIT_MODE_COMMAND_NONE;
+       priv->edit_toolbar = NULL;
        priv->contents_view = NULL;
        priv->contents_state = CONTENTS_STATE_NONE;
        priv->folder = NULL;
        priv->updating_banner = NULL;
        priv->updating_banner_timeout = 0;
+       priv->autoscroll = TRUE;
+       priv->progress_hint = FALSE;
+       priv->queue_change_handler = 0;
        
        modest_window_mgr_register_help_id (modest_runtime_get_window_mgr(),
                                            GTK_WINDOW(obj),
@@ -225,8 +288,14 @@ modest_header_window_disconnect_signals (ModestWindow *self)
        ModestHeaderWindowPrivate *priv;        
        priv = MODEST_HEADER_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;       
+       priv->sighandlers = NULL;
+
 }
 
 static void
@@ -252,20 +321,26 @@ connect_signals (ModestHeaderWindow *self)
                                           "updating-msg-list",
                                           G_CALLBACK (on_updating_msg_list), 
                                           self);
-       
-       /* TODO: connect header view activate */
-
-       /* new message button */
-
-       g_signal_connect (G_OBJECT (priv->new_message_button), "clicked",
-                         G_CALLBACK (modest_ui_actions_on_new_msg), (gpointer) self);
-       
-       /* window */
+       priv->sighandlers =
+               modest_signal_mgr_connect (priv->sighandlers,
+                                          G_OBJECT (priv->header_view),
+                                          "expose-event",
+                                          G_CALLBACK (on_expose_event),
+                                          self);
 
-       /* we don't register this in sighandlers, as it should be run after disconnecting all signals,
-        * in destroy stage */
+       priv->sighandlers =
+               modest_signal_mgr_connect (priv->sighandlers,
+                                          G_OBJECT (priv->contents_view), 
+                                          "vertical-movement", 
+                                          G_CALLBACK (on_vertical_movement), 
+                                          self);
 
-       
+       /* Mail Operation Queue */
+       priv->queue_change_handler =
+               g_signal_connect (G_OBJECT (modest_runtime_get_mail_operation_queue ()),
+                                 "queue-changed",
+                                 G_CALLBACK (on_queue_changed),
+                                 self);
 }
 
 static void 
@@ -282,13 +357,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);
 
@@ -298,15 +373,28 @@ create_header_view (TnyFolder *folder)
 static GtkWidget *
 create_empty_view (void)
 {
-       GtkLabel *label = NULL;
+       GtkWidget *label = NULL;
        GtkWidget *align = NULL;
 
        align = gtk_alignment_new(EMPTYVIEW_XALIGN, EMPTYVIEW_YALIGN, EMPTYVIEW_XSPACE, EMPTYVIEW_YSPACE);
-       label = GTK_LABEL(gtk_label_new (_("mcen_ia_nomessages")));
-       gtk_label_set_justify (label, GTK_JUSTIFY_CENTER);      
-       gtk_container_add (GTK_CONTAINER (align), GTK_WIDGET(label));
+       label = gtk_label_new (_("mcen_ia_nomessages"));
+       gtk_widget_show (label);
+       gtk_widget_show (align);
+       gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_CENTER);  
+       gtk_container_add (GTK_CONTAINER (align), label);
 
-       return GTK_WIDGET(align);
+       return align;
+}
+
+static void
+on_vertical_movement (HildonPannableArea *area,
+                     HildonMovementDirection direction,
+                     gdouble x, gdouble y, gpointer user_data)
+{
+       ModestHeaderWindow *self = (ModestHeaderWindow *) user_data;
+       ModestHeaderWindowPrivate *priv = MODEST_HEADER_WINDOW_GET_PRIVATE (self);
+
+       priv->autoscroll = FALSE;
 }
 
 
@@ -317,39 +405,36 @@ modest_header_window_new (TnyFolder *folder)
        ModestHeaderWindowPrivate *priv = NULL;
        HildonProgram *app;
        GdkPixbuf *window_icon;
-       GtkWidget *pannable;
+       ModestWindowPrivate *parent_priv = NULL;
+       ModestDimmingRulesGroup *menu_rules_group = NULL;
        
        self  = MODEST_HEADER_WINDOW(g_object_new(MODEST_TYPE_HEADER_WINDOW, NULL));
        priv = MODEST_HEADER_WINDOW_GET_PRIVATE(self);
+       parent_priv = MODEST_WINDOW_GET_PRIVATE(self);
+
+       parent_priv->ui_dimming_manager = modest_ui_dimming_manager_new();
+       menu_rules_group = modest_dimming_rules_group_new (MODEST_DIMMING_RULES_MENU, FALSE);
 
        priv->folder = g_object_ref (folder);
 
-       pannable = hildon_pannable_area_new ();
+       priv->contents_view = 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);
-       priv->contents_view = gtk_vbox_new (FALSE, 0);
-       priv->new_message_button = hildon_button_new (MODEST_EDITABLE_SIZE,
-                                                     HILDON_BUTTON_ARRANGEMENT_HORIZONTAL);
-       hildon_button_set_title (HILDON_BUTTON (priv->new_message_button), _("mcen_me_viewer_newemail"));
-       hildon_button_set_image (HILDON_BUTTON (priv->new_message_button), 
-                                gtk_image_new_from_stock (MODEST_STOCK_NEW_MAIL, GTK_ICON_SIZE_DIALOG));
-       hildon_button_set_title_alignment (HILDON_BUTTON (priv->new_message_button), 0.0, 0.5);
-       hildon_button_set_image_alignment (HILDON_BUTTON (priv->new_message_button), 0.0, 0.5);
-       hildon_button_set_alignment (HILDON_BUTTON (priv->new_message_button), 0.0, 0.5, 1.0, 0.0);
-       hildon_button_set_image_position (HILDON_BUTTON (priv->new_message_button), GTK_POS_LEFT);
-
-       setup_menu (self);
-
-       gtk_box_pack_start (GTK_BOX (priv->contents_view), priv->new_message_button, FALSE, FALSE, 0);
-       hildon_pannable_area_add_with_viewport (HILDON_PANNABLE_AREA (pannable), priv->contents_view);
-       gtk_container_add (GTK_CONTAINER (self), pannable);
+       setup_menu (self, menu_rules_group);
+
+       modest_ui_dimming_manager_insert_rules_group (parent_priv->ui_dimming_manager, menu_rules_group);
+       g_object_unref (menu_rules_group);
+
+        priv->top_vbox = gtk_vbox_new (FALSE, 0);
+       gtk_box_pack_end (GTK_BOX (priv->top_vbox), priv->contents_view, TRUE, TRUE, 0);
+
+       gtk_container_add (GTK_CONTAINER (self), priv->top_vbox);
 
        gtk_widget_show (priv->contents_view);
-       gtk_widget_show (pannable);
-       gtk_widget_show (priv->new_message_button);
+       gtk_widget_show (priv->top_vbox);
 
        connect_signals (MODEST_HEADER_WINDOW (self));
 
@@ -424,17 +509,23 @@ modest_header_window_get_header_view (ModestHeaderWindow *self)
 static void add_to_menu (ModestHeaderWindow *self,
                         HildonAppMenu *menu,
                         gchar *label,
-                        GCallback callback)
+                        GCallback callback,
+                        ModestDimmingRulesGroup *dimming_group,
+                        GCallback dimming_callback)
 {
        GtkWidget *button;
 
        button = gtk_button_new_with_label (label);
        g_signal_connect_after (G_OBJECT (button), "clicked",
                                callback, (gpointer) self);
+       modest_dimming_rules_group_add_widget_rule (dimming_group,
+                                                   button,
+                                                   dimming_callback,
+                                                   MODEST_WINDOW (self));
        hildon_app_menu_append (menu, GTK_BUTTON (button));
 }
 
-static void setup_menu (ModestHeaderWindow *self)
+static void setup_menu (ModestHeaderWindow *self, ModestDimmingRulesGroup *group)
 {
        ModestHeaderWindowPrivate *priv = NULL;
        GtkWidget *app_menu;
@@ -445,17 +536,43 @@ static void setup_menu (ModestHeaderWindow *self)
 
        app_menu = hildon_app_menu_new ();
 
+       add_to_menu (self, HILDON_APP_MENU (app_menu), _("mcen_me_inbox_moveto"),
+                    G_CALLBACK (set_moveto_edit_mode),
+                    group, G_CALLBACK (modest_ui_dimming_rules_on_delete));
+       add_to_menu (self, HILDON_APP_MENU (app_menu), _("mcen_me_inbox_delete"),
+                    G_CALLBACK (set_delete_edit_mode),
+                    group, G_CALLBACK (modest_ui_dimming_rules_on_move_to));
+       add_to_menu (self, HILDON_APP_MENU (app_menu), _("mcen_me_inbox_messagedetails"),
+                    G_CALLBACK (modest_ui_actions_on_details),
+                    group, G_CALLBACK (modest_ui_dimming_rules_on_details));
+       add_to_menu (self, HILDON_APP_MENU (app_menu), _("mcen_me_inbox_sort"),
+                    G_CALLBACK (modest_ui_actions_on_sort),
+                    group, G_CALLBACK (modest_ui_dimming_rules_on_sort));
        add_to_menu (self, HILDON_APP_MENU (app_menu), _("mcen_me_viewer_newemail"),
-                    G_CALLBACK (modest_ui_actions_on_new_msg));
+                    G_CALLBACK (modest_ui_actions_on_new_msg),
+                    group, G_CALLBACK (modest_ui_dimming_rules_on_new_msg));
        add_to_menu (self, HILDON_APP_MENU (app_menu), _("mcen_me_inbox_sendandreceive"),
-                    G_CALLBACK (modest_ui_actions_on_send_receive));
-       add_to_menu (self, HILDON_APP_MENU (app_menu), _("mcen_me_inbox_messagedetails"),
-                    G_CALLBACK (modest_ui_actions_on_details));
+                    G_CALLBACK (modest_ui_actions_on_send_receive),
+                    group, G_CALLBACK (modest_ui_dimming_rules_on_send_receive));
+       add_to_menu (self, HILDON_APP_MENU (app_menu), _("mcen_me_outbox_cancelsend"),
+                    G_CALLBACK (modest_ui_actions_cancel_send),
+                    group, G_CALLBACK (modest_ui_dimming_rules_on_cancel_sending_all));
 
        hildon_stackable_window_set_main_menu (HILDON_STACKABLE_WINDOW (self), 
                                               HILDON_APP_MENU (app_menu));
 }
 
+static gboolean 
+modest_header_window_toggle_menu (HildonWindow *window,
+                                 guint button,
+                                 guint32 time)
+{
+       modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (window));
+
+       return HILDON_WINDOW_CLASS (parent_class)->toggle_menu (window, button, time);
+}
+
+
 static void 
 update_view (ModestHeaderWindow *self,
             TnyFolderChange *change)
@@ -523,11 +640,11 @@ set_contents_state (ModestHeaderWindow *self,
        /* Add the new content */
        switch (state) {
        case CONTENTS_STATE_EMPTY:
-               gtk_box_pack_start (GTK_BOX (priv->contents_view), priv->empty_view, TRUE, TRUE, 0);
+               gtk_container_add (GTK_CONTAINER (priv->contents_view), priv->empty_view);
                gtk_widget_show (priv->empty_view);
                break;
        case CONTENTS_STATE_HEADERS:
-               gtk_box_pack_start (GTK_BOX (priv->contents_view), priv->header_view, TRUE, TRUE, 0);
+               gtk_container_add (GTK_CONTAINER (priv->contents_view), priv->header_view);
                gtk_widget_show (priv->header_view);
                break;
        case CONTENTS_STATE_NONE:
@@ -632,3 +749,270 @@ on_updating_msg_list (ModestHeaderView *header_view,
                }
        }
 }
+
+static void
+set_edit_mode (ModestHeaderWindow *self,
+              EditModeCommand command)
+{
+       ModestHeaderWindowPrivate *priv;
+
+       priv = MODEST_HEADER_WINDOW_GET_PRIVATE (self);
+       if (priv->edit_toolbar) {
+               gtk_widget_destroy (priv->edit_toolbar);
+               priv->edit_toolbar = NULL;
+       }
+
+       if (command == EDIT_MODE_COMMAND_NONE) {
+               if (priv->edit_mode) {
+                       priv->edit_mode = FALSE;
+                       priv->edit_command = command;
+                       g_object_set (G_OBJECT (priv->header_view), 
+                                     "hildon-ui-mode", HILDON_UI_MODE_NORMAL, 
+                                     NULL);
+                       gtk_widget_queue_resize (priv->header_view);
+                       gtk_window_unfullscreen (GTK_WINDOW (self));
+               }
+       } else {
+               if (!priv->edit_mode) {
+                       GtkTreeSelection *selection;
+
+                       g_object_set (G_OBJECT (priv->header_view),
+                                     "hildon-ui-mode", HILDON_UI_MODE_EDIT,
+                                     NULL);
+                       selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (priv->header_view));
+                       gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE);
+                       gtk_tree_selection_unselect_all (selection);
+
+                       priv->edit_mode = TRUE;
+                       priv->edit_command = command;
+
+                       /* Setup toolbar */
+                       priv->edit_toolbar = hildon_edit_toolbar_new ();
+                       switch (command) {
+                       case EDIT_MODE_COMMAND_DELETE:
+                               hildon_edit_toolbar_set_label (HILDON_EDIT_TOOLBAR (priv->edit_toolbar),
+                                                              _("TODO: Select messages to delete"));
+                               hildon_edit_toolbar_set_button_label (HILDON_EDIT_TOOLBAR (priv->edit_toolbar),
+                                                                     _("TODO: Delete"));
+                               break;
+                       case EDIT_MODE_COMMAND_MOVE:
+                               hildon_edit_toolbar_set_label (HILDON_EDIT_TOOLBAR (priv->edit_toolbar),
+                                                              _("TODO: Select messages to move"));
+                               hildon_edit_toolbar_set_button_label (HILDON_EDIT_TOOLBAR (priv->edit_toolbar),
+                                                                     _("TODO: Move"));
+                               break;
+                       case EDIT_MODE_COMMAND_NONE:
+                               g_assert ("Shouldn't reach");
+                       }
+                       gtk_box_pack_start (GTK_BOX (priv->top_vbox), priv->edit_toolbar, FALSE, FALSE, 0);
+                       g_signal_connect (G_OBJECT (priv->edit_toolbar), "button-clicked",
+                                         G_CALLBACK (edit_toolbar_button_clicked), (gpointer) self);
+                       g_signal_connect (G_OBJECT (priv->edit_toolbar), "arrow-clicked",
+                                         G_CALLBACK (edit_toolbar_arrow_clicked), (gpointer) self);
+                       gtk_widget_show (priv->edit_toolbar);
+
+                       gtk_widget_queue_resize (priv->header_view);
+                       gtk_window_fullscreen (GTK_WINDOW (self));
+               }
+       }
+}
+
+static void
+edit_toolbar_button_clicked (HildonEditToolbar *toolbar,
+                            ModestHeaderWindow *self)
+{
+       ModestHeaderWindowPrivate *priv = MODEST_HEADER_WINDOW_GET_PRIVATE (self);
+
+       switch (priv->edit_command) {
+       case EDIT_MODE_COMMAND_DELETE:
+               if (modest_ui_actions_on_edit_mode_delete_message (MODEST_WINDOW (self)))
+                       set_edit_mode (self, EDIT_MODE_COMMAND_NONE);
+               break;
+       case EDIT_MODE_COMMAND_MOVE:
+               modest_ui_actions_on_move_to (NULL, MODEST_WINDOW (self));
+               set_edit_mode (self, EDIT_MODE_COMMAND_NONE);
+               break;
+       case EDIT_MODE_COMMAND_NONE:
+                       g_assert_not_reached ();
+       }
+}
+
+static void
+edit_toolbar_arrow_clicked (HildonEditToolbar *toolbar,
+                           ModestHeaderWindow *self)
+{
+       set_edit_mode (self, EDIT_MODE_COMMAND_NONE);
+}
+
+static void
+set_delete_edit_mode (GtkButton *button,
+                     ModestHeaderWindow *self)
+{
+       set_edit_mode (self, EDIT_MODE_COMMAND_DELETE);
+}
+
+static void
+set_moveto_edit_mode (GtkButton *button,
+                   ModestHeaderWindow *self)
+{
+       set_edit_mode (self, EDIT_MODE_COMMAND_MOVE);
+}
+
+static gboolean 
+on_expose_event(GtkTreeView *header_view,
+               GdkEventExpose *event,
+               gpointer user_data)
+{
+       ModestHeaderWindow *self = (ModestHeaderWindow *) user_data;
+       ModestHeaderWindowPrivate *priv = MODEST_HEADER_WINDOW_GET_PRIVATE (self);
+
+       g_return_val_if_fail (MODEST_IS_HEADER_WINDOW (self), FALSE);
+
+       if (priv->autoscroll)
+               hildon_pannable_area_jump_to (HILDON_PANNABLE_AREA (priv->contents_view), 0.0, 0.0);
+
+       return FALSE;
+}
+
+static gboolean
+set_toolbar_transfer_mode (ModestHeaderWindow *self)
+{
+       ModestHeaderWindowPrivate *priv = NULL;
+       
+       g_return_val_if_fail (MODEST_IS_HEADER_WINDOW (self), FALSE);
+
+       priv = MODEST_HEADER_WINDOW_GET_PRIVATE(self);
+
+       set_progress_hint (self, TRUE);
+       
+       return FALSE;
+}
+
+static void 
+set_progress_hint (ModestHeaderWindow *self, 
+                  gboolean enabled)
+{
+       ModestWindowPrivate *parent_priv;
+       ModestHeaderWindowPrivate *priv;
+
+       g_return_if_fail (MODEST_IS_HEADER_WINDOW (self));
+
+       parent_priv = MODEST_WINDOW_GET_PRIVATE(self);
+       priv = MODEST_HEADER_WINDOW_GET_PRIVATE(self);
+                       
+       /* Sets current progress hint */
+       priv->progress_hint = enabled;
+
+       if (GTK_WIDGET_VISIBLE (self)) {
+               hildon_gtk_window_set_progress_indicator (GTK_WINDOW (self), enabled?1:0);
+       }
+
+}
+
+gboolean 
+modest_header_window_toolbar_on_transfer_mode     (ModestHeaderWindow *self)
+{
+       ModestHeaderWindowPrivate *priv= NULL; 
+
+       g_return_val_if_fail (MODEST_IS_HEADER_WINDOW (self), FALSE);
+       priv = MODEST_HEADER_WINDOW_GET_PRIVATE (self);
+
+       return priv->progress_hint;
+}
+
+static void
+modest_header_window_show_toolbar (ModestWindow *self,
+                                  gboolean show_toolbar)
+{
+       ModestHeaderWindowPrivate *priv = NULL;
+       ModestWindowPrivate *parent_priv;
+
+       parent_priv = MODEST_WINDOW_GET_PRIVATE(self);
+       priv = MODEST_HEADER_WINDOW_GET_PRIVATE(self);
+
+       if (modest_header_window_transfer_mode_enabled (MODEST_HEADER_WINDOW (self))) 
+               set_progress_hint (MODEST_HEADER_WINDOW (self), TRUE);
+       else
+               set_progress_hint (MODEST_HEADER_WINDOW (self), FALSE);
+}
+
+gboolean 
+modest_header_window_transfer_mode_enabled (ModestHeaderWindow *self)
+{
+       ModestHeaderWindowPrivate *priv;
+       
+       g_return_val_if_fail (MODEST_IS_HEADER_WINDOW (self), FALSE);   
+       priv = MODEST_HEADER_WINDOW_GET_PRIVATE(self);
+
+       return priv->progress_hint;
+}
+
+static void 
+on_mail_operation_started (ModestMailOperation *mail_op,
+                          gpointer user_data)
+{
+       ModestHeaderWindow *self;
+       ModestMailOperationTypeOperation op_type;
+       GObject *source = NULL;
+
+       self = MODEST_HEADER_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) {
+               set_toolbar_transfer_mode(self);
+       }
+       g_object_unref (source);
+}
+
+static void 
+on_mail_operation_finished (ModestMailOperation *mail_op,
+                           gpointer user_data)
+{
+       ModestHeaderWindow *self;
+       ModestMailOperationTypeOperation op_type;
+       
+       self = MODEST_HEADER_WINDOW (user_data);
+       op_type = modest_mail_operation_get_type_operation (mail_op);
+       
+       /* If no more operations are being observed, NORMAL mode is enabled again */
+       if (modest_mail_operation_queue_num_elements (modest_runtime_get_mail_operation_queue ()) == 0) {
+               set_progress_hint (self, FALSE);
+       }
+       
+       modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (self));
+}
+
+static void
+on_queue_changed (ModestMailOperationQueue *queue,
+                 ModestMailOperation *mail_op,
+                 ModestMailOperationQueueNotification type,
+                 ModestHeaderWindow *self)
+{
+       ModestHeaderWindowPrivate *priv;
+
+       priv = MODEST_HEADER_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");
+       }
+}
index 2a26b5d..1df990b 100644 (file)
@@ -83,6 +83,10 @@ ModestWindow* modest_header_window_new (TnyFolder *folder);
  */
 ModestHeaderView *modest_header_window_get_header_view (ModestHeaderWindow *self);
 
+gboolean  modest_header_window_toolbar_on_transfer_mode     (ModestHeaderWindow *self);
+gboolean  modest_header_window_transfer_mode_enabled (ModestHeaderWindow *self);
+
+
 G_END_DECLS
 
 #endif
index 93d52b6..74dfc49 100644 (file)
 #include <hildon/hildon-find-toolbar.h>
 #include <hildon/hildon-sort-dialog.h>
 #include <hildon/hildon-number-editor.h>
+#include <modest-number-editor.h>
 #include <hildon/hildon-program.h>
 #include <hildon/hildon-entry.h>
 #include <hildon/hildon-picker-button.h>
 #include <hildon/hildon-check-button.h>
 #include <hildon/hildon-pannable-area.h>
 #include <hildon/hildon-stackable-window.h>
+#include <hildon/hildon-text-view.h>
 
 
 /* backward compatibility... */
index 29873cc..99ecd07 100644 (file)
@@ -68,11 +68,11 @@ static ModestConnectedVia current_connection (void);
 
 static GtkWidget* create_updating_page   (ModestHildon2GlobalSettingsDialog *self);
 
-static gboolean   on_range_error         (HildonNumberEditor *editor, 
-                                         HildonNumberEditorErrorType type,
+static gboolean   on_range_error         (ModestNumberEditor *editor, 
+                                         ModestNumberEditorErrorType type,
                                          gpointer user_data);
 
-static void       on_size_notify         (HildonNumberEditor *editor, 
+static void       on_size_notify         (ModestNumberEditor *editor, 
                                          GParamSpec *arg1,
                                          gpointer user_data);
 
@@ -278,8 +278,8 @@ create_updating_page (ModestHildon2GlobalSettingsDialog *self)
        value_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
 
        /* Size limit */
-       ppriv->size_limit = hildon_number_editor_new (MSG_SIZE_MIN_VAL, MSG_SIZE_MAX_VAL);
-       hildon_number_editor_set_value (HILDON_NUMBER_EDITOR (ppriv->size_limit), MSG_SIZE_DEF_VAL);
+       ppriv->size_limit = modest_number_editor_new (MSG_SIZE_MIN_VAL, MSG_SIZE_MAX_VAL);
+       modest_number_editor_set_value (MODEST_NUMBER_EDITOR (ppriv->size_limit), MSG_SIZE_DEF_VAL);
        g_signal_connect (ppriv->size_limit, "range_error", G_CALLBACK (on_range_error), self);
        g_signal_connect (ppriv->size_limit, "notify", G_CALLBACK (on_size_notify), self);
        label = gtk_label_new (_("mcen_fi_advsetup_sizelimit"));
@@ -341,23 +341,23 @@ on_auto_update_clicked (GtkButton *button,
        update_sensitive ((ModestGlobalSettingsDialog *) user_data);
 }
 static gboolean
-on_range_error (HildonNumberEditor *editor, 
-               HildonNumberEditorErrorType type,
+on_range_error (ModestNumberEditor *editor, 
+               ModestNumberEditorErrorType type,
                gpointer user_data)
 {
        gchar *msg;
        gint new_val;
 
        switch (type) {
-       case HILDON_NUMBER_EDITOR_ERROR_MAXIMUM_VALUE_EXCEED:
+       case MODEST_NUMBER_EDITOR_ERROR_MAXIMUM_VALUE_EXCEED:
                msg = g_strdup_printf (dgettext("hildon-libs", "ckct_ib_maximum_value"), MSG_SIZE_MAX_VAL);
                new_val = MSG_SIZE_MAX_VAL;
                break;
-       case HILDON_NUMBER_EDITOR_ERROR_MINIMUM_VALUE_EXCEED:
+       case MODEST_NUMBER_EDITOR_ERROR_MINIMUM_VALUE_EXCEED:
                msg = g_strdup_printf (dgettext("hildon-libs", "ckct_ib_minimum_value"), MSG_SIZE_MIN_VAL);
                new_val = MSG_SIZE_MIN_VAL;
                break;
-       case HILDON_NUMBER_EDITOR_ERROR_ERRONEOUS_VALUE:
+       case MODEST_NUMBER_EDITOR_ERROR_ERRONEOUS_VALUE:
                msg = g_strdup_printf (dgettext("hildon-libs", "ckct_ib_set_a_value_within_range"), 
                                       MSG_SIZE_MIN_VAL, 
                                       MSG_SIZE_MAX_VAL);
@@ -369,7 +369,7 @@ on_range_error (HildonNumberEditor *editor,
        }
 
        /* Restore value */
-       hildon_number_editor_set_value (editor, new_val);
+       modest_number_editor_set_value (editor, new_val);
 
        /* Show error */
        hildon_banner_show_information (GTK_WIDGET (user_data), NULL, msg);
@@ -381,12 +381,12 @@ on_range_error (HildonNumberEditor *editor,
 }
 
 static void
-on_size_notify         (HildonNumberEditor *editor, 
+on_size_notify         (ModestNumberEditor *editor, 
                        GParamSpec *arg1,
                        gpointer user_data)
 {
        ModestHildon2GlobalSettingsDialog *dialog = MODEST_HILDON2_GLOBAL_SETTINGS_DIALOG (user_data);
-       gint value = hildon_number_editor_get_value (editor);
+       gint value = modest_number_editor_get_value (editor);
 
        gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, value > 0);
 }
@@ -523,7 +523,7 @@ modest_hildon2_global_settings_dialog_load_settings (ModestGlobalSettingsDialog
        }
        /* It's better to do this in the subclasses, but it's just one
           line, so we'll leave it here for the moment */
-       hildon_number_editor_set_value (HILDON_NUMBER_EDITOR (ppriv->size_limit), value);
+       modest_number_editor_set_value (MODEST_NUMBER_EDITOR (ppriv->size_limit), value);
        ppriv->initial_state.size_limit = value;
 
        /* Play sound */
index e17a2e6..b628c05 100644 (file)
@@ -28,6 +28,7 @@
  */
 
 #include <string.h>
+#include <hildon/hildon.h>
 #include "modest-hildon2-window-mgr.h"
 #include "modest-msg-edit-window.h"
 #include "modest-main-window.h"
@@ -39,7 +40,8 @@
 #include "modest-ui-actions.h"
 #include "modest-debug.h"
 #include "modest-tny-folder.h"
-#include <hildon/hildon.h>
+#include "modest-folder-window.h"
+#include "modest-accounts-window.h"
 
 /* 'private'/'protected' functions */
 static void modest_hildon2_window_mgr_class_init (ModestHildon2WindowMgrClass *klass);
@@ -74,19 +76,20 @@ static GList *modest_hildon2_window_mgr_get_window_list (ModestWindowMgr *self);
 static gboolean modest_hildon2_window_mgr_close_all_windows (ModestWindowMgr *self);
 static gboolean window_can_close (ModestWindow *window);
 static gboolean window_has_modals (ModestWindow *window);
+static ModestWindow *modest_hildon2_window_mgr_show_initial_window (ModestWindowMgr *self);
 
 typedef struct _ModestHildon2WindowMgrPrivate ModestHildon2WindowMgrPrivate;
 struct _ModestHildon2WindowMgrPrivate {
        GList        *window_list;
        GMutex       *queue_lock;
        GQueue       *modal_windows;
-       
+
        gboolean     fullscreen_mode;
-       
+
        GHashTable   *destroy_handlers;
        GHashTable   *viewer_handlers;
        GSList       *window_state_uids;
-       
+
        guint        closing_time;
 
        GSList       *modal_handler_uids;
@@ -144,6 +147,7 @@ modest_hildon2_window_mgr_class_init (ModestHildon2WindowMgrClass *klass)
        mgr_class->find_registered_header = modest_hildon2_window_mgr_find_registered_header;
        mgr_class->get_window_list = modest_hildon2_window_mgr_get_window_list;
        mgr_class->close_all_windows = modest_hildon2_window_mgr_close_all_windows;
+       mgr_class->show_initial_window = modest_hildon2_window_mgr_show_initial_window;
 
        g_type_class_add_private (gobject_class, sizeof(ModestHildon2WindowMgrPrivate));
 
@@ -162,10 +166,10 @@ modest_hildon2_window_mgr_instance_init (ModestHildon2WindowMgr *obj)
 
        priv->modal_windows = g_queue_new ();
        priv->queue_lock = g_mutex_new ();
-       
+
        /* Could not initialize it from gconf, singletons are not
           ready yet */
-       priv->destroy_handlers = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free);   
+       priv->destroy_handlers = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free);
        priv->viewer_handlers = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, g_free);
 
        priv->closing_time = 0;
@@ -214,11 +218,10 @@ modest_hildon2_window_mgr_finalize (GObject *obj)
                g_mutex_unlock (priv->queue_lock);
        }
        g_mutex_free (priv->queue_lock);
-       
+
        /* Do not unref priv->main_window because it does not hold a
           new reference */
 
-       
        G_OBJECT_CLASS(parent_class)->finalize (obj);
 }
 
@@ -231,17 +234,19 @@ modest_hildon2_window_mgr_new (void)
 static gboolean
 modest_hildon2_window_mgr_close_all_windows (ModestWindowMgr *self)
 {
+       ModestHildon2WindowMgrPrivate *priv = NULL;
        gboolean ret_value = FALSE;
        GtkWidget *window;
-       gboolean failed = FALSE;
        HildonWindowStack *stack;
+       gboolean failed = FALSE;
 
        g_return_val_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self), FALSE);
+       priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
 
        stack = hildon_window_stack_get_default ();
 
        while ((window = hildon_window_stack_peek (stack)) != NULL) {
-               g_signal_emit_by_name (window, "delete-event", NULL, &ret_value);
+               g_signal_emit_by_name (G_OBJECT (window), "delete-event", NULL, &ret_value);
                if (ret_value == TRUE) {
                        failed = TRUE;
                        break;
@@ -330,7 +335,6 @@ modest_hildon2_window_mgr_register_window (ModestWindowMgr *self,
        GList *win;
        ModestHildon2WindowMgrPrivate *priv;
        gint *handler_id;
-       ModestWindow *main_window;
        HildonProgram *program;
        GtkWidget *current_top;
        HildonWindowStack *stack;
@@ -392,17 +396,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);
 
@@ -411,7 +404,6 @@ fail:
        /* Add to list. Keep a reference to the window */
        priv->window_list = g_list_remove (priv->window_list, window);
        g_object_unref (window);
-
        current_top = hildon_window_stack_peek (stack);
        if (current_top)
                gtk_window_present (GTK_WINDOW (current_top));
@@ -424,7 +416,7 @@ cancel_window_operations (ModestWindow *window)
        GSList* pending_ops = NULL;
 
        /* cancel open and receive operations */
-       pending_ops = modest_mail_operation_queue_get_by_source (modest_runtime_get_mail_operation_queue (),
+       pending_ops = modest_mail_operation_queue_get_by_source (modest_runtime_get_mail_operation_queue (), 
                                                                 G_OBJECT (window));
        while (pending_ops != NULL) {
                ModestMailOperationTypeOperation type;
@@ -452,7 +444,8 @@ 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 (window)) {
+                   gtk_window_get_transient_for (GTK_WINDOW (node->data)) == GTK_WINDOW (window) &&
+                   GTK_WIDGET_VISIBLE (node->data)) {
                        retvalue = TRUE;
                        break;
                }
@@ -479,73 +472,36 @@ on_window_destroy (ModestWindow *window,
 {
        gboolean no_propagate = FALSE;
 
-       if (!window_can_close (window)) {
+       if (!window_can_close (window))
                return TRUE;
-       }
-       /* Specific stuff first */
-       if (MODEST_IS_MAIN_WINDOW (window)) {
-               ModestHildon2WindowMgrPrivate *priv;
-               ModestMainWindowContentsStyle style;
-               priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
-
-               /* If we're on header view, then just go to folder view and don't close */
-               style = modest_main_window_get_contents_style (MODEST_MAIN_WINDOW (window));
-               if (style == MODEST_MAIN_WINDOW_CONTENTS_STYLE_HEADERS) {
-                       modest_main_window_set_contents_style (MODEST_MAIN_WINDOW (window),
-                                                              MODEST_MAIN_WINDOW_CONTENTS_STYLE_FOLDERS);
-                       return TRUE;
-               }
-
-               /* Do not unregister it, just hide */
-               gtk_widget_hide_all (GTK_WIDGET (window));
-
-               /* Cancel pending operations */
-               cancel_window_operations (window);
 
-               /* Fake the window system, make it think that there is no window */
-               if (modest_window_mgr_num_windows (MODEST_WINDOW_MGR (self)) == 0)
-                       g_signal_emit_by_name (self, "window-list-empty");
+       if (MODEST_IS_MSG_EDIT_WINDOW (window)) {
+               gboolean sent = FALSE;
+               sent = modest_msg_edit_window_get_sent (MODEST_MSG_EDIT_WINDOW (window));
+               /* Save currently edited message to Drafts if it was not sent */
+               if (!sent && modest_msg_edit_window_is_modified (MODEST_MSG_EDIT_WINDOW (window))) {
 
-               no_propagate = TRUE;
-       }
-       else {
-               if (MODEST_IS_MSG_EDIT_WINDOW (window)) {
-                       gboolean sent = FALSE;
-                       sent = modest_msg_edit_window_get_sent (MODEST_MSG_EDIT_WINDOW (window));
-                       /* Save currently edited message to Drafts if it was not sent */
-                       if (!sent && modest_msg_edit_window_is_modified (MODEST_MSG_EDIT_WINDOW (window))) {
-
-                         if (!modest_ui_actions_on_save_to_drafts (NULL, MODEST_MSG_EDIT_WINDOW (window)))
-                                 return TRUE;
-                       }
+                       if (!modest_ui_actions_on_save_to_drafts (NULL, MODEST_MSG_EDIT_WINDOW (window)))
+                               return TRUE;
                }
-               /* Unregister window */
-               modest_window_mgr_unregister_window (MODEST_WINDOW_MGR (self), window);
-               no_propagate = FALSE;
        }
 
+       /* Unregister window */
+       modest_window_mgr_unregister_window (MODEST_WINDOW_MGR (self), window);
+       no_propagate = FALSE;
+
        return no_propagate;
 }
 
 static void
-disconnect_msg_changed (gpointer key, 
-                       gpointer value, 
-                       gpointer user_data)
-{
-       guint handler_id;
-       handler_id = GPOINTER_TO_UINT(value);
-       
-       if (key && G_IS_OBJECT(key))
-               g_signal_handler_disconnect (G_OBJECT (key), handler_id);
-}
-
-static void 
 modest_hildon2_window_mgr_unregister_window (ModestWindowMgr *self, 
                                             ModestWindow *window)
 {
        GList *win;
        ModestHildon2WindowMgrPrivate *priv;
        gulong *tmp, handler_id;
+       gboolean check_close_all = FALSE;
+       guint num_windows;
 
        g_return_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self));
        g_return_if_fail (MODEST_IS_WINDOW (window));
@@ -558,19 +514,9 @@ modest_hildon2_window_mgr_unregister_window (ModestWindowMgr *self,
                return;
        }
 
-       /* If it's the main window unset it */
-       if (MODEST_IS_MAIN_WINDOW (window)) {
-               modest_window_mgr_set_main_window (self, NULL);
-
-               /* Disconnect all emissions of msg-changed */
-               if (priv->viewer_handlers) {
-                       g_hash_table_foreach (priv->viewer_handlers, 
-                                             disconnect_msg_changed, 
-                                             NULL);
-                       g_hash_table_destroy (priv->viewer_handlers);
-                       priv->viewer_handlers = NULL;
-               }
-       }
+       /* Remember this for the end of the method */
+       if (MODEST_IS_FOLDER_WINDOW (window))
+               check_close_all = TRUE;
 
        /* Remove the viewer window handler from the hash table. The
           HashTable could not exist if the main window was closed
@@ -605,35 +551,40 @@ modest_hildon2_window_mgr_unregister_window (ModestWindowMgr *self,
 
        /* Disconnect the "window-state-event" handler, we won't need it anymore */
        if (priv->window_state_uids) {
-#ifndef MODEST_TOOLKIT_GTK
                priv->window_state_uids = 
                        modest_signal_mgr_disconnect (priv->window_state_uids, 
                                                      G_OBJECT (window), 
                                                      "notify::is-topmost");
-#else
-               priv->window_state_uids = 
-                       modest_signal_mgr_disconnect (priv->window_state_uids, 
-                                                     G_OBJECT (window), 
-                                                     "window-state-event");
-#endif
        }
-       
+
        /* Disconnect the "delete-event" handler, we won't need it anymore */
        g_signal_handler_disconnect (window, handler_id);
 
        /* Destroy the window */
        g_object_unref (win->data);
        g_list_free (win);
-       
+
        MODEST_WINDOW_MGR_CLASS (parent_class)->unregister_window (self, window);
 
+       /* We have to get the number of windows here in order not to
+          emit the signal too many times */
+       num_windows = modest_window_mgr_get_num_windows (self);
+
+       /* Check if we have to destroy the accounts window as
+          well. This happens if we only have one or none remote
+          accounts */
+       if (check_close_all) {
+               ModestTnyAccountStore *acc_store = modest_runtime_get_account_store ();
+               if (modest_tny_account_store_get_num_remote_accounts (acc_store) < 2)
+                       modest_window_mgr_close_all_windows (self);
+       }
+
        /* If there are no more windows registered emit the signal */
-       if (modest_window_mgr_num_windows (self) == 0)
+       if (num_windows == 0)
                g_signal_emit_by_name (self, "window-list-empty");
 }
 
 
-
 static void
 modest_hildon2_window_mgr_set_fullscreen_mode (ModestWindowMgr *self,
                                               gboolean on)
@@ -665,10 +616,12 @@ modest_hildon2_window_mgr_get_main_window (ModestWindowMgr *self, gboolean show)
 {
        ModestHildon2WindowMgrPrivate *priv;
        ModestWindow *result;
-       
+
        g_return_val_if_fail (MODEST_IS_HILDON2_WINDOW_MGR (self), NULL);
        priv = MODEST_HILDON2_WINDOW_MGR_GET_PRIVATE (self);
-       
+
+       /* TODO: make this return NULL always */
+
        result = MODEST_WINDOW_MGR_CLASS (parent_class)->get_main_window (self, FALSE);
        /* create the main window, if it hasn't been created yet */
        if (!result && show) {
@@ -733,3 +686,37 @@ modest_hildon2_window_mgr_set_modal (ModestWindowMgr *self,
        gtk_window_set_destroy_with_parent (window, TRUE);
 }
 
+static ModestWindow *
+modest_hildon2_window_mgr_show_initial_window (ModestWindowMgr *self)
+{
+       ModestWindow *initial_window = NULL;
+       ModestTnyAccountStore *acc_store;
+
+       /* Always create accounts window. We'll decide later if we
+          want to show it or not, depending the number of accounts */
+       initial_window = MODEST_WINDOW (modest_accounts_window_new ());
+       modest_window_mgr_register_window (self, initial_window, NULL);
+
+       /* If there are less than 2 remote accounts then directly show
+          the folder window and do not show the accounts window */
+       acc_store = modest_runtime_get_account_store ();
+       if (modest_tny_account_store_get_num_remote_accounts (acc_store) < 2) {
+               ModestAccountMgr *mgr;
+
+               /* Show first the accounts window to add it to the
+                  stack. This has to be changed when the new
+                  stackable API is available. There will be a method
+                  to show all the windows that will only show the
+                  last one to the user. The current code shows both
+                  windows, one after the other */
+               gtk_widget_show (GTK_WIDGET (initial_window));
+
+               initial_window = MODEST_WINDOW (modest_folder_window_new (NULL));
+               mgr = modest_runtime_get_account_mgr ();
+               modest_folder_window_set_account (MODEST_FOLDER_WINDOW (initial_window),
+                                                 modest_account_mgr_get_default_account (mgr));
+               modest_window_mgr_register_window (self, initial_window, NULL);
+       }
+
+       return initial_window;
+}
index 706079f..b7d1cfd 100644 (file)
@@ -61,8 +61,21 @@ struct _ModestHildon2WindowMgrClass {
 GType        modest_hildon2_window_mgr_get_type    (void) G_GNUC_CONST;
 
 /* typical parameter-less _new function */
-ModestWindowMgr*    modest_hildon2_window_mgr_new         (void);
-       
+ModestWindowMgr*    modest_hildon2_window_mgr_new  (void);
+
+/**
+ * modest_hildon2_window_mgr_set_account_store:
+ * @self: a #ModestHildon2WindowMgr
+ * @acc_store: a #TnyAccountStore
+ *
+ * The window manager will use this function to connect itself to the
+ * account-created and account-removed signals of the
+ * #TnyAccountStore, because it ill create/destroy the accounts window
+ * depending on the existence of 0, 1 or more accounts.
+ **/
+void modest_hildon2_window_mgr_set_account_store   (ModestHildon2WindowMgr *self,
+                                                   TnyAccountStore *acc_store);
+
 G_END_DECLS
 
 #endif /* __MODEST_HILDON2_WINDOW_MGR_H__ */
index afb5a1d..e0b33af 100644 (file)
@@ -36,7 +36,7 @@
 
 /* icons */
 
-#define MODEST_APP_ICON                                "general_mail"
+#define MODEST_APP_ICON                                "general_email"
 #define MODEST_APP_MSG_VIEW_ICON               "email_message_viewer"
 #define MODEST_APP_MSG_EDIT_ICON               "email_message_editor"
 
index 41e55d9..7ef6dfb 100644 (file)
@@ -38,7 +38,7 @@
 #include "modest-serversecurity-picker.h"
 #include "modest-secureauth-picker.h"
 #include "modest-maemo-utils.h"
-#include <hildon/hildon-number-editor.h>
+#include <modest-number-editor.h>
 #include <hildon/hildon-check-button.h>
 #include "modest-hildon-includes.h"
 
@@ -89,7 +89,7 @@ on_security_changed (GtkWidget *widget,
                        modest_serversecurity_picker_get_active_serversecurity_port (MODEST_SERVERSECURITY_PICKER (ppriv->security_view));
                
                if(port_number) {
-                       hildon_number_editor_set_value (HILDON_NUMBER_EDITOR (ppriv->port_view), 
+                       modest_number_editor_set_value (MODEST_NUMBER_EDITOR (ppriv->port_view), 
                                                        port_number);
                }
        }
@@ -147,7 +147,7 @@ create_incoming_security (ModestSecurityOptionsView* self,
                                               ppriv->security_view);
 
        if (ppriv->full) {              
-               ppriv->port_view = GTK_WIDGET (hildon_number_editor_new (PORT_MIN, PORT_MAX));
+               ppriv->port_view = GTK_WIDGET (modest_number_editor_new (PORT_MIN, PORT_MAX));
                entry_caption = modest_maemo_utils_create_captioned (title_size_group,
                                                                     value_size_group,
                                                                     _("mcen_fi_emailsetup_port"), 
@@ -215,7 +215,7 @@ on_entry_changed (GtkEditable *editable,
                                                                      auth_proto);
 
        if (is_secure && 
-           !g_ascii_strcasecmp (gtk_entry_get_text (GTK_ENTRY (ppriv->user_entry)), "")) {
+           !g_ascii_strcasecmp (hildon_entry_get_text (HILDON_ENTRY (ppriv->user_entry)), "")) {
                missing = TRUE;
        } else {
                missing = FALSE;
@@ -281,7 +281,7 @@ create_outgoing_security (ModestSecurityOptionsView* self,
                                                      on_entry_max, self);
                
                /* Password widgets */
-               ppriv->pwd_entry = gtk_entry_new ();
+               ppriv->pwd_entry = hildon_entry_new (MODEST_EDITABLE_SIZE);
 
                /* Auto-capitalization is the default, so let's turn it off */
                hildon_gtk_entry_set_input_mode (GTK_ENTRY (ppriv->pwd_entry),
@@ -294,7 +294,7 @@ create_outgoing_security (ModestSecurityOptionsView* self,
                                                                   _("mail_fi_password"), 
                                                                   ppriv->pwd_entry);
 
-               ppriv->port_view = GTK_WIDGET (hildon_number_editor_new (PORT_MIN, PORT_MAX));
+               ppriv->port_view = GTK_WIDGET (modest_number_editor_new (PORT_MIN, PORT_MAX));
                port_caption = modest_maemo_utils_create_captioned (title_size_group,
                                                                    value_size_group,
                                                                    _("mcen_fi_emailsetup_port"), 
@@ -391,7 +391,7 @@ modest_maemo_security_options_view_load_settings (ModestSecurityOptionsView* sel
        } else if (ppriv->full) {
                /* Keep the user-entered port-number, or the
                 * already-appropriate automatic port number */
-               hildon_number_editor_set_value (HILDON_NUMBER_EDITOR (ppriv->port_view), 
+               modest_number_editor_set_value (MODEST_NUMBER_EDITOR (ppriv->port_view), 
                                                port_number);
        }
        /* Frees */
@@ -414,7 +414,7 @@ modest_maemo_security_options_view_save_settings (ModestSecurityOptionsView* sel
                server_settings = modest_account_settings_get_transport_settings (settings);
 
        if (ppriv->full) {
-               server_port = hildon_number_editor_get_value (HILDON_NUMBER_EDITOR (ppriv->port_view));
+               server_port = modest_number_editor_get_value (MODEST_NUMBER_EDITOR (ppriv->port_view));
        } else {
                server_port = modest_serversecurity_picker_get_active_serversecurity_port (MODEST_SERVERSECURITY_PICKER (ppriv->security_view));
        }
@@ -445,7 +445,7 @@ modest_maemo_security_options_view_changed (ModestSecurityOptionsView* self,
                server_settings = modest_account_settings_get_transport_settings (settings);
        
        server_port = 
-               hildon_number_editor_get_value (HILDON_NUMBER_EDITOR (ppriv->port_view));
+               modest_number_editor_get_value (MODEST_NUMBER_EDITOR (ppriv->port_view));
 
        /* Frees */
        g_object_unref (server_settings);
index 7ef913c..efd2150 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2006, y2008 Nokia Corporation
+/* Copyright (c) 2006, 2008 Nokia Corporation
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -65,7 +65,7 @@
 #include "modest-text-utils.h"
 #include "modest-signal-mgr.h"
 #include <tny-gtk-folder-store-tree-model.h>
-#include <modest-folder-window.h>
+#include <modest-accounts-window.h>
 
 #define MODEST_MAIN_WINDOW_ACTION_GROUP_ADDITIONS "ModestMainWindowActionAdditions"
 
@@ -900,13 +900,6 @@ connect_signals (ModestMainWindow *self)
                                           G_CALLBACK (on_folder_view_focus_in), 
                                           self);
 
-       /* Folder view CSM */
-       menu = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/FolderViewCSM");
-       gtk_widget_tap_and_hold_setup (GTK_WIDGET (priv->folder_view), menu, NULL, 0);
-       priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers, G_OBJECT(priv->folder_view), "tap-and-hold",
-                                                      G_CALLBACK(_folder_view_csm_menu_activated),
-                                                      self);
-
        /* folder view row activated */
        priv->sighandlers = modest_signal_mgr_connect (priv->sighandlers, G_OBJECT(priv->folder_view), "row-activated",
                                                       G_CALLBACK(on_folder_view_row_activated),
@@ -1040,7 +1033,7 @@ modest_main_window_on_show (GtkWidget *self, gpointer user_data)
 {
        ShowHelper *helper = (ShowHelper *) user_data;
        ModestMainWindowPrivate *priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
-       
+
        priv->folder_view = MODEST_FOLDER_VIEW (modest_platform_create_folder_view (NULL));
        modest_main_window_set_contents_style (MODEST_MAIN_WINDOW (self), 
                                               MODEST_MAIN_WINDOW_CONTENTS_STYLE_FOLDERS);
@@ -1055,21 +1048,21 @@ modest_main_window_on_show (GtkWidget *self, gpointer user_data)
        tny_account_store_view_set_account_store (TNY_ACCOUNT_STORE_VIEW (priv->folder_view),
                                                  TNY_ACCOUNT_STORE (modest_runtime_get_account_store ()));
 
-       /* Load previous osso state, for instance if we are being restored from 
+       /* Load previous osso state, for instance if we are being restored from
         * hibernation:  */
        modest_osso_load_state ();
 
-       /* Restore window & widget settings */  
+       /* Restore window & widget settings */
        priv->wait_for_settings = TRUE;
        restore_settings (MODEST_MAIN_WINDOW(self), TRUE);
        priv->wait_for_settings = FALSE;
 
        /* Check if accounts exist and show the account wizard if not */
-       gboolean accounts_exist = 
+       gboolean accounts_exist =
                modest_account_mgr_has_accounts(modest_runtime_get_account_mgr(), TRUE);
 
        if (!accounts_exist) {
-               /* This is necessary to have the main window shown behind the dialog 
+               /* This is necessary to have the main window shown behind the dialog
                It's an ugly hack... jschmid */
                gtk_widget_show_all(GTK_WIDGET(self));
                modest_ui_actions_on_accounts (NULL, MODEST_WINDOW(self));
@@ -2099,13 +2092,20 @@ set_account_visible(ModestMainWindow *self, const gchar *acc_name)
        ModestAccountSettings *settings;
        ModestServerAccountSettings *store_settings = NULL;
 
-       GtkWidget *folder_window;
+/*     GtkWidget *folder_window; */
+
+/*     folder_window = GTK_WIDGET (modest_folder_window_new (NULL)); */
+/*     modest_window_mgr_register_window (modest_runtime_get_window_mgr (),  */
+/*                                        MODEST_WINDOW (folder_window), */
+/*                                        MODEST_WINDOW (self)); */
+/*     gtk_widget_show (folder_window); */
+       GtkWidget *accounts_window;
 
-       folder_window = GTK_WIDGET (modest_folder_window_new (NULL));
-       modest_window_mgr_register_window (modest_runtime_get_window_mgr (), 
-                                          MODEST_WINDOW (folder_window),
+       accounts_window = GTK_WIDGET (modest_accounts_window_new ());
+       modest_window_mgr_register_window (modest_runtime_get_window_mgr (),
+                                          MODEST_WINDOW (accounts_window),
                                           MODEST_WINDOW (self));
-       gtk_widget_show (folder_window);
+       gtk_widget_show (accounts_window);
 
        /* Get account data */
        mgr = modest_runtime_get_account_mgr ();
@@ -2125,7 +2125,7 @@ set_account_visible(ModestMainWindow *self, const gchar *acc_name)
                modest_folder_view_select_first_inbox_or_local (priv->folder_view);
                modest_window_set_active_account (MODEST_WINDOW (self), account_name);
 
-               modest_folder_window_set_account (MODEST_FOLDER_WINDOW (folder_window), acc_name);
+/*             modest_folder_window_set_account (MODEST_FOLDER_WINDOW (folder_window), acc_name); */
 
                action = gtk_action_group_get_action (priv->view_additions_group, account_name);
                if (action != NULL) {
@@ -2453,7 +2453,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 44365d0..862c787 100644 (file)
@@ -63,7 +63,7 @@
 #include <tny-simple-list.h>
 #include <wptextview.h>
 #include <wptextbuffer.h>
-#include "modest-scroll-area.h"
+#include <hildon/hildon-pannable-area.h>
 #include "modest-msg-edit-window-ui-dimming.h"
 
 #include "modest-hildon-includes.h"
@@ -171,8 +171,6 @@ static void text_buffer_mark_set (GtkTextBuffer *buffer,
                                  GtkTextIter *iter,
                                  GtkTextMark *mark,
                                  ModestMsgEditWindow *userdata);
-static void vadj_changed (GtkAdjustment *adj, 
-                         ModestMsgEditWindow *window);
 
 static void DEBUG_BUFFER (WPTextBuffer *buffer)
 {
@@ -254,6 +252,7 @@ struct _ModestMsgEditWindowPrivate {
        GtkWidget   *font_size_toolitem;
        GtkWidget   *font_face_toolitem;
        GtkWidget   *font_color_button;
+       GtkWidget   *font_color_toolitem;
        GSList      *font_items_group;
        GtkWidget   *font_tool_button_label;
        GSList      *size_items_group;
@@ -264,7 +263,7 @@ struct _ModestMsgEditWindowPrivate {
 
        GtkWidget   *font_dialog;
 
-       GtkWidget   *scroll;
+       GtkWidget   *pannable;
        guint        scroll_drag_timeout_id;
        gdouble      last_upper;
 
@@ -497,10 +496,8 @@ correct_scroll_without_drag_check (ModestMsgEditWindow *w, gboolean only_if_focu
        GtkTextMark *insert;
        GtkTextIter iter;
        GdkRectangle rectangle;
-       GtkAdjustment *vadj;
        gdouble new_value;
        gint offset;
-       GdkWindow *window;
 
        priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE(w);
 
@@ -511,37 +508,11 @@ correct_scroll_without_drag_check (ModestMsgEditWindow *w, gboolean only_if_focu
        gtk_text_buffer_get_iter_at_mark (priv->text_buffer, &iter, insert);
 
        gtk_text_view_get_iter_location (GTK_TEXT_VIEW (priv->msg_body), &iter, &rectangle);
-       vadj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (priv->scroll));
        offset = priv->msg_body->allocation.y;
 
-       new_value = vadj->value;
-       
-       if ((offset + rectangle.y + rectangle.height) > 
-           ((gint) (vadj->value +vadj->page_size))) {
-               new_value = (offset + rectangle.y) - vadj->page_size * 0.25;
-               if (new_value > vadj->upper - vadj->page_size)
-                       new_value = vadj->upper - vadj->page_size;
-       } else if ((offset + rectangle.y) < ((gint) vadj->value)) {
-               new_value = (offset + rectangle.y - vadj->page_size * 0.75);
-               if (((gint) (new_value + vadj->page_size)) < (offset + rectangle.y + rectangle.height))
-                       new_value = offset + rectangle.y + rectangle.height - (gint) vadj->page_size;
-               if (new_value < 0.0)
-                       new_value = 0.0;
-               if (new_value > vadj->value)
-                       new_value = vadj->value;
-       }
-
-       if (vadj->value != new_value) {
-               g_signal_emit_by_name (GTK_TEXT_VIEW(priv->msg_body)->layout,
-                                      "invalidated");
-               vadj->value = new_value;
-               gtk_adjustment_value_changed (vadj);
-               /* invalidate body */
-               window = gtk_widget_get_parent_window (priv->msg_body);
-               if (window)
-                       gdk_window_invalidate_rect (window, NULL, TRUE);
-       }
+       new_value = (offset + rectangle.y);
 
+       hildon_pannable_area_jump_to (HILDON_PANNABLE_AREA (priv->pannable), -1, new_value);
 }
 
 static void
@@ -603,20 +574,6 @@ copy_clipboard_check (GtkTextView *text_view,
        }
 }
 
-static void 
-vadj_changed (GtkAdjustment *adj,
-             ModestMsgEditWindow *window)
-{
-       ModestMsgEditWindowPrivate *priv;
-
-       priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (window);
-
-       if (priv->last_upper != adj->upper) {
-               priv->last_upper = adj->upper;
-               correct_scroll (window);
-       }
-}
-
 static void
 attachment_deleted (ModestAttachmentsView *attachments_view,
                    gpointer user_data)
@@ -676,11 +633,6 @@ connect_signals (ModestMsgEditWindow *obj)
        g_signal_connect (G_OBJECT (priv->find_toolbar), "close", G_CALLBACK (modest_msg_edit_window_find_toolbar_close), obj);
        g_signal_connect (G_OBJECT (priv->find_toolbar), "search", G_CALLBACK (modest_msg_edit_window_find_toolbar_search), obj);
 
-       g_signal_connect (G_OBJECT (gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (priv->scroll))),
-                         "changed",
-                         G_CALLBACK (vadj_changed),
-                         obj);
-
        priv->clipboard_change_handler_id = 
                g_signal_connect (G_OBJECT (gtk_clipboard_get (GDK_SELECTION_PRIMARY)), "owner-change",
                                  G_CALLBACK (modest_msg_edit_window_clipboard_owner_change), obj);
@@ -694,6 +646,17 @@ connect_signals (ModestMsgEditWindow *obj)
 }
 
 static void
+init_wp_text_view_style ()
+{
+       static gboolean initialized = FALSE;
+
+       if (!initialized) {
+               gtk_rc_parse_string ("class \"WPTextView\" style \"fremantle-textview\"");
+               initialized = TRUE;
+       }
+}      
+
+static void
 init_window (ModestMsgEditWindow *obj)
 {
        GtkWidget *to_caption, *subject_caption;
@@ -793,7 +756,7 @@ init_window (ModestMsgEditWindow *obj)
        gtk_button_set_relief (GTK_BUTTON (priv->add_attachment_button), GTK_RELIEF_NONE);
        gtk_button_set_focus_on_click (GTK_BUTTON (priv->add_attachment_button), FALSE);
        gtk_button_set_alignment (GTK_BUTTON (priv->add_attachment_button), 1.0, 0.5);
-       attachment_icon = gtk_image_new_from_icon_name (MODEST_HEADER_ICON_ATTACH, GTK_ICON_SIZE_BUTTON);
+       attachment_icon = gtk_image_new_from_icon_name (MODEST_HEADER_ICON_ATTACH, HILDON_ICON_SIZE_FINGER);
        gtk_container_add (GTK_CONTAINER (priv->add_attachment_button), attachment_icon);
        gtk_box_pack_start (GTK_BOX (subject_box), priv->add_attachment_button, FALSE, FALSE, 0);
        priv->attachments_view = modest_attachments_view_new (NULL);
@@ -833,8 +796,11 @@ init_window (ModestMsgEditWindow *obj)
        gtk_box_pack_start (GTK_BOX (priv->header_box), priv->attachments_caption, FALSE, FALSE, 0);
        gtk_widget_set_no_show_all (priv->attachments_caption, TRUE);
 
+       init_wp_text_view_style ();
 
        priv->msg_body = wp_text_view_new ();
+       
+
        gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (priv->msg_body), GTK_WRAP_WORD_CHAR);
        priv->text_buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->msg_body));
        g_object_set (priv->text_buffer, "font_scale", DEFAULT_FONT_SCALE, NULL);
@@ -853,25 +819,21 @@ init_window (ModestMsgEditWindow *obj)
 
 /*     g_signal_connect (G_OBJECT (obj), "key_pressed", G_CALLBACK (on_key_pressed), NULL) */
 
-       priv->scroll = gtk_scrolled_window_new (NULL, NULL);
-       gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (priv->scroll), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
-       gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (priv->scroll), GTK_SHADOW_NONE);
-       modest_maemo_set_thumbable_scrollbar (GTK_SCROLLED_WINDOW(priv->scroll), TRUE);
-
+       priv->pannable = hildon_pannable_area_new ();
+       
        main_vbox = gtk_vbox_new  (FALSE, DEFAULT_MAIN_VBOX_SPACING);
 
        gtk_box_pack_start (GTK_BOX(main_vbox), priv->header_box, FALSE, FALSE, 0);
        priv->frame = gtk_frame_new (NULL);
        gtk_box_pack_start (GTK_BOX(main_vbox), priv->frame, TRUE, TRUE, 0);
 
-       gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (priv->scroll), main_vbox);
-       gtk_container_set_focus_vadjustment (GTK_CONTAINER (main_vbox), gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (priv->scroll)));
-       gtk_widget_show_all (GTK_WIDGET(priv->scroll));
+       hildon_pannable_area_add_with_viewport (HILDON_PANNABLE_AREA (priv->pannable), main_vbox);
+       gtk_widget_show_all (GTK_WIDGET(priv->pannable));
        
        window_box = gtk_vbox_new (FALSE, 0);
        gtk_container_add (GTK_CONTAINER(obj), window_box);
 
-       gtk_box_pack_start (GTK_BOX (window_box), priv->scroll, TRUE, TRUE, 0);
+       gtk_box_pack_start (GTK_BOX (window_box), priv->pannable, TRUE, TRUE, 0);
 
        gtk_container_add (GTK_CONTAINER (priv->frame), priv->msg_body);
 
@@ -1140,15 +1102,19 @@ set_msg (ModestMsgEditWindow *self, TnyMsg *msg, gboolean preserve_is_rich)
        gchar *to, *cc, *bcc, *subject;
        gchar *body;
        ModestMsgEditWindowPrivate *priv;
+       ModestWindowPrivate *parent_priv;
        GtkTextIter iter;
        TnyHeaderFlags priority_flags;
        TnyFolder *msg_folder;
        gboolean is_html = FALSE;
+       GtkAction *action;
+       gboolean field_view_set;
        
        g_return_if_fail (MODEST_IS_MSG_EDIT_WINDOW (self));
        g_return_if_fail (TNY_IS_MSG (msg));
 
        priv = MODEST_MSG_EDIT_WINDOW_GET_PRIVATE (self);
+       parent_priv = MODEST_WINDOW_GET_PRIVATE (self);
 
        header = tny_msg_get_header (msg);
        to      = tny_header_dup_to (header);
@@ -1159,6 +1125,9 @@ set_msg (ModestMsgEditWindow *self, TnyMsg *msg, gboolean preserve_is_rich)
 
        if (to)
                modest_recpt_editor_set_recipients (MODEST_RECPT_EDITOR (priv->to_field),  to);
+
+       action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/ViewMenu/ViewCcFieldMenu");
+       field_view_set = TRUE;
        if (cc) {
                modest_recpt_editor_set_recipients (MODEST_RECPT_EDITOR (priv->cc_field),  cc);
                gtk_widget_set_no_show_all (priv->cc_caption, FALSE);
@@ -1166,7 +1135,13 @@ set_msg (ModestMsgEditWindow *self, TnyMsg *msg, gboolean preserve_is_rich)
        } else if (!modest_conf_get_bool (modest_runtime_get_conf (), MODEST_CONF_SHOW_CC, NULL)) {
                gtk_widget_set_no_show_all (priv->cc_caption, TRUE);
                gtk_widget_hide (priv->cc_caption);
+               field_view_set = FALSE;
        }
+       if (action)
+               gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), field_view_set);
+
+       action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/MenuBar/ViewMenu/ViewBccFieldMenu");
+       field_view_set = TRUE;
        if (bcc) {
                modest_recpt_editor_set_recipients (MODEST_RECPT_EDITOR (priv->bcc_field), bcc);
                gtk_widget_set_no_show_all (priv->bcc_caption, FALSE);
@@ -1174,7 +1149,12 @@ set_msg (ModestMsgEditWindow *self, TnyMsg *msg, gboolean preserve_is_rich)
        } else if (!modest_conf_get_bool (modest_runtime_get_conf (), MODEST_CONF_SHOW_BCC, NULL)) {
                gtk_widget_set_no_show_all (priv->bcc_caption, TRUE);
                gtk_widget_hide (priv->bcc_caption);
-       } 
+               field_view_set = FALSE;
+       }
+       if (action)
+               gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), field_view_set);
+
+
        if (subject)
                gtk_entry_set_text (GTK_ENTRY(priv->subject_field), subject);
        modest_msg_edit_window_set_priority_flags (MODEST_MSG_EDIT_WINDOW(self),
@@ -1331,14 +1311,14 @@ modest_msg_edit_window_setup_toolbar (ModestMsgEditWindow *window)
        insert_index = gtk_toolbar_get_item_index(GTK_TOOLBAR (parent_priv->toolbar), GTK_TOOL_ITEM(placeholder));
 
        /* font color */
-       tool_item = GTK_WIDGET (gtk_tool_item_new ());
+       priv->font_color_toolitem = GTK_WIDGET (gtk_tool_item_new ());
        priv->font_color_button = hildon_color_button_new ();
        GTK_WIDGET_UNSET_FLAGS (tool_item, GTK_CAN_FOCUS);
        GTK_WIDGET_UNSET_FLAGS (priv->font_color_button, GTK_CAN_FOCUS);
-       gtk_container_add (GTK_CONTAINER (tool_item), priv->font_color_button);
-       gtk_tool_item_set_expand (GTK_TOOL_ITEM (tool_item), TRUE);
-       gtk_tool_item_set_homogeneous (GTK_TOOL_ITEM (tool_item), TRUE);
-       gtk_toolbar_insert(GTK_TOOLBAR(parent_priv->toolbar), GTK_TOOL_ITEM (tool_item), insert_index);
+       gtk_container_add (GTK_CONTAINER (priv->font_color_toolitem), priv->font_color_button);
+       gtk_tool_item_set_expand (GTK_TOOL_ITEM (priv->font_color_toolitem), TRUE);
+       gtk_tool_item_set_homogeneous (GTK_TOOL_ITEM (priv->font_color_toolitem), TRUE);
+       gtk_toolbar_insert(GTK_TOOLBAR(parent_priv->toolbar), GTK_TOOL_ITEM (priv->font_color_toolitem), insert_index);
        g_signal_connect_swapped (G_OBJECT (priv->font_color_button), 
                                  "notify::color", 
                                  G_CALLBACK (modest_msg_edit_window_color_button_change), 
@@ -1512,7 +1492,7 @@ modest_msg_edit_window_new (TnyMsg *msg, const gchar *account_name, gboolean pre
                                              modest_msg_edit_window_toolbar_dimming_entries,
                                              G_N_ELEMENTS (modest_msg_edit_window_toolbar_dimming_entries),
                                              MODEST_WINDOW (obj));
-       modest_dimming_rules_group_add_widget_rule (toolbar_rules_group, priv->font_color_button,
+       modest_dimming_rules_group_add_widget_rule (toolbar_rules_group, priv->font_color_toolitem,
                                                    G_CALLBACK (modest_ui_dimming_rules_on_set_style),
                                                    MODEST_WINDOW (obj));
        modest_dimming_rules_group_add_widget_rule (toolbar_rules_group, priv->font_size_toolitem,
index 139a71a..29ba8a3 100644 (file)
 #include <modest-tny-folder.h>
 #include <modest-text-utils.h>
 #include <modest-account-mgr-helpers.h>
-#include "modest-progress-bar.h"
 #include <hildon/hildon-pannable-area.h>
 #include <hildon/hildon-picker-dialog.h>
-#include "hildon/hildon-pannable-area.h"
+#include <hildon/hildon-app-menu.h>
 #include "modest-defs.h"
 #include "modest-hildon-includes.h"
 #include "modest-ui-dimming-manager.h"
@@ -65,6 +64,7 @@
 #include <errno.h>
 #include <glib/gstdio.h>
 #include <modest-debug.h>
+#include <modest-header-window.h>
 
 #define MYDOCS_ENV "MYDOCSDIR"
 #define DOCS_FOLDER ".documents"
@@ -134,10 +134,16 @@ static void  modest_msg_view_window_find_toolbar_search (GtkWidget *widget,
 static void modest_msg_view_window_disconnect_signals (ModestWindow *self);
 
 static gdouble modest_msg_view_window_get_zoom (ModestWindow *window);
+static void modest_msg_view_window_set_zoom (ModestWindow *window,
+                                            gdouble zoom);
+static gboolean modest_msg_view_window_zoom_minus (ModestWindow *window);
+static gboolean modest_msg_view_window_zoom_plus (ModestWindow *window);
 static gboolean modest_msg_view_window_key_event (GtkWidget *window,
                                                  GdkEventKey *event,
                                                  gpointer userdata);
-
+static gboolean modest_msg_view_window_toggle_menu (HildonWindow *window,
+                                                   guint button,
+                                                   guint32 time);
 static void modest_msg_view_window_update_priority (ModestMsgViewWindow *window);
 
 static void modest_msg_view_window_show_toolbar   (ModestWindow *window,
@@ -217,6 +223,15 @@ static gboolean message_reader (ModestMsgViewWindow *window,
                                TnyHeader *header,
                                GtkTreeRowReference *row_reference);
 
+static void add_to_menu (ModestMsgViewWindow *self,
+                        HildonAppMenu *menu,
+                        gchar *label,
+                        GCallback callback,
+                        ModestDimmingRulesGroup *group,
+                        GCallback dimming_callback);
+static void setup_menu (ModestMsgViewWindow *self,
+                       ModestDimmingRulesGroup *group);
+
 /* list my signals */
 enum {
        MSG_CHANGED_SIGNAL,
@@ -228,6 +243,7 @@ static const GtkToggleActionEntry msg_view_toggle_action_entries [] = {
        { "FindInMessage",    MODEST_TOOLBAR_ICON_FIND,    N_("qgn_toolb_gene_find"), NULL, NULL, G_CALLBACK (modest_msg_view_window_toggle_find_toolbar), FALSE },
 };
 
+
 #define MODEST_MSG_VIEW_WINDOW_GET_PRIVATE(o)      (G_TYPE_INSTANCE_GET_PRIVATE((o), \
                                                     MODEST_TYPE_MSG_VIEW_WINDOW, \
                                                     ModestMsgViewWindowPrivate))
@@ -280,21 +296,11 @@ save_state (ModestWindow *self)
                                   MODEST_CONF_MSG_VIEW_WINDOW_KEY);
 }
 
-static void
-restore_settings (ModestMsgViewWindow *self)
-{
-       ModestConf *conf;
-
-       conf = modest_runtime_get_conf ();
-       modest_widget_memory_restore (conf,
-                                     G_OBJECT(self), 
-                                     MODEST_CONF_MSG_VIEW_WINDOW_KEY);
-}
-
-static gboolean modest_msg_view_window_scroll_child (ModestMsgViewWindow *self,
-                                                    GtkScrollType scroll_type,
-                                                    gboolean horizontal,
-                                                    gpointer userdata)
+static 
+gboolean modest_msg_view_window_scroll_child (ModestMsgViewWindow *self,
+                                             GtkScrollType scroll_type,
+                                             gboolean horizontal,
+                                             gpointer userdata)
 {
        ModestMsgViewWindowPrivate *priv;
        gboolean return_value;
@@ -325,16 +331,23 @@ static void
 modest_msg_view_window_class_init (ModestMsgViewWindowClass *klass)
 {
        GObjectClass *gobject_class;
+       HildonWindowClass *hildon_window_class;
        ModestWindowClass *modest_window_class;
        GtkBindingSet *binding_set;
 
        gobject_class = (GObjectClass*) klass;
+       hildon_window_class = (HildonWindowClass *) klass;
        modest_window_class = (ModestWindowClass *) klass;
 
        parent_class            = g_type_class_peek_parent (klass);
        gobject_class->finalize = modest_msg_view_window_finalize;
 
+       hildon_window_class->toggle_menu = modest_msg_view_window_toggle_menu;
+
+       modest_window_class->set_zoom_func = modest_msg_view_window_set_zoom;
        modest_window_class->get_zoom_func = modest_msg_view_window_get_zoom;
+       modest_window_class->zoom_plus_func = modest_msg_view_window_zoom_plus;
+       modest_window_class->zoom_minus_func = modest_msg_view_window_zoom_minus;
        modest_window_class->show_toolbar_func = modest_msg_view_window_show_toolbar;
        modest_window_class->disconnect_signals_func = modest_msg_view_window_disconnect_signals;
 
@@ -536,8 +549,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);
 
@@ -581,21 +594,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
@@ -739,15 +746,14 @@ modest_msg_view_window_construct (ModestMsgViewWindow *self,
        priv->msg_uid = g_strdup (msg_uid);
 
        /* Menubar */
-       parent_priv->menubar = modest_maemo_utils_get_manager_menubar_as_menu (parent_priv->ui_manager, "/MenuBar");
-       hildon_window_set_menu    (HILDON_WINDOW(obj), GTK_MENU(parent_priv->menubar));
-       gtk_widget_show (parent_priv->menubar);
+       parent_priv->menubar = NULL;
        parent_priv->ui_dimming_manager = modest_ui_dimming_manager_new();
 
        menu_rules_group = modest_dimming_rules_group_new (MODEST_DIMMING_RULES_MENU, FALSE);
        toolbar_rules_group = modest_dimming_rules_group_new (MODEST_DIMMING_RULES_TOOLBAR, TRUE);
        clipboard_rules_group = modest_dimming_rules_group_new (MODEST_DIMMING_RULES_CLIPBOARD, FALSE);
 
+       setup_menu (self, menu_rules_group);
        /* Add common dimming rules */
        modest_dimming_rules_group_add_rules (menu_rules_group, 
                                              modest_msg_view_menu_dimming_entries,
@@ -966,6 +972,7 @@ modest_msg_view_window_new_from_header_view (ModestHeaderView *header_view,
 
        /* Setup row references and connect signals */
        priv->header_model = gtk_tree_view_get_model (GTK_TREE_VIEW (header_view));
+       g_object_ref (priv->header_model);
 
        if (row_reference) {
                priv->row_reference = gtk_tree_row_reference_copy (row_reference);
@@ -1420,7 +1427,9 @@ modest_msg_view_window_toggle_find_toolbar (GtkToggleAction *toggle,
 
        /* update the toggle buttons status */
        action = gtk_ui_manager_get_action (parent_priv->ui_manager, "/ToolBar/FindInMessage");
-       modest_utils_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action), is_active);
+       if (action)
+               modest_utils_toggle_action_set_active_block_notify (GTK_TOGGLE_ACTION (action), is_active);
+
 }
 
 static void
@@ -1433,7 +1442,7 @@ modest_msg_view_window_find_toolbar_close (GtkWidget *widget,
 
        priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (obj);
        parent_priv = MODEST_WINDOW_GET_PRIVATE (obj);
-       
+
        toggle = GTK_TOGGLE_ACTION (gtk_ui_manager_get_action (parent_priv->ui_manager, "/ToolBar/FindInMessage"));
        gtk_toggle_action_set_active (toggle, FALSE);
        modest_msg_view_grab_focus (MODEST_MSG_VIEW (priv->msg_view));
@@ -1488,6 +1497,21 @@ modest_msg_view_window_find_toolbar_search (GtkWidget *widget,
                
 }
 
+static void
+modest_msg_view_window_set_zoom (ModestWindow *window,
+                                gdouble zoom)
+{
+       ModestMsgViewWindowPrivate *priv;
+       ModestWindowPrivate *parent_priv;
+     
+       g_return_if_fail (MODEST_IS_MSG_VIEW_WINDOW (window));
+
+       priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (window);
+       parent_priv = MODEST_WINDOW_GET_PRIVATE (window);
+       modest_zoomable_set_zoom (MODEST_ZOOMABLE (priv->msg_view), zoom);
+
+}
+
 static gdouble
 modest_msg_view_window_get_zoom (ModestWindow *window)
 {
@@ -1500,6 +1524,76 @@ modest_msg_view_window_get_zoom (ModestWindow *window)
 }
 
 static gboolean
+modest_msg_view_window_zoom_plus (ModestWindow *window)
+{
+       gdouble zoom_level;
+       ModestMsgViewWindowPrivate *priv;
+     
+       g_return_val_if_fail (MODEST_IS_MSG_VIEW_WINDOW (window), 1.0);
+       priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (window);
+  
+       zoom_level =  modest_zoomable_get_zoom (MODEST_ZOOMABLE (priv->msg_view));
+
+       if (zoom_level >= 2.0) {
+               hildon_banner_show_information (NULL, NULL, dgettext("hildon-common-strings", "ckct_ib_max_zoom_level_reached"));
+               return FALSE;
+       } else if (zoom_level >= 1.5) {
+               zoom_level = 2.0;
+       } else if (zoom_level >= 1.2) {
+               zoom_level = 1.5;
+       } else if (zoom_level >= 1.0) {
+               zoom_level = 1.2;
+       } else if (zoom_level >= 0.8) {
+               zoom_level = 1.0;
+       } else if (zoom_level >= 0.5) {
+               zoom_level = 0.8;
+       } else {
+               zoom_level = 0.5;
+       }
+
+       /* set zoom level */
+       modest_zoomable_set_zoom (MODEST_ZOOMABLE (priv->msg_view), zoom_level);
+
+       return TRUE;
+       
+}
+
+static gboolean
+modest_msg_view_window_zoom_minus (ModestWindow *window)
+{
+       gdouble zoom_level;
+       ModestMsgViewWindowPrivate *priv;
+     
+       g_return_val_if_fail (MODEST_IS_MSG_VIEW_WINDOW (window), 1.0);
+       priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (window);
+  
+       zoom_level =  modest_zoomable_get_zoom (MODEST_ZOOMABLE (priv->msg_view));
+
+       if (zoom_level <= 0.5) {
+                         hildon_banner_show_information (NULL, NULL, dgettext("hildon-common-strings", "ckct_ib_min_zoom_level_reached"));
+               return FALSE;
+       } else if (zoom_level <= 0.8) {
+               zoom_level = 0.5;
+       } else if (zoom_level <= 1.0) {
+               zoom_level = 0.8;
+       } else if (zoom_level <= 1.2) {
+               zoom_level = 1.0;
+       } else if (zoom_level <= 1.5) {
+               zoom_level = 1.2;
+       } else if (zoom_level <= 2.0) {
+               zoom_level = 1.5;
+       } else {
+               zoom_level = 2.0;
+       }
+
+       /* set zoom level */
+       modest_zoomable_set_zoom (MODEST_ZOOMABLE (priv->msg_view), zoom_level);
+
+       return TRUE;
+       
+}
+
+static gboolean
 modest_msg_view_window_key_event (GtkWidget *window,
                                  GdkEventKey *event,
                                  gpointer userdata)
@@ -2082,9 +2176,7 @@ modest_msg_view_window_show_toolbar (ModestWindow *self,
        ModestMsgViewWindowPrivate *priv = NULL;
        ModestWindowPrivate *parent_priv;
        GtkWidget *reply_button = NULL, *menu = NULL;
-       const gchar *action_name;
-       GtkAction *action;
-       
+
        parent_priv = MODEST_WINDOW_GET_PRIVATE(self);
        priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE(self);
 
@@ -2099,7 +2191,7 @@ modest_msg_view_window_show_toolbar (ModestWindow *self,
                priv->next_toolitem = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/ToolBar/ToolbarMessageNext");
                priv->prev_toolitem = gtk_ui_manager_get_widget (parent_priv->ui_manager, "/ToolBar/ToolbarMessageBack");
                toolbar_resize (MODEST_MSG_VIEW_WINDOW (self));
-               
+
                /* Add to window */
                hildon_window_add_toolbar (HILDON_WINDOW (self), 
                                           GTK_TOOLBAR (parent_priv->toolbar));
@@ -2109,7 +2201,8 @@ modest_msg_view_window_show_toolbar (ModestWindow *self,
                                                          "/ToolBar/ToolbarMessageReply");
                menu = gtk_ui_manager_get_widget (parent_priv->ui_manager, 
                                                  "/ToolbarReplyCSM");
-               gtk_widget_tap_and_hold_setup (GTK_WIDGET (reply_button), menu, NULL, 0);
+               if (menu && reply_button)
+                       gtk_widget_tap_and_hold_setup (GTK_WIDGET (reply_button), menu, NULL, 0);
        }
 
        if (show_toolbar) {
@@ -3015,6 +3108,82 @@ on_fetch_image (ModestMsgView *msgview,
        return TRUE;;
 }
 
+static void 
+add_to_menu (ModestMsgViewWindow *self,
+            HildonAppMenu *menu,
+            gchar *label,
+            GCallback callback,
+            ModestDimmingRulesGroup *dimming_group,
+            GCallback dimming_callback)
+{
+       GtkWidget *button;
+
+       button = gtk_button_new_with_label (label);
+       g_signal_connect_after (G_OBJECT (button), "clicked",
+                               callback, (gpointer) self);
+       modest_dimming_rules_group_add_widget_rule (dimming_group,
+                                                   button,
+                                                   dimming_callback,
+                                                   MODEST_WINDOW (self));
+       hildon_app_menu_append (menu, GTK_BUTTON (button));
+}
+
+static void 
+setup_menu (ModestMsgViewWindow *self, ModestDimmingRulesGroup *group)
+{
+       ModestMsgViewWindowPrivate *priv = NULL;
+       GtkWidget *app_menu;
+
+       g_return_if_fail (MODEST_IS_MSG_VIEW_WINDOW(self));
+
+       priv = MODEST_MSG_VIEW_WINDOW_GET_PRIVATE (self);
+
+       app_menu = hildon_app_menu_new ();
+
+       /* Settings menu buttons */
+       add_to_menu (self, HILDON_APP_MENU (app_menu), _("mcen_me_inbox_replytoall"),
+                    G_CALLBACK (modest_ui_actions_on_reply_all),
+                    group, G_CALLBACK (modest_ui_dimming_rules_on_reply_msg));
+       add_to_menu (self, HILDON_APP_MENU (app_menu), _("mcen_me_inbox_forward"),
+                    G_CALLBACK (modest_ui_actions_on_forward),
+                    group, G_CALLBACK (modest_ui_dimming_rules_on_reply_msg));
+
+       add_to_menu (self, HILDON_APP_MENU (app_menu), _("mcen_me_inbox_mark_as_read"),
+                    G_CALLBACK (modest_ui_actions_on_mark_as_read),
+                    group, G_CALLBACK (modest_ui_dimming_rules_on_mark_as_read_msg_in_view));
+       add_to_menu (self, HILDON_APP_MENU (app_menu), _("mcen_me_inbox_mark_as_unread"),
+                    G_CALLBACK (modest_ui_actions_on_mark_as_unread),
+                    group, G_CALLBACK (modest_ui_dimming_rules_on_mark_as_unread_msg_in_view));
+
+       add_to_menu (self, HILDON_APP_MENU (app_menu), _("mcen_me_viewer_save_attachments"),
+                    G_CALLBACK (modest_ui_actions_save_attachments),
+                    group, G_CALLBACK (modest_ui_dimming_rules_on_save_attachments));
+       add_to_menu (self, HILDON_APP_MENU (app_menu), _("mcen_me_inbox_remove_attachments"),
+                    G_CALLBACK (modest_ui_actions_remove_attachments),
+                    group, G_CALLBACK (modest_ui_dimming_rules_on_remove_attachments));
+
+       add_to_menu (self, HILDON_APP_MENU (app_menu), _("mcen_me_viewer_newemail"),
+                    G_CALLBACK (modest_ui_actions_on_new_msg),
+                    group, G_CALLBACK (modest_ui_dimming_rules_on_new_msg));
+       add_to_menu (self, HILDON_APP_MENU (app_menu), _("mcen_me_viewer_addtocontacts"),
+                    G_CALLBACK (modest_ui_actions_add_to_contacts),
+                    group, G_CALLBACK (modest_ui_dimming_rules_on_add_to_contacts));
+
+       hildon_stackable_window_set_main_menu (HILDON_STACKABLE_WINDOW (self), 
+                                              HILDON_APP_MENU (app_menu));
+}
+
+static gboolean 
+modest_msg_view_window_toggle_menu (HildonWindow *window,
+                                   guint button,
+                                   guint32 time)
+{
+       modest_ui_actions_check_menu_dimming_rules (MODEST_WINDOW (window));
+
+       return HILDON_WINDOW_CLASS (parent_class)->toggle_menu (window, button, time);
+}
+
+
 void
 modest_msg_view_window_add_to_contacts (ModestMsgViewWindow *self)
 {
@@ -3032,9 +3201,11 @@ modest_msg_view_window_add_to_contacts (ModestMsgViewWindow *self)
                GtkWidget *picker_dialog;
                GtkWidget *selector;
                GSList *node;
-               gchar *selected;
+               gchar *selected = NULL;
 
                selector = hildon_touch_selector_new_text ();
+               g_object_ref (selector);
+
                for (node = recipients; node != NULL; node = g_slist_next (node)) {
                        if (!modest_address_book_has_address ((const gchar *) node->data)) {
                                hildon_touch_selector_append_text (HILDON_TOUCH_SELECTOR (selector), 
@@ -3044,6 +3215,7 @@ modest_msg_view_window_add_to_contacts (ModestMsgViewWindow *self)
                }
 
                if (contacts_to_add) {
+                       gint picker_result;
 
                        picker_dialog = hildon_picker_dialog_new (GTK_WINDOW (self));
                        gtk_window_set_title (GTK_WINDOW (picker_dialog), _("mcen_me_viewer_addtocontacts"));
@@ -3051,8 +3223,11 @@ modest_msg_view_window_add_to_contacts (ModestMsgViewWindow *self)
                        hildon_picker_dialog_set_selector (HILDON_PICKER_DIALOG (picker_dialog), 
                                                           HILDON_TOUCH_SELECTOR (selector));
                        
-                       gtk_dialog_run (GTK_DIALOG (picker_dialog));
-                       selected = hildon_touch_selector_get_current_text (HILDON_TOUCH_SELECTOR (selector));
+                       picker_result = gtk_dialog_run (GTK_DIALOG (picker_dialog));
+
+                       if (picker_result == GTK_RESPONSE_OK) {
+                               selected = hildon_touch_selector_get_current_text (HILDON_TOUCH_SELECTOR (selector));
+                       }
                        gtk_widget_destroy (picker_dialog);
 
                        if (selected)
diff --git a/src/hildon2/modest-number-editor.c b/src/hildon2/modest-number-editor.c
new file mode 100644 (file)
index 0000000..8732a32
--- /dev/null
@@ -0,0 +1,600 @@
+/*
+ * This file is a part of modest
+ *
+ * Copyright (C) 2005, 2006, 2008 Nokia Corporation, all rights reserved.
+ *
+ */
+
+/**
+ * SECTION:modest-number-editor
+ * @short_description: A widget used to enter a number within a pre-defined range.
+ *
+ * ModestNumberEditor is used to enter a number from a specific range. 
+ * There are two buttons to scroll the value in number field. 
+ * Manual input is also possible.
+ *
+ * <example>
+ * <title>ModestNumberEditor example</title>
+ * <programlisting>
+ * number_editor = modest_number_editor_new (-250, 500);
+ * modest_number_editor_set_range (number_editor, 0, 100);
+ * </programlisting>
+ * </example>
+ */
+
+#undef                                          MODEST_DISABLE_DEPRECATED
+
+#ifdef                                          HAVE_CONFIG_H
+#include                                        <config.h>
+#endif
+
+#include                                        <string.h>
+#include                                        <stdio.h>
+#include                                        <stdlib.h>
+#include                                        <libintl.h>
+#include                                        <gdk/gdkkeysyms.h>
+
+#include                                        "modest-number-editor.h"
+#include                                        "modest-marshal.h"
+#include                                        <hildon/hildon-banner.h>
+
+#define                                         _(String) dgettext("modest-libs", String)
+
+typedef struct                                  _ModestNumberEditorPrivate ModestNumberEditorPrivate;
+
+#define                                         MODEST_NUMBER_EDITOR_GET_PRIVATE(obj) \
+                                                (G_TYPE_INSTANCE_GET_PRIVATE ((obj), MODEST_TYPE_NUMBER_EDITOR, \
+                                                ModestNumberEditorPrivate));
+
+struct                                          _ModestNumberEditorPrivate
+{
+    gint start; /* Minimum */
+    gint end;   /* Maximum */
+    gint default_val;
+
+    /* Timer IDs */
+    guint select_all_idle_id; /* Selection repaint hack
+                                see modest_number_editor_select_all */
+};
+
+
+static void
+modest_number_editor_class_init                 (ModestNumberEditorClass *editor_class);
+
+static void
+modest_number_editor_init                       (ModestNumberEditor *editor);
+
+static gboolean
+modest_number_editor_entry_focusout             (GtkWidget *widget, 
+                                                 GdkEventFocus *event,
+                                                 gpointer data);
+
+static void
+modest_number_editor_entry_changed              (GtkWidget *widget, 
+                                                 gpointer data);
+
+static void
+modest_number_editor_finalize                   (GObject *self);
+
+static gboolean
+modest_number_editor_range_error                (ModestNumberEditor *editor,
+                                                 ModestNumberEditorErrorType type);
+
+static gboolean
+modest_number_editor_select_all                 (ModestNumberEditor *editor);
+
+static void
+modest_number_editor_validate_value             (ModestNumberEditor *editor, 
+                                                 gboolean allow_intermediate);
+    
+static void 
+modest_number_editor_set_property               (GObject * object,
+                                                 guint prop_id,
+                                                 const GValue * value,
+                                                 GParamSpec * pspec);
+
+static void
+modest_number_editor_get_property               (GObject *object,
+                                                 guint prop_id,
+                                                 GValue *value, 
+                                                 GParamSpec * pspec);
+
+enum
+{
+    RANGE_ERROR,
+    LAST_SIGNAL
+};
+
+enum {
+    PROP_0,
+    PROP_VALUE
+};
+
+static GtkContainerClass*                       parent_class;
+
+static guint                                    ModestNumberEditor_signal[LAST_SIGNAL] = {0};
+
+/**
+ * modest_number_editor_get_type:
+ *
+ * Returns GType for ModestNumberEditor.
+ *
+ * Returns: ModestNumberEditor type
+ */
+GType G_GNUC_CONST
+modest_number_editor_get_type                   (void)
+{
+    static GType editor_type = 0;
+
+    if (!editor_type)
+    {
+        static const GTypeInfo editor_info =
+        {
+            sizeof (ModestNumberEditorClass),
+            NULL,       /* base_init */
+            NULL,       /* base_finalize */
+            (GClassInitFunc) modest_number_editor_class_init,
+            NULL,       /* class_finalize */
+            NULL,       /* class_data */
+            sizeof (ModestNumberEditor),
+            0,  /* n_preallocs */
+            (GInstanceInitFunc) modest_number_editor_init,
+        };
+        editor_type = g_type_register_static (HILDON_TYPE_ENTRY,
+                "ModestNumberEditor",
+                &editor_info, 0);
+    }
+    return editor_type;
+}
+
+static void
+modest_number_editor_class_init                 (ModestNumberEditorClass *editor_class)
+{
+    GObjectClass *gobject_class = G_OBJECT_CLASS (editor_class);
+
+    g_type_class_add_private (editor_class,
+            sizeof (ModestNumberEditorPrivate));
+
+    parent_class = g_type_class_peek_parent (editor_class);
+
+    editor_class->range_error = modest_number_editor_range_error;
+
+    gobject_class->finalize                 = modest_number_editor_finalize;
+    gobject_class->set_property             = modest_number_editor_set_property;
+    gobject_class->get_property             = modest_number_editor_get_property;
+
+    /**
+     * ModestNumberEditor:value:
+     *
+     * The current value of the number editor.
+     */
+    g_object_class_install_property (gobject_class, PROP_VALUE,
+            g_param_spec_int ("value",
+                "Value",
+                "The current value of number editor",
+                G_MININT,
+                G_MAXINT,
+                0, G_PARAM_READWRITE));
+
+    ModestNumberEditor_signal[RANGE_ERROR] =
+        g_signal_new ("range_error", MODEST_TYPE_NUMBER_EDITOR,
+                G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET
+                (ModestNumberEditorClass, range_error),
+                g_signal_accumulator_true_handled, NULL,
+                modest_marshal_BOOLEAN__ENUM,
+                G_TYPE_BOOLEAN, 1, MODEST_TYPE_NUMBER_EDITOR_ERROR_TYPE);
+}
+
+static void
+modest_number_editor_finalize                   (GObject *self)
+{
+    ModestNumberEditorPrivate *priv;
+
+    priv = MODEST_NUMBER_EDITOR_GET_PRIVATE (self);
+    g_assert (priv);
+
+    if (priv->select_all_idle_id)
+        g_source_remove (priv->select_all_idle_id);
+
+    /* Call parent class finalize, if have one */
+    if (G_OBJECT_CLASS (parent_class)->finalize)
+        G_OBJECT_CLASS (parent_class)->finalize(self);
+}
+
+static void
+modest_number_editor_init                       (ModestNumberEditor *editor)
+{
+    ModestNumberEditorPrivate *priv;
+
+    priv = MODEST_NUMBER_EDITOR_GET_PRIVATE (editor);
+    g_assert (priv);
+
+    priv->select_all_idle_id = 0;
+
+    /* Connect child widget signals */
+    g_signal_connect (GTK_OBJECT (editor), "changed",
+            G_CALLBACK (modest_number_editor_entry_changed),
+            editor);
+
+    g_signal_connect (GTK_OBJECT (editor), "focus-out-event",
+            G_CALLBACK (modest_number_editor_entry_focusout),
+            editor);
+
+
+    g_object_set (G_OBJECT (editor),
+            "hildon-input-mode", HILDON_GTK_INPUT_MODE_NUMERIC, NULL);
+
+    modest_number_editor_set_range (editor, G_MININT, G_MAXINT);
+}
+
+/* Format given number to editor field, no checks performed, all signals
+   are sent normally. */
+static void
+modest_number_editor_real_set_value             (ModestNumberEditor *editor, 
+                                                 gint value)
+{
+    /* FIXME: That looks REALLY bad */
+    gchar buffer[32];
+
+    /* Update text in entry to new value */
+    g_snprintf (buffer, sizeof (buffer), "%d", value);
+    gtk_entry_set_text (GTK_ENTRY (editor), buffer);
+}
+
+static void
+add_select_all_idle                             (ModestNumberEditor *editor)
+{
+    ModestNumberEditorPrivate *priv;
+
+    priv = MODEST_NUMBER_EDITOR_GET_PRIVATE (editor);
+
+    if (! priv->select_all_idle_id)
+    {
+        priv->select_all_idle_id =
+            g_idle_add((GSourceFunc) modest_number_editor_select_all, editor);
+    }    
+}
+
+static void
+modest_number_editor_validate_value             (ModestNumberEditor *editor, 
+                                                 gboolean allow_intermediate)
+{
+    ModestNumberEditorPrivate *priv;
+    gint error_code, fixup_value;
+    const gchar *text;
+    long value;
+    gchar *tail;
+    gboolean r;
+
+    g_assert (MODEST_IS_NUMBER_EDITOR(editor));
+
+    priv = MODEST_NUMBER_EDITOR_GET_PRIVATE (editor);
+    g_assert (priv);
+
+    text = gtk_entry_get_text (GTK_ENTRY (editor));
+    error_code = -1;
+    fixup_value = priv->default_val;
+
+    if (text && text[0])
+    { 
+        /* Try to convert entry text to number */
+        value = strtol (text, &tail, 10);
+
+        /* Check if conversion succeeded */
+        if (tail[0] == 0)
+        {    
+            /* Check if value is in allowed range. This is tricky in those
+               cases when user is editing a value. 
+               For example: Range = [100, 500] and user have just inputted "4".
+               This should not lead into error message. Otherwise value is
+               resetted back to "100" and next "4" press will reset it back
+               and so on. */
+            if (allow_intermediate)
+            {
+                /* We now have the following error cases:
+                 * If inputted value as above maximum and
+                 maximum is either positive or then maximum
+                 negative and value is positive.
+                 * If inputted value is below minimum and minimum
+                 is negative or minumum positive and value
+                 negative or zero.
+                 In all other cases situation can be fixed just by
+                 adding new numbers to the string.
+                 */
+                if (value > priv->end && (priv->end >= 0 || (priv->end < 0 && value >= 0)))
+                {
+                    error_code = MODEST_NUMBER_EDITOR_ERROR_MAXIMUM_VALUE_EXCEED;
+                    fixup_value = priv->end;
+                }
+                else if (value < priv->start && (priv->start < 0 || (priv->start >= 0 && value <= 0)))
+                {
+                    error_code = MODEST_NUMBER_EDITOR_ERROR_MINIMUM_VALUE_EXCEED;
+                    fixup_value = priv->start;
+                }
+            }
+            else
+            {
+                if (value > priv->end) {
+                    error_code = MODEST_NUMBER_EDITOR_ERROR_MAXIMUM_VALUE_EXCEED;
+                    fixup_value = priv->end;
+                }
+                else if (value < priv->start) {
+                    error_code = MODEST_NUMBER_EDITOR_ERROR_MINIMUM_VALUE_EXCEED;
+                    fixup_value = priv->start;
+                }
+            }
+        }
+        /* The only valid case when conversion can fail is when we
+           have plain '-', intermediate forms are allowed AND
+           minimum bound is negative */
+        else if (! allow_intermediate || strcmp (text, "-") != 0 || priv->start >= 0)
+            error_code = MODEST_NUMBER_EDITOR_ERROR_ERRONEOUS_VALUE;
+    }
+    else if (! allow_intermediate)
+        error_code = MODEST_NUMBER_EDITOR_ERROR_ERRONEOUS_VALUE;
+
+    if (error_code != -1)
+    {
+        /* If entry is empty and intermediate forms are nor allowed, 
+           emit error signal */
+        /* Change to default value */
+        modest_number_editor_set_value (editor, fixup_value);
+        g_signal_emit (editor, ModestNumberEditor_signal[RANGE_ERROR], 0, error_code, &r);
+        add_select_all_idle (editor);
+    }
+}
+
+static void 
+modest_number_editor_entry_changed              (GtkWidget *widget, 
+                                                 gpointer data)
+{
+    g_assert (MODEST_IS_NUMBER_EDITOR (data));
+    modest_number_editor_validate_value (MODEST_NUMBER_EDITOR (data), TRUE);
+    g_object_notify (G_OBJECT (data), "value");
+}
+
+static gboolean
+modest_number_editor_entry_focusout             (GtkWidget *widget, 
+                                                 GdkEventFocus *event,
+                                                 gpointer data)
+{
+    g_assert (MODEST_IS_NUMBER_EDITOR(data));
+
+    modest_number_editor_validate_value (MODEST_NUMBER_EDITOR(data), FALSE);
+    return FALSE;
+}
+
+static gboolean
+modest_number_editor_range_error                (ModestNumberEditor *editor,
+                                                 ModestNumberEditorErrorType type)
+{
+
+    gint min, max;
+    gchar *err_msg = NULL;
+    ModestNumberEditorPrivate *priv;
+
+    priv = MODEST_NUMBER_EDITOR_GET_PRIVATE (editor);
+    g_assert (priv);
+
+    min = priv->start;
+    max = priv->end;
+
+    /* Construct error message */
+    switch (type)
+    {
+        case MODEST_NUMBER_EDITOR_ERROR_MAXIMUM_VALUE_EXCEED:
+            err_msg = g_strdup_printf (_("ckct_ib_maximum_value"), max, max);
+            break;
+
+        case MODEST_NUMBER_EDITOR_ERROR_MINIMUM_VALUE_EXCEED:
+            err_msg = g_strdup_printf (_("ckct_ib_minimum_value"), min, min);
+            break;
+
+        case MODEST_NUMBER_EDITOR_ERROR_ERRONEOUS_VALUE:
+            err_msg =
+                g_strdup_printf (_("ckct_ib_set_a_value_within_range"), min, max);
+            break;
+    }
+
+    /* Infoprint error */
+    if (err_msg)
+    {
+        hildon_banner_show_information (GTK_WIDGET (GTK_WINDOW (gtk_widget_get_ancestor (GTK_WIDGET(editor),
+                                        GTK_TYPE_WINDOW))), NULL, err_msg);
+        g_free(err_msg);
+    }
+
+    return TRUE;
+}
+
+/**
+ * modest_number_editor_new:
+ * @min: minimum accepted value
+ * @max: maximum accepted value
+ * 
+ * Creates new number editor
+ *
+ * Returns: a new #ModestNumberEditor widget
+ */
+GtkWidget*
+modest_number_editor_new                        (gint min, 
+                                                 gint max)
+{
+    ModestNumberEditor *editor = g_object_new (MODEST_TYPE_NUMBER_EDITOR, NULL);
+
+    /* Set user inputted range to editor */
+    modest_number_editor_set_range (editor, min, max);
+
+    return GTK_WIDGET (editor);
+}
+
+/**
+ * modest_number_editor_set_range:
+ * @editor: a #ModestNumberEditor widget
+ * @min: minimum accepted value
+ * @max: maximum accepted value
+ *
+ * Sets accepted number range for editor
+ */
+void
+modest_number_editor_set_range                  (ModestNumberEditor *editor, 
+                                                 gint min, 
+                                                 gint max)
+{
+    ModestNumberEditorPrivate *priv;
+    gchar buffer_min[32], buffer_max[32];
+    gint a, b;
+
+    g_return_if_fail (MODEST_IS_NUMBER_EDITOR (editor));
+
+    priv = MODEST_NUMBER_EDITOR_GET_PRIVATE (editor);
+    g_assert (priv);
+
+    /* Set preferences */
+    priv->start = MIN (min, max);
+    priv->end = MAX (min, max);
+
+    /* Find maximum allowed length of value */
+    g_snprintf (buffer_min, sizeof (buffer_min), "%d", min);
+    g_snprintf (buffer_max, sizeof (buffer_max), "%d", max);
+    a = strlen (buffer_min);
+    b = strlen (buffer_max);
+
+    /* Set maximum size of entry */
+    gtk_entry_set_width_chars (GTK_ENTRY (editor), MAX (a, b));
+    modest_number_editor_set_value (editor, priv->start);
+}
+
+/**
+ * modest_number_editor_get_value:
+ * @editor: pointer to #ModestNumberEditor
+ *
+ * Returns: current NumberEditor value
+ */
+gint
+modest_number_editor_get_value                  (ModestNumberEditor *editor)
+{
+    ModestNumberEditorPrivate *priv;
+
+    g_return_val_if_fail (MODEST_IS_NUMBER_EDITOR (editor), 0);
+
+    priv = MODEST_NUMBER_EDITOR_GET_PRIVATE (editor);
+    g_assert (priv);
+
+    return atoi (gtk_entry_get_text (GTK_ENTRY (editor)));
+}
+
+/**
+ * modest_number_editor_set_value:
+ * @editor: pointer to #ModestNumberEditor
+ * @value: numeric value for number editor
+ *
+ * Sets numeric value for number editor
+ */
+void
+modest_number_editor_set_value                  (ModestNumberEditor *editor, 
+                                                 gint value)
+{
+    ModestNumberEditorPrivate *priv;
+
+    g_return_if_fail (MODEST_IS_NUMBER_EDITOR (editor));
+
+    priv = MODEST_NUMBER_EDITOR_GET_PRIVATE (editor);
+    g_assert (priv);
+
+    g_return_if_fail (value <= priv->end);
+    g_return_if_fail (value >= priv->start);
+
+    priv->default_val = value;
+    modest_number_editor_real_set_value (editor, value);
+    g_object_notify (G_OBJECT(editor), "value");
+}
+
+/* When calling gtk_entry_set_text, the entry widget does things that can
+ * cause the whole widget to redraw. This redrawing is delayed and if any
+ * selections are made right after calling the gtk_entry_set_text the
+ * setting of the selection might seem to have no effect.
+ *
+ * If the selection is delayed with a lower priority than the redrawing,
+ * the selection should stick. Calling this function with g_idle_add should
+ * do it.
+ */
+static gboolean
+modest_number_editor_select_all                 (ModestNumberEditor *editor)
+{   
+    ModestNumberEditorPrivate *priv;
+
+    g_return_val_if_fail (MODEST_IS_NUMBER_EDITOR (editor), FALSE);
+
+    priv = MODEST_NUMBER_EDITOR_GET_PRIVATE (editor);
+    g_assert (priv);
+
+    GDK_THREADS_ENTER ();
+    gtk_editable_select_region (GTK_EDITABLE (editor), 0, -1);
+    priv->select_all_idle_id = 0;
+    GDK_THREADS_LEAVE ();
+    return FALSE;
+} 
+
+static void
+modest_number_editor_set_property               (GObject *object,
+                                                 guint prop_id,
+                                                 const GValue *value, 
+                                                 GParamSpec *pspec)
+{
+    ModestNumberEditor *editor;
+
+    editor = MODEST_NUMBER_EDITOR (object);
+
+    switch (prop_id) {
+
+        case PROP_VALUE:
+            modest_number_editor_set_value (editor, g_value_get_int (value));
+            break;
+
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
+            break;
+    }
+}
+
+static void
+modest_number_editor_get_property               (GObject *object,
+                                                 guint prop_id, 
+                                                 GValue *value, 
+                                                 GParamSpec *pspec)
+{
+    ModestNumberEditor *editor;
+
+    editor = MODEST_NUMBER_EDITOR (object);
+
+    switch (prop_id) {
+
+        case PROP_VALUE:
+            g_value_set_int(value, modest_number_editor_get_value (editor));
+            break;
+
+        default:
+            G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+            break;
+    }
+}
+
+
+/* enumerations from "modest-number-editor.h" */
+GType
+modest_number_editor_error_type_get_type (void)
+{
+  static GType etype = 0;
+  if (etype == 0) {
+    static const GEnumValue values[] = {
+      { MODEST_NUMBER_EDITOR_ERROR_MAXIMUM_VALUE_EXCEED, "MODEST_NUMBER_EDITOR_ERROR_MAXIMUM_VALUE_EXCEED", "maximum-value-exceed" },
+      { MODEST_NUMBER_EDITOR_ERROR_MINIMUM_VALUE_EXCEED, "MODEST_NUMBER_EDITOR_ERROR_MINIMUM_VALUE_EXCEED", "minimum-value-exceed" },
+      { MODEST_NUMBER_EDITOR_ERROR_ERRONEOUS_VALUE, "MODEST_NUMBER_EDITOR_ERROR_ERRONEOUS_VALUE", "erroneous-value" },
+      { 0, NULL, NULL }
+    };
+    etype = g_enum_register_static ("ModestNumberEditorErrorType", values);
+  }
+  return etype;
+}
+
diff --git a/src/hildon2/modest-number-editor.h b/src/hildon2/modest-number-editor.h
new file mode 100644 (file)
index 0000000..90c0631
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * This file is a part of modest
+ *
+ * Copyright (C) 2005, 2006, 2008 Nokia Corporation, all rights reserved.
+ *
+ */
+
+#ifndef                                         __MODEST_NUMBER_EDITOR_H__
+#define                                         __MODEST_NUMBER_EDITOR_H__
+
+#include                                        <gtk/gtk.h>
+#include                                        <hildon/hildon-entry.h>
+
+G_BEGIN_DECLS
+
+#define                                         MODEST_TYPE_NUMBER_EDITOR \
+                                                (modest_number_editor_get_type())
+
+#define                                         MODEST_NUMBER_EDITOR(obj) \
+                                                (GTK_CHECK_CAST (obj, MODEST_TYPE_NUMBER_EDITOR, ModestNumberEditor))
+
+#define                                         MODEST_NUMBER_EDITOR_CLASS(klass) \
+                                                (GTK_CHECK_CLASS_CAST ((klass), MODEST_TYPE_NUMBER_EDITOR, \
+                                                ModestNumberEditorClass))
+
+#define                                         MODEST_IS_NUMBER_EDITOR(obj) \
+                                                (GTK_CHECK_TYPE (obj, MODEST_TYPE_NUMBER_EDITOR))
+
+#define                                         MODEST_IS_NUMBER_EDITOR_CLASS(klass) \
+                                                (GTK_CHECK_CLASS_TYPE ((klass), MODEST_TYPE_NUMBER_EDITOR))
+
+#define                                         MODEST_NUMBER_EDITOR_GET_CLASS(obj) \
+                                                ((ModestNumberEditorClass *) G_OBJECT_GET_CLASS(obj))
+
+typedef struct                                  _ModestNumberEditor ModestNumberEditor;
+
+typedef struct                                  _ModestNumberEditorClass ModestNumberEditorClass;
+
+struct                                          _ModestNumberEditor 
+{
+    HildonEntry parent;
+};
+
+typedef enum
+{
+    MODEST_NUMBER_EDITOR_ERROR_MAXIMUM_VALUE_EXCEED,
+    MODEST_NUMBER_EDITOR_ERROR_MINIMUM_VALUE_EXCEED,
+    MODEST_NUMBER_EDITOR_ERROR_ERRONEOUS_VALUE
+}                                               ModestNumberEditorErrorType;
+
+struct                                          _ModestNumberEditorClass 
+{
+    GtkEntryClass parent_class;
+  
+    gboolean  (*range_error)  (ModestNumberEditor *editor, ModestNumberEditorErrorType type); 
+};
+
+GType G_GNUC_CONST
+modest_number_editor_get_type                   (void);
+
+GtkWidget*  
+modest_number_editor_new                        (gint min, gint max);
+
+void
+modest_number_editor_set_range                  (ModestNumberEditor *editor, 
+                                                 gint min,
+                                                 gint max);
+
+gint
+modest_number_editor_get_value                  (ModestNumberEditor *editor);
+
+void
+modest_number_editor_set_value                  (ModestNumberEditor *editor, 
+                                                 gint value);
+
+
+GType modest_number_editor_error_type_get_type (void);
+#define MODEST_TYPE_NUMBER_EDITOR_ERROR_TYPE (modest_number_editor_error_type_get_type())
+
+G_END_DECLS
+
+#endif                                          /* __MODEST_NUMBER_EDITOR_H__ */
index d1c1b8f..2a2110e 100644 (file)
 #include <hildon/hildon-sound.h>
 #include <osso-mem.h>
 #include "hildon2/modest-hildon2-details-dialog.h"
+#include "hildon2/modest-hildon2-window-mgr.h"
+#include <keys_nokia.h>
+#include <libprofile.h>
+#include <canberra.h>
 #include <modest-datetime-formatter.h>
+#include "modest-header-window.h"
 
 #ifdef MODEST_HAVE_MCE
 #include <mce/dbus-names.h>
 
 #define HILDON_OSSO_URI_ACTION "uri-action"
 #define URI_ACTION_COPY "copy:"
-#define MODEST_NEW_MAIL_SOUND_FILE "/usr/share/sounds/ui-new_email.wav"
 #define MODEST_NEW_MAIL_LIGHTING_PATTERN "PatternCommunicationEmail"
+#define PROFILE_MAIL_TONE PROFILEKEY_EMAIL_ALERT_TONE
+#define PROFILE_MAIL_VOLUME PROFILEKEY_EMAIL_ALERT_VOLUME
+
+static void _modest_platform_play_email_tone (void);
+
 
 static void    
 on_modest_conf_update_interval_changed (ModestConf* self, 
@@ -1145,29 +1154,16 @@ modest_platform_set_update_interval (guint minutes)
 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 */
-       play_sound = modest_conf_get_bool (modest_runtime_get_conf (),
-                                          MODEST_CONF_PLAY_SOUND_MSG_ARRIVE,
-                                          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));
-
        /* Get the window status */
        app_in_foreground = hildon_program_get_is_topmost (hildon_program_get_instance ());
 
        /* If the screen is on and the app is in the
           foreground we don't show anything */
        if (!(screen_on && app_in_foreground)) {
-               /* Play a sound */
-               if (play_sound)
-                       hildon_play_system_sound (MODEST_NEW_MAIL_SOUND_FILE);
+
+               _modest_platform_play_email_tone ();
 
                /* Activate LED. This must be deactivated by
                   modest_platform_remove_new_mail_notifications */
@@ -1202,13 +1198,6 @@ modest_platform_on_new_headers_received (TnyList *header_list,
        }
 
 #ifdef MODEST_HAVE_HILDON_NOTIFY
-       gboolean play_sound;
-
-       /* Check whether or not we should play a sound */
-       play_sound = modest_conf_get_bool (modest_runtime_get_conf (),
-                                          MODEST_CONF_PLAY_SOUND_MSG_ARRIVE,
-                                          NULL);
-
        HildonNotification *notification;
        TnyIterator *iter;
        GSList *notifications_list = NULL;
@@ -1264,11 +1253,25 @@ modest_platform_on_new_headers_received (TnyList *header_list,
                /* Play sound if the user wants. Show the LED
                   pattern. Show and play just one */
                if (G_UNLIKELY (first_notification)) {
+                       gchar *active_profile;
+                       gchar *mail_tone;
+                       gchar *mail_volume;
+                       gint mail_volume_int;
+
                        first_notification = FALSE;
-                       if (play_sound)  {
+
+                       active_profile = profile_get_profile ();
+                       mail_tone = profile_get_value (active_profile, PROFILE_MAIL_TONE);
+                       mail_volume = profile_get_value (active_profile, PROFILE_MAIL_VOLUME);
+                       mail_volume_int = profile_parse_int (mail_volume);
+
+                       if (mail_volume_int > 0)
                                notify_notification_set_hint_string(NOTIFY_NOTIFICATION (notification),
-                                                                   "sound-file", MODEST_NEW_MAIL_SOUND_FILE);
-                       }
+                                                                   "sound-file", mail_tone);
+
+                       g_free (mail_volume);
+                       g_free (mail_tone);
+                       g_free (active_profile);
 
                        /* Set the led pattern */
                        notify_notification_set_hint_int32 (NOTIFY_NOTIFICATION (notification),
@@ -1395,7 +1398,7 @@ void
 modest_platform_show_addressbook (GtkWindow *parent_window)
 {
        osso_return_t result = OSSO_ERROR;
-       
+
        result = osso_rpc_run_with_defaults (modest_maemo_utils_get_osso_context(),
                                             "osso_addressbook",
                                             "top_application", NULL, DBUS_TYPE_INVALID);
@@ -1438,7 +1441,7 @@ modest_platform_information_banner (GtkWidget *parent,
        GtkWidget *banner, *banner_parent = NULL;
        ModestWindowMgr *mgr = modest_runtime_get_window_mgr ();
 
-       if (modest_window_mgr_num_windows (mgr) == 0)
+       if (modest_window_mgr_get_num_windows (mgr) == 0)
                return;
 
        if (parent && GTK_IS_WINDOW (parent)) {
@@ -1474,7 +1477,7 @@ modest_platform_information_banner_with_timeout (GtkWidget *parent,
 {
        GtkWidget *banner;
 
-       if (modest_window_mgr_num_windows (modest_runtime_get_window_mgr ()) == 0)
+       if (modest_window_mgr_get_num_windows (modest_runtime_get_window_mgr ()) == 0)
                return;
 
        banner = hildon_banner_show_information (parent, icon_name, text);
@@ -1490,7 +1493,7 @@ modest_platform_animation_banner (GtkWidget *parent,
 
        g_return_val_if_fail (text != NULL, NULL);
 
-       if (modest_window_mgr_num_windows (modest_runtime_get_window_mgr ()) == 0)
+       if (modest_window_mgr_get_num_windows (modest_runtime_get_window_mgr ()) == 0)
                return NULL;
 
        /* If the parent is not visible then do not show */
@@ -1636,19 +1639,18 @@ 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;
+       HildonWindowStack *stack;
+
+       stack = hildon_window_stack_get_default ();
+       win = MODEST_WINDOW (hildon_window_stack_peek (stack));
+
+       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);
        
@@ -1657,7 +1659,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,
                _HL("wdgt_bd_yes"),     GTK_RESPONSE_OK,
                _HL("wdgt_bd_view"),          GTK_RESPONSE_APPLY,   /* abusing this... */
@@ -1668,8 +1670,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);
@@ -2098,7 +2098,7 @@ modest_platform_run_header_details_dialog (GtkWindow *parent_window,
                                           TnyHeader *header)
 {
        GtkWidget *dialog;
-       
+
        /* Create dialog */
        dialog = modest_hildon2_details_dialog_new_with_header (parent_window, header);
 
@@ -2118,3 +2118,105 @@ modest_platform_get_osso_context (void)
 {
        return modest_maemo_utils_get_osso_context ();
 }
+
+static void
+_modest_platform_play_email_tone (void)
+{
+       gchar *active_profile;
+       gchar *mail_tone;
+       gchar *mail_volume;
+       gint mail_volume_int;
+       int ret;
+       ca_context *ca_con = NULL;
+       ca_proplist *pl = NULL;
+
+       active_profile = profile_get_profile ();
+       mail_tone = profile_get_value (active_profile, PROFILE_MAIL_TONE);
+       mail_volume = profile_get_value (active_profile, PROFILE_MAIL_VOLUME);
+       mail_volume_int = profile_parse_int (mail_volume);
+
+       if (mail_volume_int > 0) {
+
+               if ((ret = ca_context_create(&ca_con)) != CA_SUCCESS) {
+                       g_warning("ca_context_create: %s\n", ca_strerror(ret));
+                       return;
+               }
+
+               if ((ret = ca_context_open(ca_con)) != CA_SUCCESS) {
+                       g_warning("ca_context_open: %s\n", ca_strerror(ret));
+                       ca_context_destroy(ca_con);
+                       return;
+               }
+
+               ca_proplist_create(&pl);
+               ca_proplist_sets(pl, CA_PROP_MEDIA_FILENAME, mail_tone);
+               ca_proplist_setf(pl, CA_PROP_CANBERRA_VOLUME, "%f", (gfloat) mail_volume_int);
+
+               ret = ca_context_play_full(ca_con, 0, pl, NULL, NULL);
+               g_debug("ca_context_play_full (vol %f): %s\n", (gfloat) mail_volume_int, ca_strerror(ret));
+
+               ca_proplist_destroy(pl);
+               ca_context_destroy(ca_con);
+       }
+
+       g_free (mail_volume);
+       g_free (mail_tone);
+       g_free (active_profile);
+}
+
+static void
+on_move_to_dialog_folder_activated (GtkTreeView       *tree_view,
+                                    GtkTreePath       *path,
+                                    GtkTreeViewColumn *column,
+                                    gpointer           user_data)
+{
+        gtk_dialog_response (GTK_DIALOG (user_data), GTK_RESPONSE_OK);
+}
+
+GtkWidget *
+modest_platform_create_move_to_dialog (GtkWindow *parent_window,
+                                      GtkWidget **folder_view)
+{
+       GtkWidget *dialog, *folder_view_container;
+
+       /* Create dialog. We cannot use a touch selector because we
+          need to use here the folder view widget directly */
+       dialog = gtk_dialog_new_with_buttons (_("mcen_ti_moveto_folders_title"),
+                                             GTK_WINDOW (parent_window),
+                                             GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR |
+                                             GTK_DIALOG_DESTROY_WITH_PARENT,
+                                             _("mcen_bd_new"), MODEST_GTK_RESPONSE_NEW_FOLDER,
+                                             NULL);
+
+       /* Create folder view */
+       *folder_view = modest_platform_create_folder_view (NULL);
+
+        /* Simulate the behaviour of a HildonPickerDialog by emitting
+          a response when a folder is selected */
+        g_signal_connect (*folder_view, "row-activated",
+                          G_CALLBACK (on_move_to_dialog_folder_activated),
+                          dialog);
+
+       /* Create pannable and add it to the dialog */
+       folder_view_container = hildon_pannable_area_new ();
+       gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), folder_view_container);
+       gtk_container_add (GTK_CONTAINER (folder_view_container), *folder_view);
+
+       gtk_window_set_default_size (GTK_WINDOW (dialog), 300, 300);
+
+       gtk_widget_show (GTK_DIALOG (dialog)->vbox);
+       gtk_widget_show (folder_view_container);
+       gtk_widget_show (*folder_view);
+
+       return dialog;
+}
+
+TnyList *
+modest_platform_get_list_to_move (ModestWindow *window)
+{
+       ModestHeaderView *header_view;
+
+       header_view = modest_header_window_get_header_view (MODEST_HEADER_WINDOW (window));
+
+       return modest_header_view_get_selected_headers (header_view);
+}
index 83ea8b3..2226b3b 100644 (file)
@@ -42,6 +42,7 @@
 #include <glib/gi18n.h>
 #include <modest-maemo-utils.h>
 #include "modest-text-utils.h"
+#include <hildon/hildon-text-view.h>
 
 G_DEFINE_TYPE (ModestSignatureEditorDialog, modest_signature_editor_dialog, GTK_TYPE_DIALOG);
 
@@ -153,10 +154,10 @@ modest_signature_editor_dialog_init (ModestSignatureEditorDialog *self)
        gtk_box_pack_start (GTK_BOX (box), priv->pannable, TRUE, TRUE, MODEST_MARGIN_HALF);
        gtk_widget_show (priv->pannable);
                
-       priv->textview = gtk_text_view_new ();
+       priv->textview = hildon_text_view_new ();
        gtk_container_add (GTK_CONTAINER (priv->pannable), priv->textview);
        gtk_widget_show (priv->textview);
-       GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->textview));
+       GtkTextBuffer *buffer = hildon_text_view_get_buffer (HILDON_TEXT_VIEW (priv->textview));
        gtk_text_buffer_set_text (buffer, _("mcen_va_default_signature_tablet"), -1); /* Default, as per the UI spec. */
        
        /* Add the buttons: */
@@ -195,7 +196,7 @@ modest_signature_editor_dialog_set_settings (
        
        hildon_check_button_set_active (HILDON_CHECK_BUTTON (priv->checkbox_use), use_signature);
        
-       GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->textview));
+       GtkTextBuffer *buffer = hildon_text_view_get_buffer (HILDON_TEXT_VIEW (priv->textview));
        if (signature && signature[0] != '\0')
                gtk_text_buffer_set_text (buffer, signature, -1);
        else
@@ -217,7 +218,7 @@ modest_signature_editor_dialog_get_settings (
        
        *use_signature = hildon_check_button_get_active (HILDON_CHECK_BUTTON (priv->checkbox_use));
                        
-       GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (priv->textview));
+       GtkTextBuffer *buffer = hildon_text_view_get_buffer (HILDON_TEXT_VIEW (priv->textview));
        
        GtkTextIter start, end;
        gtk_text_buffer_get_bounds (buffer, &start, &end);
index edb3a72..0845ca2 100644 (file)
@@ -90,5 +90,9 @@
   <accelerator name="AccelZoomPlus" action="ZoomPlus"/>
   <accelerator name="AccelToggleFullscreen" action="ToggleFullscreen"/>
   <accelerator name="AccelCloseWindow" action="CloseWindowShortcut"/>
+  <accelerator name="CutMenu" action="Cut"/>
+  <accelerator name="CopyMenu" action="Copy"/>
+  <accelerator name="PasteMenu" action="Paste"/>
+  <accelerator name="SelectAllMenu" action="SelectAll"/>
 
 </ui>
index f41327e..9bbe466 100644 (file)
@@ -99,7 +99,7 @@ static const GtkActionEntry modest_action_entries [] = {
        { "ToolsSendReceiveAll",    NULL,      N_("mcen_me_inbox_sendandreceive_all"),          NULL, NULL, G_CALLBACK (modest_ui_actions_on_send_receive) },
        { "ToolsSendReceiveCancelSending",  NULL,      N_("mcen_me_outbox_cancelsend"),        NULL, NULL,  G_CALLBACK (modest_ui_actions_cancel_send) },
        { "ToolsContacts",            NULL,      N_("mcen_me_inbox_open_addressbook"),                      NULL, NULL,  G_CALLBACK (modest_ui_actions_on_open_addressbook) },
-       { "ToolsAddToContacts",            NULL,      N_("mcen_me_viewer_addtocontacts"),                      NULL, NULL,  G_CALLBACK (modest_ui_actions_add_to_contacts) },
+       { "ToolsAddToContacts",            NULL,      N_("mcen_me_viewer_addtocontacts"),                      NULL, NULL,  G_CALLBACK (modest_ui_actions_on_add_to_contacts) },
        { "ToolsSearchMessages",            NULL,      N_("mcen_me_inbox_search"),  "<CTRL>E", NULL,  G_CALLBACK (modest_ui_actions_on_search_messages) },
        { "ToolsHelp", NULL, N_("mcen_me_inbox_help"), NULL, NULL, G_CALLBACK (modest_ui_actions_on_help) },
 
index bab4bfd..e63d715 100644 (file)
@@ -1114,7 +1114,8 @@ modest_main_window_on_show (GtkWidget *self, gpointer user_data)
        ShowHelper *helper = (ShowHelper *) user_data;
        GtkWidget *folder_win = helper->folder_win;
        ModestMainWindowPrivate *priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
-       
+       ModestAccountMgr *mgr;
+
        priv->folder_view = MODEST_FOLDER_VIEW (modest_platform_create_folder_view (NULL));
        wrap_in_scrolled_window (folder_win, GTK_WIDGET(priv->folder_view));
 
@@ -1136,18 +1137,10 @@ modest_main_window_on_show (GtkWidget *self, gpointer user_data)
        restore_settings (MODEST_MAIN_WINDOW(self), TRUE);
        priv->wait_for_settings = FALSE;
 
-       /* Check if accounts exist and show the account wizard if not */
-       gboolean accounts_exist = 
-               modest_account_mgr_has_accounts(modest_runtime_get_account_mgr(), TRUE);
-
-       if (!accounts_exist) {
-               /* This is necessary to have the main window shown behind the dialog 
-               It's an ugly hack... jschmid */
-               gtk_widget_show_all(GTK_WIDGET(self));
-               modest_ui_actions_on_accounts (NULL, MODEST_WINDOW(self));
-       } else {
+       /* Update the menus if there are accounts */
+       mgr = modest_runtime_get_account_mgr();
+       if (modest_account_mgr_has_accounts(mgr, TRUE))
                update_menus (MODEST_MAIN_WINDOW (self));
-       }
 
        /* Never call this function again (NOTE that it could happen
           as we hide the main window instead of closing it while
index eade580..d31351f 100644 (file)
@@ -3215,3 +3215,4 @@ modest_msg_view_window_add_to_contacts (ModestMsgViewWindow *self)
        modest_ui_actions_on_add_to_contacts (NULL, MODEST_WINDOW (self));
 }
 
+
index 75662fa..f6002d5 100644 (file)
@@ -1460,7 +1460,7 @@ banner_finish (gpointer data, GObject *object)
        g_object_unref (mgr);
 }
 
-void 
+void
 modest_platform_information_banner (GtkWidget *parent,
                                    const gchar *icon_name,
                                    const gchar *text)
@@ -1468,7 +1468,7 @@ modest_platform_information_banner (GtkWidget *parent,
        GtkWidget *banner, *banner_parent = NULL;
        ModestWindowMgr *mgr = modest_runtime_get_window_mgr ();
 
-       if (modest_window_mgr_num_windows (mgr) == 0)
+       if (modest_window_mgr_get_num_windows (mgr) == 0)
                return;
 
        if (parent && GTK_IS_WINDOW (parent)) {
@@ -1478,7 +1478,7 @@ modest_platform_information_banner (GtkWidget *parent,
                        banner_parent = parent;
                /* If the window is not the topmost but it's visible
                   (it's minimized for example) then show the banner
-                  with no parent */ 
+                  with no parent */
                else if (GTK_WIDGET_VISIBLE (parent))
                        banner_parent = NULL;
                /* If the window is hidden (like the main window when
@@ -1504,7 +1504,7 @@ modest_platform_information_banner_with_timeout (GtkWidget *parent,
 {
        GtkWidget *banner;
 
-       if (modest_window_mgr_num_windows (modest_runtime_get_window_mgr ()) == 0)
+       if (modest_window_mgr_get_num_windows (modest_runtime_get_window_mgr ()) == 0)
                return;
 
        banner = hildon_banner_show_information (parent, icon_name, text);
@@ -1520,7 +1520,7 @@ modest_platform_animation_banner (GtkWidget *parent,
 
        g_return_val_if_fail (text != NULL, NULL);
 
-       if (modest_window_mgr_num_windows (modest_runtime_get_window_mgr ()) == 0)
+       if (modest_window_mgr_get_num_windows (modest_runtime_get_window_mgr ()) == 0)
                return NULL;
 
        /* If the parent is not visible then do not show */
@@ -2158,3 +2158,84 @@ modest_platform_get_osso_context (void)
 {
        return modest_maemo_utils_get_osso_context ();
 }
+
+GtkWidget* 
+modest_platform_create_move_to_dialog (GtkWindow *parent_window,
+                                      GtkWidget **folder_view)
+{
+       GtkWidget *dialog, *folder_view_container;
+
+       dialog = gtk_dialog_new_with_buttons (_("mcen_ti_moveto_folders_title"),
+                                             GTK_WINDOW (parent_window),
+                                             GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR |
+                                             GTK_DIALOG_DESTROY_WITH_PARENT,
+                                             _("mcen_bd_dialog_ok"), GTK_RESPONSE_OK,
+                                             _("mcen_bd_new"), MODEST_GTK_RESPONSE_NEW_FOLDER,
+                                             _("mcen_bd_dialog_cancel"), GTK_RESPONSE_CANCEL,
+                                             NULL);
+
+       /* Create folder view */
+       *folder_view = modest_platform_create_folder_view (NULL);
+
+       /* Create pannable and add it to the dialog */
+       folder_view_container = gtk_scrolled_window_new (NULL, NULL);
+       gtk_scrolled_window_set_policy  (GTK_SCROLLED_WINDOW (folder_view_container),
+                                        GTK_POLICY_AUTOMATIC,
+                                        GTK_POLICY_AUTOMATIC);
+       gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), folder_view_container);
+       gtk_container_add (GTK_CONTAINER (folder_view_container), *folder_view);
+
+       gtk_window_set_default_size (GTK_WINDOW (dialog), 300, 300);
+
+       gtk_widget_show (GTK_DIALOG (dialog)->vbox);
+       gtk_widget_show (folder_view_container);
+       gtk_widget_show (*folder_view);
+
+       return dialog;
+}
+
+
+TnyList *
+modest_platform_get_list_to_move (ModestWindow *window)
+{
+       TnyList *list = NULL;
+
+       /* If it's a main window then it could be that we're moving a
+          folder or a set of messages */
+       if (MODEST_IS_MAIN_WINDOW (window)) {
+               ModestHeaderView *header_view = NULL;
+               ModestFolderView *folder_view = NULL;
+
+               folder_view = (ModestFolderView *)
+                       modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (window),
+                                                            MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW);
+               header_view = (ModestHeaderView *)
+                       modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (window),
+                                                            MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW);
+
+               /* Get folder or messages to transfer */
+               if (gtk_widget_is_focus (GTK_WIDGET (folder_view))) {
+                       TnyFolderStore *src_folder;
+
+                       src_folder = modest_folder_view_get_selected (folder_view);
+                       if (src_folder) {
+                               list = tny_simple_list_new ();
+                               tny_list_prepend (list, G_OBJECT (src_folder));
+                               g_object_unref (src_folder);
+                       }
+               } else if (gtk_widget_is_focus (GTK_WIDGET(header_view))) {
+                       list = modest_header_view_get_selected_headers(header_view);
+               }
+       } else if (MODEST_IS_MSG_VIEW_WINDOW (window)) {
+               TnyHeader *header = NULL;
+
+               /* We simply return the currently viewed message */
+               header = modest_msg_view_window_get_header (MODEST_MSG_VIEW_WINDOW (window));
+               if (header) {
+                       list = tny_simple_list_new ();
+                       tny_list_prepend (list, G_OBJECT (header));
+                       g_object_unref (header);
+               }
+       }
+       return list;
+}
index 49621cf..61e40c6 100644 (file)
@@ -187,7 +187,18 @@ modest_dimming_rule_process (ModestDimmingRule *self)
                else
                        g_printerr ("modest: action path '%s' has not associatd action\n", priv->action_path);
        } else if (priv->widget != NULL) {
+#ifdef MODEST_TOOLKIT_HILDON2
+               if (GTK_IS_TOOL_ITEM (priv->widget)) {
+                       gtk_widget_set_sensitive (priv->widget, !dimmed);
+               } else {
+                       if (dimmed)
+                               gtk_widget_hide (priv->widget);
+                       else
+                               gtk_widget_show (priv->widget);
+               }
+#else
                gtk_widget_set_sensitive (priv->widget, !dimmed);
+#endif
        }
 }
 
index 7797e95..a315b2b 100644 (file)
@@ -729,7 +729,7 @@ init_default_settings (ModestConf *conf)
 
        /* Editor keys */
        if (!modest_conf_key_exists (conf, MODEST_CONF_SHOW_CC, NULL))
-               modest_conf_set_bool (conf, MODEST_CONF_SHOW_CC, TRUE, NULL);
+               modest_conf_set_bool (conf, MODEST_CONF_SHOW_CC, FALSE, NULL);
 
        if (!modest_conf_key_exists (conf, MODEST_CONF_SHOW_BCC, NULL))
                modest_conf_set_bool (conf, MODEST_CONF_SHOW_BCC, FALSE, NULL);
index 1ca4450..720e668 100644 (file)
@@ -180,7 +180,7 @@ on_finalize_foreach(gpointer op,
        g_signal_handlers_disconnect_by_func (mail_op, G_CALLBACK (on_operation_finished), user_data);
 
        MODEST_DEBUG_BLOCK (print_queue_item (mail_op, "cancel/remove"););
-       
+
        modest_mail_operation_cancel (mail_op);
        g_queue_remove (priv->op_queue, mail_op);
        g_object_unref (G_OBJECT (mail_op));
@@ -245,7 +245,7 @@ modest_mail_operation_queue_add (ModestMailOperationQueue *self,
 
        g_return_if_fail (MODEST_IS_MAIL_OPERATION_QUEUE (self));
        g_return_if_fail (MODEST_IS_MAIL_OPERATION (mail_op));
-       
+
        priv = MODEST_MAIL_OPERATION_QUEUE_GET_PRIVATE(self);
 
        priv->running_final_sync = (modest_mail_operation_get_type_operation (mail_op) == MODEST_MAIL_OPERATION_TYPE_SHUTDOWN);
@@ -253,7 +253,7 @@ modest_mail_operation_queue_add (ModestMailOperationQueue *self,
        g_mutex_lock (priv->queue_lock);
        g_queue_push_tail (priv->op_queue, g_object_ref (mail_op));
        g_mutex_unlock (priv->queue_lock);
-       
+
        MODEST_DEBUG_BLOCK (print_queue_item (mail_op, "add"););
 
        /* Get notified when the operation ends to remove it from the
@@ -302,7 +302,7 @@ notify_queue_empty (gpointer user_data)
 }
 
 
-void 
+void
 modest_mail_operation_queue_remove (ModestMailOperationQueue *self,
                                    ModestMailOperation *mail_op)
 {
@@ -367,14 +367,14 @@ modest_mail_operation_queue_remove (ModestMailOperationQueue *self,
        }
 }
 
-guint 
+guint
 modest_mail_operation_queue_num_elements (ModestMailOperationQueue *self)
 {
        ModestMailOperationQueuePrivate *priv;
        guint length = 0;
 
        g_return_val_if_fail (MODEST_IS_MAIL_OPERATION_QUEUE (self), 0);
-       
+
        priv = MODEST_MAIL_OPERATION_QUEUE_GET_PRIVATE(self);
 
        g_mutex_lock (priv->queue_lock);
@@ -513,7 +513,7 @@ modest_mail_operation_queue_to_string (ModestMailOperationQueue *self)
                g_queue_foreach (priv->op_queue, (GFunc)accumulate_mail_op_strings, &str);
                g_mutex_unlock (priv->queue_lock);
        }
-               
+
        return str;
 }
 
@@ -521,9 +521,9 @@ gboolean
 modest_mail_operation_queue_running_shutdown (ModestMailOperationQueue *self)
 {
        ModestMailOperationQueuePrivate *priv;
-       
+
        g_return_val_if_fail (MODEST_IS_MAIL_OPERATION_QUEUE (self), FALSE);
-       
+
        priv = MODEST_MAIL_OPERATION_QUEUE_GET_PRIVATE(self);
        return priv->running_final_sync;
 }
@@ -532,9 +532,9 @@ void
 modest_mail_operation_queue_set_running_shutdown (ModestMailOperationQueue *self)
 {
        ModestMailOperationQueuePrivate *priv;
-       
+
        g_return_if_fail (MODEST_IS_MAIL_OPERATION_QUEUE (self));
-       
+
        priv = MODEST_MAIL_OPERATION_QUEUE_GET_PRIVATE(self);
        priv->running_final_sync = TRUE;
 }
index 19cebd6..f84edf3 100644 (file)
 #include <gdk/gdk.h>
 #include <string.h>
 #include <glib.h>
-#include <modest-runtime.h>
-#include <modest-init.h>
+#include "modest-runtime.h"
+#include "modest-init.h"
 #include "modest-platform.h"
 #include "modest-ui-actions.h"
-#include <widgets/modest-main-window.h>
 
 typedef struct {
        gulong queue_handler;
@@ -57,18 +56,18 @@ on_idle_exit_modest (gpointer data)
 
                /* Disconnect signals. Will be freed by the destroy notify */
                handlers = (MainSignalHandlers *) data;
-               g_signal_handler_disconnect (modest_runtime_get_mail_operation_queue (), 
+               g_signal_handler_disconnect (modest_runtime_get_mail_operation_queue (),
                                             handlers->queue_handler);
-               g_signal_handler_disconnect (modest_runtime_get_window_mgr (), 
+               g_signal_handler_disconnect (modest_runtime_get_window_mgr (),
                                             handlers->window_list_handler);
-               g_signal_handler_disconnect (modest_runtime_get_account_store (), 
-                                            handlers->get_password_handler);           
+               g_signal_handler_disconnect (modest_runtime_get_account_store (),
+                                            handlers->get_password_handler);
                g_free (handlers);
 
                /* Wait for remaining tasks */
                while (gtk_events_pending ())
                        gtk_main_iteration ();
-               
+
                gtk_main_quit ();
        } else {
                ModestMailOperation *mail_op;
@@ -77,7 +76,7 @@ on_idle_exit_modest (gpointer data)
                modest_mail_operation_shutdown (mail_op, modest_runtime_get_account_store ());
                g_object_unref (mail_op);
        }
-               
+
        gdk_threads_leave ();
 
        return FALSE;
@@ -92,7 +91,7 @@ on_queue_empty (ModestMailOperationQueue *queue,
        /* Exit if the queue is empty and there are no more
           windows. We can exit as well if the main window is hidden
           and it's the only one */
-       if (modest_window_mgr_num_windows (mgr) == 0)
+       if (modest_window_mgr_get_num_windows (mgr) == 0)
                g_idle_add_full (G_PRIORITY_LOW, on_idle_exit_modest, user_data, NULL);
 }
 
@@ -110,9 +109,9 @@ on_window_list_empty (ModestWindowMgr *window_mgr,
 int
 main (int argc, char *argv[])
 {
-       /* Usually we don't show the application at first, 
-        * because we wait for the top_application D-Bus method to 
-        * be called. But that's annoying when starting from the 
+       /* Usually we don't show the application at first,
+        * because we wait for the top_application D-Bus method to
+        * be called. But that's annoying when starting from the
         * command line.: */
        gboolean show_ui_without_top_application_method = FALSE;
        int retval  = 0;
@@ -125,8 +124,8 @@ main (int argc, char *argv[])
 
        if (!show_ui_without_top_application_method) {
                g_print ("modest: use 'modest showui' to start from cmdline  with UI\n");
-       }       
-               
+       }
+
        if (!g_thread_supported())
                g_thread_init (NULL);
 
@@ -138,7 +137,7 @@ main (int argc, char *argv[])
                retval = 1;
                goto cleanup;
        }
-       
+
        if (!gtk_init_check (&argc, &argv)) {
                g_printerr ("modest: failed to initialize gtk\n");
                retval = 1;
@@ -153,21 +152,21 @@ main (int argc, char *argv[])
 
        handlers = g_malloc0 (sizeof (MainSignalHandlers));
        /* Connect to the "queue-emtpy" signal */
-       handlers->queue_handler = 
+       handlers->queue_handler =
                g_signal_connect (modest_runtime_get_mail_operation_queue (),
                                  "queue-empty",
                                  G_CALLBACK (on_queue_empty),
                                  handlers);
 
        /* Connect to the "window-list-emtpy" signal */
-       handlers->window_list_handler = 
+       handlers->window_list_handler =
                g_signal_connect (modest_runtime_get_window_mgr (),
                                  "window-list-empty",
                                  G_CALLBACK (on_window_list_empty),
                                  handlers);
 
        /* Connect to the "password-requested" signal */
-       handlers->get_password_handler = 
+       handlers->get_password_handler =
                g_signal_connect (modest_runtime_get_account_store (),
                                  "password_requested",
                                  G_CALLBACK (modest_ui_actions_on_password_requested),
@@ -180,21 +179,20 @@ 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;
+               ModestWindowMgr *mgr;
 
-               /* this will create & register the window */
-               main_win = modest_window_mgr_get_main_window (modest_runtime_get_window_mgr(), 
-                                                             TRUE);
-               if (!main_win) {
+               mgr = modest_runtime_get_window_mgr();
+               window = modest_window_mgr_show_initial_window (mgr);
+               if (!window) {
                        g_printerr ("modest: failed to get main window instance\n");
                        retval = 1;
                        goto cleanup;
                }
-       
                /* Remove new mail notifications if exist */
                modest_platform_remove_new_mail_notifications (FALSE);
        }
-       
+
        gtk_main ();
 
 cleanup:
index 4ca7a82..060ea05 100644 (file)
@@ -11,3 +11,4 @@ VOID:POINTER,INT
 BOOL:STRING
 BOOL:STRING,OBJECT
 BOOL:ENUM,BOOL
+BOOL:ENUM
index a037467..d000ae2 100644 (file)
@@ -49,11 +49,13 @@ typedef enum _ModestConnectedVia {
        MODEST_CONNECTED_VIA_ANY,
 } ModestConnectedVia;
 
+#define MODEST_GTK_RESPONSE_NEW_FOLDER 1
+
 /**
  * modest_platform_platform_init:
  *
  * platform specific initialization function
- * 
+ *
  * Returns: TRUE if succeeded, FALSE otherwise
  */
 gboolean modest_platform_init (int argc, char *argv[]);
@@ -505,7 +507,7 @@ gboolean modest_platform_check_memory_low (ModestWindow *win,
  * modest_platform_run_folder_details_dialog:
  * @parent_window: the parent #GtkWindow for the new dialog
  * @folder: the #TnyFolder whose details will be shown
- * 
+ *
  * Shows the folder details dialog
  **/
 void     modest_platform_run_folder_details_dialog (GtkWindow *parent_window,
@@ -515,12 +517,21 @@ void     modest_platform_run_folder_details_dialog (GtkWindow *parent_window,
  * modest_platform_run_header_details_dialog:
  * @parent_window: the parent #GtkWindow for the new dialog
  * @header: the #TnyHeader whose details will be shown
- * 
+ *
  * Shows the header details dialog
  **/
 void     modest_platform_run_header_details_dialog (GtkWindow *parent_window,
                                                    TnyHeader *header);
 
+/**
+ * modest_platform_on_runtime_initialized:
+ *
+ * This function will be used by platforms to connect objects between
+ * themselves once all the singletons have been created. So this
+ * function MUST be called *before* modest_init
+ **/
+void     modest_platform_on_runtime_initialized ();
+
 #ifndef MODEST_TOOLKIT_GTK
 /**
  * modest_platform_get_osso_context:
@@ -534,7 +545,11 @@ osso_context_t *modest_platform_get_osso_context (void);
 
 
 
+GtkWidget* modest_platform_create_move_to_dialog (GtkWindow *parent_window,
+                                                 GtkWidget **folder_view);
+
+TnyList* modest_platform_get_list_to_move (ModestWindow *window);
+
 G_END_DECLS
 
 #endif /* __MODEST_PLATFORM_UTILS_H__ */
-
index 2097db5..890b8db 100644 (file)
@@ -69,13 +69,13 @@ modest_runtime_init (void)
                g_printerr ("modest: modest_runtime_init can only be run once\n");
                return FALSE;
        }
-       
+
        _singletons = modest_singletons_new ();
        if (!_singletons) {
                g_printerr ("modest: failed to create singletons\n");
                return FALSE;
        }
-       
+
        return TRUE;
 }
 
@@ -143,9 +143,10 @@ modest_runtime_get_email_clipboard   (void)
 ModestTnyAccountStore*
 modest_runtime_get_account_store   (void)
 {
-       // we get the account store here instead of in Singletons
-        // as it leads to various chicken & problems with initialization
-       g_return_val_if_fail (_singletons, NULL);       
+       g_return_val_if_fail (_singletons, NULL);
+       /* we get the account store here instead of in Singletons as
+          it leads to various chicken & egg problems with
+          initialization */
        if (!_account_store) {
                _account_store  = modest_tny_account_store_new (modest_runtime_get_account_mgr(),
                                                                modest_runtime_get_device());
index c2177d8..c07baf2 100644 (file)
@@ -66,7 +66,7 @@ typedef enum {
  * environment, instantiates singletons and so on)
  * modest_runtime_init should only be called once, and
  * when done with it, modest_runtime_uninit should be called
- *  
+ *
  * TRUE if this succeeded, FALSE otherwise.
  */
 gboolean modest_runtime_init (void);
@@ -81,10 +81,10 @@ gboolean modest_runtime_init (void);
  * TRUE if this succeeded, FALSE otherwise
  */
 gboolean modest_runtime_uninit (void);
-       
+
 
 /**
- * modest_runtime_get_debug_flags 
+ * modest_runtime_get_debug_flags
  *
  * get the debug flags for modest; they are read from the MODEST_DEBUG
  * environment variable; the flags specified as strings, separated by ':'.
index 5aa8860..d228e17 100644 (file)
@@ -626,8 +626,17 @@ modest_text_utils_split_addresses_list (const gchar *addresses)
        /* nope, we are at the start of some address
         * now, let's find the end of the address */
        end = my_addrs + 1;
-       while (end[0] && end[0] != ',' && end[0] != ';')
+       while (end[0] && end[0] != ';') {
+               if (end[0] == '\"') {
+                       while (end[0] && end[0] != '\"')
+                               ++end;
+               }
+               if ((end[0] && end[0] == '>')&&(end[1] && end[1] == ',')) {
+                       ++end;
+                       break;
+               }
                ++end;
+       }
 
        /* we got the address; copy it and remove trailing whitespace */
        addr = g_strndup (my_addrs, end - my_addrs);
@@ -1351,10 +1360,11 @@ modest_text_utils_get_display_date (time_t date)
 
        /* if it's today, show the time, if it's not today, show the date instead */
 
+       /* TODO: take into account the system config for 24/12h */
        if (day == date_day) /* is the date today? */
-               modest_text_utils_strftime (date_buf, DATE_BUF_SIZE, "%X", date);
+               modest_text_utils_strftime (date_buf, DATE_BUF_SIZE, _HL("wdgt_va_24h_time"), date);
        else 
-               modest_text_utils_strftime (date_buf, DATE_BUF_SIZE, "%x", date); 
+               modest_text_utils_strftime (date_buf, DATE_BUF_SIZE, _HL("wdgt_va_date"), date); 
 
        return date_buf; /* this is a static buffer, don't free! */
 }
index e7c9886..4d88938 100644 (file)
@@ -116,7 +116,7 @@ static void    connection_status_changed   (TnyAccount *account,
                                            TnyConnectionStatus status, 
                                            gpointer data);
 
-static gboolean only_local_accounts        (ModestTnyAccountStore *self);
+static inline gboolean only_local_accounts        (ModestTnyAccountStore *self);
 
 /* list my signals */
 enum {
@@ -1716,27 +1716,10 @@ insert_account (ModestTnyAccountStore *self,
        g_object_unref (transport_account);
 }
 
-static gboolean
+static inline gboolean
 only_local_accounts (ModestTnyAccountStore *self)
 {
-       ModestTnyAccountStorePrivate *priv = NULL;
-       gboolean only_local = TRUE;
-       TnyIterator *iter;
-
-       /* Check if this is the first remote account we add */
-       priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE (self);
-       iter = tny_list_create_iterator (priv->store_accounts);
-
-       while (!tny_iterator_is_done (iter) && only_local) {
-               TnyAccount *account = (TnyAccount *) tny_iterator_get_current (iter);
-               if (modest_tny_folder_store_is_remote (TNY_FOLDER_STORE (account)))
-                       only_local = FALSE;
-               g_object_unref (account);
-               tny_iterator_next (iter);
-       }
-       g_object_unref (iter);
-
-       return only_local;
+       return (modest_tny_account_store_get_num_remote_accounts (self) > 0) ? FALSE : TRUE;
 }
 
 static void
@@ -2257,3 +2240,25 @@ modest_tny_account_store_set_send_mail_blocked (ModestTnyAccountStore *self,
 
        priv->send_mail_blocked = blocked;
 }
+
+static void
+count_remote_accounts (gpointer data, gpointer user_data)
+{
+       TnyFolderStore *account = TNY_FOLDER_STORE (data);
+       gint *count = (gint *) user_data;
+
+       if (modest_tny_folder_store_is_remote (account))
+               (*count)++;
+}
+
+guint
+modest_tny_account_store_get_num_remote_accounts (ModestTnyAccountStore *self)
+{
+       ModestTnyAccountStorePrivate *priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE (self);
+       gint count = 0;
+
+       /* Count remote accounts */
+       tny_list_foreach (priv->store_accounts, (GFunc) count_remote_accounts, &count);
+
+       return count;
+}
index 8031fe5..239deb4 100644 (file)
@@ -271,6 +271,7 @@ gboolean modest_tny_account_store_is_send_mail_blocked (ModestTnyAccountStore *s
  */
 void modest_tny_account_store_set_send_mail_blocked (ModestTnyAccountStore *self, gboolean blocked);
 
+guint modest_tny_account_store_get_num_remote_accounts (ModestTnyAccountStore *self);
 
 G_END_DECLS
 
index a62aaaf..518816e 100644 (file)
@@ -49,7 +49,9 @@
 #include <tny-camel-imap-folder.h>
 #include <tny-camel-pop-folder.h>
 #ifdef MODEST_TOOLKIT_HILDON2
+#include <modest-accounts-window.h>
 #include <hildon/hildon-pannable-area.h>
+#include <hildon/hildon-gtk.h>
 #include <modest-header-window.h>
 #endif
 
 #include "modest-account-mgr-helpers.h"
 #include "modest-mail-operation.h"
 #include "modest-text-utils.h"
-
-#ifdef MODEST_HAVE_EASYSETUP
-#ifdef MODEST_TOOLKIT_HILDON2
-#include "modest-easysetup-wizard-dialog.h"
-#else
-#include "easysetup/modest-easysetup-wizard-dialog.h"
-#endif
-#endif /* MODEST_HAVE_EASYSETUP */
-
 #include <modest-widget-memory.h>
 #include <tny-error.h>
 #include <tny-simple-list.h>
@@ -92,8 +85,7 @@
 #include <gtkhtml/gtkhtml.h>
 
 #define MIN_FREE_SPACE 5 * 1024 * 1024
-#define MOVE_FOLDER_OK_BUTTON "ok-button"
-#define MOVE_FOLDER_NEW_BUTTON "new-button"
+#define MODEST_MOVE_TO_DIALOG_FOLDER_VIEW "move-to-dialog-folder-view"
 
 typedef struct _GetMsgAsyncHelper {    
        ModestWindow *window;
@@ -128,6 +120,10 @@ typedef struct _PasteAsAttachmentHelper {
        GtkWidget *banner;
 } PasteAsAttachmentHelper;
 
+typedef struct {
+       TnyList *list;
+       ModestWindow *win;
+} MoveToInfo;
 
 /*
  * The do_headers_action uses this kind of functions to perform some
@@ -174,10 +170,18 @@ static void     do_create_folder (GtkWindow *window,
                                  TnyFolderStore *parent_folder, 
                                  const gchar *suggested_name);
 
-static GtkWidget* get_folder_view_from_move_to_dialog (GtkWidget *move_to_dialog);
-
 static TnyAccount *get_account_from_folder_store (TnyFolderStore *folder_store);
 
+static void modest_ui_actions_on_main_window_move_to (GtkAction *action,
+                                                     GtkWidget *folder_view,
+                                                     TnyFolderStore *dst_folder,
+                                                     ModestMainWindow *win);
+
+static void modest_ui_actions_on_window_move_to (GtkAction *action,
+                                                TnyList *list_to_move,
+                                                TnyFolderStore *dst_folder,
+                                                ModestWindow *win);
+
 /*
  * This function checks whether a TnyFolderStore is a pop account
  */
@@ -308,6 +312,13 @@ get_selected_headers (ModestWindow *win)
 
                return list;
 
+#ifdef MODEST_TOOLKIT_HILDON2
+       } else if (MODEST_IS_HEADER_WINDOW (win)) {
+               GtkWidget *header_view;
+
+               header_view = GTK_WIDGET (modest_header_window_get_header_view (MODEST_HEADER_WINDOW (win)));
+               return modest_header_view_get_selected_headers (MODEST_HEADER_VIEW(header_view));
+#endif
        } else
                return NULL;
 }
@@ -388,6 +399,12 @@ modest_ui_actions_refresh_message_window_after_delete (ModestMsgViewWindow* win)
 void
 modest_ui_actions_on_delete_message (GtkAction *action, ModestWindow *win)
 {
+       modest_ui_actions_on_edit_mode_delete_message (win);
+}
+
+gboolean
+modest_ui_actions_on_edit_mode_delete_message (ModestWindow *win)
+{
        TnyList *header_list = NULL;
        TnyIterator *iter = NULL;
        TnyHeader *header = NULL;
@@ -396,8 +413,9 @@ modest_ui_actions_on_delete_message (GtkAction *action, ModestWindow *win)
        gint response;
        ModestWindowMgr *mgr;
        GtkWidget *header_view = NULL;
+       gboolean retval = TRUE;
 
-       g_return_if_fail (MODEST_IS_WINDOW(win));
+       g_return_val_if_fail (MODEST_IS_WINDOW(win), FALSE);
        
        /* Check first if the header view has the focus */
        if (MODEST_IS_MAIN_WINDOW (win)) {
@@ -405,13 +423,13 @@ modest_ui_actions_on_delete_message (GtkAction *action, ModestWindow *win)
                        modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (win),
                                                             MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW);
                if (!gtk_widget_is_focus (header_view))
-                       return;
+                       return FALSE;
        }
        
        /* Get the headers, either from the header view (if win is the main window),
         * or from the message view window: */
        header_list = get_selected_headers (win);
-       if (!header_list) return;
+       if (!header_list) return FALSE;
                        
        /* Check if any of the headers are already opened, or in the process of being opened */
        if (MODEST_IS_MAIN_WINDOW (win)) {
@@ -440,7 +458,7 @@ modest_ui_actions_on_delete_message (GtkAction *action, ModestWindow *win)
                        
                        g_free (msg);
                        g_object_unref (header_list);
-                       return;
+                       return FALSE;
                }
        }
 
@@ -521,7 +539,7 @@ modest_ui_actions_on_delete_message (GtkAction *action, ModestWindow *win)
                        /* Get main window */
                        mgr = modest_runtime_get_window_mgr ();
                        main_window = modest_window_mgr_get_main_window (mgr, FALSE); /* don't create */
-               } else {                        
+               } else if (MODEST_IS_MAIN_WINDOW (win)) {
                        /* Move cursor to next row */
                        main_window = win; 
 
@@ -553,12 +571,17 @@ modest_ui_actions_on_delete_message (GtkAction *action, ModestWindow *win)
                /* Free */
                g_list_foreach (sel_list, (GFunc) gtk_tree_path_free, NULL);
                g_list_free (sel_list);
+               retval = TRUE;
+       } else {
+               retval = FALSE;
        }
 
        /* Free*/
        g_free(message);
        g_free(desc);
        g_object_unref (header_list);
+
+       return retval;
 }
 
 
@@ -636,9 +659,9 @@ modest_ui_actions_on_close_window (GtkAction *action, ModestWindow *win)
 void
 modest_ui_actions_add_to_contacts (GtkAction *action, ModestWindow *win)
 {
-       g_return_if_fail (MODEST_IS_MSG_VIEW_WINDOW (win));
-
-       modest_msg_view_window_add_to_contacts (MODEST_MSG_VIEW_WINDOW (win));
+       g_return_if_fail (MODEST_IS_MSG_VIEW_WINDOW (win));
+       
+       modest_msg_view_window_add_to_contacts (MODEST_MSG_VIEW_WINDOW (win));
 }
 
 void
@@ -661,19 +684,19 @@ modest_ui_actions_on_add_to_contacts (GtkAction *action, ModestWindow *win)
 }
 
 void
-modest_ui_actions_on_accounts (GtkAction *action, 
+modest_ui_actions_on_accounts (GtkAction *action,
                               ModestWindow *win)
 {
        /* This is currently only implemented for Maemo */
        if (!modest_account_mgr_has_accounts (modest_runtime_get_account_mgr(), TRUE)) {
-               if (!modest_ui_actions_run_account_setup_wizard (win)) 
+               if (!modest_ui_actions_run_account_setup_wizard (win))
                        g_debug ("%s: wizard was already running", __FUNCTION__);
-               
+
                return;
        } else {
                /* Show the list of accounts */
                GtkWindow *account_win = GTK_WINDOW (modest_account_view_window_new ());
-               
+
                /* The accounts dialog must be modal */
                modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (account_win), (GtkWindow *) win);
                modest_utils_show_dialog_and_forget (GTK_WINDOW (win), GTK_DIALOG (account_win)); 
@@ -688,7 +711,7 @@ modest_ui_actions_on_smtp_servers (GtkAction *action, ModestWindow *win)
         * possiblities.
         */
 #ifndef MODEST_TOOLKIT_GTK /* Defined in config.h */
-       
+
        /* Create the window if necessary: */
        GtkWidget *specific_window = GTK_WIDGET (modest_connection_specific_smtp_window_new ());
        modest_connection_specific_smtp_window_fill_with_connections (
@@ -945,12 +968,19 @@ get_info_from_header (TnyHeader *header, gboolean *is_draft)
                        if (TNY_IS_SEND_QUEUE (send_queue)) {
                                msg_id = modest_tny_send_queue_get_msg_id (header);
                                status = modest_tny_send_queue_get_msg_status(send_queue, msg_id);
-                               g_free(msg_id);
-
+                               g_free (msg_id);
                                /* Only open messages in outbox with the editor if they are in Failed state */
                                if (status == MODEST_TNY_SEND_QUEUE_FAILED) {
                                        *is_draft = TRUE;
                                }
+#ifdef MODEST_TOOLKIT_HILDON2
+                               else {
+                                       /* In Fremantle we can not
+                                          open any message from
+                                          outbox which is not in
+                                          failed state */
+                                       g_object_unref(traccount);
+                                }
 #endif
                        }
                        g_object_unref(traccount);
@@ -999,7 +1029,7 @@ open_msg_cb (ModestMailOperation *mail_op,
                account = g_strdup (modest_window_get_active_account (MODEST_WINDOW (parent_win)));
        if (!account)
                account = modest_account_mgr_get_default_account (modest_runtime_get_account_mgr());
-
+       
        if (open_in_editor) {
                ModestAccountMgr *mgr = modest_runtime_get_account_mgr ();
                gchar *from_header = NULL, *acc_name;
@@ -1035,7 +1065,7 @@ open_msg_cb (ModestMailOperation *mail_op,
                }
                g_free (uid);
        }
-
+       
        /* Register and show new window */
        if (win != NULL) {
                mgr = modest_runtime_get_window_mgr ();
@@ -1627,6 +1657,7 @@ reply_forward_cb (ModestMailOperation *mail_op,
        mgr = modest_runtime_get_window_mgr ();
        modest_window_mgr_register_window (mgr, msg_win, (ModestWindow *) rf_helper->parent_window);
 
+       /* Note that register_window could have deleted the account */
        if (MODEST_IS_WINDOW (rf_helper->parent_window)) {
                gdouble parent_zoom;
 
@@ -1941,21 +1972,27 @@ void
 modest_ui_actions_on_sort (GtkAction *action, 
                           ModestWindow *window)
 {
+       GtkWidget *header_view = NULL;
+
        g_return_if_fail (MODEST_IS_WINDOW(window));
 
        if (MODEST_IS_MAIN_WINDOW (window)) {
-               GtkWidget *header_view;
                header_view = modest_main_window_get_child_widget (MODEST_MAIN_WINDOW(window),
                                                                   MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW);
-               if (!header_view) {
-                       modest_platform_information_banner (NULL, NULL, _CS("ckdg_ib_nothing_to_sort"));
-
-                       return;
-               }
+#ifdef MODEST_TOOLKIT_HILDON2
+       } else if (MODEST_IS_HEADER_WINDOW (window)) {
+               header_view = GTK_WIDGET (modest_header_window_get_header_view (MODEST_HEADER_WINDOW (window)));
+#endif
+       }
 
-               /* Show sorting dialog */
-               modest_utils_run_sort_dialog (GTK_WINDOW (window), MODEST_SORT_HEADERS);        
+       if (!header_view) {
+               modest_platform_information_banner (NULL, NULL, _CS("ckdg_ib_nothing_to_sort"));
+               
+               return;
        }
+
+       /* Show sorting dialog */
+       modest_utils_run_sort_dialog (GTK_WINDOW (window), MODEST_SORT_HEADERS);        
 }
 
 static void
@@ -2250,11 +2287,20 @@ 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);
+#ifdef MODEST_TOOLKIT_HILDON2
+       } else if (MODEST_IS_ACCOUNTS_WINDOW (win)) {
+               modest_ui_actions_do_send_receive_all (win, TRUE, TRUE, TRUE);
+#endif
+       } 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);
 }
 
 
@@ -2495,6 +2541,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);
                        
@@ -2599,7 +2646,7 @@ modest_ui_actions_on_msg_link_contextual (ModestMsgView *msgview, const gchar* l
 void
 modest_ui_actions_on_msg_attachment_clicked (ModestMsgView *msgview, TnyMimePart *mime_part,
                                             ModestWindow *win)
-{              
+{
        /* we check for low-mem; in that case, show a warning, and don't allow
         * viewing attachments
         */
@@ -2623,6 +2670,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
@@ -2635,6 +2685,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);
 
@@ -3173,7 +3224,7 @@ do_create_folder_cb (ModestMailOperation *mail_op,
 #endif
        } else {
                /* the 'source_win' is either the ModestMainWindow, or the 'Move to folder'-dialog
-                * FIXME: any other? */         
+                * FIXME: any other? */
                GtkWidget *folder_view;
 
                if (MODEST_IS_MAIN_WINDOW(source_win)) 
@@ -3181,9 +3232,9 @@ do_create_folder_cb (ModestMailOperation *mail_op,
                                modest_main_window_get_child_widget (MODEST_MAIN_WINDOW (source_win),
                                                                     MODEST_MAIN_WINDOW_WIDGET_TYPE_FOLDER_VIEW);
                else
-                       folder_view =
-                               get_folder_view_from_move_to_dialog (GTK_WIDGET(source_win));
-               
+                       folder_view = GTK_WIDGET(g_object_get_data (G_OBJECT (source_win),
+                                                                   MODEST_MOVE_TO_DIALOG_FOLDER_VIEW));
+
                /* Select the newly created folder. It could happen
                   that the widget is no longer there (i.e. the window
                   has been destroyed, so we need to check this */
@@ -4502,13 +4553,7 @@ modest_ui_actions_on_check_names (GtkAction *action, ModestMsgEditWindow *window
        modest_msg_edit_window_check_names (window, FALSE);
 }
 
-static void
-create_move_to_dialog_on_new_folder(GtkWidget *button, gpointer user_data)
-{
-       modest_ui_actions_create_folder (gtk_widget_get_toplevel (button),
-                                        GTK_WIDGET (user_data));
-}
-
+#ifndef MODEST_TOOLKIT_HILDON2
 /*
  * This function is used to track changes in the selection of the
  * folder view that is inside the "move to" dialog to enable/disable
@@ -4524,7 +4569,6 @@ on_move_to_dialog_folder_selection_changed (ModestFolderView* self,
                                            gpointer user_data)
 {
        GtkWidget *dialog = NULL;
-       GtkWidget *ok_button = NULL, *new_button = NULL;
        gboolean ok_sensitive = TRUE, new_sensitive = TRUE;
        gboolean moving_folder = FALSE;
        gboolean is_local_account = TRUE;
@@ -4532,18 +4576,14 @@ on_move_to_dialog_folder_selection_changed (ModestFolderView* self,
        ModestTnyFolderRules rules;
 
        g_return_if_fail (MODEST_IS_FOLDER_VIEW(self));
-       
+
        if (!selected)
                return;
-       
-       /* Get the OK button */
+
        dialog = gtk_widget_get_ancestor (GTK_WIDGET (self), GTK_TYPE_DIALOG);
        if (!dialog)
                return;
 
-       ok_button = g_object_get_data (G_OBJECT (dialog), MOVE_FOLDER_OK_BUTTON);
-       new_button = g_object_get_data (G_OBJECT (dialog), MOVE_FOLDER_NEW_BUTTON);
-
        /* check if folder_store is an remote account */
        if (TNY_IS_ACCOUNT (folder_store)) {
                TnyAccount *local_account = NULL;
@@ -4599,21 +4639,21 @@ on_move_to_dialog_folder_selection_changed (ModestFolderView* self,
 
                /* Get the folder to move */
                moved_folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
-               
+
                /* Check that we're not moving to the same folder */
                if (TNY_IS_FOLDER (moved_folder)) {
                        parent = tny_folder_get_folder_store (TNY_FOLDER (moved_folder));
                        if (parent == folder_store)
                                ok_sensitive = FALSE;
                        g_object_unref (parent);
-               } 
+               }
 
                if (ok_sensitive && TNY_IS_ACCOUNT (folder_store)) {
                        /* Do not allow to move to an account unless it's the
                           local folders account */
                        if (!is_local_account)
                                ok_sensitive = FALSE;
-               } 
+               }
 
                if (ok_sensitive && (moved_folder == folder_store)) {
                        /* Do not allow to move to itself */
@@ -4654,94 +4694,82 @@ on_move_to_dialog_folder_selection_changed (ModestFolderView* self,
        }
 
  end:
-       /* Set sensitivity of the OK button */
-       gtk_widget_set_sensitive (ok_button, ok_sensitive);
-       /* Set sensitivity of the NEW button */
-       gtk_widget_set_sensitive (new_button, new_sensitive);
+       /* Set sensitivity of the OK and NEW button */
+       gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), GTK_RESPONSE_OK, ok_sensitive);
+       gtk_dialog_set_response_sensitive (GTK_DIALOG (dialog), MODEST_GTK_RESPONSE_NEW_FOLDER, new_sensitive);
 }
+#endif
 
+static void
+on_move_to_dialog_response (GtkDialog *dialog,
+                           gint       response,
+                           gpointer   user_data)
+{
+       GtkWidget *parent_win, *folder_view;
+       MoveToInfo *helper = NULL;
 
-#define MODEST_MOVE_TO_DIALOG_FOLDER_VIEW "move-to-dialog-folder-view"
+       helper = (MoveToInfo *) user_data;
 
-static GtkWidget*
-get_folder_view_from_move_to_dialog (GtkWidget *move_to_dialog)
-{
-       return GTK_WIDGET(g_object_get_data (G_OBJECT(move_to_dialog),
-                                            MODEST_MOVE_TO_DIALOG_FOLDER_VIEW));
+       parent_win = (GtkWidget *) helper->win;
+       folder_view = GTK_WIDGET (g_object_get_data (G_OBJECT (dialog),
+                                                    MODEST_MOVE_TO_DIALOG_FOLDER_VIEW));
+
+       switch (response) {
+               TnyFolderStore *dst_folder;
+
+       case MODEST_GTK_RESPONSE_NEW_FOLDER:
+               modest_ui_actions_create_folder (GTK_WIDGET (dialog), folder_view);
+               return;
+       case GTK_RESPONSE_NONE:
+       case GTK_RESPONSE_CANCEL:
+       case GTK_RESPONSE_DELETE_EVENT:
+               break;
+       case GTK_RESPONSE_OK:
+               dst_folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
+               /* Do window specific stuff */
+               if (MODEST_IS_MAIN_WINDOW (parent_win)) {
+                       modest_ui_actions_on_main_window_move_to (NULL,
+                                                                 folder_view,
+                                                                 dst_folder,
+                                                                 MODEST_MAIN_WINDOW (parent_win));
+               } else {
+                       /* Moving from headers window in edit mode */
+                       modest_ui_actions_on_window_move_to (NULL, helper->list,
+                                                            dst_folder, 
+                                                            MODEST_WINDOW (parent_win));
+               }
+
+               if (dst_folder)
+                       g_object_unref (dst_folder);
+
+               break;
+       default:
+               g_warning ("%s unexpected response id %d", __FUNCTION__, response);
+       }
+
+       /* Free the helper and exit */
+       g_object_unref (helper->list);
+       g_slice_free (MoveToInfo, helper);
+       gtk_widget_destroy (GTK_WIDGET (dialog));
 }
 
 static GtkWidget*
 create_move_to_dialog (GtkWindow *win,
-                      GtkWidget *folder_view,
-                      GtkWidget **tree_view)
+                      GtkWidget *folder_view)
 {
-       GtkWidget *dialog;
-#ifdef MODEST_TOOLKIT_HILDON2
-       GtkWidget *pannable;
-#else
-       GtkWidget *scroll;
-#endif
-       GtkWidget *new_button, *ok_button;
+       GtkWidget *dialog, *tree_view = NULL;
 
-       dialog = gtk_dialog_new_with_buttons (_("mcen_ti_moveto_folders_title"),
-                                             GTK_WINDOW (win),
-                                             GTK_DIALOG_MODAL | GTK_DIALOG_NO_SEPARATOR | GTK_DIALOG_DESTROY_WITH_PARENT,
-                                             NULL);
+       dialog = modest_platform_create_move_to_dialog (win, &tree_view);
 
-#ifndef MODEST_TOOLKIT_GTK
-       ok_button = gtk_dialog_add_button (GTK_DIALOG (dialog), _("mcen_bd_dialog_ok"), GTK_RESPONSE_ACCEPT);
-       /* We do this manually so GTK+ does not associate a response ID for
-        * the button. */
-       new_button = gtk_button_new_from_stock (_("mcen_bd_new"));
-       gtk_box_pack_end (GTK_BOX (GTK_DIALOG (dialog)->action_area), new_button, FALSE, FALSE, 0);
-       gtk_widget_show (new_button);
 #ifndef MODEST_TOOLKIT_HILDON2
-       gtk_dialog_add_button (GTK_DIALOG (dialog), _("mcen_bd_dialog_cancel"), GTK_RESPONSE_REJECT);
-#endif
-#else
-       /* We do this manually so GTK+ does not associate a response ID for
-        * the button. */
-       new_button = gtk_button_new_with_label (_("mcen_ti_new_folder"));
-       gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->action_area), new_button, FALSE, FALSE, 0);
-       gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (GTK_DIALOG (dialog)->action_area), new_button, TRUE);
-       gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT);
-       ok_button = gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_OK, GTK_RESPONSE_ACCEPT);
-       gtk_container_set_border_width (GTK_CONTAINER (dialog), 12);
-       gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 24);
-#endif
-       g_object_set_data (G_OBJECT (dialog), MOVE_FOLDER_OK_BUTTON, ok_button);
-       g_object_set_data (G_OBJECT (dialog), MOVE_FOLDER_NEW_BUTTON, new_button);
-
-       /* Create scrolled window */
-#ifdef MODEST_TOOLKIT_HILDON2
-       pannable = hildon_pannable_area_new ();
-#else
-       scroll = gtk_scrolled_window_new (NULL, NULL);
-       gtk_scrolled_window_set_policy  (GTK_SCROLLED_WINDOW (scroll),
-                                        GTK_POLICY_AUTOMATIC,
-                                        GTK_POLICY_AUTOMATIC);
-#endif
-
-#ifdef MODEST_TOOLKIT_GTK
-       gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scroll), GTK_SHADOW_IN);
-#endif
-
-       /* Create folder view */
-       *tree_view = modest_platform_create_folder_view (NULL);
-
        /* Track changes in the selection to
         * disable the OK button whenever "Move to" is not possible
         * disbale NEW button whenever New is not possible */
-       g_signal_connect (*tree_view,
+       g_signal_connect (tree_view,
                          "folder_selection_changed",
                          G_CALLBACK (on_move_to_dialog_folder_selection_changed),
                          win);
-
-       /* Listen to clicks on New button */
-       g_signal_connect (G_OBJECT (new_button), 
-                         "clicked", 
-                         G_CALLBACK(create_move_to_dialog_on_new_folder), 
-                         *tree_view);
+#endif
 
        /* It could happen that we're trying to move a message from a
           window (msg window for example) after the main window was
@@ -4750,16 +4778,16 @@ create_move_to_dialog (GtkWindow *win,
        if (MODEST_IS_FOLDER_VIEW (folder_view)) {
                const gchar *visible_id = NULL;
 
-               modest_folder_view_set_style (MODEST_FOLDER_VIEW (*tree_view),
+               modest_folder_view_set_style (MODEST_FOLDER_VIEW (tree_view),
                                              MODEST_FOLDER_VIEW_STYLE_SHOW_ALL);
                modest_folder_view_copy_model (MODEST_FOLDER_VIEW(folder_view), 
-                                              MODEST_FOLDER_VIEW(*tree_view));
+                                              MODEST_FOLDER_VIEW(tree_view));
 
                visible_id = 
                        modest_folder_view_get_account_id_of_visible_server_account (MODEST_FOLDER_VIEW(folder_view));
 
                /* Show the same account than the one that is shown in the main window */
-               modest_folder_view_set_account_id_of_visible_server_account (MODEST_FOLDER_VIEW(*tree_view), 
+               modest_folder_view_set_account_id_of_visible_server_account (MODEST_FOLDER_VIEW(tree_view),
                                                                             visible_id);
        } else {
                const gchar *active_account_name = NULL;
@@ -4767,9 +4795,9 @@ create_move_to_dialog (GtkWindow *win,
                ModestAccountSettings *settings = NULL;
                ModestServerAccountSettings *store_settings = NULL;
 
-               modest_folder_view_set_style (MODEST_FOLDER_VIEW (*tree_view),
+               modest_folder_view_set_style (MODEST_FOLDER_VIEW (tree_view),
                                              MODEST_FOLDER_VIEW_STYLE_SHOW_ALL);
-               modest_folder_view_update_model (MODEST_FOLDER_VIEW (*tree_view), 
+               modest_folder_view_update_model (MODEST_FOLDER_VIEW (tree_view),
                                                 TNY_ACCOUNT_STORE (modest_runtime_get_account_store ()));
 
                active_account_name = modest_window_get_active_account (MODEST_WINDOW (win));
@@ -4781,47 +4809,30 @@ create_move_to_dialog (GtkWindow *win,
                        store_settings = modest_account_settings_get_store_settings (settings);
                        store_account_name = modest_server_account_settings_get_account_name (store_settings);
 
-                       modest_folder_view_set_account_id_of_visible_server_account (MODEST_FOLDER_VIEW (*tree_view),
+                       modest_folder_view_set_account_id_of_visible_server_account (MODEST_FOLDER_VIEW (tree_view),
                                                                                     store_account_name);
                        g_object_unref (store_settings);
                        g_object_unref (settings);
                }
        }
 
-       /* we keep a pointer to the embedded folder view, so we can retrieve it with
-        *   get_folder_view_from_move_to_dialog 
-        * (see above) later (needed for focus handling) 
+       /* we keep a pointer to the embedded folder view, so we can
+        *   retrieve it with get_folder_view_from_move_to_dialog (see
+        *   above) later (needed for focus handling)
         */
-       g_object_set_data (G_OBJECT(dialog), MODEST_MOVE_TO_DIALOG_FOLDER_VIEW, *tree_view);
+       g_object_set_data (G_OBJECT(dialog), MODEST_MOVE_TO_DIALOG_FOLDER_VIEW, tree_view);
 
-       
        /* Hide special folders */
-       modest_folder_view_show_non_move_folders (MODEST_FOLDER_VIEW (*tree_view), FALSE);
-
-#ifdef MODEST_TOOLKIT_HILDON2
-       gtk_container_add (GTK_CONTAINER (pannable), *tree_view);
-       gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), 
-                           pannable, TRUE, TRUE, 0);
-#else
-       gtk_container_add (GTK_CONTAINER (scroll), *tree_view);
-       /* Add scroll to dialog */
-       gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), 
-                           scroll, TRUE, TRUE, 0);
+       modest_folder_view_show_non_move_folders (MODEST_FOLDER_VIEW (tree_view), FALSE);
+#ifndef MODEST_TOOLKIT_HILDON2
+       modest_folder_view_select_first_inbox_or_local (MODEST_FOLDER_VIEW (tree_view));
 #endif
 
-
-       gtk_widget_show_all (GTK_WIDGET(GTK_DIALOG(dialog)->vbox));
-#ifndef MODEST_TOOLKIT_GTK
-       gtk_window_set_default_size (GTK_WINDOW (dialog), 300, 300);
-#else
-       gtk_window_set_default_size (GTK_WINDOW (dialog), 600, 400);
-#endif
+       gtk_widget_show (GTK_WIDGET (tree_view));
 
        return dialog;
 }
 
-
-
 /*
  * Shows a confirmation dialog to the user when we're moving messages
  * from a remote server to the local storage. Returns the dialog
@@ -5430,7 +5441,8 @@ modest_ui_actions_on_main_window_move_to (GtkAction *action,
        src_folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (folder_view));
 
        /* Get header view */
-       header_view = MODEST_HEADER_VIEW(modest_main_window_get_child_widget (win, MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW));
+       header_view = (ModestHeaderView *)
+               modest_main_window_get_child_widget (win, MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW);
 
        /* Get folder or messages to transfer */
        if (gtk_widget_is_focus (folder_view)) {
@@ -5446,7 +5458,7 @@ modest_ui_actions_on_main_window_move_to (GtkAction *action,
                        do_xfer = FALSE;
                }
 
-               if (do_xfer) {                  
+               if (do_xfer) {
                        MoveFolderInfo *info = g_new0 (MoveFolderInfo, 1);
                        DoubleConnectionInfo *connect_info = g_slice_new (DoubleConnectionInfo);
 
@@ -5529,44 +5541,45 @@ modest_ui_actions_transfer_messages_helper (GtkWindow *win,
  * UI handler for the "Move to" action when invoked from the
  * ModestMsgViewWindow
  */
-static void 
-modest_ui_actions_on_msg_view_window_move_to (GtkAction *action, 
-                                             TnyFolderStore *dst_folder,
-                                             ModestMsgViewWindow *win)
+static void
+modest_ui_actions_on_window_move_to (GtkAction *action,
+                                    TnyList *headers,
+                                    TnyFolderStore *dst_folder,
+                                    ModestWindow *win)
 {
-       TnyList *headers = NULL;
-       TnyHeader *header = NULL;
        TnyFolder *src_folder = NULL;
 
        g_return_if_fail (TNY_IS_FOLDER (dst_folder));
 
-       /* Create header list */
-       header = modest_msg_view_window_get_header (MODEST_MSG_VIEW_WINDOW (win));
-       src_folder = TNY_FOLDER (tny_header_get_folder(header));
-       headers = tny_simple_list_new ();
-       tny_list_append (headers, G_OBJECT (header));
+       if (headers) {
+               TnyHeader *header = NULL;
+               TnyIterator *iter;
 
-       /* Transfer the messages */
-       modest_ui_actions_transfer_messages_helper (GTK_WINDOW (win), src_folder, headers, 
-                                                   TNY_FOLDER (dst_folder));
+               iter = tny_list_create_iterator (headers);
+               header = (TnyHeader *) tny_iterator_get_current (iter);
+               src_folder = tny_header_get_folder (header);
 
-       /* Frees */
-       g_object_unref (src_folder);
-       g_object_unref (header);
-       g_object_unref (headers);
+               /* Transfer the messages */
+               modest_ui_actions_transfer_messages_helper (GTK_WINDOW (win), src_folder, 
+                                                           headers,
+                                                           TNY_FOLDER (dst_folder));
+
+               /* Frees */
+               g_object_unref (header);
+               g_object_unref (iter);
+               g_object_unref (src_folder);
+       }
 }
 
 void 
 modest_ui_actions_on_move_to (GtkAction *action, 
                              ModestWindow *win)
 {
-       GtkWidget *dialog = NULL, *folder_view = NULL, *tree_view = NULL;
-       gint result = 0;
-       TnyFolderStore *dst_folder = NULL;
+       GtkWidget *dialog = NULL, *folder_view = NULL;
        ModestMainWindow *main_window;
+       MoveToInfo *helper = NULL;
 
-       g_return_if_fail (MODEST_IS_MAIN_WINDOW (win) ||
-                         MODEST_IS_MSG_VIEW_WINDOW (win));
+       g_return_if_fail (MODEST_IS_WINDOW (win));
 
        /* Get the main window if exists */
        if (MODEST_IS_MAIN_WINDOW (win))
@@ -5584,31 +5597,21 @@ modest_ui_actions_on_move_to (GtkAction *action,
                folder_view = NULL;
 
        /* Create and run the dialog */
-       dialog = create_move_to_dialog (GTK_WINDOW (win), folder_view, &tree_view);
-       modest_folder_view_select_first_inbox_or_local (MODEST_FOLDER_VIEW (tree_view));
-       modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), GTK_WINDOW (dialog), (GtkWindow *) win);
-       result = gtk_dialog_run (GTK_DIALOG(dialog));
-       g_object_ref (tree_view);
-       gtk_widget_destroy (dialog);
+       dialog = create_move_to_dialog (GTK_WINDOW (win), folder_view);
+       modest_window_mgr_set_modal (modest_runtime_get_window_mgr (), 
+                                    GTK_WINDOW (dialog), 
+                                    (GtkWindow *) win);
 
-       if (result != GTK_RESPONSE_ACCEPT)
-               return;
+       /* Create helper */
+       helper = g_slice_new0 (MoveToInfo);
+       helper->list = modest_platform_get_list_to_move (MODEST_WINDOW (win));
+       helper->win = win;
 
-       dst_folder = modest_folder_view_get_selected (MODEST_FOLDER_VIEW (tree_view));
-       /* Do window specific stuff */
-       if (MODEST_IS_MAIN_WINDOW (win)) {
-               modest_ui_actions_on_main_window_move_to (action,
-                               folder_view,
-                               dst_folder,
-                               MODEST_MAIN_WINDOW (win));
-       } else {
-               modest_ui_actions_on_msg_view_window_move_to (action,
-                               dst_folder,
-                               MODEST_MSG_VIEW_WINDOW (win));
-       }
+       /* Listen to response signal */
+       g_signal_connect (dialog, "response", G_CALLBACK (on_move_to_dialog_response), helper);
 
-       if (dst_folder)
-               g_object_unref (dst_folder);
+       /* Show the dialog */
+       gtk_widget_show (dialog);
 }
 
 /*
@@ -6198,6 +6201,24 @@ modest_ui_actions_get_msg_already_deleted_error_msg (ModestWindow *win)
                folder = TNY_FOLDER_STORE (tny_header_get_folder (header));
                g_object_unref (iter);
                g_object_unref (headers);
+#ifdef MODEST_TOOLKIT_HILDON2
+       } else if (MODEST_IS_HEADER_WINDOW (win)) {
+               GtkWidget *header_view;
+               TnyList* headers = NULL;
+               TnyIterator *iter;
+               header_view = GTK_WIDGET (modest_header_window_get_header_view (MODEST_HEADER_WINDOW (win)));
+               headers = modest_header_view_get_selected_headers (MODEST_HEADER_VIEW (header_view));
+               if (!headers || tny_list_get_length (headers) == 0) {
+                       if (headers)
+                               g_object_unref (headers);
+                       return NULL;
+               }
+               iter = tny_list_create_iterator (headers);
+               header = TNY_HEADER (tny_iterator_get_current (iter));
+               folder = TNY_FOLDER_STORE (tny_header_get_folder (header));
+               g_object_unref (iter);
+               g_object_unref (headers);
+#endif
        } else if (MODEST_IS_MSG_VIEW_WINDOW (win)) {
                header = modest_msg_view_window_get_header (MODEST_MSG_VIEW_WINDOW (win));
                folder = TNY_FOLDER_STORE (tny_header_get_folder (header));
index 645663a..bc9924d 100644 (file)
@@ -46,6 +46,8 @@ void     modest_ui_actions_refresh_message_window_after_delete (ModestMsgViewWin
 
 void     modest_ui_actions_on_delete_message     (GtkAction *action, ModestWindow *win);
 
+gboolean modest_ui_actions_on_edit_mode_delete_message (ModestWindow *win);
+
 void     modest_ui_actions_on_delete_message_or_folder (GtkAction *action, ModestWindow *win);
 
 void     modest_ui_actions_on_quit          (GtkAction *action, ModestWindow *win);
index 42525ee..377329f 100644 (file)
 #include <tny-simple-list.h>
 #include <widgets/modest-recpt-editor.h>
 #include <gtkhtml/gtkhtml.h>
+#include <modest-runtime.h>
+#ifdef MODEST_TOOLKIT_HILDON2
+#include <modest-header-window.h>
+#endif
 
 
 static gboolean _folder_is_any_of_type (TnyFolder *folder, TnyFolderType types[], guint ntypes);
@@ -75,6 +79,8 @@ static gboolean _invalid_folder_for_purge (ModestWindow *win, ModestDimmingRule
 static gboolean _transfer_mode_enabled (ModestWindow *win);
 static gboolean _selected_folder_has_subfolder_with_same_name (ModestWindow *win);
 static void fill_list_of_caches (gpointer key, gpointer value, gpointer userdata);
+static gboolean _send_receive_in_progress (ModestWindow *win);
+static gboolean _msgs_send_in_progress (void);
 
 
 static DimmedState *
@@ -458,8 +464,31 @@ modest_ui_dimming_rules_on_delete (ModestWindow *win, gpointer user_data)
                    !gtk_widget_is_focus (header_view) &&
                    !gtk_widget_is_focus (folder_view)) {
                        dimmed = TRUE;
-                       modest_dimming_rule_set_notification (rule, dgettext("hildon-common-strings", "ckct_ib_nothing_to_delete"));                    
+                       modest_dimming_rule_set_notification (rule, dgettext("hildon-common-strings", "ckct_ib_nothing_to_delete"));
+               }
+                       
+#ifdef MODEST_TOOLKIT_HILDON2
+       } else if (MODEST_IS_HEADER_WINDOW (win)) {
+
+               if (!dimmed) {
+                       dimmed = _transfer_mode_enabled (win);
+               }
+               if (dimmed)
+                       modest_dimming_rule_set_notification (rule, _("mail_ib_notavailable_downloading"));     
+
+               if (!dimmed) {
+                       GtkWidget *header_view;
+                       TnyFolder *folder;
+
+                       header_view = GTK_WIDGET (modest_header_window_get_header_view (MODEST_HEADER_WINDOW (win)));
+                       folder = modest_header_view_get_folder (MODEST_HEADER_VIEW (header_view));
+                       if (folder) {
+                               dimmed = (tny_folder_get_all_count (TNY_FOLDER (folder)) == 0);
+                               g_object_unref (folder);
+                       }
                }
+
+#endif
        } else {
                dimmed = modest_ui_dimming_rules_on_delete_folder (win, rule);
        }
@@ -517,10 +546,16 @@ modest_ui_dimming_rules_on_sort (ModestWindow *win, gpointer user_data)
        ModestDimmingRule *rule = NULL;
        gboolean dimmed = FALSE;
 
+#ifdef MODEST_TOOLKIT_HILDON2
+       if (MODEST_IS_HEADER_WINDOW (win)) {
+               return FALSE;
+       }
+#endif         
+
        g_return_val_if_fail (MODEST_IS_MAIN_WINDOW(win), FALSE);
        g_return_val_if_fail (MODEST_IS_DIMMING_RULE (user_data), FALSE);
        rule = MODEST_DIMMING_RULE (user_data);
-               
+
        /* Check dimmed rule */ 
        dimmed = _selected_folder_is_root (MODEST_MAIN_WINDOW(win));
 
@@ -855,7 +890,7 @@ modest_ui_dimming_rules_on_details (ModestWindow *win, gpointer user_data)
                        dimmed = _msg_download_in_progress (win);
                if (dimmed)
                        modest_dimming_rule_set_notification (rule, "");                
-               if (!dimmed) {
+               if (!dimmed && MODEST_IS_MSG_VIEW_WINDOW (win)) {
                        if (!modest_msg_view_window_is_search_result (MODEST_MSG_VIEW_WINDOW(win))) {
                                dimmed = !modest_msg_view_window_has_headers_model (MODEST_MSG_VIEW_WINDOW (win));
                        }
@@ -869,6 +904,65 @@ modest_ui_dimming_rules_on_details (ModestWindow *win, gpointer user_data)
 
 
 gboolean 
+modest_ui_dimming_rules_on_mark_as_read_msg_in_view (ModestWindow *win, gpointer user_data)
+{
+       ModestDimmingRule *rule = NULL;
+       TnyHeader *header;
+       TnyHeaderFlags flags;
+       gboolean dimmed = FALSE;
+       
+
+       g_return_val_if_fail (MODEST_IS_MSG_VIEW_WINDOW(win), FALSE);
+       g_return_val_if_fail (MODEST_IS_DIMMING_RULE (user_data), FALSE);
+       rule = MODEST_DIMMING_RULE (user_data);
+       
+       header = modest_msg_view_window_get_header (MODEST_MSG_VIEW_WINDOW (win));
+       if (!header) {
+               dimmed = TRUE;
+       }
+
+       if (!dimmed) {
+               flags = tny_header_get_flags (header);
+               if (flags & TNY_HEADER_FLAG_SEEN)
+                       dimmed = TRUE;
+       }
+
+       if (header)
+               g_object_unref (header);
+       return dimmed;
+}
+
+
+gboolean 
+modest_ui_dimming_rules_on_mark_as_unread_msg_in_view (ModestWindow *win, gpointer user_data)
+{
+       ModestDimmingRule *rule = NULL;
+       TnyHeader *header;
+       TnyHeaderFlags flags;
+       gboolean dimmed = FALSE;
+       
+
+       g_return_val_if_fail (MODEST_IS_MSG_VIEW_WINDOW(win), FALSE);
+       g_return_val_if_fail (MODEST_IS_DIMMING_RULE (user_data), FALSE);
+       rule = MODEST_DIMMING_RULE (user_data);
+       
+       header = modest_msg_view_window_get_header (MODEST_MSG_VIEW_WINDOW (win));
+       if (!header) {
+               dimmed = TRUE;
+       }
+
+       if (!dimmed) {
+               flags = tny_header_get_flags (header);
+               if (!(flags & TNY_HEADER_FLAG_SEEN))
+                       dimmed = TRUE;
+       }
+
+       if (header)
+               g_object_unref (header);
+       return dimmed;
+}
+
+gboolean 
 modest_ui_dimming_rules_on_mark_as_read_msg (ModestWindow *win, gpointer user_data)
 {
        ModestDimmingRule *rule = NULL;
@@ -931,6 +1025,10 @@ modest_ui_dimming_rules_on_move_to (ModestWindow *win, gpointer user_data)
 
        if (MODEST_IS_MAIN_WINDOW (win)) 
                dimmed = modest_ui_dimming_rules_on_main_window_move_to (win, user_data);
+#ifdef MODEST_TOOLKIT_HILDON2
+       else if (MODEST_IS_HEADER_WINDOW (win))
+               dimmed = modest_ui_dimming_rules_on_header_window_move_to (win, user_data);
+#endif
        else if (MODEST_IS_MSG_VIEW_WINDOW (win)) 
                 dimmed = modest_ui_dimming_rules_on_view_window_move_to (win, user_data);
 
@@ -1053,6 +1151,38 @@ modest_ui_dimming_rules_on_view_window_move_to (ModestWindow *win, gpointer user
        return dimmed;
 }
 
+#ifdef MODEST_TOOLKIT_HILDON2
+gboolean 
+modest_ui_dimming_rules_on_header_window_move_to (ModestWindow *win, gpointer user_data)
+{
+       ModestDimmingRule *rule = NULL;
+       gboolean dimmed = FALSE;
+
+       g_return_val_if_fail (MODEST_IS_HEADER_WINDOW(win), FALSE);
+       g_return_val_if_fail (MODEST_IS_DIMMING_RULE (user_data), FALSE);
+       rule = MODEST_DIMMING_RULE (user_data);
+
+       /* Check dimmed rule */ 
+       dimmed = _transfer_mode_enabled (win);                  
+       if (dimmed)
+               modest_dimming_rule_set_notification (rule, _("mail_ib_notavailable_downloading"));     
+
+       if (!dimmed) {
+               GtkWidget *header_view;
+               TnyFolder *folder;
+
+               header_view = GTK_WIDGET (modest_header_window_get_header_view (MODEST_HEADER_WINDOW (win)));
+               folder = modest_header_view_get_folder (MODEST_HEADER_VIEW (header_view));
+               if (folder) {
+                       dimmed = (tny_folder_get_all_count (TNY_FOLDER (folder)) == 0);
+                       g_object_unref (folder);
+               }
+       }
+
+       return dimmed;
+}
+#endif
+
 gboolean 
 modest_ui_dimming_rules_on_find_msg (ModestWindow *win, gpointer user_data)
 {
@@ -1713,6 +1843,14 @@ modest_ui_dimming_rules_on_cancel_sending (ModestWindow *win, gpointer user_data
 }
 
 gboolean 
+modest_ui_dimming_rules_on_cancel_sending_all (ModestWindow *win, gpointer user_data)
+{
+       /* We dim if no msg send is in progress (and then cancelling send all has no
+        * effect */
+       return !_msgs_send_in_progress ();
+}
+
+gboolean 
 modest_ui_dimming_rules_on_send_receive (ModestWindow *win, gpointer user_data)
 {
        ModestDimmingRule *rule = NULL;
@@ -1748,6 +1886,10 @@ modest_ui_dimming_rules_on_send_receive_all (ModestWindow *win, gpointer user_da
        
        modest_account_mgr_free_account_names (account_names);
 
+       if (!dimmed) {
+               dimmed = _send_receive_in_progress (win);
+       }
+
        return dimmed;
 }
 
@@ -1763,6 +1905,11 @@ modest_ui_dimming_rules_on_add_to_contacts (ModestWindow *win, gpointer user_dat
        g_return_val_if_fail (MODEST_IS_MSG_VIEW_WINDOW (win), FALSE);
 
        msg = modest_msg_view_window_get_message (MODEST_MSG_VIEW_WINDOW (win));
+
+       /* Message is loaded asynchronously, so this could happen */
+       if (!msg)
+               return TRUE;
+
        recipients = modest_tny_msg_get_all_recipients_list (msg);
 
        has_recipients_to_add = FALSE;
@@ -2606,6 +2753,10 @@ _transfer_mode_enabled (ModestWindow *win)
                 result = modest_msg_view_window_transfer_mode_enabled (MODEST_MSG_VIEW_WINDOW (win));
         } else if (MODEST_IS_MAIN_WINDOW(win)) {
                 result = modest_main_window_transfer_mode_enabled (MODEST_MAIN_WINDOW (win));
+#ifdef MODEST_TOOLKIT_HILDON2
+       } else if (MODEST_IS_HEADER_WINDOW (win)) {
+               result = modest_header_window_transfer_mode_enabled (MODEST_HEADER_WINDOW (win));
+#endif
         } else {
                 g_warning("_transfer_mode_enabled called with wrong window type");
         }
@@ -2677,3 +2828,60 @@ modest_ui_dimming_rules_on_insert_image (ModestWindow *win,
 
        return (format != MODEST_MSG_EDIT_FORMAT_HTML);
 }
+
+static gboolean 
+_send_receive_in_progress (ModestWindow *win)
+{
+       ModestMailOperationQueue *queue;
+       GSList *op_list, *node;
+       gboolean found_send_receive;
+
+       queue = modest_runtime_get_mail_operation_queue ();
+       op_list = modest_mail_operation_queue_get_by_source (queue, G_OBJECT (win));
+
+       found_send_receive = FALSE;
+       for (node = op_list; node != NULL; node = g_slist_next (node)) {
+               ModestMailOperation *op;
+
+               op = (ModestMailOperation *) node->data;
+               if (modest_mail_operation_get_type_operation (op) == MODEST_MAIL_OPERATION_TYPE_SEND_AND_RECEIVE) {
+                       found_send_receive = TRUE;
+                       break;
+               }
+       }
+
+       g_slist_foreach (op_list, (GFunc) g_object_unref, NULL);
+       g_slist_free (op_list);
+
+       return found_send_receive;
+}
+
+static gboolean
+_msgs_send_in_progress (void)
+{
+       ModestCacheMgr *cache_mgr;
+       GHashTable *send_queue_cache;
+       ModestTnySendQueue *send_queue;
+       GSList *send_queues = NULL, *node = NULL;
+       gboolean found = FALSE;
+
+       cache_mgr = modest_runtime_get_cache_mgr ();
+       send_queue_cache = modest_cache_mgr_get_cache (cache_mgr,
+                                                      MODEST_CACHE_MGR_CACHE_TYPE_SEND_QUEUE);
+       
+       g_hash_table_foreach (send_queue_cache, (GHFunc) fill_list_of_caches, &send_queues);
+               
+       for (node = send_queues; node != NULL && !found; node = g_slist_next (node)) {
+               send_queue = MODEST_TNY_SEND_QUEUE (node->data);
+               
+               /* Check if msg uid is being processed inside send queue */
+               if (modest_tny_send_queue_sending_in_progress (send_queue)) {
+                       found = TRUE;
+                       break;
+               }
+       }
+
+       g_slist_free (send_queues);
+
+       return found;
+}
index 4ab51b8..846a901 100644 (file)
@@ -53,6 +53,8 @@ gboolean modest_ui_dimming_rules_on_reply_msg (ModestWindow *win, gpointer user_
 gboolean modest_ui_dimming_rules_on_contents_msg (ModestWindow *win, gpointer user_data);
 gboolean modest_ui_dimming_rules_always_dimmed (ModestWindow *win, gpointer user_data);
 gboolean modest_ui_dimming_rules_on_details (ModestWindow *win, gpointer user_data);
+gboolean modest_ui_dimming_rules_on_mark_as_read_msg_in_view (ModestWindow *win, gpointer user_data);
+gboolean modest_ui_dimming_rules_on_mark_as_unread_msg_in_view (ModestWindow *win, gpointer user_data);
 gboolean modest_ui_dimming_rules_on_mark_as_read_msg (ModestWindow *win, gpointer user_data);
 gboolean modest_ui_dimming_rules_on_mark_as_unread_msg (ModestWindow *win, gpointer user_data);
 gboolean modest_ui_dimming_rules_on_move_to (ModestWindow *win, gpointer user_data);
@@ -72,6 +74,7 @@ gboolean modest_ui_dimming_rules_on_view_previous (ModestWindow *win, gpointer u
 gboolean modest_ui_dimming_rules_on_view_next (ModestWindow *win, gpointer user_data);
 gboolean modest_ui_dimming_rules_on_tools_smtp_servers (ModestWindow *win, gpointer user_data);
 gboolean modest_ui_dimming_rules_on_cancel_sending (ModestWindow *win, gpointer user_data);
+gboolean modest_ui_dimming_rules_on_cancel_sending_all (ModestWindow *win, gpointer user_data);
 gboolean modest_ui_dimming_rules_on_send_receive (ModestWindow *win, gpointer user_data);
 gboolean modest_ui_dimming_rules_on_send_receive_all (ModestWindow *win, gpointer user_data);
 gboolean modest_ui_dimming_rules_on_add_to_contacts (ModestWindow *win, gpointer user_data);
@@ -84,6 +87,9 @@ gboolean modest_ui_dimming_rules_on_editor_paste (ModestWindow *win, gpointer us
 gboolean modest_ui_dimming_rules_on_editor_paste_show_menu (ModestWindow *win, gpointer user_data);
 gboolean modest_ui_dimming_rules_on_save_to_drafts (ModestWindow *win, gpointer user_data);
 gboolean modest_ui_dimming_rules_on_insert_image (ModestWindow *win, gpointer user_data);
+#ifdef MODEST_TOOLKIT_HILDON2
+gboolean modest_ui_dimming_rules_on_header_window_move_to (ModestWindow *win, gpointer user_data);
+#endif
 
 G_END_DECLS
 #endif 
index 75e056c..415ca73 100644 (file)
@@ -51,6 +51,9 @@
 #include "widgets/modest-main-window.h"
 #include "modest-widget-memory.h"
 #include "widgets/modest-sort-criterium-view.h"
+#ifdef MODEST_TOOLKIT_HILDON2
+#include "modest-header-window.h"
+#endif
 
 GQuark
 modest_utils_get_supported_secure_authentication_error_quark (void)
@@ -587,6 +590,11 @@ launch_sort_headers_dialog (GtkWindow *parent_window,
        if (MODEST_IS_MAIN_WINDOW (parent_window)) {
                header_view = MODEST_HEADER_VIEW(modest_main_window_get_child_widget (MODEST_MAIN_WINDOW(parent_window),
                                                                                      MODEST_MAIN_WINDOW_WIDGET_TYPE_HEADER_VIEW));
+#ifdef MODEST_TOOLKIT_HILDON2
+       } else if (MODEST_IS_HEADER_WINDOW (parent_window)) {
+               header_view = MODEST_HEADER_VIEW (modest_header_window_get_header_view (MODEST_HEADER_WINDOW (parent_window)));
+#endif
+
        }
        if (!header_view)
                return;
index 4d8696d..0ce8caf 100644 (file)
@@ -345,9 +345,24 @@ on_account_busy_changed(ModestAccountMgr *account_mgr,
                                return;
                        }
                        const gchar* last_updated_string = get_last_updated_string(self, account_mgr, settings);
+#ifdef MODEST_TOOLKIT_HILDON2
+                       gchar *last_updated_hildon2;
+
+                       last_updated_hildon2 = g_strconcat ("<span size='x-small'>", _("mcen_ti_lastupdated"), "\n", 
+                                                           last_updated_string, "</span>",
+                                                           NULL);
+#endif
                        gtk_list_store_set(model, &iter, 
+#ifdef MODEST_TOOLKIT_HILDON2
+                                          MODEST_ACCOUNT_VIEW_LAST_UPDATED_COLUMN, last_updated_hildon2,
+#else
                                           MODEST_ACCOUNT_VIEW_LAST_UPDATED_COLUMN, last_updated_string,
+#endif
                                           -1);
+
+#ifdef MODEST_TOOLKIT_HILDON2
+                       g_free (last_updated_hildon2);
+#endif
                        g_object_unref (settings);
                        found = TRUE;
                }
index 6b3ea71..2c0d678 100644 (file)
@@ -380,6 +380,12 @@ modest_attachment_view_instance_init (GTypeInstance *instance, gpointer g_class)
        PangoContext *context;
        GtkWidget *box = NULL;
 
+#ifdef MODEST_TOOLKIT_HILDON2
+       PangoAttrList *attr_list;
+       attr_list = pango_attr_list_new ();
+       pango_attr_list_insert (attr_list, pango_attr_underline_new (PANGO_UNDERLINE_SINGLE));
+#endif
+
        priv->mime_part = NULL;
        priv->icon = gtk_image_new ();
        priv->filename_view = gtk_label_new ("");
@@ -393,6 +399,11 @@ modest_attachment_view_instance_init (GTypeInstance *instance, gpointer g_class)
        gtk_misc_set_alignment (GTK_MISC (priv->size_view), 0.0, 0.5);
        gtk_misc_set_alignment (GTK_MISC (priv->filename_view), 0.0, 0.5);
 
+#ifdef MODEST_TOOLKIT_HILDON2
+       gtk_label_set_attributes (GTK_LABEL (priv->filename_view), attr_list);
+       gtk_label_set_attributes (GTK_LABEL (priv->size_view), attr_list);
+#endif
+
        priv->get_size_stream = NULL;
        priv->size = 0;
        priv->detect_size = TRUE;
@@ -415,6 +426,10 @@ modest_attachment_view_instance_init (GTypeInstance *instance, gpointer g_class)
        gtk_event_box_set_visible_window (GTK_EVENT_BOX (instance), TRUE);
        gtk_widget_set_events (GTK_WIDGET (instance), 0);
 
+#ifdef MODEST_TOOLKIT_HILDON2
+       pango_attr_list_unref (attr_list);
+#endif
+
        GTK_WIDGET_UNSET_FLAGS (GTK_WIDGET (instance), GTK_CAN_FOCUS);
 
        return;
index 8f1a03e..b0849b2 100644 (file)
@@ -36,6 +36,8 @@
 #include <modest-compact-mail-header-view.h>
 #include <modest-tny-folder.h>
 #include <modest-ui-constants.h>
+#include <modest-icon-names.h>
+#include <modest-datetime-formatter.h>
 #ifdef MODEST_TOOLKIT_HILDON2
 #include <hildon/hildon-gtk.h>
 #endif
@@ -56,14 +58,16 @@ struct _ModestCompactMailHeaderViewPriv
        GtkWidget    *date_label;
        GtkWidget    *subject_label;
 
-       GtkSizeGroup *labels_size_group;
+       GSList       *custom_labels;
 
        gboolean     is_outgoing;
        gboolean     is_draft;
-       gchar        *first_address;
        
        TnyHeader    *header;
        TnyHeaderFlags priority_flags;
+
+       time_t       date_to_show;
+       ModestDatetimeFormatter *datetime_formatter;
 };
 
 #define MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE(o) \
@@ -103,22 +107,33 @@ static const GtkWidget *modest_compact_mail_header_view_add_custom_header_defaul
 /* internal */
 static void on_notify_style (GObject *obj, GParamSpec *spec, gpointer userdata);
 static void on_details_button_clicked  (GtkButton *button, gpointer userdata);
-static void on_fromto_button_clicked  (GtkButton *button, gpointer userdata);
 static void update_style (ModestCompactMailHeaderView *self);
-static void set_date_time (ModestCompactMailHeaderView *compact_mail_header, time_t date);
+static void set_date_time (ModestCompactMailHeaderView *compact_mail_header);
 static void fill_address (ModestCompactMailHeaderView *self);
 
 static void
-set_date_time (ModestCompactMailHeaderView *compact_mail_header, time_t date)
+set_date_time (ModestCompactMailHeaderView *compact_mail_header)
 {
        const guint BUF_SIZE = 64; 
-       gchar date_buf [BUF_SIZE];
+       const gchar *date_str;
+       gchar date_buf[BUF_SIZE];
+       GString *buffer = g_string_new ("");
 
        ModestCompactMailHeaderViewPriv *priv = MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE (compact_mail_header);
 
-       modest_text_utils_strftime (date_buf, BUF_SIZE, "%x %X", date);
+       modest_text_utils_strftime (date_buf, BUF_SIZE, _HL("wdgt_va_week"), priv->date_to_show);
+       buffer = g_string_append (buffer, date_buf);
+       buffer = g_string_append_c (buffer, ' ');
+       buffer = g_string_append_unichar (buffer, 0x2015);
+       buffer = g_string_append_c (buffer, ' ');
+       date_str = modest_datetime_formatter_format_time (priv->datetime_formatter, priv->date_to_show);
+       buffer = g_string_append (buffer, date_str);
+       buffer = g_string_append (buffer, "\n");
+       modest_text_utils_strftime (date_buf, BUF_SIZE, _HL("wdgt_va_date_long"), priv->date_to_show);
+       buffer = g_string_append (buffer, date_buf);
 
-       gtk_label_set_text (GTK_LABEL (priv->date_label), date_buf);
+       gtk_label_set_text (GTK_LABEL (priv->date_label), buffer->str);
+       g_string_free (buffer, TRUE);
 
 }
 
@@ -184,7 +199,6 @@ modest_compact_mail_header_view_set_header_default (TnyHeaderView *self, TnyHead
        if (header && G_IS_OBJECT (header))
        {
                gchar *subject;
-               time_t date_to_show;
 
                g_object_ref (G_OBJECT (header)); 
                priv->header = header;
@@ -199,11 +213,11 @@ modest_compact_mail_header_view_set_header_default (TnyHeaderView *self, TnyHead
                        gtk_label_set_text (GTK_LABEL (priv->subject_label), _("mail_va_no_subject"));
 
                if (priv->is_outgoing && priv->is_draft) {
-                       date_to_show = tny_header_get_date_sent (header);
+                       priv->date_to_show = tny_header_get_date_sent (header);
                } else {
-                       date_to_show = tny_header_get_date_received (header);
+                       priv->date_to_show = tny_header_get_date_received (header);
                }
-               set_date_time (MODEST_COMPACT_MAIL_HEADER_VIEW (self), date_to_show);
+               set_date_time (MODEST_COMPACT_MAIL_HEADER_VIEW (self));
 
                fill_address (MODEST_COMPACT_MAIL_HEADER_VIEW (self));
 
@@ -269,10 +283,10 @@ modest_compact_mail_header_view_add_custom_header_default (ModestMailHeaderView
        hbox = gtk_hbox_new (FALSE, 12);
        label_field = gtk_label_new (NULL);
        gtk_label_set_text (GTK_LABEL (label_field), label);
+       priv->custom_labels = g_slist_prepend (priv->custom_labels, (gpointer) label_field);
        gtk_misc_set_alignment (GTK_MISC (label_field), 1.0, 0.0);
        gtk_box_pack_start (GTK_BOX (hbox), label_field, FALSE, FALSE, 0);
        gtk_box_pack_start (GTK_BOX (hbox), custom_widget, TRUE, TRUE, 0);
-       gtk_size_group_add_widget (priv->labels_size_group, label_field);
 
        if (start)
                gtk_box_pack_start (GTK_BOX (priv->headers_vbox), hbox, FALSE, FALSE, 0);
@@ -299,16 +313,23 @@ modest_compact_mail_header_view_new ()
 }
 
 static void
+datetime_format_changed (ModestDatetimeFormatter *formatter,
+                        ModestCompactMailHeaderView *self)
+{
+       set_date_time (self);
+}
+
+static void
 modest_compact_mail_header_view_instance_init (GTypeInstance *instance, gpointer g_class)
 {
        ModestCompactMailHeaderView *self = (ModestCompactMailHeaderView *)instance;
        ModestCompactMailHeaderViewPriv *priv = MODEST_COMPACT_MAIL_HEADER_VIEW_GET_PRIVATE (self);
        GtkWidget *first_hbox, *second_hbox, *vbox, *main_vbox;
-       GtkWidget *details_button, *fromto_button;
+       GtkWidget *details_button;
        PangoAttrList *attr_list;
 
        priv->header = NULL;
-       priv->first_address = NULL;
+       priv->custom_labels = NULL;
 
        main_vbox = gtk_vbox_new (FALSE, 0);
        vbox = gtk_vbox_new (FALSE, 0);
@@ -338,7 +359,7 @@ modest_compact_mail_header_view_instance_init (GTypeInstance *instance, gpointer
        gtk_box_pack_start (GTK_BOX (first_hbox), priv->subject_box, TRUE, TRUE, 0);
        gtk_box_pack_start (GTK_BOX (first_hbox), details_button, FALSE, FALSE, 0);
 
-       second_hbox = gtk_hbox_new (FALSE, MODEST_MARGIN_HALF);
+       second_hbox = gtk_hbox_new (FALSE, MODEST_MARGIN_DOUBLE);
 
        priv->fromto_label = gtk_label_new (NULL);
        gtk_misc_set_alignment (GTK_MISC (priv->fromto_label), 0.0, 1.0);
@@ -346,36 +367,28 @@ modest_compact_mail_header_view_instance_init (GTypeInstance *instance, gpointer
        priv->fromto_contents = gtk_label_new (NULL);
        gtk_misc_set_alignment (GTK_MISC (priv->fromto_contents), 0.0, 1.0);
        gtk_label_set_ellipsize (GTK_LABEL (priv->fromto_contents), PANGO_ELLIPSIZE_END);
-       attr_list = pango_attr_list_new ();
-       pango_attr_list_insert (attr_list, pango_attr_underline_new (PANGO_UNDERLINE_SINGLE));
-       gtk_label_set_attributes (GTK_LABEL (priv->fromto_contents), attr_list);
-       pango_attr_list_unref (attr_list);
-       fromto_button = gtk_button_new ();
-       gtk_button_set_relief (GTK_BUTTON (fromto_button), GTK_RELIEF_NONE);
-       gtk_container_add (GTK_CONTAINER (fromto_button), priv->fromto_contents);
 
        priv->date_label = gtk_label_new (NULL);
+       gtk_label_set_justify (GTK_LABEL (priv->date_label), GTK_JUSTIFY_RIGHT);
        gtk_misc_set_alignment (GTK_MISC (priv->date_label), 1.0, 1.0);
        gtk_misc_set_padding (GTK_MISC (priv->date_label), MODEST_MARGIN_DEFAULT, 0);
 
        gtk_box_pack_start (GTK_BOX (second_hbox), priv->fromto_label, FALSE, FALSE, 0);
-       gtk_box_pack_start (GTK_BOX (second_hbox), fromto_button, TRUE, TRUE, 0);
+       gtk_box_pack_start (GTK_BOX (second_hbox), priv->fromto_contents, TRUE, TRUE, 0);
        gtk_box_pack_start (GTK_BOX (second_hbox), priv->date_label, FALSE, FALSE, 0);
 
        gtk_box_pack_start (GTK_BOX (vbox), first_hbox, FALSE, FALSE, 0);
        gtk_box_pack_start (GTK_BOX (vbox), second_hbox, FALSE, FALSE, 0);
 
-       priv->labels_size_group = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL);
-       gtk_size_group_add_widget (priv->labels_size_group, priv->fromto_label);
-       
        update_style (self);
 
        g_signal_connect (G_OBJECT (self), "notify::style", G_CALLBACK (on_notify_style), (gpointer) self);
 
   &n