pidgin/pidginaddchatdialog.c

changeset 41864
6f490dec468f
parent 41860
9315e7772780
child 41901
55a099a1e619
equal deleted inserted replaced
41863:0067a0ff5b74 41864:6f490dec468f
25 #include "pidginaddchatdialog.h" 25 #include "pidginaddchatdialog.h"
26 26
27 #include "gtkaccount.h" 27 #include "gtkaccount.h"
28 #include "gtkroomlist.h" 28 #include "gtkroomlist.h"
29 #include "pidginaccountchooser.h" 29 #include "pidginaccountchooser.h"
30 #include "pidginaccountstore.h"
31 #include "pidgincore.h" 30 #include "pidgincore.h"
32 31
33 struct _PidginAddChatDialog { 32 struct _PidginAddChatDialog {
34 GtkDialog parent; 33 GtkDialog parent;
35 34
36 GtkTreeModel *filter; 35 GtkCustomFilter *filter;
37 36
38 const gchar *default_name; 37 const gchar *default_name;
39 38
40 GtkWidget *account; 39 GtkWidget *account;
41 GtkWidget *dynamic_box; 40 GtkWidget *dynamic_box;
181 180
182 pidgin_add_chat_dialog_validate(dialog); 181 pidgin_add_chat_dialog_validate(dialog);
183 } 182 }
184 183
185 static gboolean 184 static gboolean
186 pidgin_add_chat_dialog_filter_accounts(GtkTreeModel *model, GtkTreeIter *iter, 185 pidgin_add_chat_dialog_filter_accounts(gpointer item,
187 gpointer data) 186 G_GNUC_UNUSED gpointer data)
188 { 187 {
189 PurpleAccount *account = NULL;
190 PurpleProtocol *protocol = NULL;
191 gboolean ret = FALSE; 188 gboolean ret = FALSE;
192 189
193 g_return_val_if_fail(GTK_IS_TREE_MODEL(model), FALSE); 190 if(PURPLE_IS_ACCOUNT(item)) {
194 g_return_val_if_fail(iter != NULL, FALSE); 191 PurpleAccount *account = PURPLE_ACCOUNT(item);
195 192 PurpleProtocol *protocol = purple_account_get_protocol(account);
196 gtk_tree_model_get(model, iter, PIDGIN_ACCOUNT_STORE_COLUMN_ACCOUNT, 193
197 &account, -1); 194 if(PURPLE_IS_PROTOCOL(protocol)) {
198 195 ret = PURPLE_PROTOCOL_IMPLEMENTS(protocol, CHAT, info);
199 if(!PURPLE_IS_ACCOUNT(account)) { 196 }
200 return FALSE; 197 }
201 }
202
203 protocol = purple_account_get_protocol(account);
204 if(PURPLE_IS_PROTOCOL(protocol)) {
205 ret = PURPLE_PROTOCOL_IMPLEMENTS(protocol, CHAT, info);
206 }
207
208 g_object_unref(G_OBJECT(account));
209 198
210 return ret; 199 return ret;
211 } 200 }
212 201
213 static void 202 static void
377 pidgin_add_chat_dialog_init(PidginAddChatDialog *dialog) { 366 pidgin_add_chat_dialog_init(PidginAddChatDialog *dialog) {
378 gtk_widget_init_template(GTK_WIDGET(dialog)); 367 gtk_widget_init_template(GTK_WIDGET(dialog));
379 368
380 gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK); 369 gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
381 370
382 gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(dialog->filter), 371 gtk_custom_filter_set_filter_func(dialog->filter,
383 pidgin_add_chat_dialog_filter_accounts, 372 pidgin_add_chat_dialog_filter_accounts,
384 NULL, NULL); 373 NULL, NULL);
385 gtk_tree_model_filter_refilter(GTK_TREE_MODEL_FILTER(dialog->filter));
386
387 gtk_combo_box_set_active(GTK_COMBO_BOX(dialog->account), 0);
388 374
389 purple_blist_walk(pidgin_add_chat_dialog_group_cb, NULL, NULL, NULL, 375 purple_blist_walk(pidgin_add_chat_dialog_group_cb, NULL, NULL, NULL,
390 dialog); 376 dialog);
391 } 377 }
392 378

mercurial