3 #include "empathy-roster-model.h"
4 #include "empathy-roster-model-manager.h"
5 #include "empathy-roster-view.h"
6 #include "empathy-ui-utils.h"
9 individual_activated_cb (EmpathyRosterView
*self
,
10 FolksIndividual
*individual
,
13 g_assert (FOLKS_IS_INDIVIDUAL (individual
));
15 g_print ("'%s' activated\n",
16 folks_alias_details_get_alias (FOLKS_ALIAS_DETAILS (individual
)));
20 popup_individual_menu_cb (EmpathyRosterView
*self
,
22 FolksIndividual
*individual
,
27 GtkWidget
*menu
, *item
;
29 g_print ("'%s' (group: %s) popup menu\n",
30 folks_alias_details_get_alias (FOLKS_ALIAS_DETAILS (individual
)), group
);
32 menu
= gtk_menu_new ();
34 g_signal_connect (menu
, "deactivate",
35 G_CALLBACK (gtk_widget_destroy
), NULL
);
37 item
= gtk_menu_item_new_with_label (folks_alias_details_get_alias (
38 FOLKS_ALIAS_DETAILS (individual
)));
39 gtk_widget_show (item
);
41 gtk_menu_shell_append (GTK_MENU_SHELL (menu
), item
);
43 gtk_menu_attach_to_widget (GTK_MENU (menu
), GTK_WIDGET (self
), NULL
);
45 gtk_menu_popup (GTK_MENU (menu
), NULL
, NULL
, NULL
, NULL
, button
, time
);
49 individual_tooltip_cb (EmpathyRosterView
*view
,
50 FolksIndividual
*individual
,
51 gboolean keyboard_mode
,
55 gtk_tooltip_set_text (tooltip
,
56 folks_alias_details_get_alias (FOLKS_ALIAS_DETAILS (individual
)));
62 empty_cb (EmpathyRosterView
*view
,
66 if (empathy_roster_view_is_empty (view
))
67 g_print ("view is now empty\n");
69 g_print ("view is no longer empty\n");
73 create_view_box (EmpathyRosterModel
*model
,
74 gboolean show_offline
,
77 GtkWidget
*view
, *scrolled
, *box
, *search
;
79 box
= gtk_box_new (GTK_ORIENTATION_VERTICAL
, 8);
81 view
= empathy_roster_view_new (model
);
83 g_signal_connect (view
, "individual-activated",
84 G_CALLBACK (individual_activated_cb
), NULL
);
85 g_signal_connect (view
, "popup-individual-menu",
86 G_CALLBACK (popup_individual_menu_cb
), NULL
);
87 g_signal_connect (view
, "notify::empty",
88 G_CALLBACK (empty_cb
), NULL
);
89 g_signal_connect (view
, "individual-tooltip",
90 G_CALLBACK (individual_tooltip_cb
), NULL
);
92 gtk_widget_set_has_tooltip (view
, TRUE
);
94 empathy_roster_view_show_offline (EMPATHY_ROSTER_VIEW (view
), show_offline
);
95 empathy_roster_view_show_groups (EMPATHY_ROSTER_VIEW (view
), show_groups
);
97 search
= tpaw_live_search_new (view
);
98 empathy_roster_view_set_live_search (EMPATHY_ROSTER_VIEW (view
),
99 TPAW_LIVE_SEARCH (search
));
101 scrolled
= gtk_scrolled_window_new (NULL
, NULL
);
102 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled
),
103 GTK_POLICY_NEVER
, GTK_POLICY_AUTOMATIC
);
105 gtk_container_add (GTK_CONTAINER (scrolled
), view
);
107 gtk_box_pack_start (GTK_BOX (box
), search
, FALSE
, TRUE
, 0);
108 gtk_box_pack_start (GTK_BOX (box
), scrolled
, TRUE
, TRUE
, 0);
117 GtkWidget
*window
, *view1
, *view2
, *box_horiz
;
118 EmpathyIndividualManager
*mgr
;
119 EmpathyRosterModel
*model
;
121 gtk_init (&argc
, &argv
);
124 window
= gtk_window_new (GTK_WINDOW_TOPLEVEL
);
126 empathy_set_css_provider (window
);
128 box_horiz
= gtk_box_new (GTK_ORIENTATION_HORIZONTAL
, 8);
130 mgr
= empathy_individual_manager_dup_singleton ();
132 model
= EMPATHY_ROSTER_MODEL (empathy_roster_model_manager_new (mgr
));
134 view1
= create_view_box (model
, TRUE
, TRUE
);
135 view2
= create_view_box (model
, FALSE
, FALSE
);
137 g_object_unref (model
);
138 g_object_unref (mgr
);
140 gtk_box_pack_start (GTK_BOX (box_horiz
), view1
, FALSE
, TRUE
, 0);
141 gtk_box_pack_start (GTK_BOX (box_horiz
), view2
, FALSE
, TRUE
, 0);
142 gtk_container_add (GTK_CONTAINER (window
), box_horiz
);
144 gtk_window_set_default_size (GTK_WINDOW (window
), 600, 600);
145 gtk_widget_show_all (window
);
147 g_signal_connect_swapped (window
, "destroy",
148 G_CALLBACK (gtk_main_quit
), NULL
);