MODEST_ACCOUNT_VIEW_COLUMN_NUM
} AccountViewColumns;
-
-/* list my signals */
-enum {
- /* MY_SIGNAL_1, */
- /* MY_SIGNAL_2, */
- LAST_SIGNAL
-};
-
typedef struct _ModestAccountViewPrivate ModestAccountViewPrivate;
struct _ModestAccountViewPrivate {
ModestAccountMgr *account_mgr;
- gulong sig1, sig2, sig3;
-
- /* When this is TRUE, we ignore configuration key changes.
- * This is useful when making many changes. */
- gboolean block_conf_updates;
-
+
+ /* Signal handlers */
+ gulong acc_inserted_handler, acc_removed_handler,
+ acc_busy_changed_handler, acc_changed_handler;
};
#define MODEST_ACCOUNT_VIEW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
MODEST_TYPE_ACCOUNT_VIEW, \
/* globals */
static GtkTreeViewClass *parent_class = NULL;
-/* uncomment the following if you have defined any signals */
-/* static guint signals[LAST_SIGNAL] = {0}; */
-
GType
modest_account_view_get_type (void)
{
priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE(obj);
priv->account_mgr = NULL;
- priv->sig1 = 0;
- priv->sig2 = 0;
+ priv->acc_inserted_handler = 0;
+ priv->acc_removed_handler = 0;
+ priv->acc_busy_changed_handler = 0;
+ priv->acc_changed_handler = 0;
}
static void
priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE(obj);
if (priv->account_mgr) {
- if (priv->sig1)
- g_signal_handler_disconnect (priv->account_mgr, priv->sig1);
-
- if (priv->sig2)
- g_signal_handler_disconnect (priv->account_mgr, priv->sig2);
-
- if (priv->sig3)
- g_signal_handler_disconnect (priv->account_mgr, priv->sig3);
+ if (g_signal_handler_is_connected (modest_runtime_get_account_store (),
+ priv->acc_inserted_handler))
+ g_signal_handler_disconnect (modest_runtime_get_account_store (),
+ priv->acc_inserted_handler);
+
+ if (g_signal_handler_is_connected (modest_runtime_get_account_store (),
+ priv->acc_removed_handler))
+ g_signal_handler_disconnect (modest_runtime_get_account_store (),
+ priv->acc_removed_handler);
+
+ if (priv->acc_busy_changed_handler)
+ g_signal_handler_disconnect (priv->account_mgr, priv->acc_busy_changed_handler);
+ if (priv->acc_changed_handler)
+ g_signal_handler_disconnect (priv->account_mgr, priv->acc_changed_handler);
g_object_unref (G_OBJECT(priv->account_mgr));
priv->account_mgr = NULL;
/* FIXME: let's assume that 'last update' applies to the store account... */
gchar* last_updated_string;
time_t last_updated = account_data->store_account->last_updated;
- if (!modest_account_mgr_account_is_busy(account_mgr, account_data->account_name))
- {
+ if (!modest_account_mgr_account_is_busy(account_mgr, account_data->account_name)) {
if (last_updated > 0)
- last_updated_string = modest_text_utils_get_display_date(last_updated);
+ last_updated_string = modest_text_utils_get_display_date(last_updated);
else
- last_updated_string = g_strdup (_("mcen_va_never"));
- }
- else
- {
+ last_updated_string = g_strdup (_("mcen_va_never"));
+ } else {
/* FIXME: There should be a logical name in the UI specs */
- last_updated_string = g_strdup(_("Refreshing..."));
+ last_updated_string = g_strdup(_("..."));
}
return last_updated_string;
}
* current use instead */
cursor = account_names = modest_account_mgr_account_names (account_mgr,
TRUE /* only enabled accounts. */);
-
- if (!account_names)
- g_warning ("debug: modest_account_mgr_account_names() returned NULL\n");
while (cursor) {
gchar *account_name;
}
}
-
-static void
-on_account_changed (ModestAccountMgr *account_mgr,
- const gchar* account, GSList *keys,
- gboolean server_account, ModestAccountView *self)
-{
- /* Never update the view in response to gconf changes.
- * Always do it explicitly instead.
- * This is because we have no way to avoid 10 updates when changing
- * 10 items, and this blocks the UI.
- *
- * But this block/unblock API might be useful on platforms where the
- * notification does not happen so long after the key was set.
- * (We have no way to know when the last key was set, to do a final update)..
- */
-
- update_account_view (account_mgr, self);
-}
-
static void
-on_account_busy_changed(ModestAccountMgr *account_mgr, const gchar *account_name,
- gboolean busy, ModestAccountView *self)
+on_account_busy_changed(ModestAccountMgr *account_mgr,
+ const gchar *account_name,
+ gboolean busy,
+ ModestAccountView *self)
{
GtkListStore *model = GTK_LIST_STORE(gtk_tree_view_get_model (GTK_TREE_VIEW(self)));
GtkTreeIter iter;
}
static void
-on_account_removed (ModestAccountMgr *account_mgr,
- const gchar* account, gboolean server_account,
- ModestAccountView *self)
-{
- update_account_view (account_mgr, self);
+on_account_inserted (TnyAccountStore *account_store,
+ TnyAccount *account,
+ gpointer user_data)
+{
+ ModestAccountView *self;
+ ModestAccountViewPrivate *priv;
+
+ self = MODEST_ACCOUNT_VIEW (user_data);
+ priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE (self);
+
+ update_account_view (priv->account_mgr, self);
+}
+
+static void
+on_account_removed (TnyAccountStore *account_store,
+ TnyAccount *account,
+ gpointer user_data)
+{
+ ModestAccountView *self;
+ ModestAccountViewPrivate *priv;
+
+ self = MODEST_ACCOUNT_VIEW (user_data);
+ priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE (self);
+
+ update_account_view (priv->account_mgr, self);
}
-/* currently unused */
-#if 0
static void
-on_account_enable_toggled (GtkCellRendererToggle *cell_renderer, gchar *path,
- ModestAccountView *self)
+on_account_changed (TnyAccountStore *account_store,
+ TnyAccount *account,
+ gpointer user_data)
{
- GtkTreeIter iter;
+ ModestAccountView *self;
ModestAccountViewPrivate *priv;
- GtkTreeModel *model;
- gchar *account_name;
- gboolean enabled;
-
- priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE(self);
- model = gtk_tree_view_get_model (GTK_TREE_VIEW(self));
-
- if (!gtk_tree_model_get_iter_from_string (model, &iter, path)) {
- g_printerr ("modest: cannot find iterator\n");
- return;
- }
- gtk_tree_model_get (model, &iter, MODEST_ACCOUNT_VIEW_IS_ENABLED_COLUMN, &enabled,
- MODEST_ACCOUNT_VIEW_NAME_COLUMN, &account_name,
- -1);
+
+ self = MODEST_ACCOUNT_VIEW (user_data);
+ priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE (self);
+
+ g_warning ("account changed: %s", tny_account_get_id(account));
- /* toggle enabled / disabled */
- modest_account_mgr_set_enabled (priv->account_mgr, account_name, !enabled);
- g_free (account_name);
+ update_account_view (priv->account_mgr, self);
}
-#endif
+
+
static gboolean
find_default_account(ModestAccountView *self, GtkTreeIter *iter)
*/
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(self), TRUE);
- priv->sig1 = g_signal_connect (G_OBJECT(priv->account_mgr),"account_removed",
- G_CALLBACK(on_account_removed), self);
- priv->sig2 = g_signal_connect (G_OBJECT(priv->account_mgr), "account_changed",
- G_CALLBACK(on_account_changed), self);
- priv->sig3 = g_signal_connect (G_OBJECT(priv->account_mgr), "account_busy_changed",
- G_CALLBACK(on_account_busy_changed), self);
+ priv->acc_removed_handler = g_signal_connect (G_OBJECT (modest_runtime_get_account_store ()),
+ "account_removed",
+ G_CALLBACK(on_account_removed), self);
+
+ priv->acc_inserted_handler = g_signal_connect (G_OBJECT (modest_runtime_get_account_store ()),
+ "account_inserted",
+ G_CALLBACK(on_account_inserted), self);
+
+ priv->acc_busy_changed_handler = g_signal_connect (G_OBJECT(priv->account_mgr),
+ "account_busy_changed",
+ G_CALLBACK(on_account_busy_changed), self);
+
+ priv->acc_changed_handler = g_signal_connect (G_OBJECT(priv->account_mgr),
+ "account_changed",
+ G_CALLBACK(on_account_changed), self);
}