]> git.0d.be Git - empathy.git/blob - tests/interactive/test-empathy-roster-view.c
test-empathy-roster-view: add --groups option
[empathy.git] / tests / interactive / test-empathy-roster-view.c
1 #include <config.h>
2
3 #include <libempathy-gtk/empathy-roster-view.h>
4 #include <libempathy-gtk/empathy-ui-utils.h>
5
6 static gboolean show_offline = FALSE;
7 static gboolean show_groups = FALSE;
8
9 static GOptionEntry entries[] =
10 {
11   { "offline", 0, 0, G_OPTION_ARG_NONE, &show_offline, "Show offline contacts", NULL },
12   { "groups", 0, 0, G_OPTION_ARG_NONE, &show_groups, "Show groups", NULL },
13   { NULL }
14 };
15
16 int
17 main (int argc,
18     char **argv)
19 {
20   GtkWidget *window, *view, *scrolled;
21   EmpathyIndividualManager *mgr;
22   GError *error = NULL;
23   GOptionContext *context;
24
25   gtk_init (&argc, &argv);
26   empathy_gtk_init ();
27
28   context = g_option_context_new ("- test tree model performance");
29   g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
30   g_option_context_add_group (context, gtk_get_option_group (TRUE));
31   if (!g_option_context_parse (context, &argc, &argv, &error))
32     {
33       g_print ("option parsing failed: %s\n", error->message);
34       return 1;
35     }
36
37   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
38
39   empathy_set_css_provider (window);
40
41   mgr = empathy_individual_manager_dup_singleton ();
42
43   view = empathy_roster_view_new (mgr);
44
45   empathy_roster_view_show_offline (EMPATHY_ROSTER_VIEW (view), show_offline);
46   empathy_roster_view_show_groups (EMPATHY_ROSTER_VIEW (view), show_groups);
47
48   g_object_unref (mgr);
49
50   scrolled = gtk_scrolled_window_new (NULL, NULL);
51   gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled),
52       GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
53
54   egg_list_box_add_to_scrolled (EGG_LIST_BOX (view),
55       GTK_SCROLLED_WINDOW (scrolled));
56   gtk_container_add (GTK_CONTAINER (window), scrolled);
57
58   gtk_window_set_default_size (GTK_WINDOW (window), 300, 600);
59   gtk_widget_show_all (window);
60
61   g_signal_connect_swapped (window, "destroy",
62       G_CALLBACK (gtk_main_quit), NULL);
63
64   gtk_main ();
65
66   return 0;
67 }