Show more button also in empty view.
authorJose Dapena Paz <jdapena@igalia.com>
Tue, 3 Nov 2009 09:32:13 +0000 (10:32 +0100)
committerJose Dapena Paz <jdapena@igalia.com>
Thu, 5 Nov 2009 11:02:48 +0000 (12:02 +0100)
src/hildon2/modest-header-window.c

index f89121f..7d7b916 100644 (file)
@@ -74,6 +74,7 @@ struct _ModestHeaderWindowPrivate {
        GtkWidget *top_vbox;
        GtkWidget *new_message_button;
        GtkWidget *show_more_button;
+       GtkWidget *show_more_button2;
 
        /* state bar */
        ContentsState contents_state;
@@ -261,6 +262,7 @@ 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;
@@ -425,6 +427,12 @@ 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) {
@@ -648,7 +656,7 @@ create_header_view (ModestWindow *self, TnyFolder *folder)
        ModestHeaderWindowPrivate *priv;
 
        header_view  = modest_header_view_new (NULL, MODEST_HEADER_VIEW_STYLE_TWOLINES);
-       modest_header_view_set_show_latest (MODEST_HEADER_VIEW (header_view), 50);
+       modest_header_view_set_show_latest (MODEST_HEADER_VIEW (header_view), SHOW_LATEST_SIZE);
        priv = MODEST_HEADER_WINDOW_GET_PRIVATE (self);
        priv->notify_model = g_signal_connect ((GObject*) header_view, "notify::model",
                                               G_CALLBACK (on_header_view_model_changed), self);
@@ -696,8 +704,12 @@ create_empty_view (ModestWindow *self)
        GtkWidget *label = NULL;
        GtkWidget *align = NULL;
        GtkWidget *vbox = NULL;
+       GtkWidget *hbox = NULL;
        GtkWidget *button = NULL;
        GdkPixbuf *new_message_pixbuf;
+       ModestHeaderWindowPrivate *priv;
+
+       priv = MODEST_HEADER_WINDOW_GET_PRIVATE(self);
 
        vbox = gtk_vbox_new (0, FALSE);
 
@@ -720,7 +732,17 @@ create_empty_view (ModestWindow *self)
                                 gtk_image_new_from_pixbuf (new_message_pixbuf));
        g_object_unref (new_message_pixbuf);
        gtk_widget_show_all (button);
-       gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+
+       priv->show_more_button2 = hildon_button_new (MODEST_EDITABLE_SIZE, HILDON_BUTTON_ARRANGEMENT_VERTICAL);
+       hildon_button_set_title (HILDON_BUTTON (priv->show_more_button2), _("TODO: show 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);
 
@@ -1006,14 +1028,19 @@ update_view (ModestHeaderWindow *self,
        visible = modest_header_view_get_show_latest (MODEST_HEADER_VIEW (priv->header_view));
        if (visible > all_count)
                visible = all_count;
-       if (visible == all_count)
+       if (visible == all_count) {
                gtk_widget_hide_all (priv->show_more_button);
-       else
+               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 (_("TODO: %d of %d shown"), 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 
@@ -1564,7 +1591,8 @@ modest_header_window_show_more (GtkAction *action, ModestWindow *win)
        
        if (modest_header_view_get_not_latest (MODEST_HEADER_VIEW (priv->header_view)) > 0) {
                modest_header_view_set_show_latest (MODEST_HEADER_VIEW (priv->header_view),
-                                                   modest_header_view_get_show_latest (MODEST_HEADER_VIEW (priv->header_view)) + 50);
+                                                   modest_header_view_get_show_latest (MODEST_HEADER_VIEW (priv->header_view)) + 
+                                                   SHOW_LATEST_SIZE);
                update_view (self, NULL);
        }
 }