]> git.0d.be Git - empathy.git/commitdiff
empathy-roster-view: start using empathy-roster-model
authorLaurent Contzen <lcontzen@gmail.com>
Wed, 4 Jul 2012 09:59:15 +0000 (11:59 +0200)
committerLaurent Contzen <lcontzen@gmail.com>
Mon, 23 Jul 2012 07:48:42 +0000 (09:48 +0200)
https://bugzilla.gnome.org/show_bug.cgi?id=680302

libempathy-gtk/empathy-roster-view.c
libempathy-gtk/empathy-roster-view.h
nautilus-sendto-plugin/empathy-nautilus-sendto.c
src/empathy-roster-window.c
tests/interactive/test-empathy-roster-view.c

index 9647a1a4f4b55cda4e7cfdf0f2c66d5ada07e316..fb157ac90dec40ab0462575a6bacf211b5dcc50f 100644 (file)
@@ -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);
 }
 
index 07c1709709b780abdf8a916554bfa3e52decc8c6..fd4f13ec1ded2706fcfdf9e5628189140cc5f9aa 100644 (file)
@@ -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);
index f93088952687ec8e430646a09a3f9f084974856a..fcfc282154e1bb6ac15900a8bc64e60e38341f23 100644 (file)
@@ -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);
index b292bf976ea541308122ef98113cf4b8d93b73db..2b7f98a2c1f071b2438094ed5594ca82b129885d 100644 (file)
@@ -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));
 
index d0f739d7133c4e3c9957e20f2262611b7c323121..6ab56c8361977ce9419c3394cd76862fa695cf61 100644 (file)
@@ -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",