]> git.0d.be Git - empathy.git/commitdiff
add initial_loading() as a virtual method
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Tue, 22 Nov 2011 09:04:40 +0000 (10:04 +0100)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Thu, 24 Nov 2011 11:29:03 +0000 (12:29 +0100)
This allows us to remove setup_idle_id as a protected variable.

https://bugzilla.gnome.org/show_bug.cgi?id=663387

libempathy-gtk/empathy-individual-store-channel.c
libempathy-gtk/empathy-individual-store-manager.c
libempathy-gtk/empathy-individual-store.c
libempathy-gtk/empathy-individual-store.h

index aa9f0e2753799c05504ce562a3f16d92cc2c4017..75284602bc41aaca0caf8f58009bde6a8f4637db 100644 (file)
@@ -275,6 +275,16 @@ individual_store_channel_reload_individuals (EmpathyIndividualStore *store)
   g_ptr_array_unref (members);
 }
 
   g_ptr_array_unref (members);
 }
 
+static gboolean
+individual_store_channel_initial_loading (EmpathyIndividualStore *store)
+{
+  EmpathyIndividualStoreChannel *self = EMPATHY_INDIVIDUAL_STORE_CHANNEL (
+      store);
+
+  return !tp_proxy_is_prepared (self->priv->channel,
+      TP_CHANNEL_FEATURE_CONTACTS);
+}
+
 static void
 empathy_individual_store_channel_class_init (
     EmpathyIndividualStoreChannelClass *klass)
 static void
 empathy_individual_store_channel_class_init (
     EmpathyIndividualStoreChannelClass *klass)
@@ -288,6 +298,7 @@ empathy_individual_store_channel_class_init (
   object_class->set_property = individual_store_channel_set_property;
 
   store_class->reload_individuals = individual_store_channel_reload_individuals;
   object_class->set_property = individual_store_channel_set_property;
 
   store_class->reload_individuals = individual_store_channel_reload_individuals;
+  store_class->initial_loading = individual_store_channel_initial_loading;
 
   g_object_class_install_property (object_class,
       PROP_CHANNEL,
 
   g_object_class_install_property (object_class,
       PROP_CHANNEL,
index 72ddab61bd055493e6c0ee68002c522a044a9b26..03841f17585f584e7f810204eab6babb927a3ed9 100644 (file)
@@ -50,6 +50,7 @@
 struct _EmpathyIndividualStoreManagerPriv
 {
   EmpathyIndividualManager *manager;
 struct _EmpathyIndividualStoreManagerPriv
 {
   EmpathyIndividualManager *manager;
+  gboolean setup_idle_id;
 };
 
 enum
 };
 
 enum
@@ -136,7 +137,7 @@ individual_store_manager_manager_setup (gpointer user_data)
       g_list_free (individuals);
     }
 
       g_list_free (individuals);
     }
 
-  store->setup_idle_id = 0;
+  self->priv->setup_idle_id = 0;
   return FALSE;
 }
 
   return FALSE;
 }
 
@@ -151,8 +152,8 @@ individual_store_manager_set_individual_manager (
   self->priv->manager = g_object_ref (manager);
 
   /* Let a chance to have all properties set before populating */
   self->priv->manager = g_object_ref (manager);
 
   /* Let a chance to have all properties set before populating */
-  store->setup_idle_id = g_idle_add (individual_store_manager_manager_setup,
-      self);
+  self->priv->setup_idle_id = g_idle_add (
+      individual_store_manager_manager_setup, self);
 }
 
 static void
 }
 
 static void
@@ -203,6 +204,12 @@ individual_store_manager_dispose (GObject *object)
       g_clear_object (&self->priv->manager);
     }
 
       g_clear_object (&self->priv->manager);
     }
 
+  if (self->priv->setup_idle_id != 0)
+    {
+      g_source_remove (self->priv->setup_idle_id);
+      self->priv->setup_idle_id = 0;
+    }
+
   G_OBJECT_CLASS (empathy_individual_store_manager_parent_class)->dispose (
       object);
 }
   G_OBJECT_CLASS (empathy_individual_store_manager_parent_class)->dispose (
       object);
 }
@@ -262,6 +269,15 @@ individual_store_manager_reload_individuals (EmpathyIndividualStore *store)
   g_list_free (contacts);
 }
 
   g_list_free (contacts);
 }
 
+static gboolean
+individual_store_manager_initial_loading (EmpathyIndividualStore *store)
+{
+  EmpathyIndividualStoreManager *self = EMPATHY_INDIVIDUAL_STORE_MANAGER (
+      store);
+
+  return self->priv->setup_idle_id != 0;
+}
+
 static void
 empathy_individual_store_manager_class_init (
     EmpathyIndividualStoreManagerClass *klass)
 static void
 empathy_individual_store_manager_class_init (
     EmpathyIndividualStoreManagerClass *klass)
@@ -275,6 +291,7 @@ empathy_individual_store_manager_class_init (
   object_class->set_property = individual_store_manager_set_property;
 
   store_class->reload_individuals = individual_store_manager_reload_individuals;
   object_class->set_property = individual_store_manager_set_property;
 
   store_class->reload_individuals = individual_store_manager_reload_individuals;
+  store_class->initial_loading = individual_store_manager_initial_loading;
 
   g_object_class_install_property (object_class,
       PROP_INDIVIDUAL_MANAGER,
 
   g_object_class_install_property (object_class,
       PROP_INDIVIDUAL_MANAGER,
index d2ba6297aa0d3cc8f695e2fd7057a2991c26e5c8..aa3f6334d77f033115ab5ba3a9ae4691367fae13 100644 (file)
@@ -946,11 +946,6 @@ individual_store_dispose (GObject *object)
       g_source_remove (self->priv->inhibit_active);
     }
 
       g_source_remove (self->priv->inhibit_active);
     }
 
-  if (self->setup_idle_id != 0)
-    {
-      g_source_remove (self->setup_idle_id);
-    }
-
   g_hash_table_unref (self->priv->status_icons);
   g_hash_table_unref (self->priv->folks_individual_cache);
   g_hash_table_unref (self->priv->empathy_group_cache);
   g_hash_table_unref (self->priv->status_icons);
   g_hash_table_unref (self->priv->folks_individual_cache);
   g_hash_table_unref (self->priv->empathy_group_cache);
@@ -1500,8 +1495,12 @@ void
 empathy_individual_store_set_show_groups (EmpathyIndividualStore *self,
     gboolean show_groups)
 {
 empathy_individual_store_set_show_groups (EmpathyIndividualStore *self,
     gboolean show_groups)
 {
+  EmpathyIndividualStoreClass *klass;
+
   g_return_if_fail (EMPATHY_IS_INDIVIDUAL_STORE (self));
 
   g_return_if_fail (EMPATHY_IS_INDIVIDUAL_STORE (self));
 
+  klass = EMPATHY_INDIVIDUAL_STORE_GET_CLASS ( self);
+
   if (self->priv->show_groups == show_groups)
     {
       return;
   if (self->priv->show_groups == show_groups)
     {
       return;
@@ -1509,7 +1508,7 @@ empathy_individual_store_set_show_groups (EmpathyIndividualStore *self,
 
   self->priv->show_groups = show_groups;
 
 
   self->priv->show_groups = show_groups;
 
-  if (self->setup_idle_id == 0)
+  if (!klass->initial_loading (self))
     {
       /* Remove all contacts and add them back, not optimized but
        * that's the easy way :)
     {
       /* Remove all contacts and add them back, not optimized but
        * that's the easy way :)
@@ -1517,8 +1516,6 @@ empathy_individual_store_set_show_groups (EmpathyIndividualStore *self,
        * This is only done if there's not a pending setup idle
        * callback, otherwise it will race and the contacts will get
        * added twice */
        * This is only done if there's not a pending setup idle
        * callback, otherwise it will race and the contacts will get
        * added twice */
-      EmpathyIndividualStoreClass *klass = EMPATHY_INDIVIDUAL_STORE_GET_CLASS (
-          self);
 
       gtk_tree_store_clear (GTK_TREE_STORE (self));
       /* Also clear the cache */
 
       gtk_tree_store_clear (GTK_TREE_STORE (self));
       /* Also clear the cache */
index 3e077a95dbbced47e50612ec204e8e210df1390c..61fd4b8d8d94dd3c29de8e1d9c16d8bde985219d 100644 (file)
@@ -77,9 +77,6 @@ struct _EmpathyIndividualStore
 {
   GtkTreeStore parent;
   EmpathyIndividualStorePriv *priv;
 {
   GtkTreeStore parent;
   EmpathyIndividualStorePriv *priv;
-
-  /* protected */
-  guint setup_idle_id;
 };
 
 struct _EmpathyIndividualStoreClass
 };
 
 struct _EmpathyIndividualStoreClass
@@ -87,6 +84,7 @@ struct _EmpathyIndividualStoreClass
   GtkTreeStoreClass parent_class;
 
   void (*reload_individuals) (EmpathyIndividualStore *self);
   GtkTreeStoreClass parent_class;
 
   void (*reload_individuals) (EmpathyIndividualStore *self);
+  gboolean (*initial_loading) (EmpathyIndividualStore *self);
 };
 
 GType
 };
 
 GType