#define YSPACE 0
/* 'private'/'protected' functions */
-static void modest_main_window_class_init (ModestMainWindowClass *klass);
-static void modest_main_window_init (ModestMainWindow *obj);
-static void modest_main_window_finalize (GObject *obj);
+static void modest_main_window_class_init (ModestMainWindowClass *klass);
+static void modest_main_window_init (ModestMainWindow *obj);
+static void modest_main_window_finalize (GObject *obj);
+
static gboolean modest_main_window_window_state_event (GtkWidget *widget,
GdkEventWindowState *event,
gpointer userdata);
static void connect_signals (ModestMainWindow *self);
-static void restore_settings (ModestMainWindow *self, gboolean do_folder_view_too);
+static void modest_main_window_disconnect_signals (ModestWindow *self);
+
+static void restore_settings (ModestMainWindow *self,
+ gboolean do_folder_view_too);
+
static void save_state (ModestWindow *self);
static void modest_main_window_show_toolbar (ModestWindow *window,
static void cancel_progressbar (GtkToolButton *toolbutton,
ModestMainWindow *self);
-static void on_queue_changed (ModestMailOperationQueue *queue,
- ModestMailOperation *mail_op,
- ModestMailOperationQueueNotification type,
- ModestMainWindow *self);
+static void on_queue_changed (ModestMailOperationQueue *queue,
+ ModestMailOperation *mail_op,
+ ModestMailOperationQueueNotification type,
+ ModestMainWindow *self);
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);
static void on_configuration_key_changed (ModestConf* conf,
const gchar *key,
- ModestConfEvent event,
+ ModestConfEvent event,
+ ModestConfNotificationId id,
ModestMainWindow *self);
static void set_toolbar_mode (ModestMainWindow *self,
GtkWidget *empty_view;
/* Progress observers */
- GtkWidget *progress_bar;
- GSList *progress_widgets;
+ GtkWidget *progress_bar;
+ GSList *progress_widgets;
/* Tollbar items */
GtkWidget *progress_toolitem;
/* Signal handler UIDs */
gint queue_changed_handler_uid;
GList *queue_err_signals;
+
+ ModestConfNotificationId notification_id;
};
#define MODEST_MAIN_WINDOW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), \
MODEST_TYPE_MAIN_WINDOW, \
modest_window_class->save_state_func = save_state;
modest_window_class->zoom_minus_func = on_zoom_minus_plus_not_implemented;
modest_window_class->zoom_plus_func = on_zoom_minus_plus_not_implemented;
+ modest_window_class->disconnect_signals_func = modest_main_window_disconnect_signals;
}
static void
priv = MODEST_MAIN_WINDOW_GET_PRIVATE(obj);
+ /* Sanity check: shouldn't be needed, the window mgr should
+ call this function before */
+ modest_main_window_disconnect_signals (MODEST_WINDOW (obj));
+
modest_main_window_cleanup_queue_error_signals ((ModestMainWindow *) obj);
g_slist_free (priv->progress_widgets);
priv->progress_bar_timeout = 0;
}
- /* Disconnect signal handlers */
- if (priv->queue_changed_handler_uid)
- g_signal_handler_disconnect (modest_runtime_get_mail_operation_queue (),
- priv->queue_changed_handler_uid);
+ if (priv->notification_id) {
+ modest_conf_forget_namespace (modest_runtime_get_conf (),
+ MODEST_CONF_NAMESPACE,
+ priv->notification_id);
+ }
G_OBJECT_CLASS(parent_class)->finalize (obj);
}
}
static void
+modest_main_window_disconnect_signals (ModestWindow *self)
+{
+ ModestMainWindowPrivate *priv;
+
+ priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);
+
+ /* Disconnect signal handlers */
+ if (g_signal_handler_is_connected (modest_runtime_get_mail_operation_queue (),
+ priv->queue_changed_handler_uid))
+ g_signal_handler_disconnect (modest_runtime_get_mail_operation_queue (),
+ priv->queue_changed_handler_uid);
+}
+
+static void
connect_signals (ModestMainWindow *self)
{
ModestWindowPrivate *parent_priv;
self);
/* window */
-/* g_signal_connect (G_OBJECT(self), "delete-event", G_CALLBACK(on_delete_event), self); */
g_signal_connect (G_OBJECT (self), "window-state-event",
G_CALLBACK (modest_main_window_window_state_event),
NULL);
"queue-changed", G_CALLBACK (on_queue_changed), self);
/* Track changes in the device name */
+ priv->notification_id = modest_conf_listen_to_namespace (modest_runtime_get_conf (),
+ MODEST_CONF_NAMESPACE);
g_signal_connect (G_OBJECT(modest_runtime_get_conf ()),
"key_changed", G_CALLBACK (on_configuration_key_changed),
self);
/* 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);
static void
on_configuration_key_changed (ModestConf* conf,
const gchar *key,
- ModestConfEvent event,
+ ModestConfEvent event,
+ ModestConfNotificationId id,
ModestMainWindow *self)
{
ModestMainWindowPrivate *priv;
TnyAccount *account;
- if (!key || strcmp (key, MODEST_CONF_DEVICE_NAME))
+ if (!key ||
+ priv->notification_id != id ||
+ strcmp (key, MODEST_CONF_DEVICE_NAME))
return;
priv = MODEST_MAIN_WINDOW_GET_PRIVATE(self);