diff options
-rw-r--r-- | libempathy-gtk/empathy-roster-view.c | 27 | ||||
-rw-r--r-- | libempathy-gtk/empathy-roster-view.h | 4 | ||||
-rw-r--r-- | nautilus-sendto-plugin/empathy-nautilus-sendto.c | 10 | ||||
-rw-r--r-- | src/empathy-roster-window.c | 10 | ||||
-rw-r--r-- | tests/interactive/test-empathy-roster-view.c | 8 |
5 files changed, 51 insertions, 8 deletions
diff --git a/libempathy-gtk/empathy-roster-view.c b/libempathy-gtk/empathy-roster-view.c index 9647a1a4f..fb157ac90 100644 --- a/libempathy-gtk/empathy-roster-view.c +++ b/libempathy-gtk/empathy-roster-view.c @@ -18,6 +18,7 @@ G_DEFINE_TYPE (EmpathyRosterView, empathy_roster_view, EGG_TYPE_LIST_BOX) enum { PROP_MANAGER = 1, + PROP_MODEL, PROP_SHOW_OFFLINE, PROP_SHOW_GROUPS, PROP_EMPTY, @@ -66,6 +67,8 @@ struct _EmpathyRosterViewPriv gboolean empty; EmpathyLiveSearch *search; + + EmpathyRosterModel *model; }; typedef struct @@ -114,6 +117,9 @@ empathy_roster_view_get_property (GObject *object, case PROP_MANAGER: g_value_set_object (value, self->priv->manager); break; + case PROP_MODEL: + g_value_set_object (value, self->priv->model); + break; case PROP_SHOW_OFFLINE: g_value_set_boolean (value, self->priv->show_offline); break; @@ -143,6 +149,10 @@ empathy_roster_view_set_property (GObject *object, g_assert (self->priv->manager == NULL); /* construct only */ self->priv->manager = g_value_dup_object (value); break; + case PROP_MODEL: + g_assert (self->priv->model == NULL); + self->priv->model = g_value_dup_object (value); + break; case PROP_SHOW_OFFLINE: empathy_roster_view_show_offline (self, g_value_get_boolean (value)); break; @@ -930,7 +940,7 @@ populate_view (EmpathyRosterView *self) { GList *individuals, *l; - individuals = empathy_individual_manager_get_members (self->priv->manager); + individuals = empathy_roster_model_get_individuals (self->priv->model); for (l = individuals; l != NULL; l = g_list_next (l)) { FolksIndividual *individual = l->data; @@ -1109,6 +1119,7 @@ empathy_roster_view_constructed (GObject *object) chain_up (object); g_assert (EMPATHY_IS_INDIVIDUAL_MANAGER (self->priv->manager)); + g_assert (EMPATHY_IS_ROSTER_MODEL (self->priv->model)); populate_view (self); @@ -1143,6 +1154,7 @@ empathy_roster_view_dispose (GObject *object) empathy_roster_view_set_live_search (self, NULL); g_clear_object (&self->priv->manager); + g_clear_object (&self->priv->model); if (chain_up != NULL) chain_up (object); @@ -1375,6 +1387,12 @@ empathy_roster_view_class_init ( G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); g_object_class_install_property (oclass, PROP_MANAGER, spec); + spec = g_param_spec_object ("model", "Model", + "EmpathyRosterModel", + EMPATHY_TYPE_ROSTER_MODEL, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS); + g_object_class_install_property (oclass, PROP_MODEL, spec); + spec = g_param_spec_boolean ("show-offline", "Show Offline", "Show offline contacts", FALSE, @@ -1442,12 +1460,15 @@ empathy_roster_view_init (EmpathyRosterView *self) } GtkWidget * -empathy_roster_view_new (EmpathyIndividualManager *manager) +empathy_roster_view_new (EmpathyIndividualManager *manager, + EmpathyRosterModel *model) { g_return_val_if_fail (EMPATHY_IS_INDIVIDUAL_MANAGER (manager), NULL); - + g_return_val_if_fail (EMPATHY_IS_ROSTER_MODEL (model), NULL); + return g_object_new (EMPATHY_TYPE_ROSTER_VIEW, "manager", manager, + "model", model, NULL); } diff --git a/libempathy-gtk/empathy-roster-view.h b/libempathy-gtk/empathy-roster-view.h index 07c170970..fd4f13ec1 100644 --- a/libempathy-gtk/empathy-roster-view.h +++ b/libempathy-gtk/empathy-roster-view.h @@ -6,6 +6,7 @@ #include <libempathy-gtk/empathy-live-search.h> #include <libempathy/empathy-individual-manager.h> +#include <libempathy-gtk/empathy-roster-model.h> G_BEGIN_DECLS @@ -54,7 +55,8 @@ GType empathy_roster_view_get_type (void); EMPATHY_TYPE_ROSTER_VIEW, \ EmpathyRosterViewClass)) -GtkWidget * empathy_roster_view_new (EmpathyIndividualManager *manager); +GtkWidget * empathy_roster_view_new (EmpathyIndividualManager *manager, + EmpathyRosterModel *model); EmpathyIndividualManager * empathy_roster_view_get_manager ( EmpathyRosterView *self); diff --git a/nautilus-sendto-plugin/empathy-nautilus-sendto.c b/nautilus-sendto-plugin/empathy-nautilus-sendto.c index f93088952..fcfc28215 100644 --- a/nautilus-sendto-plugin/empathy-nautilus-sendto.c +++ b/nautilus-sendto-plugin/empathy-nautilus-sendto.c @@ -34,6 +34,8 @@ #include <libempathy/empathy-ft-factory.h> #include <libempathy/empathy-ft-handler.h> +#include <libempathy-gtk/empathy-roster-model.h> +#include <libempathy-gtk/empathy-roster-model-manager.h> #include <libempathy-gtk/empathy-contact-chooser.h> #include <libempathy-gtk/empathy-ui-utils.h> #include <libempathy-gtk/empathy-roster-view.h> @@ -111,12 +113,16 @@ get_contacts_widget (NstPlugin *plugin) { GtkWidget *roster_view, *box, *scrolled; EmpathyIndividualManager *mgr; - + EmpathyRosterModel *model; + box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8); mgr = empathy_individual_manager_dup_singleton (); - roster_view = empathy_roster_view_new (mgr); + model = EMPATHY_ROSTER_MODEL (empathy_roster_model_manager_new (mgr)); + roster_view = empathy_roster_view_new (mgr, model); + g_object_unref (model); + scrolled = gtk_scrolled_window_new (NULL, NULL); g_object_unref (mgr); diff --git a/src/empathy-roster-window.c b/src/empathy-roster-window.c index b292bf976..2b7f98a2c 100644 --- a/src/empathy-roster-window.c +++ b/src/empathy-roster-window.c @@ -49,6 +49,8 @@ #include <libempathy-gtk/empathy-gtk-enum-types.h> #include <libempathy-gtk/empathy-individual-dialogs.h> #include <libempathy-gtk/empathy-individual-store-manager.h> +#include <libempathy-gtk/empathy-roster-model.h> +#include <libempathy-gtk/empathy-roster-model-manager.h> #include <libempathy-gtk/empathy-roster-view.h> #include <libempathy-gtk/empathy-new-message-dialog.h> #include <libempathy-gtk/empathy-new-call-dialog.h> @@ -2118,6 +2120,7 @@ empathy_roster_window_init (EmpathyRosterWindow *self) gchar *filename; GtkWidget *search_vbox; guint i; + EmpathyRosterModel *model; self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, EMPATHY_TYPE_ROSTER_WINDOW, EmpathyRosterWindowPriv); @@ -2218,6 +2221,8 @@ empathy_roster_window_init (EmpathyRosterWindow *self) self->priv->individual_manager = empathy_individual_manager_dup_singleton (); + model = EMPATHY_ROSTER_MODEL (empathy_roster_model_manager_new (self->priv->individual_manager)); + if (!empathy_individual_manager_get_contacts_loaded ( self->priv->individual_manager)) { @@ -2228,7 +2233,10 @@ empathy_roster_window_init (EmpathyRosterWindow *self) } self->priv->view = EMPATHY_ROSTER_VIEW ( - empathy_roster_view_new (self->priv->individual_manager)); + empathy_roster_view_new (self->priv->individual_manager, + model)); + + g_object_unref (model); gtk_widget_show (GTK_WIDGET (self->priv->view)); diff --git a/tests/interactive/test-empathy-roster-view.c b/tests/interactive/test-empathy-roster-view.c index d0f739d71..6ab56c836 100644 --- a/tests/interactive/test-empathy-roster-view.c +++ b/tests/interactive/test-empathy-roster-view.c @@ -1,5 +1,8 @@ #include <config.h> +#include <libempathy-gtk/empathy-roster-model.h> +#include <libempathy-gtk/empathy-roster-model-manager.h> + #include <libempathy-gtk/empathy-roster-view.h> #include <libempathy-gtk/empathy-ui-utils.h> @@ -84,6 +87,7 @@ main (int argc, EmpathyIndividualManager *mgr; GError *error = NULL; GOptionContext *context; + EmpathyRosterModel *model; gtk_init (&argc, &argv); empathy_gtk_init (); @@ -105,8 +109,10 @@ main (int argc, mgr = empathy_individual_manager_dup_singleton (); - view = empathy_roster_view_new (mgr); + model = EMPATHY_ROSTER_MODEL (empathy_roster_model_manager_new (mgr)); + view = empathy_roster_view_new (mgr, model); + g_object_unref (model); g_signal_connect (view, "individual-activated", G_CALLBACK (individual_activated_cb), NULL); g_signal_connect (view, "popup-individual-menu", |