[evolution/evolution-3-12] Bug 730977 - Online state change received in a dedicated thread



commit a4db773c81a835a035f9ea46b8399faeb1082dd1
Author: Milan Crha <mcrha redhat com>
Date:   Fri Jun 6 08:59:53 2014 +0200

    Bug 730977 - Online state change received in a dedicated thread

 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 02a0b29..aff084d 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);
        }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]