Moved "Send&Receive" menu item to the first row.
[modest] / src / hildon2 / modest-header-window.c
index 30816a3..eba8dbc 100644 (file)
@@ -50,6 +50,7 @@
 #include <hildon/hildon-banner.h>
 #include <modest-ui-dimming-rules.h>
 #include <modest-tny-folder.h>
+#include <modest-tny-account.h>
 #include <tny-simple-list.h>
 
 #define SHOW_LATEST_SIZE 250
@@ -74,7 +75,6 @@ struct _ModestHeaderWindowPrivate {
        GtkWidget *top_vbox;
        GtkWidget *new_message_button;
        GtkWidget *show_more_button;
-       GtkWidget *show_more_button2;
 
        /* state bar */
        ContentsState contents_state;
@@ -262,7 +262,6 @@ modest_header_window_init (ModestHeaderWindow *obj)
        priv->sort_button = NULL;
        priv->new_message_button = NULL;
        priv->show_more_button = NULL;
-       priv->show_more_button2 = NULL;
        priv->x_coord = 0;
        priv->y_coord = 0;
        priv->notify_model = 0;
@@ -427,12 +426,6 @@ connect_signals (ModestHeaderWindow *self)
                                           "clicked",
                                           G_CALLBACK (modest_header_window_show_more), self);
 
-       priv->sighandlers =
-               modest_signal_mgr_connect (priv->sighandlers,
-                                          G_OBJECT (priv->show_more_button2),
-                                          "clicked",
-                                          G_CALLBACK (modest_header_window_show_more), self);
-
        /* Delete using horizontal gesture */
        /* DISABLED because it's unreliabile */
        if (FALSE) {
@@ -654,10 +647,26 @@ create_header_view (ModestWindow *self, TnyFolder *folder)
        GtkWidget *header_view;
        GtkWidget *delete_item, *mark_read_item, *mark_unread_item;
        ModestHeaderWindowPrivate *priv;
+       TnyAccount *account;
+       ModestProtocolType protocol_type;
+       gboolean limit_headers;
 
-       header_view  = modest_header_view_new (NULL, MODEST_HEADER_VIEW_STYLE_TWOLINES);
-       modest_header_view_set_show_latest (MODEST_HEADER_VIEW (header_view), SHOW_LATEST_SIZE);
        priv = MODEST_HEADER_WINDOW_GET_PRIVATE (self);
+
+       header_view  = modest_header_view_new (NULL, MODEST_HEADER_VIEW_STYLE_TWOLINES);
+
+       account = modest_tny_folder_get_account (folder);
+       limit_headers = FALSE;
+       if (account) {
+               protocol_type = modest_tny_account_get_protocol_type (account);
+               if (modest_protocol_registry_protocol_type_has_tag (modest_runtime_get_protocol_registry (),
+                                                                   protocol_type,
+                                                                   MODEST_PROTOCOL_REGISTRY_STORE_LIMIT_HEADER_WINDOW)) {
+                       limit_headers = TRUE;
+               }
+       }
+       modest_header_view_set_show_latest (MODEST_HEADER_VIEW (header_view), limit_headers?SHOW_LATEST_SIZE:0);
+
        priv->notify_model = g_signal_connect ((GObject*) header_view, "notify::model",
                                               G_CALLBACK (on_header_view_model_changed), self);
 
@@ -733,15 +742,9 @@ create_empty_view (ModestWindow *self)
        g_object_unref (new_message_pixbuf);
        gtk_widget_show_all (button);
 
-       priv->show_more_button2 = hildon_button_new (MODEST_EDITABLE_SIZE, HILDON_BUTTON_ARRANGEMENT_VERTICAL);
-       hildon_button_set_title (HILDON_BUTTON (priv->show_more_button2), _("mcen_va_more"));
-       gtk_widget_hide_all (priv->show_more_button2);
-
        hbox = gtk_hbox_new (TRUE, 0);
        gtk_widget_show (hbox);
        gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
-       gtk_box_pack_start (GTK_BOX (hbox), priv->show_more_button2, TRUE, TRUE, 0);
-
        gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
 
        gtk_widget_show (vbox);
@@ -824,13 +827,8 @@ modest_header_window_new (TnyFolder *folder, const gchar *account_name, const gc
        hildon_button_set_image (HILDON_BUTTON (priv->new_message_button), gtk_image_new_from_pixbuf (new_message_pixbuf));
        g_object_unref (new_message_pixbuf);
 
-       priv->show_more_button = hildon_button_new (MODEST_EDITABLE_SIZE, HILDON_BUTTON_ARRANGEMENT_VERTICAL);
-       hildon_button_set_title (HILDON_BUTTON (priv->show_more_button), _("mcen_va_more"));
-
        gtk_box_pack_start (GTK_BOX (action_area_box), priv->new_message_button, TRUE, TRUE, 0);
-       gtk_box_pack_start (GTK_BOX (action_area_box), priv->show_more_button, TRUE, TRUE, 0);
        gtk_widget_show_all (priv->new_message_button);
-       gtk_widget_hide_all (priv->show_more_button);
        hildon_tree_view_set_action_area_visible (GTK_TREE_VIEW (priv->header_view), TRUE);
        
        setup_menu (self);
@@ -944,6 +942,9 @@ static void setup_menu (ModestHeaderWindow *self)
        modest_hildon2_window_add_to_menu (MODEST_HILDON2_WINDOW (self), _("mcen_me_new_message"), "<Control>n",
                                           APP_MENU_CALLBACK (modest_ui_actions_on_new_msg),
                                           MODEST_DIMMING_CALLBACK (modest_ui_dimming_rules_on_new_msg));
+       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),
                                           dngettext(GETTEXT_PACKAGE,
                                                     "mcen_me_move_message",
@@ -968,9 +969,16 @@ static void setup_menu (ModestHeaderWindow *self)
        hildon_button_set_value_alignment (HILDON_BUTTON (priv->sort_button), 0.5, 0.5);
        modest_hildon2_window_add_button_to_menu (MODEST_HILDON2_WINDOW (self), GTK_BUTTON (priv->sort_button),
                                                  modest_ui_dimming_rules_on_sort);
-       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));
+
+       priv->show_more_button = hildon_button_new (MODEST_EDITABLE_SIZE, HILDON_BUTTON_ARRANGEMENT_VERTICAL);
+       hildon_button_set_title (HILDON_BUTTON (priv->show_more_button), _("mcen_va_more"));
+       hildon_button_set_alignment (HILDON_BUTTON (priv->show_more_button), 0.5, 0.5, 1.0, 1.0);
+       hildon_button_set_title_alignment (HILDON_BUTTON (priv->show_more_button), 0.5, 0.5);
+       hildon_button_set_value_alignment (HILDON_BUTTON (priv->show_more_button), 0.5, 0.5);
+       modest_hildon2_window_add_button_to_menu (MODEST_HILDON2_WINDOW (self), GTK_BUTTON (priv->show_more_button),
+                                                 NULL);
+       gtk_widget_hide_all (priv->show_more_button);
+
        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));
@@ -1033,25 +1041,21 @@ update_view (ModestHeaderWindow *self,
 
        visible = modest_header_view_get_show_latest (MODEST_HEADER_VIEW (priv->header_view));
 
-       if (all_count > 0 && visible < all_count && folder_empty) {
+       if (visible > 0 && all_count > 0 && visible < all_count && folder_empty) {
                modest_header_view_set_show_latest (MODEST_HEADER_VIEW (priv->header_view), visible + SHOW_LATEST_SIZE);
        }
 
        if (visible > all_count)
                visible = all_count;
-       if (visible == all_count) {
+       if (visible == 0 || visible == all_count) {
                gtk_widget_hide_all (priv->show_more_button);
-               gtk_widget_hide_all (priv->show_more_button2);
        } else {
                gtk_widget_show_all (priv->show_more_button);
-               gtk_widget_show_all (priv->show_more_button2);
        }
        show_more_value = g_strdup_printf (_("mcen_va_more_toview"), visible, all_count);
 
        hildon_button_set_value (HILDON_BUTTON (priv->show_more_button),
                                 show_more_value);
-       hildon_button_set_value (HILDON_BUTTON (priv->show_more_button2),
-                                show_more_value);
 }
 
 static void