]> git.0d.be Git - empathy.git/blobdiff - tests/interactive/test-empathy-roster-view.c
roster-view: inherit from GtkListBox
[empathy.git] / tests / interactive / test-empathy-roster-view.c
index f10aaf2d76f912879d466e67cf8613bbcde39a0c..fbf09c71d556158a537fa9c33f7746303cd877db 100644 (file)
@@ -1,7 +1,9 @@
-#include <config.h>
+#include "config.h"
 
-#include <libempathy-gtk/empathy-roster-view.h>
-#include <libempathy-gtk/empathy-ui-utils.h>
+#include "empathy-roster-model.h"
+#include "empathy-roster-model-manager.h"
+#include "empathy-roster-view.h"
+#include "empathy-ui-utils.h"
 
 static gboolean show_offline = FALSE;
 static gboolean show_groups = FALSE;
@@ -26,6 +28,7 @@ individual_activated_cb (EmpathyRosterView *self,
 
 static void
 popup_individual_menu_cb (EmpathyRosterView *self,
+    const gchar *group,
     FolksIndividual *individual,
     guint button,
     guint time,
@@ -33,8 +36,8 @@ popup_individual_menu_cb (EmpathyRosterView *self,
 {
   GtkWidget *menu, *item;
 
-  g_print ("'%s' popup menu\n",
-      folks_alias_details_get_alias (FOLKS_ALIAS_DETAILS (individual)));
+  g_print ("'%s' (group: %s) popup menu\n",
+      folks_alias_details_get_alias (FOLKS_ALIAS_DETAILS (individual)), group);
 
   menu = gtk_menu_new ();
 
@@ -65,6 +68,17 @@ individual_tooltip_cb (EmpathyRosterView *view,
   return TRUE;
 }
 
+static void
+empty_cb (EmpathyRosterView *view,
+    GParamSpec *spec,
+    gpointer user_data)
+{
+  if (empathy_roster_view_is_empty (view))
+    g_print ("view is now empty\n");
+  else
+    g_print ("view is no longer empty\n");
+}
+
 int
 main (int argc,
     char **argv)
@@ -73,6 +87,7 @@ main (int argc,
   EmpathyIndividualManager *mgr;
   GError *error = NULL;
   GOptionContext *context;
+  EmpathyRosterModel *model;
 
   gtk_init (&argc, &argv);
   empathy_gtk_init ();
@@ -94,31 +109,35 @@ 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 (model);
 
+  g_object_unref (model);
   g_signal_connect (view, "individual-activated",
       G_CALLBACK (individual_activated_cb), NULL);
   g_signal_connect (view, "popup-individual-menu",
       G_CALLBACK (popup_individual_menu_cb), NULL);
+  g_signal_connect (view, "notify::empty",
+      G_CALLBACK (empty_cb), NULL);
+  g_signal_connect (view, "individual-tooltip",
+      G_CALLBACK (individual_tooltip_cb), NULL);
+
+  gtk_widget_set_has_tooltip (view, TRUE);
 
   empathy_roster_view_show_offline (EMPATHY_ROSTER_VIEW (view), show_offline);
   empathy_roster_view_show_groups (EMPATHY_ROSTER_VIEW (view), show_groups);
 
-  empathy_roster_view_set_individual_tooltip_cb (EMPATHY_ROSTER_VIEW (view),
-      individual_tooltip_cb, NULL);
-
   g_object_unref (mgr);
 
-  search = empathy_live_search_new (view);
+  search = tpaw_live_search_new (view);
   empathy_roster_view_set_live_search (EMPATHY_ROSTER_VIEW (view),
-      EMPATHY_LIVE_SEARCH (search));
+      TPAW_LIVE_SEARCH (search));
 
   scrolled = gtk_scrolled_window_new (NULL, NULL);
   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
       GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
 
-  egg_list_box_add_to_scrolled (EGG_LIST_BOX (view),
-      GTK_SCROLLED_WINDOW (scrolled));
+  gtk_container_add (GTK_CONTAINER (scrolled), view);
 
   gtk_box_pack_start (GTK_BOX (box), search, FALSE, TRUE, 0);
   gtk_box_pack_start (GTK_BOX (box), scrolled, TRUE, TRUE, 0);