2007-05-09 Murray Cumming <murrayc@murrayc.com>
+ * src/widgets/modest-account-view.h:
+ * src/widgets/modest-account-view.c: (on_account_changed),
+ (on_account_removed). Added a boolean flag, set/unset by
+ modest_account_view_block_conf_updates(),
+ modest_account_view_unblock_conf_updates() to prevent unnecessary
+ updates, but this is not very useful because the gconf notifications are
+ so delays (maybe only on Maemo Bora).
+ So auto-updating is turned off, and these functions do an explicit
+ update when necessary.
+ However, something else is still doing too much work when adding/removing
+ accounts, probably in another part of the application.
+
+ * src/maemo/modest-account-view-window.c:
+ (on_delete_button_clicked), (on_edit_button_clicked),
+ (on_new_button_clicked): Use the new functions.
+
+2007-05-09 Murray Cumming <murrayc@murrayc.com>
+
* src/modest-account-mgr-helpers.c:
(modest_account_mgr_set_first_account_as_default):
Sort the list of names alphabetically-by-title, so we choose the first one
GtkWidget *dialog;
gchar *txt;
+ /* Freeze updates, so we can do just one update afterwards,
+ * instead of responding to every conf key change: */
+ modest_account_view_block_conf_updates (priv->account_view);
+
dialog = gtk_dialog_new_with_buttons (_("Confirmation dialog"),
GTK_WINDOW (self),
GTK_DIALOG_MODAL,
gtk_widget_destroy (dialog);
g_free (account_title);
g_free (account_name);
+
+ /* Update the view: */
+ modest_account_view_unblock_conf_updates (priv->account_view);
}
}
if (!account_name)
return;
+ /* Freeze updates, so we can do just one update afterwards,
+ * instead of responding to every conf key change: */
+ modest_account_view_block_conf_updates (priv->account_view);
+
/* Show the Account Settings window: */
ModestAccountSettingsDialog *dialog = modest_account_settings_dialog_new ();
modest_account_settings_dialog_set_account_name (dialog, account_name);
gtk_widget_destroy (GTK_WIDGET (dialog));
g_free (account_name);
+
+ /* Update the view: */
+ modest_account_view_unblock_conf_updates (priv->account_view);
}
static void
on_new_button_clicked (GtkWidget *button, ModestAccountViewWindow *self)
{
+ ModestAccountViewWindowPrivate *priv = MODEST_ACCOUNT_VIEW_WINDOW_GET_PRIVATE(self);
+
+ /* Freeze updates, so we can do just one update afterwards,
+ * instead of responding to every conf key change: */
+ modest_account_view_block_conf_updates (priv->account_view);
+
/* Show the easy-setup wizard: */
ModestEasysetupWizardDialog *wizard = modest_easysetup_wizard_dialog_new ();
gtk_window_set_transient_for (GTK_WINDOW (wizard), GTK_WINDOW (self));
gtk_dialog_run (GTK_DIALOG (wizard));
gtk_widget_destroy (GTK_WIDGET (wizard));
+
+ /* Allow updates: */
+ modest_account_view_unblock_conf_updates (priv->account_view);
}
static void
on_key_change (ModestConf *conf, const gchar *key, ModestConfEvent event, gpointer user_data)
{
+ /* printf("DEBUG: %s: key=%s\n", __FUNCTION__, key); */
+
ModestAccountMgr *self = MODEST_ACCOUNT_MGR (user_data);
/* ModestAccountMgrPrivate *priv = MODEST_ACCOUNT_MGR_GET_PRIVATE (self); */
else
enabled = modest_account_mgr_get_enabled (self, account);
- /* server account was changed, default account was changed
- * and always notify when enabled/disabled changes
+ /* 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) ||
#include <modest-account-mgr.h>
#include <modest-account-mgr-helpers.h>
#include <modest-text-utils.h>
+#include <modest-runtime.h>
#include <gtk/gtkcellrenderertoggle.h>
#include <gtk/gtkcellrenderertext.h>
ModestAccountMgr *account_mgr;
gulong sig1, sig2;
+ /* When this is TRUE, we ignore configuration key changes.
+ * This is useful when making many changes. */
+ gboolean block_conf_updates;
+
};
#define MODEST_ACCOUNT_VIEW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
MODEST_TYPE_ACCOUNT_VIEW, \
const gchar* account, const gchar* key,
gboolean server_account, ModestAccountView *self)
{
- update_account_view (account_mgr, 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)..
+ */
+ return;
+
+ ModestAccountViewPrivate* priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE(self);
+
+ if (!priv->block_conf_updates)
+ update_account_view (account_mgr, self);
}
const gchar* account, gboolean server_account,
ModestAccountView *self)
{
- on_account_changed (account_mgr, account, NULL, server_account, self);
+ ModestAccountViewPrivate* priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE(self);
+ if (!priv->block_conf_updates)
+ on_account_changed (account_mgr, account, NULL, server_account, self);
}
return account_name;
}
+
+
+void modest_account_view_block_conf_updates (ModestAccountView *account_view)
+{
+ ModestAccountViewPrivate* priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE(account_view);
+ priv->block_conf_updates = TRUE;
+}
+
+void modest_account_view_unblock_conf_updates (ModestAccountView *account_view)
+{
+ ModestAccountViewPrivate* priv = MODEST_ACCOUNT_VIEW_GET_PRIVATE(account_view);
+ priv->block_conf_updates = FALSE;
+
+ update_account_view (modest_runtime_get_account_mgr(), account_view);
+}
**/
gchar* modest_account_view_get_selected_account (ModestAccountView *account_view);
+/**
+ * modest_account_view_block_conf_updates
+ * @account_view: a #ModestAccountView
+ *
+ * Stops the widget from updating in response to configuration key changes.
+ * This can be a useful optimization when making many configuration changes.
+ **/
+void modest_account_view_block_conf_updates (ModestAccountView *account_view);
+
+/**
+ * modest_account_view_unblock_conf_updates
+ * @account_view: a #ModestAccountView
+ *
+ * Allows the widget tp update again in response to configuration key changes.
+ * When this is called it will cause the widget to immediately update its view from the
+ * configuration data.
+ **/
+void modest_account_view_unblock_conf_updates (ModestAccountView *account_view);
+
G_END_DECLS
#endif /* __MODEST_ACCOUNT_VIEW_H__ */