aboutsummaryrefslogtreecommitdiffstats
path: root/libempathy-gtk
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-11-04 19:15:47 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2011-11-24 19:28:44 +0800
commitedf88058847eb77f8ecc1e5b37fa76e7db9f7ad3 (patch)
tree4bc158be693aab3c3d9c66ad61a0f6761059ded6 /libempathy-gtk
parent0c7f25a8206c918d4a84405b7d1ab8e994c65d0f (diff)
downloadgsoc2013-empathy-edf88058847eb77f8ecc1e5b37fa76e7db9f7ad3.tar
gsoc2013-empathy-edf88058847eb77f8ecc1e5b37fa76e7db9f7ad3.tar.gz
gsoc2013-empathy-edf88058847eb77f8ecc1e5b37fa76e7db9f7ad3.tar.bz2
gsoc2013-empathy-edf88058847eb77f8ecc1e5b37fa76e7db9f7ad3.tar.lz
gsoc2013-empathy-edf88058847eb77f8ecc1e5b37fa76e7db9f7ad3.tar.xz
gsoc2013-empathy-edf88058847eb77f8ecc1e5b37fa76e7db9f7ad3.tar.zst
gsoc2013-empathy-edf88058847eb77f8ecc1e5b37fa76e7db9f7ad3.zip
Abstract the individual store
We now have EmpathyIndividualStoreManager which implements the store using EmpathyIndividualManager as its contact source. https://bugzilla.gnome.org/show_bug.cgi?id=663387
Diffstat (limited to 'libempathy-gtk')
-rw-r--r--libempathy-gtk/Makefile.am2
-rw-r--r--libempathy-gtk/empathy-contact-chooser.c4
-rw-r--r--libempathy-gtk/empathy-individual-linker.c4
-rw-r--r--libempathy-gtk/empathy-individual-store-manager.c319
-rw-r--r--libempathy-gtk/empathy-individual-store-manager.h67
-rw-r--r--libempathy-gtk/empathy-individual-store.c171
-rw-r--r--libempathy-gtk/empathy-individual-store.h10
7 files changed, 400 insertions, 177 deletions
diff --git a/libempathy-gtk/Makefile.am b/libempathy-gtk/Makefile.am
index 0d3762aff..50f93265b 100644
--- a/libempathy-gtk/Makefile.am
+++ b/libempathy-gtk/Makefile.am
@@ -62,6 +62,7 @@ libempathy_gtk_handwritten_source = \
empathy-individual-linker.c \
empathy-individual-menu.c \
empathy-individual-store.c \
+ empathy-individual-store-manager.c \
empathy-individual-view.c \
empathy-individual-widget.c \
empathy-input-text-view.c \
@@ -132,6 +133,7 @@ libempathy_gtk_headers = \
empathy-individual-linker.h \
empathy-individual-menu.h \
empathy-individual-store.h \
+ empathy-individual-store-manager.h \
empathy-individual-view.h \
empathy-individual-widget.h \
empathy-input-text-view.h \
diff --git a/libempathy-gtk/empathy-contact-chooser.c b/libempathy-gtk/empathy-contact-chooser.c
index 5ff17a432..6d93e6813 100644
--- a/libempathy-gtk/empathy-contact-chooser.c
+++ b/libempathy-gtk/empathy-contact-chooser.c
@@ -14,6 +14,7 @@
#include "empathy-contact-chooser.h"
+#include <libempathy-gtk/empathy-individual-store-manager.h>
#include <libempathy-gtk/empathy-individual-view.h>
#include <libempathy-gtk/empathy-ui-utils.h>
@@ -412,7 +413,8 @@ empathy_contact_chooser_init (EmpathyContactChooser *self)
/* Add the treeview */
mgr = empathy_individual_manager_dup_singleton ();
- self->priv->store = empathy_individual_store_new (mgr);
+ self->priv->store = EMPATHY_INDIVIDUAL_STORE (
+ empathy_individual_store_manager_new (mgr));
g_object_unref (mgr);
empathy_individual_store_set_show_groups (self->priv->store, FALSE);
diff --git a/libempathy-gtk/empathy-individual-linker.c b/libempathy-gtk/empathy-individual-linker.c
index d53633f7a..7de5e4add 100644
--- a/libempathy-gtk/empathy-individual-linker.c
+++ b/libempathy-gtk/empathy-individual-linker.c
@@ -35,6 +35,7 @@
#include "empathy-individual-linker.h"
#include "empathy-individual-store.h"
+#include "empathy-individual-store-manager.h"
#include "empathy-individual-view.h"
#include "empathy-individual-widget.h"
#include "empathy-persona-store.h"
@@ -376,7 +377,8 @@ set_up (EmpathyIndividualLinker *self)
/* Individual selector */
individual_manager = empathy_individual_manager_dup_singleton ();
- priv->individual_store = empathy_individual_store_new (individual_manager);
+ priv->individual_store = EMPATHY_INDIVIDUAL_STORE (
+ empathy_individual_store_manager_new (individual_manager));
g_object_unref (individual_manager);
empathy_individual_store_set_show_protocols (priv->individual_store, FALSE);
diff --git a/libempathy-gtk/empathy-individual-store-manager.c b/libempathy-gtk/empathy-individual-store-manager.c
new file mode 100644
index 000000000..ca586493f
--- /dev/null
+++ b/libempathy-gtk/empathy-individual-store-manager.c
@@ -0,0 +1,319 @@
+/*
+ * Copyright (C) 2005-2007 Imendio AB
+ * Copyright (C) 2007-2011 Collabora Ltd.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ *
+ * Authors: Mikael Hallendal <micke@imendio.com>
+ * Martyn Russell <martyn@imendio.com>
+ * Xavier Claessens <xclaesse@gmail.com>
+ * Travis Reitter <travis.reitter@collabora.co.uk>
+ */
+
+#include "config.h"
+
+#include <string.h>
+
+#include <glib.h>
+#include <glib/gi18n-lib.h>
+#include <gtk/gtk.h>
+
+#include <folks/folks.h>
+#include <folks/folks-telepathy.h>
+#include <telepathy-glib/util.h>
+
+#include <libempathy/empathy-utils.h>
+#include <libempathy/empathy-enum-types.h>
+#include <libempathy/empathy-individual-manager.h>
+
+#include "empathy-individual-store-manager.h"
+
+#include "empathy-ui-utils.h"
+#include "empathy-gtk-enum-types.h"
+
+#define DEBUG_FLAG EMPATHY_DEBUG_CONTACT
+#include <libempathy/empathy-debug.h>
+
+struct _EmpathyIndividualStoreManagerPriv
+{
+ EmpathyIndividualManager *manager;
+};
+
+enum
+{
+ PROP_0,
+ PROP_INDIVIDUAL_MANAGER,
+};
+
+
+G_DEFINE_TYPE (EmpathyIndividualStoreManager, empathy_individual_store_manager,
+ EMPATHY_TYPE_INDIVIDUAL_STORE);
+
+static void
+individual_store_manager_members_changed_cb (EmpathyIndividualManager *manager,
+ const gchar *message,
+ GList *added,
+ GList *removed,
+ guint reason,
+ EmpathyIndividualStoreManager *self)
+{
+ GList *l;
+ EmpathyIndividualStore *store = EMPATHY_INDIVIDUAL_STORE (self);
+
+ for (l = removed; l; l = l->next)
+ {
+ DEBUG ("Individual %s %s",
+ folks_individual_get_id (l->data), "removed");
+
+ individual_store_remove_individual_and_disconnect (store, l->data);
+ }
+
+ for (l = added; l; l = l->next)
+ {
+ DEBUG ("Individual %s %s", folks_individual_get_id (l->data), "added");
+
+ individual_store_add_individual_and_connect (store, l->data);
+ }
+}
+
+static void
+individual_store_manager_groups_changed_cb (EmpathyIndividualManager *manager,
+ FolksIndividual *individual,
+ gchar *group,
+ gboolean is_member,
+ EmpathyIndividualStoreManager *self)
+{
+ gboolean show_active;
+ EmpathyIndividualStore *store = EMPATHY_INDIVIDUAL_STORE (self);
+
+ DEBUG ("Updating groups for individual %s",
+ folks_individual_get_id (individual));
+
+ /* We do this to make sure the groups are correct, if not, we
+ * would have to check the groups already set up for each
+ * contact and then see what has been updated.
+ */
+ show_active = store->show_active;
+ store->show_active = FALSE;
+ empathy_individual_store_remove_individual (store, individual);
+ empathy_individual_store_add_individual (store, individual);
+ store->show_active = show_active;
+}
+
+static gboolean
+individual_store_manager_manager_setup (gpointer user_data)
+{
+ EmpathyIndividualStoreManager *self = user_data;
+ EmpathyIndividualStore *store = user_data;
+ GList *individuals;
+
+ /* Signal connection. */
+
+ DEBUG ("handling individual renames unimplemented");
+
+ g_signal_connect (self->priv->manager,
+ "members-changed",
+ G_CALLBACK (individual_store_manager_members_changed_cb), self);
+
+ g_signal_connect (self->priv->manager,
+ "groups-changed",
+ G_CALLBACK (individual_store_manager_groups_changed_cb), self);
+
+ /* Add contacts already created. */
+ individuals = empathy_individual_manager_get_members (self->priv->manager);
+ if (individuals != NULL)
+ {
+ individual_store_manager_members_changed_cb (self->priv->manager, "initial add",
+ individuals, NULL, 0, self);
+ g_list_free (individuals);
+ }
+
+ store->setup_idle_id = 0;
+ return FALSE;
+}
+
+static void
+individual_store_manager_set_individual_manager (
+ EmpathyIndividualStoreManager *self,
+ EmpathyIndividualManager *manager)
+{
+ EmpathyIndividualStore *store = EMPATHY_INDIVIDUAL_STORE (self);
+
+ g_assert (self->priv->manager == NULL); /* construct only */
+ 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);
+}
+
+static void
+individual_store_manager_member_renamed_cb (EmpathyIndividualManager *manager,
+ FolksIndividual *old_individual,
+ FolksIndividual *new_individual,
+ guint reason,
+ const gchar *message,
+ EmpathyIndividualStoreManager *self)
+{
+ EmpathyIndividualStore *store = EMPATHY_INDIVIDUAL_STORE (self);
+
+ DEBUG ("Individual %s renamed to %s",
+ folks_individual_get_id (old_individual),
+ folks_individual_get_id (new_individual));
+
+ /* remove old contact */
+ individual_store_remove_individual_and_disconnect (store, old_individual);
+
+ /* add the new contact */
+ individual_store_add_individual_and_connect (store, new_individual);
+}
+
+static void
+individual_store_manager_dispose (GObject *object)
+{
+ EmpathyIndividualStoreManager *self = EMPATHY_INDIVIDUAL_STORE_MANAGER (
+ object);
+ EmpathyIndividualStore *store = EMPATHY_INDIVIDUAL_STORE (object);
+ GList *individuals, *l;
+
+ individuals = empathy_individual_manager_get_members (self->priv->manager);
+ for (l = individuals; l; l = l->next)
+ {
+ empathy_individual_store_disconnect_individual (store,
+ FOLKS_INDIVIDUAL (l->data));
+ }
+ tp_clear_pointer (&individuals, g_list_free);
+
+ if (self->priv->manager != NULL)
+ {
+ g_signal_handlers_disconnect_by_func (self->priv->manager,
+ G_CALLBACK (individual_store_manager_member_renamed_cb), object);
+ g_signal_handlers_disconnect_by_func (self->priv->manager,
+ G_CALLBACK (individual_store_manager_members_changed_cb), object);
+ g_signal_handlers_disconnect_by_func (self->priv->manager,
+ G_CALLBACK (individual_store_manager_groups_changed_cb), object);
+ g_clear_object (&self->priv->manager);
+ }
+
+ G_OBJECT_CLASS (empathy_individual_store_manager_parent_class)->dispose (
+ object);
+}
+
+static void
+individual_store_manager_get_property (GObject *object,
+ guint param_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ EmpathyIndividualStoreManager *self = EMPATHY_INDIVIDUAL_STORE_MANAGER (
+ object);
+
+ switch (param_id)
+ {
+ case PROP_INDIVIDUAL_MANAGER:
+ g_value_set_object (value, self->priv->manager);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ };
+}
+
+static void
+individual_store_manager_set_property (GObject *object,
+ guint param_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (param_id)
+ {
+ case PROP_INDIVIDUAL_MANAGER:
+ individual_store_manager_set_individual_manager (
+ EMPATHY_INDIVIDUAL_STORE_MANAGER (object),
+ g_value_get_object (value));
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
+ break;
+ };
+}
+
+static void
+individual_store_manager_reload_individuals (EmpathyIndividualStore *store)
+{
+ EmpathyIndividualStoreManager *self = EMPATHY_INDIVIDUAL_STORE_MANAGER (
+ store);
+ GList *contacts;
+
+ contacts = empathy_individual_manager_get_members (self->priv->manager);
+
+ individual_store_manager_members_changed_cb (self->priv->manager,
+ "re-adding members: toggled group visibility",
+ contacts, NULL, 0, self);
+
+ g_list_free (contacts);
+}
+
+static void
+empathy_individual_store_manager_class_init (
+ EmpathyIndividualStoreManagerClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ EmpathyIndividualStoreClass *store_class = EMPATHY_INDIVIDUAL_STORE_CLASS (
+ klass);
+
+ object_class->dispose = individual_store_manager_dispose;
+ object_class->get_property = individual_store_manager_get_property;
+ object_class->set_property = individual_store_manager_set_property;
+
+ store_class->reload_individuals = individual_store_manager_reload_individuals;
+
+ g_object_class_install_property (object_class,
+ PROP_INDIVIDUAL_MANAGER,
+ g_param_spec_object ("individual-manager",
+ "Individual manager",
+ "Individual manager",
+ EMPATHY_TYPE_INDIVIDUAL_MANAGER,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
+
+ g_type_class_add_private (object_class,
+ sizeof (EmpathyIndividualStoreManagerPriv));
+}
+
+static void
+empathy_individual_store_manager_init (EmpathyIndividualStoreManager *self)
+{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
+ EMPATHY_TYPE_INDIVIDUAL_STORE_MANAGER, EmpathyIndividualStoreManagerPriv);
+}
+
+EmpathyIndividualStoreManager *
+empathy_individual_store_manager_new (EmpathyIndividualManager *manager)
+{
+ g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_MANAGER (manager), NULL);
+
+ return g_object_new (EMPATHY_TYPE_INDIVIDUAL_STORE_MANAGER,
+ "individual-manager", manager, NULL);
+}
+
+EmpathyIndividualManager *
+empathy_individual_store_manager_get_manager (
+ EmpathyIndividualStoreManager *self)
+{
+ g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_STORE_MANAGER (self), FALSE);
+
+ return self->priv->manager;
+}
diff --git a/libempathy-gtk/empathy-individual-store-manager.h b/libempathy-gtk/empathy-individual-store-manager.h
new file mode 100644
index 000000000..7656b50ea
--- /dev/null
+++ b/libempathy-gtk/empathy-individual-store-manager.h
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2005-2007 Imendio AB
+ * Copyright (C) 2007-2011 Collabora Ltd.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301 USA
+ *
+ * Authors: Mikael Hallendal <micke@imendio.com>
+ * Martyn Russell <martyn@imendio.com>
+ * Xavier Claessens <xclaesse@gmail.com>
+ * Travis Reitter <travis.reitter@collabora.co.uk>
+ */
+
+#ifndef __EMPATHY_INDIVIDUAL_STORE_MANAGER_H__
+#define __EMPATHY_INDIVIDUAL_STORE_MANAGER_H__
+
+#include <gtk/gtk.h>
+
+#include <libempathy/empathy-individual-manager.h>
+
+#include <libempathy-gtk/empathy-individual-store.h>
+
+G_BEGIN_DECLS
+#define EMPATHY_TYPE_INDIVIDUAL_STORE_MANAGER (empathy_individual_store_manager_get_type ())
+#define EMPATHY_INDIVIDUAL_STORE_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_INDIVIDUAL_STORE_MANAGER, EmpathyIndividualStoreManager))
+#define EMPATHY_INDIVIDUAL_STORE_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), EMPATHY_TYPE_INDIVIDUAL_STORE_MANAGER, EmpathyIndividualStoreManagerClass))
+#define EMPATHY_IS_INDIVIDUAL_STORE_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_INDIVIDUAL_STORE_MANAGER))
+#define EMPATHY_IS_INDIVIDUAL_STORE_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_INDIVIDUAL_STORE_MANAGER))
+#define EMPATHY_INDIVIDUAL_STORE_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_INDIVIDUAL_STORE_MANAGER, EmpathyIndividualStoreManagerClass))
+
+typedef struct _EmpathyIndividualStoreManager EmpathyIndividualStoreManager;
+typedef struct _EmpathyIndividualStoreManagerClass EmpathyIndividualStoreManagerClass;
+typedef struct _EmpathyIndividualStoreManagerPriv EmpathyIndividualStoreManagerPriv;
+
+struct _EmpathyIndividualStoreManager
+{
+ EmpathyIndividualStore parent;
+ EmpathyIndividualStoreManagerPriv *priv;
+};
+
+struct _EmpathyIndividualStoreManagerClass
+{
+ EmpathyIndividualStoreClass parent_class;
+};
+
+GType empathy_individual_store_manager_get_type (void) G_GNUC_CONST;
+
+EmpathyIndividualStoreManager *empathy_individual_store_manager_new (
+ EmpathyIndividualManager *manager);
+
+EmpathyIndividualManager *empathy_individual_store_manager_get_manager (
+ EmpathyIndividualStoreManager *store);
+
+G_END_DECLS
+#endif /* __EMPATHY_INDIVIDUAL_STORE_MANAGER_H__ */
diff --git a/libempathy-gtk/empathy-individual-store.c b/libempathy-gtk/empathy-individual-store.c
index 650cfb4e4..07d97b95b 100644
--- a/libempathy-gtk/empathy-individual-store.c
+++ b/libempathy-gtk/empathy-individual-store.c
@@ -38,7 +38,6 @@
#include <libempathy/empathy-utils.h>
#include <libempathy/empathy-enum-types.h>
-#include <libempathy/empathy-individual-manager.h>
#include "empathy-individual-store.h"
#include "empathy-ui-utils.h"
@@ -59,7 +58,6 @@
struct _EmpathyIndividualStorePriv
{
- EmpathyIndividualManager *manager;
gboolean show_avatars;
gboolean show_groups;
gboolean is_compact;
@@ -87,7 +85,6 @@ typedef struct
enum
{
PROP_0,
- PROP_INDIVIDUAL_MANAGER,
PROP_SHOW_AVATARS,
PROP_SHOW_PROTOCOLS,
PROP_SHOW_GROUPS,
@@ -926,119 +923,10 @@ individual_store_remove_individual_and_disconnect (
}
static void
-individual_store_members_changed_cb (EmpathyIndividualManager *manager,
- const gchar *message,
- GList *added,
- GList *removed,
- guint reason,
- EmpathyIndividualStore *self)
-{
- GList *l;
-
- for (l = added; l; l = l->next)
- {
- DEBUG ("Individual %s %s", folks_individual_get_id (l->data), "added");
-
- individual_store_add_individual_and_connect (self, l->data);
- }
- for (l = removed; l; l = l->next)
- {
- DEBUG ("Individual %s %s",
- folks_individual_get_id (l->data), "removed");
-
- individual_store_remove_individual_and_disconnect (self, l->data);
- }
-}
-
-static void
-individual_store_groups_changed_cb (EmpathyIndividualManager *manager,
- FolksIndividual *individual,
- gchar *group,
- gboolean is_member,
- EmpathyIndividualStore *self)
-{
- gboolean show_active;
-
- DEBUG ("Updating groups for individual %s",
- folks_individual_get_id (individual));
-
- /* We do this to make sure the groups are correct, if not, we
- * would have to check the groups already set up for each
- * contact and then see what has been updated.
- */
- show_active = self->show_active;
- self->show_active = FALSE;
- empathy_individual_store_remove_individual (self, individual);
- empathy_individual_store_add_individual (self, individual);
- self->show_active = show_active;
-}
-
-static gboolean
-individual_store_manager_setup (gpointer user_data)
-{
- EmpathyIndividualStore *self = user_data;
- GList *individuals;
-
- /* Signal connection. */
-
- /* TODO: implement */
- DEBUG ("handling individual renames unimplemented");
-
- g_signal_connect (self->priv->manager,
- "members-changed",
- G_CALLBACK (individual_store_members_changed_cb), self);
-
- g_signal_connect (self->priv->manager,
- "groups-changed",
- G_CALLBACK (individual_store_groups_changed_cb), self);
-
- /* Add contacts already created. */
- individuals = empathy_individual_manager_get_members (self->priv->manager);
- if (individuals != NULL && FOLKS_IS_INDIVIDUAL (individuals->data))
- {
- individual_store_members_changed_cb (self->priv->manager, "initial add",
- individuals, NULL, 0, self);
- g_list_free (individuals);
- }
-
- self->setup_idle_id = 0;
- return FALSE;
-}
-
-static void
-individual_store_set_individual_manager (EmpathyIndividualStore *self,
- EmpathyIndividualManager *manager)
-{
- self->priv->manager = g_object_ref (manager);
-
- /* Let a chance to have all properties set before populating */
- self->setup_idle_id = g_idle_add (individual_store_manager_setup, self);
-}
-
-static void
-individual_store_member_renamed_cb (EmpathyIndividualManager *manager,
- FolksIndividual *old_individual,
- FolksIndividual *new_individual,
- guint reason,
- const gchar *message,
- EmpathyIndividualStore *self)
-{
- DEBUG ("Individual %s renamed to %s",
- folks_individual_get_id (old_individual),
- folks_individual_get_id (new_individual));
-
- /* add the new contact */
- individual_store_add_individual_and_connect (self, new_individual);
-
- /* remove old contact */
- individual_store_remove_individual_and_disconnect (self, old_individual);
-}
-
-static void
individual_store_dispose (GObject *object)
{
EmpathyIndividualStore *self = EMPATHY_INDIVIDUAL_STORE (object);
- GList *individuals, *l;
+ GList *l;
if (self->priv->dispose_has_run)
return;
@@ -1052,22 +940,6 @@ individual_store_dispose (GObject *object)
}
g_list_free (self->priv->avatar_cancellables);
- individuals = empathy_individual_manager_get_members (self->priv->manager);
- for (l = individuals; l; l = l->next)
- {
- empathy_individual_store_disconnect_individual (self,
- FOLKS_INDIVIDUAL (l->data));
- }
- g_list_free (individuals);
-
- g_signal_handlers_disconnect_by_func (self->priv->manager,
- G_CALLBACK (individual_store_member_renamed_cb), object);
- g_signal_handlers_disconnect_by_func (self->priv->manager,
- G_CALLBACK (individual_store_members_changed_cb), object);
- g_signal_handlers_disconnect_by_func (self->priv->manager,
- G_CALLBACK (individual_store_groups_changed_cb), object);
- g_object_unref (self->priv->manager);
-
if (self->priv->inhibit_active)
{
g_source_remove (self->priv->inhibit_active);
@@ -1094,9 +966,6 @@ individual_store_get_property (GObject *object,
switch (param_id)
{
- case PROP_INDIVIDUAL_MANAGER:
- g_value_set_object (value, self->priv->manager);
- break;
case PROP_SHOW_AVATARS:
g_value_set_boolean (value, self->priv->show_avatars);
break;
@@ -1126,10 +995,6 @@ individual_store_set_property (GObject *object,
{
switch (param_id)
{
- case PROP_INDIVIDUAL_MANAGER:
- individual_store_set_individual_manager (EMPATHY_INDIVIDUAL_STORE
- (object), g_value_get_object (value));
- break;
case PROP_SHOW_AVATARS:
empathy_individual_store_set_show_avatars (EMPATHY_INDIVIDUAL_STORE
(object), g_value_get_boolean (value));
@@ -1166,13 +1031,6 @@ empathy_individual_store_class_init (EmpathyIndividualStoreClass *klass)
object_class->set_property = individual_store_set_property;
g_object_class_install_property (object_class,
- PROP_INDIVIDUAL_MANAGER,
- g_param_spec_object ("individual-manager",
- "The individual manager",
- "The individual manager",
- EMPATHY_TYPE_INDIVIDUAL_MANAGER,
- G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE));
- g_object_class_install_property (object_class,
PROP_SHOW_AVATARS,
g_param_spec_boolean ("show-avatars",
"Show Avatars",
@@ -1539,23 +1397,6 @@ empathy_individual_store_init (EmpathyIndividualStore *self)
individual_store_setup (self);
}
-EmpathyIndividualStore *
-empathy_individual_store_new (EmpathyIndividualManager *manager)
-{
- g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_MANAGER (manager), NULL);
-
- return g_object_new (EMPATHY_TYPE_INDIVIDUAL_STORE,
- "individual-manager", manager, NULL);
-}
-
-EmpathyIndividualManager *
-empathy_individual_store_get_manager (EmpathyIndividualStore *self)
-{
- g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_STORE (self), FALSE);
-
- return self->priv->manager;
-}
-
gboolean
empathy_individual_store_get_show_avatars (EmpathyIndividualStore *self)
{
@@ -1675,19 +1516,15 @@ 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 */
- GList *contacts;
+ EmpathyIndividualStoreClass *klass = EMPATHY_INDIVIDUAL_STORE_GET_CLASS (
+ self);
gtk_tree_store_clear (GTK_TREE_STORE (self));
/* Also clear the cache */
g_hash_table_remove_all (self->priv->folks_individual_cache);
g_hash_table_remove_all (self->priv->empathy_group_cache);
- contacts = empathy_individual_manager_get_members (self->priv->manager);
-
- individual_store_members_changed_cb (self->priv->manager,
- "re-adding members: toggled group visibility",
- contacts, NULL, 0, self);
- g_list_free (contacts);
+ klass->reload_individuals (self);
}
g_object_notify (G_OBJECT (self), "show-groups");
diff --git a/libempathy-gtk/empathy-individual-store.h b/libempathy-gtk/empathy-individual-store.h
index 8e62b19d7..3a102d7f8 100644
--- a/libempathy-gtk/empathy-individual-store.h
+++ b/libempathy-gtk/empathy-individual-store.h
@@ -29,8 +29,6 @@
#include <gtk/gtk.h>
-#include <libempathy/empathy-individual-manager.h>
-
G_BEGIN_DECLS
#define EMPATHY_TYPE_INDIVIDUAL_STORE (empathy_individual_store_get_type ())
#define EMPATHY_INDIVIDUAL_STORE(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_INDIVIDUAL_STORE, EmpathyIndividualStore))
@@ -88,17 +86,13 @@ struct _EmpathyIndividualStore
struct _EmpathyIndividualStoreClass
{
GtkTreeStoreClass parent_class;
+
+ void (*reload_individuals) (EmpathyIndividualStore *self);
};
GType
empathy_individual_store_get_type (void) G_GNUC_CONST;
-EmpathyIndividualStore *empathy_individual_store_new (
- EmpathyIndividualManager *manager);
-
-EmpathyIndividualManager *empathy_individual_store_get_manager (
- EmpathyIndividualStore *store);
-
gboolean empathy_individual_store_get_show_avatars (
EmpathyIndividualStore *store);