From: José Dapena Paz Date: Tue, 9 Feb 2010 11:14:39 +0000 (+0100) Subject: Show as active (color) the accounts that have new messages X-Git-Tag: 3.2.12-5~4 X-Git-Url: http://git.maemo.org/git/?p=modest;a=commitdiff_plain;h=9b2d6b21063f3adbee86a734424bf643cac64511 Show as active (color) the accounts that have new messages Fixes NB#155455. --- diff --git a/src/hildon2/modest-hildon2-window-mgr.c b/src/hildon2/modest-hildon2-window-mgr.c index 6ebd0c3..7c34155 100644 --- a/src/hildon2/modest-hildon2-window-mgr.c +++ b/src/hildon2/modest-hildon2-window-mgr.c @@ -51,6 +51,7 @@ #include "modest-tny-msg.h" #include "modest-tny-account.h" #include +#include /* 'private'/'protected' functions */ static void modest_hildon2_window_mgr_class_init (ModestHildon2WindowMgrClass *klass); @@ -588,6 +589,9 @@ modest_hildon2_window_mgr_register_window (ModestWindowMgr *self, if (acc_name) { modest_platform_remove_new_mail_notifications (FALSE, acc_name); + modest_account_mgr_set_has_new_mails (modest_runtime_get_account_mgr (), + acc_name, + FALSE); } } diff --git a/src/modest-account-mgr-helpers.c b/src/modest-account-mgr-helpers.c index 98095b9..b88ec80 100644 --- a/src/modest-account-mgr-helpers.c +++ b/src/modest-account-mgr-helpers.c @@ -1049,6 +1049,30 @@ modest_account_mgr_set_last_updated (ModestAccountMgr *self, /* TODO: notify about changes */ } +gboolean +modest_account_mgr_get_has_new_mails (ModestAccountMgr *self, + const gchar* account_name) +{ + return modest_account_mgr_get_bool (modest_runtime_get_account_mgr (), + account_name, + MODEST_ACCOUNT_HAS_NEW_MAILS, + FALSE); +} + +void +modest_account_mgr_set_has_new_mails (ModestAccountMgr *self, + const gchar* account_name, + gboolean has_new_mails) +{ + modest_account_mgr_set_bool (self, + account_name, + MODEST_ACCOUNT_HAS_NEW_MAILS, + has_new_mails, + FALSE); + + /* TODO: notify about changes */ +} + gint modest_account_mgr_get_retrieve_limit (ModestAccountMgr *self, const gchar* account_name) diff --git a/src/modest-account-mgr-helpers.h b/src/modest-account-mgr-helpers.h index f10d873..43a4494 100644 --- a/src/modest-account-mgr-helpers.h +++ b/src/modest-account-mgr-helpers.h @@ -426,6 +426,13 @@ void modest_account_mgr_set_last_updated (ModestAccountMgr *self, const gchar* account_name, gint time); +gboolean modest_account_mgr_get_has_new_mails (ModestAccountMgr *self, + const gchar* account_name); + +void modest_account_mgr_set_has_new_mails (ModestAccountMgr *self, + const gchar* account_name, + gboolean has_new_mails); + gint modest_account_mgr_get_retrieve_limit (ModestAccountMgr *self, const gchar* account_name); diff --git a/src/modest-account-mgr.c b/src/modest-account-mgr.c index c0b7cf2..1ce99a1 100644 --- a/src/modest-account-mgr.c +++ b/src/modest-account-mgr.c @@ -1075,6 +1075,13 @@ modest_account_mgr_set_bool (ModestAccountMgr * self, const gchar * name, g_printerr ("modest: error setting bool '%s': %s\n", keyname, err->message); g_error_free (err); retval = FALSE; + } else { + /* check whether this field is one of those interesting for the + * "account-updated" signal */ + if (strcmp (key, MODEST_ACCOUNT_HAS_NEW_MAILS) == 0) { + g_signal_emit (G_OBJECT(self), signals[ACCOUNT_UPDATED_SIGNAL], + 0, name); + } } return retval; diff --git a/src/modest-defs.h b/src/modest-defs.h index 988ba1a..adb65b9 100644 --- a/src/modest-defs.h +++ b/src/modest-defs.h @@ -205,6 +205,7 @@ const gchar *modest_defs_namespace (const gchar *string); #define MODEST_ACCOUNT_ENABLED "enabled" /* boolean */ #define MODEST_ACCOUNT_TYPE "type" /* string */ #define MODEST_ACCOUNT_LAST_UPDATED "last_updated" /* int */ +#define MODEST_ACCOUNT_HAS_NEW_MAILS "has_new_mails" /* boolean */ #define MODEST_ACCOUNT_LEAVE_ON_SERVER "leave_on_server" /* boolean */ #define MODEST_ACCOUNT_PREFERRED_CNX "preferred_cnx" /* string */ diff --git a/src/modest-mail-operation.c b/src/modest-mail-operation.c index 9a38bcf..7eef26e 100644 --- a/src/modest-mail-operation.c +++ b/src/modest-mail-operation.c @@ -1773,6 +1773,8 @@ inbox_refreshed_cb (TnyFolder *inbox, new_headers_iter = tny_list_create_iterator (((InternalFolderObserver *) info->inbox_observer)->new_headers); if (!tny_iterator_is_done (new_headers_iter)) { modest_platform_emit_folder_updated_signal (info->account_name, tny_folder_get_id (TNY_FOLDER (inbox))); + modest_account_mgr_set_has_new_mails (modest_runtime_get_account_mgr (), + info->account_name, TRUE); } while (!tny_iterator_is_done (new_headers_iter)) { TnyHeader *header = NULL; diff --git a/src/widgets/modest-account-view.c b/src/widgets/modest-account-view.c index f78c5da..792b48b 100644 --- a/src/widgets/modest-account-view.c +++ b/src/widgets/modest-account-view.c @@ -75,6 +75,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); +static void update_style (ModestAccountView *self); static void update_display_mode (ModestAccountView *self); typedef enum { @@ -84,6 +85,7 @@ typedef enum { MODEST_ACCOUNT_VIEW_IS_DEFAULT_COLUMN, MODEST_ACCOUNT_VIEW_PROTO_COLUMN, MODEST_ACCOUNT_VIEW_LAST_UPDATED_COLUMN, + MODEST_ACCOUNT_VIEW_HAS_NEW_MAILS_COLUMN, MODEST_ACCOUNT_VIEW_COLUMN_NUM } AccountViewColumns; @@ -101,6 +103,9 @@ struct _ModestAccountViewPrivate { /* Signal handlers */ GSList *sig_handlers; + + GtkTreeViewColumn *account_name_column; + GtkCellRenderer *account_name_renderer; }; #define MODEST_ACCOUNT_VIEW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \ MODEST_TYPE_ACCOUNT_VIEW, \ @@ -283,6 +288,7 @@ update_account_view (ModestAccountMgr *account_mgr, ModestAccountView *view) /* don't free */ const gchar *last_updated_string = get_last_updated_string(view, account_mgr, settings); + gboolean has_new_mails = modest_account_mgr_get_has_new_mails (account_mgr, account_name); if (modest_account_settings_get_enabled (settings)) { ModestProtocolType protocol_type; @@ -319,6 +325,7 @@ update_account_view (ModestAccountMgr *account_mgr, ModestAccountView *view) #else MODEST_ACCOUNT_VIEW_LAST_UPDATED_COLUMN, last_updated_string, #endif + MODEST_ACCOUNT_VIEW_HAS_NEW_MAILS_COLUMN, has_new_mails, -1); #ifdef MODEST_TOOLKIT_HILDON2 g_free (last_updated_hildon2); @@ -509,8 +516,9 @@ bold_if_default_account_cell_data (GtkTreeViewColumn *column, GtkCellRenderer PangoAttrList *attr_list = NULL; GtkWidget *widget; - gtk_tree_model_get (tree_model, iter, MODEST_ACCOUNT_VIEW_IS_DEFAULT_COLUMN, - &is_default, -1); + gtk_tree_model_get (tree_model, iter, + MODEST_ACCOUNT_VIEW_IS_DEFAULT_COLUMN, &is_default, + -1); /* widget = gtk_tree_view_column_get_tree_view (column); */ widget = GTK_WIDGET (user_data); @@ -584,13 +592,15 @@ init_view (ModestAccountView *self) g_return_if_fail (MODEST_IS_ACCOUNT_VIEW (self)); priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE(self); - priv->model = GTK_TREE_MODEL (gtk_list_store_new (6, + priv->model = GTK_TREE_MODEL (gtk_list_store_new (8, G_TYPE_STRING, /* account name */ G_TYPE_STRING, /* account display name */ G_TYPE_BOOLEAN, /* is-enabled */ G_TYPE_BOOLEAN, /* is-default */ G_TYPE_STRING, /* account proto (pop, imap,...) */ - G_TYPE_STRING /* last updated (time_t) */ + G_TYPE_STRING, /* last updated (time_t) */ + G_TYPE_BOOLEAN, /* has_new_mails has_color */ + G_TYPE_POINTER /* has_new_mails color */ )); gtk_tree_sortable_set_sort_column_id ( @@ -631,19 +641,21 @@ init_view (ModestAccountView *self) self); /* account name */ - text_renderer = gtk_cell_renderer_text_new (); - g_object_set (G_OBJECT (text_renderer), + priv->account_name_renderer = gtk_cell_renderer_text_new (); + g_object_set (G_OBJECT (priv->account_name_renderer), "ellipsize", PANGO_ELLIPSIZE_END, "ellipsize-set", TRUE, #ifdef MODEST_TOOLKIT_HILDON2 "xpad", HILDON_MARGIN_DOUBLE, #endif NULL); - column = gtk_tree_view_column_new_with_attributes (_("mcen_ti_account"), text_renderer, "text", - MODEST_ACCOUNT_VIEW_DISPLAY_NAME_COLUMN, NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW(self), column); - gtk_tree_view_column_set_expand (column, TRUE); - gtk_tree_view_column_set_cell_data_func(column, text_renderer, bold_if_default_account_cell_data, + priv->account_name_column = gtk_tree_view_column_new_with_attributes (_("mcen_ti_account"), priv->account_name_renderer, + "text", MODEST_ACCOUNT_VIEW_DISPLAY_NAME_COLUMN, + NULL); + gtk_tree_view_append_column (GTK_TREE_VIEW(self), priv->account_name_column); + gtk_tree_view_column_set_expand (priv->account_name_column, TRUE); + gtk_tree_view_column_set_cell_data_func(priv->account_name_column, priv->account_name_renderer, + bold_if_default_account_cell_data, self, NULL); /* last update for this account */ @@ -893,6 +905,7 @@ static void on_notify_style (GObject *obj, GParamSpec *spec, gpointer userdata) { if (strcmp ("style", spec->name) == 0) { + update_style (MODEST_ACCOUNT_VIEW (obj)); gtk_widget_queue_draw (GTK_WIDGET (obj)); } } @@ -1024,3 +1037,34 @@ modest_account_view_setup_live_search (ModestAccountView *self) return live_search; } #endif + +static void +update_style (ModestAccountView *self) +{ + ModestAccountViewPrivate *priv; + GdkColor style_active_color; + + g_return_if_fail (MODEST_IS_ACCOUNT_VIEW (self)); + priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE (self); + + if (gtk_style_lookup_color (GTK_WIDGET (self)->style, "ActiveTextColor", &style_active_color)) { + g_object_set (G_OBJECT (priv->account_name_renderer), + "foreground-gdk", &style_active_color, + NULL); + gtk_tree_view_column_set_attributes (priv->account_name_column, priv->account_name_renderer, + "text", MODEST_ACCOUNT_VIEW_DISPLAY_NAME_COLUMN, + "foreground-set", MODEST_ACCOUNT_VIEW_HAS_NEW_MAILS_COLUMN, + NULL); + } else { + g_object_set (G_OBJECT (priv->account_name_renderer), + "foreground-set", FALSE, + "foreground-gdk", NULL, + NULL); + gtk_tree_view_column_set_attributes (priv->account_name_column, priv->account_name_renderer, + "text", MODEST_ACCOUNT_VIEW_DISPLAY_NAME_COLUMN, + NULL); + } + + update_account_view (priv->account_mgr, self); +} + diff --git a/src/widgets/modest-window-mgr.c b/src/widgets/modest-window-mgr.c index fa198e3..95113a7 100644 --- a/src/widgets/modest-window-mgr.c +++ b/src/widgets/modest-window-mgr.c @@ -556,6 +556,7 @@ modest_window_mgr_register_window (ModestWindowMgr *self, application is closed */ modest_runtime_set_allow_shutdown (TRUE); } + return retval; }