Replaced some logical id's. Use singular/plural forms
[modest] / src / hildon2 / modest-folder-window.c
index 84f12aa..df05c43 100644 (file)
@@ -53,6 +53,7 @@
 #include <modest-window-priv.h>
 #include "modest-text-utils.h"
 #include "modest-tny-account.h"
+#include "modest-account-protocol.h"
 
 typedef enum {
        EDIT_MODE_COMMAND_MOVE = 1,
@@ -299,7 +300,7 @@ modest_folder_window_new (TnyFolderStoreQuery *query)
                          G_CALLBACK (edit_mode_changed), (gpointer) self);
 
        action_area_box = hildon_tree_view_get_action_area_box (GTK_TREE_VIEW (priv->folder_view));
-       priv->new_message_button = hildon_button_new (0, HILDON_BUTTON_ARRANGEMENT_HORIZONTAL);
+       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_ti_new_message"));
        new_message_pixbuf = modest_platform_get_icon ("general_add", MODEST_ICON_SIZE_BIG);
@@ -319,7 +320,7 @@ modest_folder_window_new (TnyFolderStoreQuery *query)
        priv->top_vbox = gtk_vbox_new (0, FALSE);
        top_alignment = gtk_alignment_new (0.0, 0.0, 1.0, 1.0);
        gtk_alignment_set_padding (GTK_ALIGNMENT (top_alignment),
-                                  0, 0,
+                                  HILDON_MARGIN_HALF, 0,
                                   HILDON_MARGIN_DOUBLE, HILDON_MARGIN_DOUBLE);
 
        gtk_container_add (GTK_CONTAINER (pannable), priv->folder_view);
@@ -463,6 +464,38 @@ modest_folder_window_set_mailbox (ModestFolderWindow *self,
 }
 
 static void
+edit_account (GtkButton *button,
+             ModestFolderWindow *self)
+{
+       const gchar *account_name;
+
+       account_name = modest_window_get_active_account ((ModestWindow *) self);
+       if (modest_ui_actions_check_for_active_account ((ModestWindow *) self, account_name)) {
+               /* Show the account settings dialog */
+               ModestAccountProtocol *proto;
+               ModestProtocolType proto_type;
+
+               /* Get proto */
+               proto_type = modest_account_mgr_get_store_protocol (modest_runtime_get_account_mgr (),
+                                                                   account_name);
+               proto = (ModestAccountProtocol *)
+                       modest_protocol_registry_get_protocol_by_type (modest_runtime_get_protocol_registry (),
+                                                                      proto_type);
+
+               /* Create and show the dialog */
+               if (proto && MODEST_IS_ACCOUNT_PROTOCOL (proto)) {
+                       ModestAccountSettingsDialog *dialog =
+                               modest_account_protocol_get_account_settings_dialog (proto, account_name);
+                       modest_window_mgr_set_modal (modest_runtime_get_window_mgr (),
+                                                    (GtkWindow *) dialog,
+                                                    (GtkWindow *) self);
+                       gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), FALSE);
+                       gtk_widget_show (GTK_WIDGET (dialog));
+               }
+       }
+}
+
+static void
 setup_menu (ModestFolderWindow *self)
 {
        g_return_if_fail (MODEST_IS_FOLDER_WINDOW(self));
@@ -482,15 +515,21 @@ setup_menu (ModestFolderWindow *self)
                                           MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_folder_window_delete));
 
        /* send receive actions should be only one visible always */
-       modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), 
-                                          _("mcen_me_inbox_sendandreceive"), 
-                                          NULL,
+       modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_inbox_sendandreceive"), NULL,
                                           APP_MENU_CALLBACK (modest_ui_actions_on_send_receive),
                                           MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_send_receive));
 
        modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_outbox_cancelsend"), NULL,
                                           APP_MENU_CALLBACK (modest_ui_actions_cancel_send),
                                           MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_cancel_sending_all));
+
+       modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self),
+                                          dngettext(GETTEXT_PACKAGE,
+                                                    "mcen_me_edit_account",
+                                                    "mcen_me_edit_accounts",
+                                                    1),
+                                          NULL, APP_MENU_CALLBACK (edit_account),
+                                          MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_edit_accounts));
 }
 
 static void
@@ -506,10 +545,7 @@ on_folder_activated (ModestFolderView *folder_view,
 
        priv = MODEST_FOLDER_WINDOW_GET_PRIVATE (self);
 
-       if (!folder)
-               return;
-
-       if (!TNY_IS_FOLDER (folder))
+       if (!folder || !TNY_IS_FOLDER (folder))
                return;
 
        /* We cannot open noselect folders (fake ones) */
@@ -811,6 +847,9 @@ on_visible_account_changed (ModestFolderView *folder_view,
 {
        TnyAccount *account;
 
+       if (!account_id)
+               return;
+
        account = modest_tny_account_store_get_tny_account_by (modest_runtime_get_account_store(),
                                                               MODEST_TNY_ACCOUNT_STORE_QUERY_ID,
                                                               account_id);