Save screenshot on closing modest (fixes NB#139348).
authorJose Dapena Paz <jdapena@igalia.com>
Fri, 6 Nov 2009 15:49:50 +0000 (16:49 +0100)
committerJose Dapena Paz <jdapena@igalia.com>
Mon, 9 Nov 2009 16:34:32 +0000 (17:34 +0100)
* src/widgets/modest-account-view.c: add API to hide/show the last updated
  values. The goal is hiding it on taking the screenshot.
* src/hildon2/modest-accounts-window.c: save screenshot on delete event,
  removing the last updated values.

src/hildon2/modest-accounts-window.c
src/widgets/modest-account-view.c
src/widgets/modest-account-view.h

index 3eec8a5..176cec9 100644 (file)
@@ -84,6 +84,9 @@ static void row_count_changed (ModestAccountsWindow *self);
 static gboolean on_key_press(GtkWidget *widget,
                                GdkEventKey *event,
                                gpointer user_data);
 static gboolean on_key_press(GtkWidget *widget,
                                GdkEventKey *event,
                                gpointer user_data);
+static gboolean on_delete_event (GtkWidget *widget,
+                                GdkEvent *event,
+                                gpointer userdata);
 
 typedef struct _ModestAccountsWindowPrivate ModestAccountsWindowPrivate;
 struct _ModestAccountsWindowPrivate {
 
 typedef struct _ModestAccountsWindowPrivate ModestAccountsWindowPrivate;
 struct _ModestAccountsWindowPrivate {
@@ -371,6 +374,8 @@ modest_accounts_window_new (void)
        g_signal_connect (G_OBJECT (self), "map-event",
                          G_CALLBACK (_modest_accounts_window_map_event),
                          G_OBJECT (self));
        g_signal_connect (G_OBJECT (self), "map-event",
                          G_CALLBACK (_modest_accounts_window_map_event),
                          G_OBJECT (self));
+       g_signal_connect (G_OBJECT (self), "delete-event",
+                         G_CALLBACK (on_delete_event), self);
        update_progress_hint (MODEST_ACCOUNTS_WINDOW (self));
 
        row_count_changed (MODEST_ACCOUNTS_WINDOW (self));
        update_progress_hint (MODEST_ACCOUNTS_WINDOW (self));
 
        row_count_changed (MODEST_ACCOUNTS_WINDOW (self));
@@ -697,3 +702,25 @@ on_key_press(GtkWidget *widget, GdkEventKey *event, gpointer user_data)
 
        return FALSE;
 }
 
        return FALSE;
 }
+
+static gboolean
+on_delete_event (GtkWidget *widget,
+                GdkEvent *event,
+                gpointer userdata)
+{
+       ModestAccountsWindowPrivate *priv;
+
+       priv = MODEST_ACCOUNTS_WINDOW_GET_PRIVATE (widget);
+
+       modest_account_view_set_show_last_update (MODEST_ACCOUNT_VIEW (priv->account_view), FALSE);
+
+       gtk_widget_queue_resize (widget);
+
+       gdk_window_process_updates (priv->account_view->window, TRUE);
+       hildon_gtk_window_take_screenshot (GTK_WINDOW (widget), TRUE);
+
+       modest_account_view_set_show_last_update (MODEST_ACCOUNT_VIEW (priv->account_view), TRUE);
+
+       return FALSE;
+
+}
index b5bed2c..fd9f115 100644 (file)
@@ -74,7 +74,7 @@ static void on_account_updated (ModestAccountMgr* mgr, gchar* account_name,
                     gpointer user_data);
 static void update_account_view (ModestAccountMgr *account_mgr, ModestAccountView *view);
 static void on_notify_style (GObject *obj, GParamSpec *spec, gpointer userdata);
                     gpointer user_data);
 static void update_account_view (ModestAccountMgr *account_mgr, ModestAccountView *view);
 static void on_notify_style (GObject *obj, GParamSpec *spec, gpointer userdata);
-static void update_picker_mode (ModestAccountView *self);
+static void update_display_mode (ModestAccountView *self);
 
 typedef enum {
        MODEST_ACCOUNT_VIEW_NAME_COLUMN,
 
 typedef enum {
        MODEST_ACCOUNT_VIEW_NAME_COLUMN,
@@ -93,6 +93,7 @@ struct _ModestAccountViewPrivate {
 
        ModestDatetimeFormatter *datetime_formatter;
        gboolean picker_mode;
 
        ModestDatetimeFormatter *datetime_formatter;
        gboolean picker_mode;
+       gboolean show_last_updated;
 
        /* Signal handlers */
        GSList *sig_handlers;
 
        /* Signal handlers */
        GSList *sig_handlers;
@@ -160,6 +161,7 @@ modest_account_view_init (ModestAccountView *obj)
 
        priv->datetime_formatter = modest_datetime_formatter_new ();
        priv->picker_mode = FALSE;
 
        priv->datetime_formatter = modest_datetime_formatter_new ();
        priv->picker_mode = FALSE;
+       priv->show_last_updated = TRUE;
        g_signal_connect (G_OBJECT (priv->datetime_formatter), "format-changed", 
                          G_CALLBACK (datetime_format_changed), (gpointer) obj);
 #ifdef MODEST_TOOLKIT_HILDON2
        g_signal_connect (G_OBJECT (priv->datetime_formatter), "format-changed", 
                          G_CALLBACK (datetime_format_changed), (gpointer) obj);
 #ifdef MODEST_TOOLKIT_HILDON2
@@ -234,7 +236,9 @@ update_account_view (ModestAccountMgr *account_mgr, ModestAccountView *view)
 {
        GSList *account_names, *cursor;
        GtkListStore *model;
 {
        GSList *account_names, *cursor;
        GtkListStore *model;
-
+       ModestAccountViewPrivate *priv;
+       
+       priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE(view);
        model = GTK_LIST_STORE(gtk_tree_view_get_model (GTK_TREE_VIEW(view)));
 
        /* Get the ID of the currently-selected account,
        model = GTK_LIST_STORE(gtk_tree_view_get_model (GTK_TREE_VIEW(view)));
 
        /* Get the ID of the currently-selected account,
@@ -286,9 +290,13 @@ update_account_view (ModestAccountMgr *account_mgr, ModestAccountView *view)
 #ifdef MODEST_TOOLKIT_HILDON2
                                gchar *last_updated_hildon2;
 
 #ifdef MODEST_TOOLKIT_HILDON2
                                gchar *last_updated_hildon2;
 
-                               last_updated_hildon2 = g_strconcat (_("mcen_ti_lastupdated"), "\n", 
-                                                                  last_updated_string,
-                                                                  NULL);
+                               if (priv->show_last_updated) {
+                                       last_updated_hildon2 = g_strconcat (_("mcen_ti_lastupdated"), "\n", 
+                                                                           last_updated_string,
+                                                                           NULL);
+                               } else {
+                                       last_updated_hildon2 = g_strconcat (_("mcen_ti_lastupdated"), "\n", NULL);
+                               }
 #endif
                                protocol_registry = modest_runtime_get_protocol_registry ();
                                protocol_type = modest_server_account_settings_get_protocol (store_settings);
 #endif
                                protocol_registry = modest_runtime_get_protocol_registry ();
                                protocol_type = modest_server_account_settings_get_protocol (store_settings);
@@ -658,7 +666,7 @@ init_view (ModestAccountView *self)
        gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(self), TRUE);
 #endif
 
        gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(self), TRUE);
 #endif
 
-       update_picker_mode (self);
+       update_display_mode (self);
 
        priv->sig_handlers = 
                modest_signal_mgr_connect (priv->sig_handlers, 
 
        priv->sig_handlers = 
                modest_signal_mgr_connect (priv->sig_handlers, 
@@ -886,7 +894,7 @@ on_notify_style (GObject *obj, GParamSpec *spec, gpointer userdata)
 }
 
 static void
 }
 
 static void
-update_picker_mode (ModestAccountView *self)
+update_display_mode (ModestAccountView *self)
 {
        ModestAccountViewPrivate *priv;
        GtkTreeViewColumn *column;
 {
        ModestAccountViewPrivate *priv;
        GtkTreeViewColumn *column;
@@ -920,7 +928,7 @@ modest_account_view_set_picker_mode (ModestAccountView *self, gboolean enable)
        priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE(self);
 
        priv->picker_mode = enable;
        priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE(self);
 
        priv->picker_mode = enable;
-       update_picker_mode (self);
+       update_display_mode (self);
 }
 
 gboolean 
 }
 
 gboolean 
@@ -933,3 +941,27 @@ modest_account_view_get_picker_mode (ModestAccountView *self)
 
        return priv->picker_mode;
 }
 
        return priv->picker_mode;
 }
+
+void
+modest_account_view_set_show_last_update (ModestAccountView *self, 
+                                         gboolean show)
+{
+       ModestAccountViewPrivate *priv;
+       
+       g_return_if_fail (MODEST_IS_ACCOUNT_VIEW (self));
+       priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE(self);
+
+       priv->show_last_updated = show;
+       update_account_view (priv->account_mgr, self);
+}
+
+gboolean 
+modest_account_view_get_show_last_updated (ModestAccountView *self)
+{
+       ModestAccountViewPrivate *priv;
+       
+       g_return_val_if_fail (MODEST_IS_ACCOUNT_VIEW (self), FALSE);
+       priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE(self);
+
+       return priv->show_last_updated;
+}
index 31a7674..b354469 100644 (file)
@@ -118,6 +118,25 @@ void modest_account_view_set_picker_mode (ModestAccountView *self, gboolean enab
  */
 gboolean modest_account_view_get_picker_mode (ModestAccountView *self);
 
  */
 gboolean modest_account_view_get_picker_mode (ModestAccountView *self);
 
+/**
+ * modest_account_view_set_show_last_update:
+ * @self: a #ModestAccountView
+ * @show: a #gboolean
+ *
+ * show/hide the last update column
+ */
+void modest_account_view_set_show_last_update (ModestAccountView *self, gboolean show);
+
+/**
+ * modest_account_view_get_show_last_update:
+ * @self: a #ModestAccountView
+ *
+ * tell if it's showing  the last update column
+ *
+ * Returns: a #gboolean
+ */
+gboolean modest_account_view_get_show_last_update (ModestAccountView *self);
+
 G_END_DECLS
 
 #endif /* __MODEST_ACCOUNT_VIEW_H__ */
 G_END_DECLS
 
 #endif /* __MODEST_ACCOUNT_VIEW_H__ */