static gboolean on_zoom_minus_plus_not_implemented (ModestWindow *window);
-static void on_account_update (TnyAccountStore *account_store,
+static void account_number_changed (TnyAccountStore *account_store,
const gchar *account_name,
gpointer user_data);
/* Track account changes. We need to refresh the toolbar */
g_signal_connect (G_OBJECT (modest_runtime_get_account_store ()),
- "account_update", G_CALLBACK (on_account_update),
+ "account_inserted", G_CALLBACK (account_number_changed),
+ self);
+ g_signal_connect (G_OBJECT (modest_runtime_get_account_store ()),
+ "account_removed", G_CALLBACK (account_number_changed),
self);
/* Account store */
gtk_widget_tap_and_hold_setup (GTK_WIDGET (reply_button), menu, NULL, 0);
/* Set send & receive button tap and hold menu */
- on_account_update (TNY_ACCOUNT_STORE (modest_runtime_get_account_store ()),
+ account_number_changed (TNY_ACCOUNT_STORE (modest_runtime_get_account_store ()),
NULL, self);
}
}
static void
-on_account_update (TnyAccountStore *account_store,
- const gchar *account_name,
- gpointer user_data)
+account_number_changed (TnyAccountStore *account_store,
+ const gchar *account_name,
+ gpointer user_data)
{
GSList *account_names, *iter, *accounts;
ModestMainWindow *self;
for (i = 0; i < num_accounts; i++) {
ModestAccountData *account_data = (ModestAccountData *) g_slist_nth_data (accounts, i);
- if(account_data->account_name &&
+ if(account_data->account_name && default_account &&
strcmp (account_data->account_name, default_account) == 0) {
gchar *item_name = g_strconcat (account_data->account_name, "Menu", NULL);
{
GtkWidget *widget = modest_folder_view_new (query);
- /* Show all accounts by default */
+ /* Show one account by default */
modest_folder_view_set_style (MODEST_FOLDER_VIEW (widget),
MODEST_FOLDER_VIEW_STYLE_SHOW_ONE);
+
/* Restore settings */
modest_widget_memory_restore (modest_runtime_get_conf(),
G_OBJECT (widget),
conf = MODEST_ACCOUNT_MGR_GET_PRIVATE (self)->modest_conf;
- return modest_conf_set_string (conf, MODEST_CONF_DEFAULT_ACCOUNT,
- account, NULL);
-
+ return modest_conf_set_string (conf, MODEST_CONF_DEFAULT_ACCOUNT, account, NULL);
}
gboolean
LAST_SIGNAL
};
-
/* globals */
static GObjectClass *parent_class = NULL;
static guint signals[LAST_SIGNAL] = {0};
-/* We signal key changes in batches, every X seconds: */
-static gboolean
-on_timeout_notify_changes (gpointer data)
-{
- ModestAccountMgr *self = MODEST_ACCOUNT_MGR (data);
- ModestAccountMgrPrivate *priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
+/* /\* We signal key changes in batches, every X seconds: *\/ */
+/* static gboolean */
+/* on_timeout_notify_changes (gpointer data) */
+/* { */
+/* ModestAccountMgr *self = MODEST_ACCOUNT_MGR (data); */
+/* ModestAccountMgrPrivate *priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self); */
- /* TODO: Also store the account names, and notify one list for each account,
- * if anything uses the account names. */
+/* /\* TODO: Also store the account names, and notify one list for each account, */
+/* * if anything uses the account names. *\/ */
- if (priv->changed_conf_keys) {
- gchar *default_account =
- modest_account_mgr_get_default_account (self);
+/* if (priv->changed_conf_keys) { */
+/* gchar *default_account = */
+/* modest_account_mgr_get_default_account (self); */
- /* printf ("DEBUG: %s: priv->changed_conf_key length=%d\n",
- __FUNCTION__, g_slist_length (priv->changed_conf_keys)); */
- g_signal_emit (G_OBJECT(self), signals[ACCOUNT_CHANGED_SIGNAL], 0,
- default_account, priv->changed_conf_keys, FALSE);
+/* /\* printf ("DEBUG: %s: priv->changed_conf_key length=%d\n", */
+/* __FUNCTION__, g_slist_length (priv->changed_conf_keys)); *\/ */
+/* g_signal_emit (G_OBJECT(self), signals[ACCOUNT_CHANGED_SIGNAL], 0, */
+/* default_account, priv->changed_conf_keys, FALSE); */
- g_free (default_account);
+/* g_free (default_account); */
- g_slist_foreach (priv->changed_conf_keys, (GFunc) g_free, NULL);
- g_slist_free (priv->changed_conf_keys);
- priv->changed_conf_keys = NULL;
- }
+/* g_slist_foreach (priv->changed_conf_keys, (GFunc) g_free, NULL); */
+/* g_slist_free (priv->changed_conf_keys); */
+/* priv->changed_conf_keys = NULL; */
+/* } */
- return TRUE; /* Call this again later. */
-}
-
-static void
-on_key_change (ModestConf *conf, const gchar *key, ModestConfEvent event, gpointer user_data)
-{
- ModestAccountMgr *self = MODEST_ACCOUNT_MGR (user_data);
- ModestAccountMgrPrivate *priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self);
- gboolean is_account_key;
- gboolean is_server_account;
- gchar* account = NULL;
-
- /* there is only one not-really-account key which will still emit
- * a signal: a change in MODEST_CONF_DEFAULT_ACCOUNT */
- if (key && strcmp (key, MODEST_CONF_DEFAULT_ACCOUNT) == 0) {
- /* Get the default account instead. */
+/* return TRUE; /\* Call this again later. *\/ */
+/* } */
+
+/* static void */
+/* on_key_change (ModestConf *conf, const gchar *key, ModestConfEvent event, gpointer user_data) */
+/* { */
+/* ModestAccountMgr *self = MODEST_ACCOUNT_MGR (user_data); */
+/* ModestAccountMgrPrivate *priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self); */
+/* gboolean is_account_key; */
+/* gboolean is_server_account; */
+/* gchar* account = NULL; */
+
+/* /\* there is only one not-really-account key which will still emit */
+/* * a signal: a change in MODEST_CONF_DEFAULT_ACCOUNT *\/ */
+/* if (key && strcmp (key, MODEST_CONF_DEFAULT_ACCOUNT) == 0) { */
+/* /\* Get the default account instead. *\/ */
- /* Store the key for later notification in our timeout callback.
- * Notifying for every key change would cause unnecessary work: */
- priv->changed_conf_keys = g_slist_append (priv->changed_conf_keys,
- (gpointer) g_strdup (key));
- }
+/* /\* Store the key for later notification in our timeout callback. */
+/* * Notifying for every key change would cause unnecessary work: *\/ */
+/* priv->changed_conf_keys = g_slist_append (priv->changed_conf_keys, */
+/* (gpointer) g_strdup (key)); */
+/* } */
- is_account_key = FALSE;
- is_server_account = FALSE;
- account = _modest_account_mgr_account_from_key (key, &is_account_key,
- &is_server_account);
-
- /* if this is not an account-related key change, ignore */
- if (!account)
- return;
-
- /* account was removed. Do not emit an account removed signal
- because it was already being done in the remove_account
- method. Do not notify also the removal of the server
- account keys for the same reason */
- if ((is_account_key || is_server_account) &&
- event == MODEST_CONF_EVENT_KEY_UNSET) {
- g_free (account);
- return;
- }
-
- /* is this account enabled? */
- gboolean enabled = FALSE;
- if (is_server_account)
- enabled = TRUE;
- else
- enabled = modest_account_mgr_get_enabled (self, account);
-
- /* Notify is server account was changed, default account was changed
- * or when enabled/disabled changes:
- */
- if (enabled ||
- g_str_has_suffix (key, MODEST_ACCOUNT_ENABLED) ||
- strcmp (key, MODEST_CONF_DEFAULT_ACCOUNT) == 0) {
- /* Store the key for later notification in our timeout callback.
- * Notifying for every key change would cause unnecessary work: */
- priv->changed_conf_keys = g_slist_append (NULL,
- (gpointer) g_strdup (key));
- }
- g_free (account);
-}
+/* is_account_key = FALSE; */
+/* is_server_account = FALSE; */
+/* account = _modest_account_mgr_account_from_key (key, &is_account_key, */
+/* &is_server_account); */
+
+/* /\* if this is not an account-related key change, ignore *\/ */
+/* if (!account) */
+/* return; */
+
+/* /\* account was removed. Do not emit an account removed signal */
+/* because it was already being done in the remove_account */
+/* method. Do not notify also the removal of the server */
+/* account keys for the same reason *\/ */
+/* if ((is_account_key || is_server_account) && */
+/* event == MODEST_CONF_EVENT_KEY_UNSET) { */
+/* g_free (account); */
+/* return; */
+/* } */
+
+/* /\* is this account enabled? *\/ */
+/* gboolean enabled = FALSE; */
+/* if (is_server_account) */
+/* enabled = TRUE; */
+/* else */
+/* enabled = modest_account_mgr_get_enabled (self, account); */
+
+/* /\* Notify is server account was changed, default account was changed */
+/* * or when enabled/disabled changes: */
+/* *\/ */
+/* if (enabled || */
+/* g_str_has_suffix (key, MODEST_ACCOUNT_ENABLED) || */
+/* strcmp (key, MODEST_CONF_DEFAULT_ACCOUNT) == 0) { */
+/* /\* Store the key for later notification in our timeout callback. */
+/* * Notifying for every key change would cause unnecessary work: *\/ */
+/* priv->changed_conf_keys = g_slist_append (NULL, */
+/* (gpointer) g_strdup (key)); */
+/* } */
+/* g_free (account); */
+/* } */
GType
priv->modest_conf = NULL;
priv->busy_accounts = NULL;
- priv->timeout = g_timeout_add (1000 /* milliseconds */, on_timeout_notify_changes, obj);
+/* priv->timeout = g_timeout_add (1000 /\* milliseconds *\/, on_timeout_notify_changes, obj); */
}
static void
priv->modest_conf = NULL;
}
- if (priv->timeout)
- g_source_remove (priv->timeout);
+/* if (priv->timeout) */
+/* g_source_remove (priv->timeout); */
if (priv->changed_conf_keys) {
g_slist_foreach (priv->changed_conf_keys, (GFunc) g_free, NULL);
g_object_ref (G_OBJECT(conf));
priv->modest_conf = conf;
- priv->key_changed_handler_uid =
- g_signal_connect (G_OBJECT (conf), "key_changed",
- G_CALLBACK (on_key_change),
- obj);
+/* priv->key_changed_handler_uid = */
+/* g_signal_connect (G_OBJECT (conf), "key_changed", */
+/* G_CALLBACK (on_key_change), */
+/* obj); */
return MODEST_ACCOUNT_MGR (obj);
}
modest_account_mgr_set_enabled (self, name, enabled);
+ /* Notify the observers */
+ g_signal_emit (self, signals[ACCOUNT_INSERTED_SIGNAL], 0, name);
+
/* if no default account has been defined yet, do so now */
default_account = modest_account_mgr_get_default_account (self);
if (!default_account)
TnyList *list,
TnyAccountType type);
+static void on_account_inserted (ModestAccountMgr *acc_mgr,
+ const gchar *account,
+ gpointer user_data);
+
+static void on_account_removed (ModestAccountMgr *acc_mgr,
+ const gchar *account,
+ gpointer user_data);
+
+
/* list my signals */
enum {
ACCOUNT_CHANGED_SIGNAL,
ACCOUNT_INSERTED_SIGNAL,
ACCOUNT_REMOVED_SIGNAL,
- ACCOUNT_UPDATE_SIGNAL,
PASSWORD_REQUESTED_SIGNAL,
LAST_SIGNAL
};
ModestAccountMgr *account_mgr;
TnySessionCamel *session;
TnyDevice *device;
+
+ gulong acc_inserted_handler;
+ gulong acc_changed_handler;
+ gulong acc_removed_handler;
/* We cache the lists of accounts here.
* They are created in our get_accounts_func() implementation. */
/* g_cclosure_marshal_VOID__VOID, */
/* G_TYPE_NONE, 0); */
- signals[ACCOUNT_UPDATE_SIGNAL] =
- g_signal_new ("account_update",
- MODEST_TYPE_TNY_ACCOUNT_STORE,
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET(ModestTnyAccountStoreClass, account_update),
- NULL, NULL,
- g_cclosure_marshal_VOID__STRING,
- G_TYPE_NONE, 1, G_TYPE_STRING);
-
signals[PASSWORD_REQUESTED_SIGNAL] =
g_signal_new ("password_requested",
MODEST_TYPE_TNY_ACCOUNT_STORE,
static void
on_vfs_volume_mounted(GnomeVFSVolumeMonitor *volume_monitor,
- GnomeVFSVolume *volume, gpointer user_data)
+ GnomeVFSVolume *volume,
+ gpointer user_data)
{
- ModestTnyAccountStore *self = MODEST_TNY_ACCOUNT_STORE(user_data);
+/* ModestTnyAccountStore *self = MODEST_TNY_ACCOUNT_STORE(user_data); */
/* Check whether this was the external MMC1 card: */
gchar *uri = gnome_vfs_volume_get_activation_uri (volume);
if (uri && (strcmp (uri, MODEST_MCC1_VOLUMEPATH_URI) == 0)) {
printf ("DEBUG: %s: MMC1 card mounted.\n", __FUNCTION__);
- /* TODO: Just add an account and emit (and respond to)
- * TnyAccountStore::accountinserted signal?
- */
- recreate_all_accounts (self);
-
- g_signal_emit (G_OBJECT(self), signals[ACCOUNT_UPDATE_SIGNAL], 0,
- NULL);
+/* /\* TODO: Just add an account and emit (and respond to) */
+/* * TnyAccountStore::accountinserted signal? */
+/* *\/ */
+/* recreate_all_accounts (self); */
+
+ /* TODO */
+/* g_signal_emit (G_OBJECT(self), signals[ACCOUNT_UPDATE_SIGNAL], 0, */
+/* NULL); */
+/* g_signal_emit (G_OBJECT (self), */
+/* signals [ACCOUNT_INSERTED_SIGNAL], */
+/* 0, mmc_account); */
}
-
g_free (uri);
}
static void
on_vfs_volume_unmounted(GnomeVFSVolumeMonitor *volume_monitor,
- GnomeVFSVolume *volume, gpointer user_data)
+ GnomeVFSVolume *volume,
+ gpointer user_data)
{
- ModestTnyAccountStore *self = MODEST_TNY_ACCOUNT_STORE(user_data);
+/* ModestTnyAccountStore *self = MODEST_TNY_ACCOUNT_STORE(user_data); */
/* Check whether this was the external MMC1 card: */
gchar *uri = gnome_vfs_volume_get_activation_uri (volume);
if (uri && (strcmp (uri, MODEST_MCC1_VOLUMEPATH_URI) == 0)) {
printf ("DEBUG: %s: MMC1 card unmounted.\n", __FUNCTION__);
- /* TODO: Just add an account and emit (and respond to)
- * TnyAccountStore::accountinserted signal?
- */
- recreate_all_accounts (self);
+/* /\* TODO: Just add an account and emit (and respond to) */
+/* * TnyAccountStore::accountinserted signal? */
+/* *\/ */
+/* recreate_all_accounts (self); */
- g_signal_emit (G_OBJECT(self), signals[ACCOUNT_UPDATE_SIGNAL], 0,
- NULL);
+/* g_signal_emit (G_OBJECT(self), signals[ACCOUNT_UPDATE_SIGNAL], 0, */
+/* NULL); */
+
+ /* TODO */
+/* g_signal_emit (G_OBJECT (self), */
+/* signals [ACCOUNT_REMOVED_SIGNAL], */
+/* 0, mmc_account); */
}
-
g_free (uri);
}
static void
-on_account_removed (ModestAccountMgr *acc_mgr,
- const gchar *account,
- gpointer user_data)
+on_account_inserted (ModestAccountMgr *acc_mgr,
+ const gchar *account,
+ gpointer user_data)
{
+ ModestTnyAccountStorePrivate *priv = NULL;
TnyAccount *store_account = NULL, *transport_account = NULL;
- ModestTnyAccountStore *self = MODEST_TNY_ACCOUNT_STORE(user_data);
+ ModestTnyAccountStore *self = NULL;
+ self = MODEST_TNY_ACCOUNT_STORE(user_data);
+ priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
+
/* Get the server and the transport account */
store_account =
modest_tny_account_store_get_server_account (self, account, TNY_ACCOUNT_TYPE_STORE);
transport_account =
modest_tny_account_store_get_server_account (self, account, TNY_ACCOUNT_TYPE_TRANSPORT);
- /* Clear the cache */
- tny_store_account_delete_cache (TNY_STORE_ACCOUNT (store_account));
+ /* Add to the cached accounts */
+ tny_list_prepend (priv->store_accounts, G_OBJECT (store_account));
+ tny_list_prepend (priv->transport_accounts, G_OBJECT (transport_account));
/* Notify the observers */
- g_signal_emit (G_OBJECT (self),
- signals [ACCOUNT_REMOVED_SIGNAL],
- 0, store_account);
- g_signal_emit (G_OBJECT (self),
- signals [ACCOUNT_REMOVED_SIGNAL],
- 0, transport_account);
+ g_signal_emit (G_OBJECT (self), signals [ACCOUNT_INSERTED_SIGNAL], 0, store_account);
+ g_signal_emit (G_OBJECT (self), signals [ACCOUNT_INSERTED_SIGNAL], 0, transport_account);
/* Frees */
g_object_unref (store_account);
g_object_unref (transport_account);
}
+static void
+on_account_removed (ModestAccountMgr *acc_mgr,
+ const gchar *account,
+ gpointer user_data)
+{
+ TnyAccount *store_account = NULL, *transport_account = NULL;
+ ModestTnyAccountStore *self = MODEST_TNY_ACCOUNT_STORE(user_data);
+
+ /* Get the server and the transport account */
+ store_account =
+ modest_tny_account_store_get_server_account (self, account, TNY_ACCOUNT_TYPE_STORE);
+ transport_account =
+ modest_tny_account_store_get_server_account (self, account, TNY_ACCOUNT_TYPE_TRANSPORT);
+
+ /* If there was any problem creating the account, for example,
+ with the configuration system this could not exist */
+ if (store_account) {
+ /* Clear the cache */
+ tny_store_account_delete_cache (TNY_STORE_ACCOUNT (store_account));
+
+ /* Notify the observers */
+ g_signal_emit (G_OBJECT (self), signals [ACCOUNT_REMOVED_SIGNAL], 0, store_account);
+ g_object_unref (store_account);
+ } else {
+ g_warning ("There is no store account for account %s\n", account);
+ }
+
+ /* If there was any problem creating the account, for example,
+ with the configuration system this could not exist */
+ if (transport_account) {
+ /* Notify the observers */
+ g_signal_emit (G_OBJECT (self), signals [ACCOUNT_REMOVED_SIGNAL], 0, transport_account);
+ g_object_unref (transport_account);
+ } else {
+ g_warning ("There is no transport account for account %s\n", account);
+ }
+}
+
/**
* modest_tny_account_store_forget_password_in_memory
* @self: a TnyAccountStore instance
}
static void
-on_account_changed (ModestAccountMgr *acc_mgr, const gchar *account,
- const GSList *keys, gboolean server_account, gpointer user_data)
-
+on_account_changed (ModestAccountMgr *acc_mgr,
+ const gchar *account,
+ const GSList *keys,
+ gboolean server_account,
+ gpointer user_data)
{
ModestTnyAccountStore *self = MODEST_TNY_ACCOUNT_STORE(user_data);
}
#endif
- g_signal_emit (G_OBJECT(self), signals[ACCOUNT_UPDATE_SIGNAL], 0,
- account);
+/* g_signal_emit (G_OBJECT(self), signals[ACCOUNT_UPDATE_SIGNAL], 0, */
+/* account); */
}
destroy_password_hashtable (self);
if (priv->account_mgr) {
+ /* Disconnect signals */
+ if (g_signal_handler_is_connected (priv->account_mgr,
+ priv->acc_inserted_handler))
+ g_signal_handler_disconnect (priv->account_mgr,
+ priv->acc_inserted_handler);
+ if (g_signal_handler_is_connected (priv->account_mgr,
+ priv->acc_changed_handler))
+ g_signal_handler_disconnect (priv->account_mgr,
+ priv->acc_changed_handler);
+ if (g_signal_handler_is_connected (priv->account_mgr,
+ priv->acc_removed_handler))
+ g_signal_handler_disconnect (priv->account_mgr,
+ priv->acc_removed_handler);
+
g_object_unref (G_OBJECT(priv->account_mgr));
priv->account_mgr = NULL;
}
tny_session_camel_set_ui_locker (priv->session, tny_gtk_lockable_new ());
/* Connect signals */
- g_signal_connect (G_OBJECT(account_mgr), "account_changed",
- G_CALLBACK (on_account_changed), obj);
- g_signal_connect (G_OBJECT(account_mgr), "account_removed",
- G_CALLBACK (on_account_removed), obj);
+ priv->acc_inserted_handler = g_signal_connect (G_OBJECT(account_mgr), "account_inserted",
+ G_CALLBACK (on_account_inserted), obj);
+ priv->acc_changed_handler = g_signal_connect (G_OBJECT(account_mgr), "account_changed",
+ G_CALLBACK (on_account_changed), obj);
+ priv->acc_removed_handler = g_signal_connect (G_OBJECT(account_mgr), "account_removed",
+ G_CALLBACK (on_account_removed), obj);
return MODEST_TNY_ACCOUNT_STORE(obj);
}
g_return_if_fail (type == TNY_ACCOUNT_TYPE_STORE ||
type == TNY_ACCOUNT_TYPE_TRANSPORT);
- g_return_if_fail (list);
g_return_if_fail (self);
priv = MODEST_TNY_ACCOUNT_STORE_GET_PRIVATE(self);
(gpointer)self);
/* Append to the list and cache it */
- tny_list_append (list, G_OBJECT (tny_account));
+ if (list)
+ tny_list_append (list, G_OBJECT (tny_account));
tny_list_append (accounts, G_OBJECT (tny_account));
} else
g_printerr ("modest: failed to create account for %s\n",
priv->session, MODEST_MCC1_VOLUMEPATH);
/* Append to the list and cache it */
- tny_list_prepend (list, G_OBJECT(tny_account));
+ if (list)
+ tny_list_prepend (list, G_OBJECT(tny_account));
tny_list_append (accounts, G_OBJECT (tny_account));
}
}
(gpointer)self);
/* Append to the list and cache it */
- tny_list_prepend (list, G_OBJECT(tny_account));
+ if (list)
+ tny_list_prepend (list, G_OBJECT(tny_account));
tny_list_append (accounts, G_OBJECT (tny_account));
} else
g_printerr ("modest: failed to create smtp-specific account for %s\n",
/* Add them to the TnyList: */
if (priv->store_accounts_outboxes) {
/* Add accounts to the lists */
- tny_list_foreach (priv->store_accounts_outboxes,
- foreach_account_append_to_list, list);
+ if (list)
+ tny_list_foreach (priv->store_accounts_outboxes,
+ foreach_account_append_to_list, list);
tny_list_foreach (priv->store_accounts_outboxes,
foreach_account_append_to_list, accounts);
}
}
/* Append to the list and cache it */
- tny_list_append (list, G_OBJECT(tny_account));
+ if (list)
+ tny_list_append (list, G_OBJECT(tny_account));
tny_list_append (accounts, G_OBJECT(tny_account));
}
/* ******************** WARNING ******************** */
/* /\* Make sure that the tny accounts have been created: */
-/* * TODO: We might want to do this in several places. */
-/* *\/ */
-/* if (!priv->store_accounts || !priv->transport_accounts) */
-/* recreate_all_accounts (self); */
+ if (!priv->store_accounts || !priv->transport_accounts)
+ recreate_all_accounts (self);
account_list = (type == TNY_ACCOUNT_TYPE_STORE) ?
priv->store_accounts :
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;
+ gulong acc_removed_handler;
+ gulong sig3;
};
#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->sig3 = 0;
}
static void
priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE(obj);
if (priv->account_mgr) {
- if (priv->sig1)
+ 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->sig1);
+ priv->acc_inserted_handler);
- if (priv->sig2)
- g_signal_handler_disconnect (priv->account_mgr, priv->sig2);
+ 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->sig3)
g_signal_handler_disconnect (priv->account_mgr, priv->sig3);
}
}
-
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_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)
self = MODEST_ACCOUNT_VIEW (user_data);
priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE (self);
- update_account_view (priv->account_mgr, MODEST_ACCOUNT_VIEW (user_data));
+ update_account_view (priv->account_mgr, self);
}
*/
gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(self), TRUE);
- priv->sig1 = g_signal_connect (G_OBJECT (modest_runtime_get_account_store ()),"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->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->sig3 = g_signal_connect (G_OBJECT(priv->account_mgr), "account_busy_changed",
G_CALLBACK(on_account_busy_changed), self);
}
static void on_selection_changed (GtkTreeSelection *sel, gpointer data);
-static void on_account_update (TnyAccountStore *account_store,
- const gchar *account,
- gpointer user_data);
-
static void on_account_removed (TnyAccountStore *self,
TnyAccount *account,
gpointer user_data);
TnyFolder *folder_to_select; /* folder to select after the next update */
- gulong account_update_signal;
gulong changed_signal;
gulong account_inserted_signal;
gulong account_removed_signal;
if (priv->account_store) {
g_signal_handler_disconnect (G_OBJECT(priv->account_store),
- priv->account_update_signal);
- g_signal_handler_disconnect (G_OBJECT(priv->account_store),
priv->account_inserted_signal);
g_signal_handler_disconnect (G_OBJECT(priv->account_store),
priv->account_removed_signal);
if (G_UNLIKELY (priv->account_store)) {
- if (g_signal_handler_is_connected (G_OBJECT (priv->account_store),
- priv->account_update_signal))
- g_signal_handler_disconnect (G_OBJECT (priv->account_store),
- priv->account_update_signal);
if (g_signal_handler_is_connected (G_OBJECT (priv->account_store),
priv->account_inserted_signal))
g_signal_handler_disconnect (G_OBJECT (priv->account_store),
priv->account_store = g_object_ref (G_OBJECT (account_store));
- priv->account_update_signal =
- g_signal_connect (G_OBJECT(account_store), "account_update",
- G_CALLBACK (on_account_update), self);
-
priv->account_removed_signal =
g_signal_connect (G_OBJECT(account_store), "account_removed",
G_CALLBACK (on_account_removed), self);
TnyAccount *account,
gpointer user_data)
{
+ ModestFolderViewPrivate *priv;
GtkTreeModel *sort_model, *filter_model;
- /* TODO: invalidate the cur_folder_* and folder_to_select things */
+ /* Ignore transport account insertions, we're not showing them
+ in the folder view */
+ if (TNY_IS_TRANSPORT_ACCOUNT (account))
+ return;
+
+ priv = MODEST_FOLDER_VIEW_GET_PRIVATE (user_data);
+
+ /* If we're adding a new account, and there is no previous
+ one, we need to select the visible server account */
+ if (priv->style == MODEST_FOLDER_VIEW_STYLE_SHOW_ONE &&
+ !priv->visible_account_id)
+ modest_widget_memory_restore (modest_runtime_get_conf(),
+ G_OBJECT (user_data),
+ MODEST_CONF_FOLDER_VIEW_KEY);
/* Get the inner model */
filter_model = gtk_tree_view_get_model (GTK_TREE_VIEW (user_data));
sort_model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (filter_model));
/* Insert the account in the model */
- tny_list_append (TNY_LIST (gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (sort_model))),
+ tny_list_append (TNY_LIST (gtk_tree_model_sort_get_model (GTK_TREE_MODEL_SORT (sort_model))),
G_OBJECT (account));
}
TnyAccount *account,
gpointer user_data)
{
- ModestFolderView *self = MODEST_FOLDER_VIEW (user_data);
+ ModestFolderView *self = NULL;
ModestFolderViewPrivate *priv;
GtkTreeModel *sort_model, *filter_model;
+ self = MODEST_FOLDER_VIEW (user_data);
priv = MODEST_FOLDER_VIEW_GET_PRIVATE (self);
/* TODO: invalidate the cur_folder_* and folder_to_select things */
}
}
-static void
-on_account_update (TnyAccountStore *account_store,
- const gchar *account,
- gpointer user_data)
-{
- ModestFolderView *self = NULL;
- ModestFolderViewPrivate *priv;
-
- g_return_if_fail (MODEST_IS_FOLDER_VIEW (user_data));
- self = MODEST_FOLDER_VIEW (user_data);
- priv = MODEST_FOLDER_VIEW_GET_PRIVATE (self);
-
- /* If we're adding a new account, and there is no previous
- one, we need to select the visible server account */
- if (priv->style == MODEST_FOLDER_VIEW_STYLE_SHOW_ONE &&
- !priv->visible_account_id)
- modest_widget_memory_restore (modest_runtime_get_conf(), G_OBJECT(self),
- MODEST_CONF_FOLDER_VIEW_KEY);
-
- if (!modest_folder_view_update_model (self, account_store))
- g_printerr ("modest: failed to update model for changes in '%s'",
- account);
-}
-
-/* static void */
-/* on_accounts_reloaded (TnyAccountStore *account_store, */
-/* gpointer user_data) */
-/* { */
-/* g_return_if_fail (MODEST_IS_FOLDER_VIEW (user_data)); */
-/* modest_folder_view_update_model (MODEST_FOLDER_VIEW (user_data), account_store); */
-/* } */
-
void
modest_folder_view_set_title (ModestFolderView *self, const gchar *title)
{
}
}
-void
+void
modest_folder_view_set_style (ModestFolderView *self,
ModestFolderViewStyle style)
{
if (win)
*win = NULL;
- g_debug ("windows in list: %d", g_list_length (priv->window_list));
- g_debug ("headers in list: %d", g_slist_length (priv->preregistered_uids));
+/* g_debug ("windows in list: %d", g_list_length (priv->window_list)); */
+/* g_debug ("headers in list: %d", g_slist_length (priv->preregistered_uids)); */
has_header = has_uid (priv->preregistered_uids, uid);