diff options
author | Milan Crha <mcrha@redhat.com> | 2014-06-06 14:59:53 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2014-06-06 14:59:53 +0800 |
commit | 1205a86888d0d3af669c4c7f97b82ef6987b4beb (patch) | |
tree | d0e18fd460e55152c20fb7eed057bc3931113456 | |
parent | 402d1f16bed907ee4749e5e6831c1961b395f6a3 (diff) | |
download | gsoc2013-evolution-1205a86888d0d3af669c4c7f97b82ef6987b4beb.tar gsoc2013-evolution-1205a86888d0d3af669c4c7f97b82ef6987b4beb.tar.gz gsoc2013-evolution-1205a86888d0d3af669c4c7f97b82ef6987b4beb.tar.bz2 gsoc2013-evolution-1205a86888d0d3af669c4c7f97b82ef6987b4beb.tar.lz gsoc2013-evolution-1205a86888d0d3af669c4c7f97b82ef6987b4beb.tar.xz gsoc2013-evolution-1205a86888d0d3af669c4c7f97b82ef6987b4beb.tar.zst gsoc2013-evolution-1205a86888d0d3af669c4c7f97b82ef6987b4beb.zip |
Bug 730977 - Online state change received in a dedicated thread
-rw-r--r-- | modules/mail/e-mail-shell-view-private.c | 58 |
1 files changed, 54 insertions, 4 deletions
diff --git a/modules/mail/e-mail-shell-view-private.c b/modules/mail/e-mail-shell-view-private.c index 02a0b29e55..aff084d522 100644 --- a/modules/mail/e-mail-shell-view-private.c +++ b/modules/mail/e-mail-shell-view-private.c @@ -1182,6 +1182,56 @@ send_receive_account_item_activate_cb (GtkMenuItem *menu_item, mail_receive_service (service); } +typedef struct _EMenuItemSensitivityData { + GObject *service; + GtkWidget *menu_item; +} EMenuItemSensitivityData; + +static void +free_menu_item_sensitivity_data (gpointer ptr) +{ + EMenuItemSensitivityData *data = ptr; + + if (!data) + return; + + g_object_unref (data->service); + g_object_unref (data->menu_item); + g_free (data); +} + +static gboolean +update_menu_item_sensitivity_cb (gpointer user_data) +{ + EMenuItemSensitivityData *data = user_data; + gboolean is_online = FALSE; + + g_return_val_if_fail (data != NULL, FALSE); + + g_object_get (data->service, "online", &is_online, NULL); + + gtk_widget_set_sensitive (data->menu_item, is_online); + + return FALSE; +} + +static void +service_online_state_changed_cb (GObject *service, + GParamSpec *param, + GObject *menu_item) +{ + EMenuItemSensitivityData *data; + + g_return_if_fail (G_IS_OBJECT (service)); + g_return_if_fail (GTK_IS_WIDGET (menu_item)); + + data = g_new0 (EMenuItemSensitivityData, 1); + data->service = g_object_ref (service); + data->menu_item = g_object_ref (menu_item); + + g_idle_add_full (G_PRIORITY_HIGH_IDLE, update_menu_item_sensitivity_cb, data, free_menu_item_sensitivity_data); +} + static void send_receive_add_to_menu (SendReceiveData *data, CamelService *service, @@ -1211,10 +1261,10 @@ send_receive_add_to_menu (SendReceiveData *data, else object = camel_service_ref_session (service); - g_object_bind_property ( - object, "online", - menu_item, "sensitive", - G_BINDING_SYNC_CREATE); + e_signal_connect_notify_object ( + object, "notify::online", + G_CALLBACK (service_online_state_changed_cb), menu_item, + 0); g_object_unref (object); } |