*/
#include <modest-header-window.h>
-#include <modest-osso-state-saving.h>
-#include <libosso.h>
#include <hildon/hildon-pannable-area.h>
#include <hildon/hildon-helper.h>
#include <modest-window-mgr.h>
#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
+
typedef enum {
CONTENTS_STATE_NONE = 0,
CONTENTS_STATE_EMPTY = 1,
GtkWidget *contents_view;
GtkWidget *top_vbox;
GtkWidget *new_message_button;
+ GtkWidget *show_more_button;
/* state bar */
ContentsState contents_state;
static gboolean on_key_press(GtkWidget *widget,
GdkEventKey *event,
gpointer user_data);
+static void modest_header_window_show_more (GtkAction *action, ModestWindow *win);
/* globals */
static GtkWindowClass *parent_class = NULL;
priv->current_store_account = NULL;
priv->sort_button = NULL;
priv->new_message_button = NULL;
+ priv->show_more_button = NULL;
priv->x_coord = 0;
priv->y_coord = 0;
priv->notify_model = 0;
"clicked",
G_CALLBACK (modest_ui_actions_on_new_msg), self);
+ priv->sighandlers =
+ modest_signal_mgr_connect (priv->sighandlers,
+ G_OBJECT (priv->show_more_button),
+ "clicked",
+ G_CALLBACK (modest_header_window_show_more), self);
+
/* Delete using horizontal gesture */
/* DISABLED because it's unreliabile */
if (FALSE) {
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);
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);
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);
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);
+
+ 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 (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (vbox);
update_view (self, NULL);
- /* 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 ();
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",
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));
gboolean folder_empty = FALSE;
gboolean all_marked_as_deleted = FALSE;
TnyFolder *folder;
+ gchar *show_more_value;
+ guint visible;
+ guint all_count;
g_return_if_fail (MODEST_IS_HEADER_WINDOW(self));
+
+ /* It could happen when some event is received and the window
+ was previously closed */
+ if (!MODEST_IS_HEADER_WINDOW (self))
+ return;
+
priv = MODEST_HEADER_WINDOW_GET_PRIVATE (self);
folder = modest_header_view_get_folder ((ModestHeaderView *) priv->header_view);
changed = tny_folder_change_get_changed (change);
/* If something changes */
if ((changed) & TNY_FOLDER_CHANGE_CHANGED_ALL_COUNT)
- folder_empty = (((guint) tny_folder_change_get_new_all_count (change)) == 0);
+ all_count = (guint) tny_folder_change_get_new_all_count (change);
else
- folder_empty = (((guint) tny_folder_get_all_count (folder)) == 0);
+ all_count = (guint) tny_folder_get_all_count (folder);
+ folder_empty = (all_count == 0);
if ((changed) & TNY_FOLDER_CHANGE_CHANGED_EXPUNGED_HEADERS)
refilter = TRUE;
} else {
- folder_empty = (((guint) tny_folder_get_all_count (folder)) == 0);
+ all_count = (guint) tny_folder_get_all_count (folder);
+ folder_empty = (all_count == 0);
}
g_object_unref (folder);
if (refilter)
modest_header_view_refilter (MODEST_HEADER_VIEW (priv->header_view));
+
+ visible = modest_header_view_get_show_latest (MODEST_HEADER_VIEW (priv->header_view));
+
+ 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 == 0 || visible == all_count) {
+ gtk_widget_hide_all (priv->show_more_button);
+ } else {
+ gtk_widget_show_all (priv->show_more_button);
+ }
+ 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);
}
static void
return FALSE;
}
+
+static void
+modest_header_window_show_more (GtkAction *action, ModestWindow *win)
+{
+ ModestHeaderWindow *self;
+ ModestHeaderWindowPrivate *priv = NULL;
+
+ self = MODEST_HEADER_WINDOW (win);
+ priv = MODEST_HEADER_WINDOW_GET_PRIVATE (self);
+ if (!priv->header_view)
+ return;
+
+ 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)) +
+ SHOW_LATEST_SIZE);
+ update_view (self, NULL);
+ }
+}