| 28 #include "pidgin/pidgincontactlist.h" |
28 #include "pidgin/pidgincontactlist.h" |
| 29 |
29 |
| 30 struct _PidginContactList { |
30 struct _PidginContactList { |
| 31 GtkBox parent; |
31 GtkBox parent; |
| 32 |
32 |
| |
33 GtkWidget *show_offline; |
| |
34 |
| 33 GtkFilterListModel *filter_model; |
35 GtkFilterListModel *filter_model; |
| 34 GtkCustomFilter *account_connected_filter; |
36 GtkCustomFilter *account_connected_filter; |
| |
37 GtkCustomFilter *offline_filter; |
| 35 GtkCustomFilter *search_filter; |
38 GtkCustomFilter *search_filter; |
| 36 |
39 |
| 37 GtkWidget *search_entry; |
40 GtkWidget *search_entry; |
| 38 }; |
41 }; |
| 39 |
42 |
| 99 gtk_filter_changed(GTK_FILTER(list->account_connected_filter), |
102 gtk_filter_changed(GTK_FILTER(list->account_connected_filter), |
| 100 GTK_FILTER_CHANGE_MORE_STRICT); |
103 GTK_FILTER_CHANGE_MORE_STRICT); |
| 101 } |
104 } |
| 102 |
105 |
| 103 static gboolean |
106 static gboolean |
| |
107 pidgin_contact_list_offline_filter(GObject *item, gpointer data) { |
| |
108 PidginContactList *list = data; |
| |
109 PurplePerson *person = PURPLE_PERSON(item); |
| |
110 PurpleContactInfo *info = NULL; |
| |
111 PurplePresence *presence = NULL; |
| |
112 |
| |
113 /* If we're showing offline, there's nothing to do here. */ |
| |
114 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(list->show_offline))) { |
| |
115 return TRUE; |
| |
116 } |
| |
117 |
| |
118 info = purple_person_get_priority_contact_info(person); |
| |
119 if(!PURPLE_IS_CONTACT_INFO(info)) { |
| |
120 return FALSE; |
| |
121 } |
| |
122 |
| |
123 presence = purple_contact_info_get_presence(info); |
| |
124 if(PURPLE_IS_PRESENCE(presence)) { |
| |
125 PurplePresencePrimitive primitive = PURPLE_PRESENCE_PRIMITIVE_OFFLINE; |
| |
126 |
| |
127 primitive = purple_presence_get_primitive(presence); |
| |
128 if(primitive == PURPLE_PRESENCE_PRIMITIVE_OFFLINE) { |
| |
129 return FALSE; |
| |
130 } |
| |
131 } |
| |
132 |
| |
133 return TRUE; |
| |
134 } |
| |
135 |
| |
136 static gboolean |
| 104 pidgin_contact_list_search_filter(GObject *item, gpointer data) { |
137 pidgin_contact_list_search_filter(GObject *item, gpointer data) { |
| 105 PidginContactList *list = data; |
138 PidginContactList *list = data; |
| 106 PurplePerson *person = PURPLE_PERSON(item); |
139 PurplePerson *person = PURPLE_PERSON(item); |
| 107 const char *needle = NULL; |
140 const char *needle = NULL; |
| 108 |
141 |
| 112 } |
145 } |
| 113 |
146 |
| 114 /****************************************************************************** |
147 /****************************************************************************** |
| 115 * Callbacks |
148 * Callbacks |
| 116 *****************************************************************************/ |
149 *****************************************************************************/ |
| |
150 static void |
| |
151 pidgin_contact_list_show_offline_toggled_cb(G_GNUC_UNUSED GtkToggleButton *self, |
| |
152 gpointer data) |
| |
153 { |
| |
154 PidginContactList *list = data; |
| |
155 |
| |
156 gtk_filter_changed(GTK_FILTER(list->offline_filter), |
| |
157 GTK_FILTER_CHANGE_DIFFERENT); |
| |
158 } |
| |
159 |
| 117 static void |
160 static void |
| 118 pidgin_contact_list_search_changed_cb(GtkSearchEntry *self, gpointer data) { |
161 pidgin_contact_list_search_changed_cb(GtkSearchEntry *self, gpointer data) { |
| 119 PidginContactList *list = data; |
162 PidginContactList *list = data; |
| 120 |
163 |
| 121 gtk_filter_changed(GTK_FILTER(list->search_filter), |
164 gtk_filter_changed(GTK_FILTER(list->search_filter), |
| 331 list, 0); |
374 list, 0); |
| 332 g_signal_connect_object(account_manager, "account-disconnected", |
375 g_signal_connect_object(account_manager, "account-disconnected", |
| 333 G_CALLBACK(pidgin_contact_list_account_disconnected_cb), |
376 G_CALLBACK(pidgin_contact_list_account_disconnected_cb), |
| 334 list, 0); |
377 list, 0); |
| 335 |
378 |
| |
379 /* Set the filter function for the offline filter. */ |
| |
380 gtk_custom_filter_set_filter_func(list->offline_filter, |
| |
381 (GtkCustomFilterFunc)pidgin_contact_list_offline_filter, |
| |
382 list, NULL); |
| |
383 |
| 336 /* Setup the search filter and forwarding widget. */ |
384 /* Setup the search filter and forwarding widget. */ |
| 337 gtk_custom_filter_set_filter_func(list->search_filter, |
385 gtk_custom_filter_set_filter_func(list->search_filter, |
| 338 (GtkCustomFilterFunc)pidgin_contact_list_search_filter, |
386 (GtkCustomFilterFunc)pidgin_contact_list_search_filter, |
| 339 list, NULL); |
387 list, NULL); |
| 340 |
388 |
| 354 gtk_widget_class_bind_template_child(widget_class, PidginContactList, |
402 gtk_widget_class_bind_template_child(widget_class, PidginContactList, |
| 355 filter_model); |
403 filter_model); |
| 356 gtk_widget_class_bind_template_child(widget_class, PidginContactList, |
404 gtk_widget_class_bind_template_child(widget_class, PidginContactList, |
| 357 account_connected_filter); |
405 account_connected_filter); |
| 358 gtk_widget_class_bind_template_child(widget_class, PidginContactList, |
406 gtk_widget_class_bind_template_child(widget_class, PidginContactList, |
| |
407 show_offline); |
| |
408 gtk_widget_class_bind_template_child(widget_class, PidginContactList, |
| |
409 offline_filter); |
| |
410 gtk_widget_class_bind_template_child(widget_class, PidginContactList, |
| 359 search_filter); |
411 search_filter); |
| 360 |
412 |
| 361 gtk_widget_class_bind_template_child(widget_class, PidginContactList, |
413 gtk_widget_class_bind_template_child(widget_class, PidginContactList, |
| 362 search_entry); |
414 search_entry); |
| 363 |
415 |
| |
416 gtk_widget_class_bind_template_callback(widget_class, |
| |
417 pidgin_contact_list_show_offline_toggled_cb); |
| 364 gtk_widget_class_bind_template_callback(widget_class, |
418 gtk_widget_class_bind_template_callback(widget_class, |
| 365 pidgin_contact_list_search_changed_cb); |
419 pidgin_contact_list_search_changed_cb); |
| 366 gtk_widget_class_bind_template_callback(widget_class, |
420 gtk_widget_class_bind_template_callback(widget_class, |
| 367 pidgin_contact_list_avatar_cb); |
421 pidgin_contact_list_avatar_cb); |
| 368 gtk_widget_class_bind_template_callback(widget_class, |
422 gtk_widget_class_bind_template_callback(widget_class, |