* src/maemo/modest-msg-edit-window.c:
[modest] / src / maemo / modest-main-window.c
index 4050038..0facd90 100644 (file)
 #include "modest-ui-dimming-manager.h"
 #include "maemo/modest-osso-state-saving.h"
 
-#ifdef MODEST_HILDON_VERSION_0
+#ifdef MODEST_HAVE_HILDON0_WIDGETS
 #include <hildon-widgets/hildon-program.h>
 #else
 #include <hildon/hildon-program.h>
-#endif /*MODEST_HILDON_VERSION_0*/
+#endif /*MODEST_HAVE_HILDON0_WIDGETS*/
 
 #define MODEST_MAIN_WINDOW_ACTION_GROUP_ADDITIONS "ModestMainWindowActionAdditions"
 
@@ -96,6 +96,8 @@ static void         on_queue_changed                     (ModestMailOperationQue
                                                          ModestMailOperationQueueNotification type,
                                                          ModestMainWindow *self);
 
+static gboolean on_zoom_minus_plus_not_implemented (ModestWindow *window);
+
 static void on_account_update                 (TnyAccountStore *account_store, 
                                               const gchar *account_name,
                                               gpointer user_data);
@@ -135,10 +137,6 @@ modest_main_window_cleanup_queue_error_signals (ModestMainWindow *self);
 
 static GtkWidget * create_empty_view (void);
 
-static gchar * 
-translate_func (const gchar *msgid,
-               const gchar *domain_name);
-
 
 /* list my signals */
 enum {
@@ -216,7 +214,7 @@ static const GtkActionEntry modest_folder_view_action_entries [] = {
        /* Folder View CSM actions */
        { "FolderViewCSMNewFolder", NULL, N_("mcen_ti_new_folder"), NULL, NULL, G_CALLBACK (modest_ui_actions_on_new_folder) },
        { "FolderViewCSMRenameFolder", NULL, N_("mcen_me_user_renamefolder"), NULL, NULL, G_CALLBACK (modest_ui_actions_on_rename_folder) },
-       { "FolderViewCSMPasteMsgs", NULL, N_("mcen_me_inbox_paste"), NULL, NULL, NULL },
+       { "FolderViewCSMPasteMsgs", NULL, N_("mcen_me_inbox_paste"), NULL, NULL,  G_CALLBACK (modest_ui_actions_on_paste)},
        { "FolderViewCSMDeleteFolder", NULL, N_("mcen_me_inbox_delete"), NULL, NULL, G_CALLBACK (modest_ui_actions_on_delete_folder) },
        { "FolderViewCSMSearchMessages", NULL, N_("mcen_me_inbox_search"), NULL, NULL, G_CALLBACK (modest_ui_actions_on_search_messages) },
        { "FolderViewCSMHelp", NULL, N_("mcen_me_inbox_help"), NULL, NULL, G_CALLBACK (modest_ui_actions_on_help) },
@@ -281,6 +279,8 @@ modest_main_window_class_init (ModestMainWindowClass *klass)
        
        modest_window_class->show_toolbar_func = modest_main_window_show_toolbar;
        modest_window_class->save_state_func = save_state;
+       modest_window_class->zoom_minus_func = on_zoom_minus_plus_not_implemented;
+       modest_window_class->zoom_plus_func = on_zoom_minus_plus_not_implemented;
 }
 
 static void
@@ -290,6 +290,7 @@ modest_main_window_init (ModestMainWindow *obj)
 
        priv = MODEST_MAIN_WINDOW_GET_PRIVATE(obj);
 
+       priv->queue_err_signals = NULL;
        priv->msg_paned    = NULL;
        priv->main_paned   = NULL;      
        priv->main_vbox    = NULL;
@@ -469,7 +470,7 @@ on_sendqueue_error_happened (TnySendQueue *self, TnyHeader *header, TnyMsg *msg,
                gchar *str = g_strdup_printf ("%s. Do you want to remove the message (%s)?",
                        err->message, tny_header_get_subject (header));
                OnResponseInfo *info = g_slice_new (OnResponseInfo);
-               GtkWidget *dialog = gtk_message_dialog_new (NULL, 0,
+               GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW (user_data), 0,
                        GTK_MESSAGE_ERROR, GTK_BUTTONS_YES_NO, str);
                g_free (str);
                info->queue = g_object_ref (self);
@@ -512,6 +513,8 @@ on_account_store_connecting_finished (TnyAccountStore *store, ModestMainWindow *
         * (without the check for >0 accounts, though that is not specified): */
 
        TnyDevice *device = tny_account_store_get_device (store);
+
+       modest_folder_view_update_model (MODEST_FOLDER_VIEW (priv->folder_view), store);
        
        /* Check that we are really online.
         * This signal should not be emitted when we are not connected, 
@@ -546,6 +549,7 @@ on_account_store_connecting_finished (TnyAccountStore *store, ModestMainWindow *
                                modest_tny_account_store_get_transport_account_for_open_connection
                                                 (modest_runtime_get_account_store(), account_name));
                        if (account) {
+                               /* Q: Is this the first location where the send-queues are requested? */
                                QueueErrorSignal *esignal = g_slice_new (QueueErrorSignal);
                                printf ("debug: %s:\n  Transport account for %s: %s\n", __FUNCTION__, account_name, 
                                        tny_account_get_id(TNY_ACCOUNT(account)));
@@ -558,9 +562,9 @@ on_account_store_connecting_finished (TnyAccountStore *store, ModestMainWindow *
                
                iter = g_slist_next (iter);
        }
-       
-       g_slist_free (account_names);
-       
+
+       modest_account_mgr_free_account_names (account_names);
+       account_names = NULL;
        
        modest_ui_actions_do_send_receive (NULL, MODEST_WINDOW (self));
 }
@@ -745,24 +749,19 @@ modest_main_window_on_show (GtkWidget *self, gpointer user_data)
                It's an ugly hack... jschmid */
                gtk_widget_show_all(GTK_WIDGET(self));
                modest_ui_actions_on_accounts (NULL, MODEST_WINDOW(self));
+       } else {
+               GSList *accounts;
+               GtkAction *send_receive_all;
+               ModestWindowPrivate *parent_priv = MODEST_WINDOW_GET_PRIVATE (self);
+               accounts = modest_account_mgr_account_names (modest_runtime_get_account_mgr (), TRUE);
+               send_receive_all = gtk_ui_manager_get_action (parent_priv->ui_manager, 
+                                                             "/MenuBar/ToolsMenu/ToolsSendReceiveMainMenu/ToolsSendReceiveAllMenu");
+               gtk_action_set_visible (send_receive_all, g_slist_length (accounts));
+               modest_account_mgr_free_account_names (accounts);
        }
-}
-
-/* Debugging */
-/* static void  */
-/* on_window_destroy (ModestWindow *window,  */
-/*                ModestWindowMgr *self) */
-/* { */
-/*     ModestMainWindow *mw = NULL;     */
-/*     ModestMainWindowPrivate *priv = NULL; */
 
-/*     mw  = MODEST_MAIN_WINDOW (window); */
-/*     priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self); */
 
-/*     g_print ("\tMW: %d\n", ((GObject*)mw)->ref_count); */
-/*     g_print ("\tHV: %d\n", ((GObject*)priv->header_view)->ref_count); */
-/*     g_print ("\tFV: %d\n", ((GObject*)priv->folder_view)->ref_count); */
-/* } */
+}
 
 ModestWindow *
 modest_main_window_new (void)
@@ -788,7 +787,6 @@ modest_main_window_new (void)
 
        action_group = gtk_action_group_new ("ModestMainWindowActions");
        gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
-       gtk_action_group_set_translate_func (action_group, (GtkTranslateFunc) translate_func, GETTEXT_PACKAGE, g_free);
 
        menu_rules_group = modest_dimming_rules_group_new ("ModestMenuDimmingRules");
        toolbar_rules_group = modest_dimming_rules_group_new ("ModestToolbarDimmingRules");
@@ -917,11 +915,6 @@ modest_main_window_new (void)
 
        restore_settings (MODEST_MAIN_WINDOW(self), FALSE);
 
-/*     { */
-/*             g_signal_connect (self, "destroy",  */
-/*                               G_CALLBACK (on_window_destroy), self); */
-/*     } */
-
        return MODEST_WINDOW(self);
 }
 
@@ -1159,6 +1152,7 @@ on_account_update (TnyAccountStore *account_store,
        GList *groups;
        gchar *default_account;
        GtkWidget *send_receive_button, *item;
+       GtkAction *send_receive_all = NULL;
                
        self = MODEST_MAIN_WINDOW (user_data);
        priv = MODEST_MAIN_WINDOW_GET_PRIVATE (self);
@@ -1177,12 +1171,17 @@ on_account_update (TnyAccountStore *account_store,
 
                iter = iter->next;
        }
-       g_slist_free (account_names);
+       modest_account_mgr_free_account_names (account_names);
+       account_names = NULL;
 
        /* Order the list of accounts by its display name */
        accounts = g_slist_sort (accounts, (GCompareFunc) compare_display_names);
        num_accounts = g_slist_length (accounts);
 
+       send_receive_all = gtk_ui_manager_get_action (parent_priv->ui_manager, 
+                                                     "/MenuBar/ToolsMenu/ToolsSendReceiveMainMenu/ToolsSendReceiveAllMenu");
+       gtk_action_set_visible (send_receive_all, num_accounts > 1);
+
        /* Delete old send&receive popup items. We can not just do a
           menu_detach because it does not work well with
           tap_and_hold */
@@ -1400,25 +1399,40 @@ create_empty_view (void)
 }
 
 static GtkWidget *
-create_details_widget (TnyAccount *account)
+create_details_widget (GtkWidget *styled_widget, TnyAccount *account)
 {
        GtkWidget *vbox;
+       GtkWidget *label_w;
        gchar *label;
+       gchar *gray_color_markup;
 
        vbox = gtk_vbox_new (FALSE, 0);
 
+       /* Obtain the secondary text color. We need a realized widget, that's why 
+          we get styled_widget from outside */
+#ifndef MODEST_HAVE_HILDON0_WIDGETS
+       GdkColor color;
+       gtk_style_lookup_color (styled_widget->style, "SecondaryTextColor", &color);
+       gray_color_markup = modest_text_utils_get_color_string (&color);
+#else
+       gray_color_markup = "#BBBBBB";  
+#endif 
        /* Account description: */
        
        if (modest_tny_account_is_virtual_local_folders (account)) {
+               gchar *tmp;
                /* Local folders: */
        
                /* Get device name */
                gchar *device_name = modest_conf_get_string (modest_runtime_get_conf(),
                                                      MODEST_CONF_DEVICE_NAME, NULL);
-   
-               label = g_strdup_printf (_("mcen_fi_localroot_description"),
-                                        device_name);
-               gtk_box_pack_start (GTK_BOX (vbox), gtk_label_new (label), FALSE, FALSE, 0);
+               tmp = g_strdup_printf (_("mcen_fi_localroot_description"), "");
+               label = g_markup_printf_escaped ("<span color='%s'>%s</span>%s",
+                                                gray_color_markup, tmp, device_name);
+               g_free (tmp);
+               label_w = gtk_label_new (NULL);
+               gtk_label_set_markup (GTK_LABEL (label_w), label);
+               gtk_box_pack_start (GTK_BOX (vbox), label_w, FALSE, FALSE, 0);
                g_free (device_name);
                g_free (label);
        } else {
@@ -1439,10 +1453,13 @@ create_details_widget (TnyAccount *account)
                        /* note: mcen_fi_localroot_description is something like "%s account"
                         * however, we should display "%s account: %s"... therefore, ugly tmp */
                        tmp   = g_strdup_printf (_("mcen_fi_remoteroot_account"),proto->str);
-                       label = g_strdup_printf ("%s: %s", tmp,tny_account_get_name (account));
+                       label = g_markup_printf_escaped ("<span color='%s'>%s:</span> %s", 
+                                                        gray_color_markup, tmp, tny_account_get_name (account));
                        g_free (tmp);
 
-                       gtk_box_pack_start (GTK_BOX (vbox), gtk_label_new (label), FALSE, FALSE, 0);
+                       label_w = gtk_label_new (NULL);
+                       gtk_label_set_markup (GTK_LABEL (label_w), label);
+                       gtk_box_pack_start (GTK_BOX (vbox), label_w, FALSE, FALSE, 0);
                        g_string_free (proto, TRUE);
                        g_free (label);
                }
@@ -1450,23 +1467,33 @@ create_details_widget (TnyAccount *account)
 
        /* Message count */
        TnyFolderStore *folder_store = TNY_FOLDER_STORE (account);
-       label = g_strdup_printf ("%s: %d", _("mcen_fi_rootfolder_messages"), 
-                                modest_tny_folder_store_get_message_count (folder_store));
-       gtk_box_pack_start (GTK_BOX (vbox), gtk_label_new (label), FALSE, FALSE, 0);
+       label = g_markup_printf_escaped ("<span color='%s'>%s:</span> %d", 
+                                        gray_color_markup, _("mcen_fi_rootfolder_messages"), 
+                                        modest_tny_folder_store_get_message_count (folder_store));
+       label_w = gtk_label_new (NULL);
+       gtk_label_set_markup (GTK_LABEL (label_w), label);
+       gtk_box_pack_start (GTK_BOX (vbox), label_w, FALSE, FALSE, 0);
        g_free (label);
 
        /* Folder count */
-       label = g_strdup_printf ("%s: %d", _("mcen_fi_rootfolder_folders"), 
-                                modest_tny_folder_store_get_folder_count (folder_store));
-       gtk_box_pack_start (GTK_BOX (vbox), gtk_label_new (label), FALSE, FALSE, 0);
+       label = g_markup_printf_escaped ("<span color='%s'>%s</span>: %d", 
+                                        gray_color_markup, 
+                                        _("mcen_fi_rootfolder_folders"), 
+                                        modest_tny_folder_store_get_folder_count (folder_store));
+       label_w = gtk_label_new (NULL);
+       gtk_label_set_markup (GTK_LABEL (label_w), label);
+       gtk_box_pack_start (GTK_BOX (vbox), label_w, FALSE, FALSE, 0);
        g_free (label);
 
        /* Size / Date */
        if (modest_tny_account_is_virtual_local_folders (account)) {
                /* FIXME: format size */
-               label = g_strdup_printf ("%s: %d", _("mcen_fi_rootfolder_size"), 
-                                        modest_tny_folder_store_get_local_size (folder_store));
-               gtk_box_pack_start (GTK_BOX (vbox), gtk_label_new (label), FALSE, FALSE, 0);
+               label = g_markup_printf_escaped ("<span color='%s'>%s:</span> %d", 
+                                                gray_color_markup, _("mcen_fi_rootfolder_size"), 
+                                                modest_tny_folder_store_get_local_size (folder_store));
+               label_w = gtk_label_new (NULL);
+               gtk_label_set_markup (GTK_LABEL (label_w), label);
+               gtk_box_pack_start (GTK_BOX (vbox), label_w, FALSE, FALSE, 0);
                g_free (label);
        } else if (TNY_IS_ACCOUNT(folder_store)) {
                TnyAccount *account = TNY_ACCOUNT(folder_store);
@@ -1483,12 +1510,17 @@ create_details_widget (TnyAccount *account)
                else
                        last_updated_string = g_strdup (_("mcen_va_never"));
 
-               label = g_strdup_printf ("%s: %s", _("mcen_ti_lastupdated"), last_updated_string);
-               gtk_box_pack_start (GTK_BOX (vbox), gtk_label_new (label), FALSE, FALSE, 0);
+               label = g_markup_printf_escaped ("<span color='%s'>%s:</span> %s", 
+                                                gray_color_markup, _("mcen_ti_lastupdated"), last_updated_string);
+               label_w = gtk_label_new (NULL);
+               gtk_label_set_markup (GTK_LABEL (label_w), label);
+               gtk_box_pack_start (GTK_BOX (vbox), label_w, FALSE, FALSE, 0);
                g_free (last_updated_string);
                g_free (label);
        }
 
+       g_free (gray_color_markup);
+
        /* Set alignment */
        gtk_container_foreach (GTK_CONTAINER (vbox), (GtkCallback) set_alignment, NULL);
 
@@ -1606,8 +1638,8 @@ modest_main_window_set_contents_style (ModestMainWindow *self,
                TnyFolderStore *selected_folderstore = 
                        modest_folder_view_get_selected (priv->folder_view);
                if (TNY_IS_ACCOUNT (selected_folderstore)) {    
-                       priv->details_widget = create_details_widget (
-                               TNY_ACCOUNT (selected_folderstore));
+                 priv->details_widget = create_details_widget (GTK_WIDGET (self),
+                                                               TNY_ACCOUNT (selected_folderstore));
 
                        wrap_in_scrolled_window (priv->contents_widget, 
                                         priv->details_widget);
@@ -1918,6 +1950,7 @@ refresh_account (const gchar *account_name)
                modest_ui_actions_do_send_receive_all (win);
        else
                modest_ui_actions_do_send_receive (account_name, win);
+       
 }
 
 static void 
@@ -1934,9 +1967,12 @@ on_send_receive_csm_activated (GtkMenuItem *item,
        refresh_account ((const gchar*) user_data);
 }
 
-static gchar * 
-translate_func (const gchar *msgid,
-               const gchar *domain_name)
+static gboolean
+on_zoom_minus_plus_not_implemented (ModestWindow *window)
 {
-       return _(msgid);
+       g_return_val_if_fail (MODEST_IS_MAIN_WINDOW (window), FALSE);
+
+       hildon_banner_show_information (NULL, NULL, dgettext("hildon-common-strings", "ckct_ib_cannot_zoom_here"));
+       return FALSE;
+
 }