aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-11-22 17:04:40 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-11-24 19:29:03 +0800
commit70ec5dfc46d6177c74139ad84e6a74f521e8b374 (patch)
treef4dcf03134f55bb8929ca1675fceef67f3cee4a7
parentf13e0c152b9de168c88f6ebde45c8e35e4df4934 (diff)
downloadgsoc2013-empathy-70ec5dfc46d6177c74139ad84e6a74f521e8b374.tar
gsoc2013-empathy-70ec5dfc46d6177c74139ad84e6a74f521e8b374.tar.gz
gsoc2013-empathy-70ec5dfc46d6177c74139ad84e6a74f521e8b374.tar.bz2
gsoc2013-empathy-70ec5dfc46d6177c74139ad84e6a74f521e8b374.tar.lz
gsoc2013-empathy-70ec5dfc46d6177c74139ad84e6a74f521e8b374.tar.xz
gsoc2013-empathy-70ec5dfc46d6177c74139ad84e6a74f521e8b374.tar.zst
gsoc2013-empathy-70ec5dfc46d6177c74139ad84e6a74f521e8b374.zip
add initial_loading() as a virtual method
This allows us to remove setup_idle_id as a protected variable. https://bugzilla.gnome.org/show_bug.cgi?id=663387
-rw-r--r--libempathy-gtk/empathy-individual-store-channel.c11
-rw-r--r--libempathy-gtk/empathy-individual-store-manager.c23
-rw-r--r--libempathy-gtk/empathy-individual-store.c13
-rw-r--r--libempathy-gtk/empathy-individual-store.h4
4 files changed, 37 insertions, 14 deletions
diff --git a/libempathy-gtk/empathy-individual-store-channel.c b/libempathy-gtk/empathy-individual-store-channel.c
index aa9f0e275..75284602b 100644
--- a/libempathy-gtk/empathy-individual-store-channel.c
+++ b/libempathy-gtk/empathy-individual-store-channel.c
@@ -275,6 +275,16 @@ individual_store_channel_reload_individuals (EmpathyIndividualStore *store)
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)
@@ -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;
+ store_class->initial_loading = individual_store_channel_initial_loading;
g_object_class_install_property (object_class,
PROP_CHANNEL,
diff --git a/libempathy-gtk/empathy-individual-store-manager.c b/libempathy-gtk/empathy-individual-store-manager.c
index 72ddab61b..03841f175 100644
--- a/libempathy-gtk/empathy-individual-store-manager.c
+++ b/libempathy-gtk/empathy-individual-store-manager.c
@@ -50,6 +50,7 @@
struct _EmpathyIndividualStoreManagerPriv
{
EmpathyIndividualManager *manager;
+ gboolean setup_idle_id;
};
enum
@@ -136,7 +137,7 @@ individual_store_manager_manager_setup (gpointer user_data)
g_list_free (individuals);
}
- store->setup_idle_id = 0;
+ self->priv->setup_idle_id = 0;
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 */
- 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
@@ -203,6 +204,12 @@ individual_store_manager_dispose (GObject *object)
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);
}
@@ -262,6 +269,15 @@ individual_store_manager_reload_individuals (EmpathyIndividualStore *store)
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)
@@ -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;
+ store_class->initial_loading = individual_store_manager_initial_loading;
g_object_class_install_property (object_class,
PROP_INDIVIDUAL_MANAGER,
diff --git a/libempathy-gtk/empathy-individual-store.c b/libempathy-gtk/empathy-individual-store.c
index d2ba6297a..aa3f6334d 100644
--- a/libempathy-gtk/empathy-individual-store.c
+++ b/libempathy-gtk/empathy-individual-store.c
@@ -946,11 +946,6 @@ individual_store_dispose (GObject *object)
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);
@@ -1500,8 +1495,12 @@ void
empathy_individual_store_set_show_groups (EmpathyIndividualStore *self,
gboolean show_groups)
{
+ EmpathyIndividualStoreClass *klass;
+
g_return_if_fail (EMPATHY_IS_INDIVIDUAL_STORE (self));
+ klass = EMPATHY_INDIVIDUAL_STORE_GET_CLASS ( self);
+
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;
- 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 :)
@@ -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 */
- EmpathyIndividualStoreClass *klass = EMPATHY_INDIVIDUAL_STORE_GET_CLASS (
- self);
gtk_tree_store_clear (GTK_TREE_STORE (self));
/* Also clear the cache */
diff --git a/libempathy-gtk/empathy-individual-store.h b/libempathy-gtk/empathy-individual-store.h
index 3e077a95d..61fd4b8d8 100644
--- a/libempathy-gtk/empathy-individual-store.h
+++ b/libempathy-gtk/empathy-individual-store.h
@@ -77,9 +77,6 @@ struct _EmpathyIndividualStore
{
GtkTreeStore parent;
EmpathyIndividualStorePriv *priv;
-
- /* protected */
- guint setup_idle_id;
};
struct _EmpathyIndividualStoreClass
@@ -87,6 +84,7 @@ struct _EmpathyIndividualStoreClass
GtkTreeStoreClass parent_class;
void (*reload_individuals) (EmpathyIndividualStore *self);
+ gboolean (*initial_loading) (EmpathyIndividualStore *self);
};
GType