finch/gntblist.c

branch
soc.2013.gobjectification
changeset 34699
09b2c9219b57
parent 34696
6e0d13978666
child 34706
02cb08146888
equal deleted inserted replaced
34698:e0bd77bd4508 34699:09b2c9219b57
70 { 70 {
71 GntWidget *window; 71 GntWidget *window;
72 GntWidget *tree; 72 GntWidget *tree;
73 73
74 GntWidget *tooltip; 74 GntWidget *tooltip;
75 PurpleBlistNode *tnode; /* Who is the tooltip being displayed for? */ 75 PurpleBListNode *tnode; /* Who is the tooltip being displayed for? */
76 GList *tagged; /* A list of tagged blistnodes */ 76 GList *tagged; /* A list of tagged blistnodes */
77 77
78 GntWidget *context; 78 GntWidget *context;
79 PurpleBlistNode *cnode; 79 PurpleBListNode *cnode;
80 80
81 /* XXX: I am KISSing */ 81 /* XXX: I am KISSing */
82 GntWidget *status; /* Dropdown with the statuses */ 82 GntWidget *status; /* Dropdown with the statuses */
83 GntWidget *statustext; /* Status message */ 83 GntWidget *statustext; /* Status message */
84 int typing; 84 int typing;
127 127
128 static void add_buddy(PurpleBuddy *buddy, FinchBlist *ggblist); 128 static void add_buddy(PurpleBuddy *buddy, FinchBlist *ggblist);
129 static void add_contact(PurpleContact *contact, FinchBlist *ggblist); 129 static void add_contact(PurpleContact *contact, FinchBlist *ggblist);
130 static void add_group(PurpleGroup *group, FinchBlist *ggblist); 130 static void add_group(PurpleGroup *group, FinchBlist *ggblist);
131 static void add_chat(PurpleChat *chat, FinchBlist *ggblist); 131 static void add_chat(PurpleChat *chat, FinchBlist *ggblist);
132 static void add_node(PurpleBlistNode *node, FinchBlist *ggblist); 132 static void add_node(PurpleBListNode *node, FinchBlist *ggblist);
133 static void node_update(PurpleBuddyList *list, PurpleBlistNode *node); 133 static void node_update(PurpleBuddyList *list, PurpleBListNode *node);
134 #if 0 134 #if 0
135 static gboolean is_contact_online(PurpleContact *contact); 135 static gboolean is_contact_online(PurpleContact *contact);
136 static gboolean is_group_online(PurpleGroup *group); 136 static gboolean is_group_online(PurpleGroup *group);
137 #endif 137 #endif
138 static void draw_tooltip(FinchBlist *ggblist); 138 static void draw_tooltip(FinchBlist *ggblist);
139 static void tooltip_for_buddy(PurpleBuddy *buddy, GString *str, gboolean full); 139 static void tooltip_for_buddy(PurpleBuddy *buddy, GString *str, gboolean full);
140 static gboolean remove_typing_cb(gpointer null); 140 static gboolean remove_typing_cb(gpointer null);
141 static void remove_peripherals(FinchBlist *ggblist); 141 static void remove_peripherals(FinchBlist *ggblist);
142 static const char * get_display_name(PurpleBlistNode *node); 142 static const char * get_display_name(PurpleBListNode *node);
143 static void savedstatus_changed(PurpleSavedStatus *now, PurpleSavedStatus *old); 143 static void savedstatus_changed(PurpleSavedStatus *now, PurpleSavedStatus *old);
144 static void blist_show(PurpleBuddyList *list); 144 static void blist_show(PurpleBuddyList *list);
145 static void update_node_display(PurpleBlistNode *buddy, FinchBlist *ggblist); 145 static void update_node_display(PurpleBListNode *buddy, FinchBlist *ggblist);
146 static void update_buddy_display(PurpleBuddy *buddy, FinchBlist *ggblist); 146 static void update_buddy_display(PurpleBuddy *buddy, FinchBlist *ggblist);
147 static gboolean account_autojoin_cb(PurpleConnection *pc, gpointer null); 147 static gboolean account_autojoin_cb(PurpleConnection *pc, gpointer null);
148 static void finch_request_add_buddy(PurpleAccount *account, const char *username, const char *grp, const char *alias); 148 static void finch_request_add_buddy(PurpleAccount *account, const char *username, const char *grp, const char *alias);
149 static void menu_group_set_cb(GntMenuItem *item, gpointer null); 149 static void menu_group_set_cb(GntMenuItem *item, gpointer null);
150 150
151 /* Sort functions */ 151 /* Sort functions */
152 static int blist_node_compare_position(PurpleBlistNode *n1, PurpleBlistNode *n2); 152 static int blist_node_compare_position(PurpleBListNode *n1, PurpleBListNode *n2);
153 static int blist_node_compare_text(PurpleBlistNode *n1, PurpleBlistNode *n2); 153 static int blist_node_compare_text(PurpleBListNode *n1, PurpleBListNode *n2);
154 static int blist_node_compare_status(PurpleBlistNode *n1, PurpleBlistNode *n2); 154 static int blist_node_compare_status(PurpleBListNode *n1, PurpleBListNode *n2);
155 static int blist_node_compare_log(PurpleBlistNode *n1, PurpleBlistNode *n2); 155 static int blist_node_compare_log(PurpleBListNode *n1, PurpleBListNode *n2);
156 156
157 static int color_available; 157 static int color_available;
158 static int color_away; 158 static int color_away;
159 static int color_offline; 159 static int color_offline;
160 static int color_idle; 160 static int color_idle;
161 161
162 /** 162 /**
163 * Buddy List Manager functions. 163 * Buddy List Manager functions.
164 */ 164 */
165 165
166 static gboolean default_can_add_node(PurpleBlistNode *node) 166 static gboolean default_can_add_node(PurpleBListNode *node)
167 { 167 {
168 gboolean offline = purple_prefs_get_bool(PREF_ROOT "/showoffline"); 168 gboolean offline = purple_prefs_get_bool(PREF_ROOT "/showoffline");
169 169
170 if (PURPLE_IS_BUDDY(node)) { 170 if (PURPLE_IS_BUDDY(node)) {
171 PurpleBuddy *buddy = (PurpleBuddy*)node; 171 PurpleBuddy *buddy = (PurpleBuddy*)node;
181 if (fnode && fnode->signed_timer) 181 if (fnode && fnode->signed_timer)
182 return TRUE; /* Show if the buddy just signed off */ 182 return TRUE; /* Show if the buddy just signed off */
183 if (purple_blist_node_get_bool(node, "show_offline")) 183 if (purple_blist_node_get_bool(node, "show_offline"))
184 return TRUE; 184 return TRUE;
185 } else if (PURPLE_IS_CONTACT(node)) { 185 } else if (PURPLE_IS_CONTACT(node)) {
186 PurpleBlistNode *nd; 186 PurpleBListNode *nd;
187 for (nd = purple_blist_node_get_first_child(node); 187 for (nd = purple_blist_node_get_first_child(node);
188 nd; nd = purple_blist_node_get_sibling_next(nd)) { 188 nd; nd = purple_blist_node_get_sibling_next(nd)) {
189 if (default_can_add_node(nd)) 189 if (default_can_add_node(nd))
190 return TRUE; 190 return TRUE;
191 } 191 }
192 } else if (PURPLE_IS_CHAT(node)) { 192 } else if (PURPLE_IS_CHAT(node)) {
193 PurpleChat *chat = (PurpleChat*)node; 193 PurpleChat *chat = (PurpleChat*)node;
194 if (purple_account_is_connected(purple_chat_get_account(chat))) 194 if (purple_account_is_connected(purple_chat_get_account(chat)))
195 return TRUE; /* Show whenever the account is online */ 195 return TRUE; /* Show whenever the account is online */
196 } else if (PURPLE_IS_GROUP(node)) { 196 } else if (PURPLE_IS_GROUP(node)) {
197 PurpleBlistNode *nd; 197 PurpleBListNode *nd;
198 gboolean empty = purple_prefs_get_bool(PREF_ROOT "/emptygroups"); 198 gboolean empty = purple_prefs_get_bool(PREF_ROOT "/emptygroups");
199 if (empty) 199 if (empty)
200 return TRUE; /* If we want to see empty groups, we can show any group */ 200 return TRUE; /* If we want to see empty groups, we can show any group */
201 201
202 for (nd = purple_blist_node_get_first_child(node); 202 for (nd = purple_blist_node_get_first_child(node);
210 } 210 }
211 211
212 return FALSE; 212 return FALSE;
213 } 213 }
214 214
215 static gpointer default_find_parent(PurpleBlistNode *node) 215 static gpointer default_find_parent(PurpleBListNode *node)
216 { 216 {
217 gpointer ret = NULL; 217 gpointer ret = NULL;
218 switch (purple_blist_node_get_type(node)) { 218 switch (purple_blist_node_get_type(node)) {
219 case PURPLE_BLIST_BUDDY_NODE: 219 case PURPLE_BLIST_BUDDY_NODE:
220 case PURPLE_BLIST_CONTACT_NODE: 220 case PURPLE_BLIST_CONTACT_NODE:
230 } 230 }
231 231
232 static gboolean default_create_tooltip(gpointer selected_row, GString **body, char **tool_title) 232 static gboolean default_create_tooltip(gpointer selected_row, GString **body, char **tool_title)
233 { 233 {
234 GString *str; 234 GString *str;
235 PurpleBlistNode *node = selected_row; 235 PurpleBListNode *node = selected_row;
236 int lastseen = 0; 236 int lastseen = 0;
237 char *title; 237 char *title;
238 238
239 if (!node || 239 if (!node ||
240 purple_blist_node_get_type(node) == PURPLE_BLIST_OTHER_NODE) 240 purple_blist_node_get_type(node) == PURPLE_BLIST_OTHER_NODE)
255 if (offline) { 255 if (offline) {
256 int value = purple_blist_node_get_int(node, "last_seen"); 256 int value = purple_blist_node_get_int(node, "last_seen");
257 if (value > lastseen) 257 if (value > lastseen)
258 lastseen = value; 258 lastseen = value;
259 } 259 }
260 if (node == (PurpleBlistNode*)pr) 260 if (node == (PurpleBListNode*)pr)
261 continue; 261 continue;
262 if (!purple_account_is_connected(purple_buddy_get_account(buddy))) 262 if (!purple_account_is_connected(purple_buddy_get_account(buddy)))
263 continue; 263 continue;
264 if (!showoffline && !PURPLE_IS_BUDDY_ONLINE(buddy)) 264 if (!showoffline && !PURPLE_IS_BUDDY_ONLINE(buddy))
265 continue; 265 continue;
325 {NULL, NULL, NULL, NULL} 325 {NULL, NULL, NULL, NULL}
326 }; 326 };
327 static GList *managers; 327 static GList *managers;
328 328
329 static FinchBlistNode * 329 static FinchBlistNode *
330 create_finch_blist_node(PurpleBlistNode *node, gpointer row) 330 create_finch_blist_node(PurpleBListNode *node, gpointer row)
331 { 331 {
332 FinchBlistNode *fnode = purple_blist_node_get_ui_data(node); 332 FinchBlistNode *fnode = purple_blist_node_get_ui_data(node);
333 if (!fnode) { 333 if (!fnode) {
334 fnode = g_new0(FinchBlistNode, 1); 334 fnode = g_new0(FinchBlistNode, 1);
335 fnode->signed_timer = 0; 335 fnode->signed_timer = 0;
338 fnode->row = row; 338 fnode->row = row;
339 return fnode; 339 return fnode;
340 } 340 }
341 341
342 static void 342 static void
343 reset_blist_node_ui_data(PurpleBlistNode *node) 343 reset_blist_node_ui_data(PurpleBListNode *node)
344 { 344 {
345 FinchBlistNode *fnode = purple_blist_node_get_ui_data(node); 345 FinchBlistNode *fnode = purple_blist_node_get_ui_data(node);
346 if (fnode == NULL) 346 if (fnode == NULL)
347 return; 347 return;
348 if (fnode->signed_timer) 348 if (fnode->signed_timer)
350 g_free(fnode); 350 g_free(fnode);
351 purple_blist_node_set_ui_data(node, NULL); 351 purple_blist_node_set_ui_data(node, NULL);
352 } 352 }
353 353
354 static int 354 static int
355 get_display_color(PurpleBlistNode *node) 355 get_display_color(PurpleBListNode *node)
356 { 356 {
357 PurpleBuddy *buddy; 357 PurpleBuddy *buddy;
358 int color = 0; 358 int color = 0;
359 359
360 if (PURPLE_IS_CONTACT(node)) 360 if (PURPLE_IS_CONTACT(node))
376 376
377 return color; 377 return color;
378 } 378 }
379 379
380 static GntTextFormatFlags 380 static GntTextFormatFlags
381 get_blist_node_flag(PurpleBlistNode *node) 381 get_blist_node_flag(PurpleBListNode *node)
382 { 382 {
383 GntTextFormatFlags flag = 0; 383 GntTextFormatFlags flag = 0;
384 FinchBlistNode *fnode = purple_blist_node_get_ui_data(node); 384 FinchBlistNode *fnode = purple_blist_node_get_ui_data(node);
385 385
386 if (ggblist->tagged && g_list_find(ggblist->tagged, node)) 386 if (ggblist->tagged && g_list_find(ggblist->tagged, node))
402 * API addition would be necessary */ 402 * API addition would be necessary */
403 #if 0 403 #if 0
404 if (!gnt_tree_get_expanded(GNT_TREE(ggblist->tree), node)) { 404 if (!gnt_tree_get_expanded(GNT_TREE(ggblist->tree), node)) {
405 for (node = purple_blist_node_get_first_child(node); node; 405 for (node = purple_blist_node_get_first_child(node); node;
406 node = purple_blist_node_get_sibling_next(node)) { 406 node = purple_blist_node_get_sibling_next(node)) {
407 PurpleBlistNode *pnode; 407 PurpleBListNode *pnode;
408 pnode = purple_contact_get_priority_buddy((PurpleContact*)node); 408 pnode = purple_contact_get_priority_buddy((PurpleContact*)node);
409 fnode = purple_blist_node_get_ui_data(node); 409 fnode = purple_blist_node_get_ui_data(node);
410 if (fnode && fnode->signed_timer) { 410 if (fnode && fnode->signed_timer) {
411 flag |= GNT_TEXT_FLAG_BLINK; 411 flag |= GNT_TEXT_FLAG_BLINK;
412 break; 412 break;
418 418
419 return flag; 419 return flag;
420 } 420 }
421 421
422 static void 422 static void
423 blist_update_row_flags(PurpleBlistNode *node) 423 blist_update_row_flags(PurpleBListNode *node)
424 { 424 {
425 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), node, get_blist_node_flag(node)); 425 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), node, get_blist_node_flag(node));
426 gnt_tree_set_row_color(GNT_TREE(ggblist->tree), node, get_display_color(node)); 426 gnt_tree_set_row_color(GNT_TREE(ggblist->tree), node, get_display_color(node));
427 } 427 }
428 428
429 #if 0 429 #if 0
430 static gboolean 430 static gboolean
431 is_contact_online(PurpleContact *contact) 431 is_contact_online(PurpleContact *contact)
432 { 432 {
433 PurpleBlistNode *node; 433 PurpleBListNode *node;
434 for (node = purple_blist_node_get_first_child(((PurpleBlistNode*)contact)); node; 434 for (node = purple_blist_node_get_first_child(((PurpleBListNode*)contact)); node;
435 node = purple_blist_node_get_sibling_next(node)) { 435 node = purple_blist_node_get_sibling_next(node)) {
436 FinchBlistNode *fnode = purple_blist_node_get_ui_data(node); 436 FinchBlistNode *fnode = purple_blist_node_get_ui_data(node);
437 if (PURPLE_IS_BUDDY_ONLINE((PurpleBuddy*)node) || 437 if (PURPLE_IS_BUDDY_ONLINE((PurpleBuddy*)node) ||
438 (fnode && fnode->signed_timer)) 438 (fnode && fnode->signed_timer))
439 return TRUE; 439 return TRUE;
442 } 442 }
443 443
444 static gboolean 444 static gboolean
445 is_group_online(PurpleGroup *group) 445 is_group_online(PurpleGroup *group)
446 { 446 {
447 PurpleBlistNode *node; 447 PurpleBListNode *node;
448 for (node = purple_blist_node_get_first_child(((PurpleBlistNode*)group)); node; 448 for (node = purple_blist_node_get_first_child(((PurpleBListNode*)group)); node;
449 node = purple_blist_node_get_sibling_next(node)) { 449 node = purple_blist_node_get_sibling_next(node)) {
450 if (PURPLE_IS_CHAT(node) && 450 if (PURPLE_IS_CHAT(node) &&
451 purple_account_is_connected(((PurpleChat *)node)->account)) 451 purple_account_is_connected(((PurpleChat *)node)->account))
452 return TRUE; 452 return TRUE;
453 else if (is_contact_online((PurpleContact*)node)) 453 else if (is_contact_online((PurpleContact*)node))
456 return FALSE; 456 return FALSE;
457 } 457 }
458 #endif 458 #endif
459 459
460 static void 460 static void
461 new_node(PurpleBlistNode *node) 461 new_node(PurpleBListNode *node)
462 { 462 {
463 } 463 }
464 464
465 static void 465 static void
466 add_node(PurpleBlistNode *node, FinchBlist *ggblist) 466 add_node(PurpleBListNode *node, FinchBlist *ggblist)
467 { 467 {
468 if (purple_blist_node_get_ui_data(node)) 468 if (purple_blist_node_get_ui_data(node))
469 return; 469 return;
470 470
471 if (!ggblist->manager->can_add_node(node)) 471 if (!ggblist->manager->can_add_node(node))
481 add_chat((PurpleChat *)node, ggblist); 481 add_chat((PurpleChat *)node, ggblist);
482 482
483 draw_tooltip(ggblist); 483 draw_tooltip(ggblist);
484 } 484 }
485 485
486 void finch_blist_manager_add_node(PurpleBlistNode *node) 486 void finch_blist_manager_add_node(PurpleBListNode *node)
487 { 487 {
488 add_node(node, ggblist); 488 add_node(node, ggblist);
489 } 489 }
490 490
491 static void 491 static void
495 ggblist->tooltip = NULL; 495 ggblist->tooltip = NULL;
496 ggblist->tnode = NULL; 496 ggblist->tnode = NULL;
497 } 497 }
498 498
499 static void 499 static void
500 node_remove(PurpleBuddyList *list, PurpleBlistNode *node) 500 node_remove(PurpleBuddyList *list, PurpleBListNode *node)
501 { 501 {
502 FinchBlist *ggblist = FINCH_GET_DATA(list); 502 FinchBlist *ggblist = FINCH_GET_DATA(list);
503 PurpleBlistNode *parent; 503 PurpleBListNode *parent;
504 504
505 if (ggblist == NULL || purple_blist_node_get_ui_data(node) == NULL) 505 if (ggblist == NULL || purple_blist_node_get_ui_data(node) == NULL)
506 return; 506 return;
507 507
508 if (PURPLE_IS_GROUP(node) && ggblist->new_group) { 508 if (PURPLE_IS_GROUP(node) && ggblist->new_group) {
528 528
529 draw_tooltip(ggblist); 529 draw_tooltip(ggblist);
530 } 530 }
531 531
532 static void 532 static void
533 node_update(PurpleBuddyList *list, PurpleBlistNode *node) 533 node_update(PurpleBuddyList *list, PurpleBListNode *node)
534 { 534 {
535 /* It really looks like this should never happen ... but it does. 535 /* It really looks like this should never happen ... but it does.
536 This will at least emit a warning to the log when it 536 This will at least emit a warning to the log when it
537 happens, so maybe someone will figure it out. */ 537 happens, so maybe someone will figure it out. */
538 g_return_if_fail(node != NULL); 538 g_return_if_fail(node != NULL);
553 node_remove(list, node); 553 node_remove(list, node);
554 } 554 }
555 555
556 if (PURPLE_IS_BUDDY(node)) { 556 if (PURPLE_IS_BUDDY(node)) {
557 PurpleBuddy *buddy = (PurpleBuddy*)node; 557 PurpleBuddy *buddy = (PurpleBuddy*)node;
558 add_node((PurpleBlistNode*)buddy, FINCH_GET_DATA(list)); 558 add_node((PurpleBListNode*)buddy, FINCH_GET_DATA(list));
559 node_update(list, purple_blist_node_get_parent(node)); 559 node_update(list, purple_blist_node_get_parent(node));
560 } else if (PURPLE_IS_CHAT(node)) { 560 } else if (PURPLE_IS_CHAT(node)) {
561 add_node(node, FINCH_GET_DATA(list)); 561 add_node(node, FINCH_GET_DATA(list));
562 } else if (PURPLE_IS_CONTACT(node)) { 562 } else if (PURPLE_IS_CONTACT(node)) {
563 if (purple_blist_node_get_ui_data(node)== NULL) { 563 if (purple_blist_node_get_ui_data(node)== NULL) {
610 list = purple_get_blist(); 610 list = purple_get_blist();
611 g_return_val_if_fail(list, FALSE); 611 g_return_val_if_fail(list, FALSE);
612 612
613 ggblist->new_group_timeout = 0; 613 ggblist->new_group_timeout = 0;
614 while (ggblist->new_group) { 614 while (ggblist->new_group) {
615 PurpleBlistNode *group = ggblist->new_group->data; 615 PurpleBListNode *group = ggblist->new_group->data;
616 ggblist->new_group = g_list_delete_link(ggblist->new_group, ggblist->new_group); 616 ggblist->new_group = g_list_delete_link(ggblist->new_group, ggblist->new_group);
617 node_update(list, group); 617 node_update(list, group);
618 } 618 }
619 619
620 return FALSE; 620 return FALSE;
763 grp = purple_group_new(group); 763 grp = purple_group_new(group);
764 purple_blist_add_group(grp, NULL); 764 purple_blist_add_group(grp, NULL);
765 } 765 }
766 purple_blist_add_chat(chat, grp, NULL); 766 purple_blist_add_chat(chat, grp, NULL);
767 purple_blist_alias_chat(chat, alias); 767 purple_blist_alias_chat(chat, alias);
768 purple_blist_node_set_bool((PurpleBlistNode*)chat, "gnt-autojoin", autojoin); 768 purple_blist_node_set_bool((PurpleBListNode*)chat, "gnt-autojoin", autojoin);
769 if (autojoin) { 769 if (autojoin) {
770 join_chat(chat); 770 join_chat(chat);
771 } 771 }
772 } 772 }
773 } 773 }
836 ggblist->new_group_timeout = purple_timeout_add_seconds(SHOW_EMPTY_GROUP_TIMEOUT, 836 ggblist->new_group_timeout = purple_timeout_add_seconds(SHOW_EMPTY_GROUP_TIMEOUT,
837 remove_new_empty_group, NULL); 837 remove_new_empty_group, NULL);
838 838
839 /* Select the group */ 839 /* Select the group */
840 if (ggblist->tree) { 840 if (ggblist->tree) {
841 FinchBlistNode *fnode = purple_blist_node_get_ui_data((PurpleBlistNode*)grp); 841 FinchBlistNode *fnode = purple_blist_node_get_ui_data((PurpleBListNode*)grp);
842 if (!fnode) 842 if (!fnode)
843 add_node((PurpleBlistNode*)grp, ggblist); 843 add_node((PurpleBListNode*)grp, ggblist);
844 gnt_tree_set_selected(GNT_TREE(ggblist->tree), grp); 844 gnt_tree_set_selected(GNT_TREE(ggblist->tree), grp);
845 } 845 }
846 } 846 }
847 847
848 static void 848 static void
883 883
884 static void 884 static void
885 add_group(PurpleGroup *group, FinchBlist *ggblist) 885 add_group(PurpleGroup *group, FinchBlist *ggblist)
886 { 886 {
887 gpointer parent; 887 gpointer parent;
888 PurpleBlistNode *node = (PurpleBlistNode *)group; 888 PurpleBListNode *node = (PurpleBListNode *)group;
889 if (purple_blist_node_get_ui_data(node)) 889 if (purple_blist_node_get_ui_data(node))
890 return; 890 return;
891 parent = ggblist->manager->find_parent((PurpleBlistNode*)group); 891 parent = ggblist->manager->find_parent((PurpleBListNode*)group);
892 create_finch_blist_node(node, gnt_tree_add_row_after(GNT_TREE(ggblist->tree), group, 892 create_finch_blist_node(node, gnt_tree_add_row_after(GNT_TREE(ggblist->tree), group,
893 gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)), 893 gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)),
894 parent, NULL)); 894 parent, NULL));
895 gnt_tree_set_expanded(GNT_TREE(ggblist->tree), node, 895 gnt_tree_set_expanded(GNT_TREE(ggblist->tree), node,
896 !purple_blist_node_get_bool(node, "collapsed")); 896 !purple_blist_node_get_bool(node, "collapsed"));
897 } 897 }
898 898
899 static const char * 899 static const char *
900 get_display_name(PurpleBlistNode *node) 900 get_display_name(PurpleBListNode *node)
901 { 901 {
902 static char text[2096]; 902 static char text[2096];
903 char status[8] = " "; 903 char status[8] = " ";
904 const char *name = NULL; 904 const char *name = NULL;
905 905
956 956
957 static void 957 static void
958 add_chat(PurpleChat *chat, FinchBlist *ggblist) 958 add_chat(PurpleChat *chat, FinchBlist *ggblist)
959 { 959 {
960 gpointer parent; 960 gpointer parent;
961 PurpleBlistNode *node = (PurpleBlistNode *)chat; 961 PurpleBListNode *node = (PurpleBListNode *)chat;
962 if (purple_blist_node_get_ui_data(node)) 962 if (purple_blist_node_get_ui_data(node))
963 return; 963 return;
964 if (!purple_account_is_connected(purple_chat_get_account(chat))) 964 if (!purple_account_is_connected(purple_chat_get_account(chat)))
965 return; 965 return;
966 966
967 parent = ggblist->manager->find_parent((PurpleBlistNode*)chat); 967 parent = ggblist->manager->find_parent((PurpleBListNode*)chat);
968 968
969 create_finch_blist_node(node, gnt_tree_add_row_after(GNT_TREE(ggblist->tree), chat, 969 create_finch_blist_node(node, gnt_tree_add_row_after(GNT_TREE(ggblist->tree), chat,
970 gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)), 970 gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)),
971 parent, NULL)); 971 parent, NULL));
972 } 972 }
973 973
974 static void 974 static void
975 add_contact(PurpleContact *contact, FinchBlist *ggblist) 975 add_contact(PurpleContact *contact, FinchBlist *ggblist)
976 { 976 {
977 gpointer parent; 977 gpointer parent;
978 PurpleBlistNode *node = (PurpleBlistNode*)contact; 978 PurpleBListNode *node = (PurpleBListNode*)contact;
979 const char *name; 979 const char *name;
980 980
981 if (purple_blist_node_get_ui_data(node)) 981 if (purple_blist_node_get_ui_data(node))
982 return; 982 return;
983 983
984 name = get_display_name(node); 984 name = get_display_name(node);
985 if (name == NULL) 985 if (name == NULL)
986 return; 986 return;
987 987
988 parent = ggblist->manager->find_parent((PurpleBlistNode*)contact); 988 parent = ggblist->manager->find_parent((PurpleBListNode*)contact);
989 989
990 create_finch_blist_node(node, gnt_tree_add_row_after(GNT_TREE(ggblist->tree), contact, 990 create_finch_blist_node(node, gnt_tree_add_row_after(GNT_TREE(ggblist->tree), contact,
991 gnt_tree_create_row(GNT_TREE(ggblist->tree), name), 991 gnt_tree_create_row(GNT_TREE(ggblist->tree), name),
992 parent, NULL)); 992 parent, NULL));
993 993
996 996
997 static void 997 static void
998 add_buddy(PurpleBuddy *buddy, FinchBlist *ggblist) 998 add_buddy(PurpleBuddy *buddy, FinchBlist *ggblist)
999 { 999 {
1000 gpointer parent; 1000 gpointer parent;
1001 PurpleBlistNode *node = (PurpleBlistNode *)buddy; 1001 PurpleBListNode *node = (PurpleBListNode *)buddy;
1002 PurpleContact *contact; 1002 PurpleContact *contact;
1003 1003
1004 if (purple_blist_node_get_ui_data(node)) 1004 if (purple_blist_node_get_ui_data(node))
1005 return; 1005 return;
1006 1006
1007 contact = purple_buddy_get_contact(buddy); 1007 contact = purple_buddy_get_contact(buddy);
1008 parent = ggblist->manager->find_parent((PurpleBlistNode*)buddy); 1008 parent = ggblist->manager->find_parent((PurpleBListNode*)buddy);
1009 1009
1010 create_finch_blist_node(node, gnt_tree_add_row_after(GNT_TREE(ggblist->tree), buddy, 1010 create_finch_blist_node(node, gnt_tree_add_row_after(GNT_TREE(ggblist->tree), buddy,
1011 gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)), 1011 gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)),
1012 parent, NULL)); 1012 parent, NULL));
1013 1013
1014 blist_update_row_flags((PurpleBlistNode*)buddy); 1014 blist_update_row_flags((PurpleBListNode*)buddy);
1015 if (buddy == purple_contact_get_priority_buddy(contact)) 1015 if (buddy == purple_contact_get_priority_buddy(contact))
1016 blist_update_row_flags((PurpleBlistNode*)contact); 1016 blist_update_row_flags((PurpleBListNode*)contact);
1017 } 1017 }
1018 1018
1019 #if 0 1019 #if 0
1020 static void 1020 static void
1021 buddy_signed_on(PurpleBuddy *buddy, FinchBlist *ggblist) 1021 buddy_signed_on(PurpleBuddy *buddy, FinchBlist *ggblist)
1022 { 1022 {
1023 add_node((PurpleBlistNode*)buddy, ggblist); 1023 add_node((PurpleBListNode*)buddy, ggblist);
1024 } 1024 }
1025 1025
1026 static void 1026 static void
1027 buddy_signed_off(PurpleBuddy *buddy, FinchBlist *ggblist) 1027 buddy_signed_off(PurpleBuddy *buddy, FinchBlist *ggblist)
1028 { 1028 {
1029 node_remove(purple_get_blist(), (PurpleBlistNode*)buddy); 1029 node_remove(purple_get_blist(), (PurpleBListNode*)buddy);
1030 } 1030 }
1031 #endif 1031 #endif
1032 1032
1033 PurpleBlistUiOps *finch_blist_get_ui_ops() 1033 PurpleBlistUiOps *finch_blist_get_ui_ops()
1034 { 1034 {
1037 1037
1038 static void 1038 static void
1039 selection_activate(GntWidget *widget, FinchBlist *ggblist) 1039 selection_activate(GntWidget *widget, FinchBlist *ggblist)
1040 { 1040 {
1041 GntTree *tree = GNT_TREE(ggblist->tree); 1041 GntTree *tree = GNT_TREE(ggblist->tree);
1042 PurpleBlistNode *node = gnt_tree_get_selection_data(tree); 1042 PurpleBListNode *node = gnt_tree_get_selection_data(tree);
1043 1043
1044 if (!node) 1044 if (!node)
1045 return; 1045 return;
1046 1046
1047 if (PURPLE_IS_CONTACT(node)) 1047 if (PURPLE_IS_CONTACT(node))
1067 join_chat((PurpleChat*)node); 1067 join_chat((PurpleChat*)node);
1068 } 1068 }
1069 } 1069 }
1070 1070
1071 static void 1071 static void
1072 append_proto_menu(GntMenu *menu, PurpleConnection *gc, PurpleBlistNode *node) 1072 append_proto_menu(GntMenu *menu, PurpleConnection *gc, PurpleBListNode *node)
1073 { 1073 {
1074 GList *list; 1074 GList *list;
1075 PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc)); 1075 PurplePluginProtocolInfo *prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc));
1076 1076
1077 if(!prpl_info || !prpl_info->blist_node_menu) 1077 if(!prpl_info || !prpl_info->blist_node_menu)
1122 } 1122 }
1123 } 1123 }
1124 } 1124 }
1125 1125
1126 static void 1126 static void
1127 chat_components_edit(PurpleBlistNode *selected, PurpleChat *chat) 1127 chat_components_edit(PurpleBListNode *selected, PurpleChat *chat)
1128 { 1128 {
1129 PurpleRequestFields *fields = purple_request_fields_new(); 1129 PurpleRequestFields *fields = purple_request_fields_new();
1130 PurpleRequestFieldGroup *group = purple_request_field_group_new(NULL); 1130 PurpleRequestFieldGroup *group = purple_request_field_group_new(NULL);
1131 PurpleRequestField *field; 1131 PurpleRequestField *field;
1132 GList *parts, *iter; 1132 GList *parts, *iter;
1181 { 1181 {
1182 PurpleMenuAction *action = purple_menu_action_new(_("Auto-join"), NULL, chat, NULL); 1182 PurpleMenuAction *action = purple_menu_action_new(_("Auto-join"), NULL, chat, NULL);
1183 GntMenuItem *check = gnt_menuitem_check_new( 1183 GntMenuItem *check = gnt_menuitem_check_new(
1184 purple_menu_action_get_label(action)); 1184 purple_menu_action_get_label(action));
1185 gnt_menuitem_check_set_checked(GNT_MENU_ITEM_CHECK(check), 1185 gnt_menuitem_check_set_checked(GNT_MENU_ITEM_CHECK(check),
1186 purple_blist_node_get_bool((PurpleBlistNode*)chat, "gnt-autojoin")); 1186 purple_blist_node_get_bool((PurpleBListNode*)chat, "gnt-autojoin"));
1187 gnt_menu_add_item(menu, check); 1187 gnt_menu_add_item(menu, check);
1188 gnt_menuitem_set_callback(check, autojoin_toggled, action); 1188 gnt_menuitem_set_callback(check, autojoin_toggled, action);
1189 g_signal_connect_swapped(G_OBJECT(menu), "destroy", 1189 g_signal_connect_swapped(G_OBJECT(menu), "destroy",
1190 G_CALLBACK(purple_menu_action_free), action); 1190 G_CALLBACK(purple_menu_action_free), action);
1191 1191
1192 add_custom_action(menu, _("Edit Settings"), (PurpleCallback)chat_components_edit, chat); 1192 add_custom_action(menu, _("Edit Settings"), (PurpleCallback)chat_components_edit, chat);
1193 } 1193 }
1194 1194
1195 static void 1195 static void
1196 finch_add_buddy(PurpleBlistNode *selected, PurpleGroup *grp) 1196 finch_add_buddy(PurpleBListNode *selected, PurpleGroup *grp)
1197 { 1197 {
1198 purple_blist_request_add_buddy(NULL, NULL, grp ? purple_group_get_name(grp) : NULL, NULL); 1198 purple_blist_request_add_buddy(NULL, NULL, grp ? purple_group_get_name(grp) : NULL, NULL);
1199 } 1199 }
1200 1200
1201 static void 1201 static void
1202 finch_add_group(PurpleBlistNode *selected, PurpleGroup *grp) 1202 finch_add_group(PurpleBListNode *selected, PurpleGroup *grp)
1203 { 1203 {
1204 purple_blist_request_add_group(); 1204 purple_blist_request_add_group();
1205 } 1205 }
1206 1206
1207 static void 1207 static void
1208 finch_add_chat(PurpleBlistNode *selected, PurpleGroup *grp) 1208 finch_add_chat(PurpleBListNode *selected, PurpleGroup *grp)
1209 { 1209 {
1210 purple_blist_request_add_chat(NULL, grp, NULL, NULL); 1210 purple_blist_request_add_chat(NULL, grp, NULL, NULL);
1211 } 1211 }
1212 1212
1213 static void 1213 static void
1232 serv_get_info(conn, name); 1232 serv_get_info(conn, name);
1233 return uihandle; 1233 return uihandle;
1234 } 1234 }
1235 1235
1236 static void 1236 static void
1237 finch_blist_get_buddy_info_cb(PurpleBlistNode *selected, PurpleBuddy *buddy) 1237 finch_blist_get_buddy_info_cb(PurpleBListNode *selected, PurpleBuddy *buddy)
1238 { 1238 {
1239 finch_retrieve_user_info(purple_account_get_connection(purple_buddy_get_account(buddy)), purple_buddy_get_name(buddy)); 1239 finch_retrieve_user_info(purple_account_get_connection(purple_buddy_get_account(buddy)), purple_buddy_get_name(buddy));
1240 } 1240 }
1241 1241
1242 static void 1242 static void
1243 finch_blist_menu_send_file_cb(PurpleBlistNode *selected, PurpleBuddy *buddy) 1243 finch_blist_menu_send_file_cb(PurpleBListNode *selected, PurpleBuddy *buddy)
1244 { 1244 {
1245 serv_send_file(purple_account_get_connection(purple_buddy_get_account(buddy)), purple_buddy_get_name(buddy), NULL); 1245 serv_send_file(purple_account_get_connection(purple_buddy_get_account(buddy)), purple_buddy_get_name(buddy), NULL);
1246 } 1246 }
1247 1247
1248 static void 1248 static void
1249 finch_blist_pounce_node_cb(PurpleBlistNode *selected, PurpleBlistNode *node) 1249 finch_blist_pounce_node_cb(PurpleBListNode *selected, PurpleBListNode *node)
1250 { 1250 {
1251 PurpleBuddy *b; 1251 PurpleBuddy *b;
1252 if (PURPLE_IS_CONTACT(node)) 1252 if (PURPLE_IS_CONTACT(node))
1253 b = purple_contact_get_priority_buddy((PurpleContact *)node); 1253 b = purple_contact_get_priority_buddy((PurpleContact *)node);
1254 else 1254 else
1312 gnt_menuitem_check_set_checked(GNT_MENU_ITEM_CHECK(item), !permitted); 1312 gnt_menuitem_check_set_checked(GNT_MENU_ITEM_CHECK(item), !permitted);
1313 gnt_menuitem_set_callback(item, toggle_block_buddy, buddy); 1313 gnt_menuitem_set_callback(item, toggle_block_buddy, buddy);
1314 gnt_menu_add_item(menu, item); 1314 gnt_menu_add_item(menu, item);
1315 1315
1316 item = gnt_menuitem_check_new(_("Show when offline")); 1316 item = gnt_menuitem_check_new(_("Show when offline"));
1317 gnt_menuitem_check_set_checked(GNT_MENU_ITEM_CHECK(item), purple_blist_node_get_bool((PurpleBlistNode*)buddy, "show_offline")); 1317 gnt_menuitem_check_set_checked(GNT_MENU_ITEM_CHECK(item), purple_blist_node_get_bool((PurpleBListNode*)buddy, "show_offline"));
1318 gnt_menuitem_set_callback(item, toggle_show_offline, buddy); 1318 gnt_menuitem_set_callback(item, toggle_show_offline, buddy);
1319 gnt_menu_add_item(menu, item); 1319 gnt_menu_add_item(menu, item);
1320 1320
1321 /* Protocol actions */ 1321 /* Protocol actions */
1322 append_proto_menu(menu, 1322 append_proto_menu(menu,
1323 purple_account_get_connection(purple_buddy_get_account(buddy)), 1323 purple_account_get_connection(purple_buddy_get_account(buddy)),
1324 (PurpleBlistNode*)buddy); 1324 (PurpleBListNode*)buddy);
1325 } 1325 }
1326 1326
1327 static void 1327 static void
1328 append_extended_menu(GntMenu *menu, PurpleBlistNode *node) 1328 append_extended_menu(GntMenu *menu, PurpleBListNode *node)
1329 { 1329 {
1330 GList *iter; 1330 GList *iter;
1331 1331
1332 for (iter = purple_blist_node_get_extended_menu(node); 1332 for (iter = purple_blist_node_get_extended_menu(node);
1333 iter; iter = g_list_delete_link(iter, iter)) 1333 iter; iter = g_list_delete_link(iter, iter))
1338 1338
1339 /* Xerox'd from gtkdialogs.c:purple_gtkdialogs_remove_contact_cb */ 1339 /* Xerox'd from gtkdialogs.c:purple_gtkdialogs_remove_contact_cb */
1340 static void 1340 static void
1341 remove_contact(PurpleContact *contact) 1341 remove_contact(PurpleContact *contact)
1342 { 1342 {
1343 PurpleBlistNode *bnode, *cnode; 1343 PurpleBListNode *bnode, *cnode;
1344 PurpleGroup *group; 1344 PurpleGroup *group;
1345 1345
1346 cnode = (PurpleBlistNode *)contact; 1346 cnode = (PurpleBListNode *)contact;
1347 group = (PurpleGroup*)purple_blist_node_get_parent(cnode); 1347 group = (PurpleGroup*)purple_blist_node_get_parent(cnode);
1348 for (bnode = purple_blist_node_get_first_child(cnode); bnode; bnode = purple_blist_node_get_sibling_next(bnode)) { 1348 for (bnode = purple_blist_node_get_first_child(cnode); bnode; bnode = purple_blist_node_get_sibling_next(bnode)) {
1349 PurpleBuddy *buddy = (PurpleBuddy*)bnode; 1349 PurpleBuddy *buddy = (PurpleBuddy*)bnode;
1350 PurpleAccount *account = purple_buddy_get_account(buddy); 1350 PurpleAccount *account = purple_buddy_get_account(buddy);
1351 if (purple_account_is_connected(account)) 1351 if (purple_account_is_connected(account))
1353 } 1353 }
1354 purple_blist_remove_contact(contact); 1354 purple_blist_remove_contact(contact);
1355 } 1355 }
1356 1356
1357 static void 1357 static void
1358 rename_blist_node(PurpleBlistNode *node, const char *newname) 1358 rename_blist_node(PurpleBListNode *node, const char *newname)
1359 { 1359 {
1360 const char *name = newname; 1360 const char *name = newname;
1361 if (name && !*name) 1361 if (name && !*name)
1362 name = NULL; 1362 name = NULL;
1363 1363
1377 else 1377 else
1378 g_return_if_reached(); 1378 g_return_if_reached();
1379 } 1379 }
1380 1380
1381 static void 1381 static void
1382 finch_blist_rename_node_cb(PurpleBlistNode *selected, PurpleBlistNode *node) 1382 finch_blist_rename_node_cb(PurpleBListNode *selected, PurpleBListNode *node)
1383 { 1383 {
1384 const char *name = NULL; 1384 const char *name = NULL;
1385 char *prompt; 1385 char *prompt;
1386 const char *text; 1386 const char *text;
1387 1387
1407 1407
1408 g_free(prompt); 1408 g_free(prompt);
1409 } 1409 }
1410 1410
1411 1411
1412 static void showlog_cb(PurpleBlistNode *sel, PurpleBlistNode *node) 1412 static void showlog_cb(PurpleBListNode *sel, PurpleBListNode *node)
1413 { 1413 {
1414 PurpleLogType type; 1414 PurpleLogType type;
1415 PurpleAccount *account; 1415 PurpleAccount *account;
1416 char *name = NULL; 1416 char *name = NULL;
1417 1417
1447 1447
1448 /* Xeroxed from gtkdialogs.c:purple_gtkdialogs_remove_group_cb*/ 1448 /* Xeroxed from gtkdialogs.c:purple_gtkdialogs_remove_group_cb*/
1449 static void 1449 static void
1450 remove_group(PurpleGroup *group) 1450 remove_group(PurpleGroup *group)
1451 { 1451 {
1452 PurpleBlistNode *cnode, *bnode; 1452 PurpleBListNode *cnode, *bnode;
1453 1453
1454 cnode = purple_blist_node_get_first_child(((PurpleBlistNode*)group)); 1454 cnode = purple_blist_node_get_first_child(((PurpleBListNode*)group));
1455 1455
1456 while (cnode) { 1456 while (cnode) {
1457 if (PURPLE_IS_CONTACT(cnode)) { 1457 if (PURPLE_IS_CONTACT(cnode)) {
1458 bnode = purple_blist_node_get_first_child(cnode); 1458 bnode = purple_blist_node_get_first_child(cnode);
1459 cnode = purple_blist_node_get_sibling_next(cnode); 1459 cnode = purple_blist_node_get_sibling_next(cnode);
1484 1484
1485 purple_blist_remove_group(group); 1485 purple_blist_remove_group(group);
1486 } 1486 }
1487 1487
1488 static void 1488 static void
1489 finch_blist_remove_node(PurpleBlistNode *node) 1489 finch_blist_remove_node(PurpleBListNode *node)
1490 { 1490 {
1491 if (PURPLE_IS_CONTACT(node)) { 1491 if (PURPLE_IS_CONTACT(node)) {
1492 remove_contact((PurpleContact*)node); 1492 remove_contact((PurpleContact*)node);
1493 } else if (PURPLE_IS_BUDDY(node)) { 1493 } else if (PURPLE_IS_BUDDY(node)) {
1494 PurpleBuddy *buddy = (PurpleBuddy*)node; 1494 PurpleBuddy *buddy = (PurpleBuddy*)node;
1501 remove_group((PurpleGroup*)node); 1501 remove_group((PurpleGroup*)node);
1502 } 1502 }
1503 } 1503 }
1504 1504
1505 static void 1505 static void
1506 finch_blist_remove_node_cb(PurpleBlistNode *selected, PurpleBlistNode *node) 1506 finch_blist_remove_node_cb(PurpleBListNode *selected, PurpleBListNode *node)
1507 { 1507 {
1508 PurpleAccount *account = NULL; 1508 PurpleAccount *account = NULL;
1509 char *primary; 1509 char *primary;
1510 const char *name, *sec = NULL; 1510 const char *name, *sec = NULL;
1511 1511
1538 _("Cancel"), NULL); 1538 _("Cancel"), NULL);
1539 g_free(primary); 1539 g_free(primary);
1540 } 1540 }
1541 1541
1542 static void 1542 static void
1543 finch_blist_toggle_tag_buddy(PurpleBlistNode *node) 1543 finch_blist_toggle_tag_buddy(PurpleBListNode *node)
1544 { 1544 {
1545 GList *iter; 1545 GList *iter;
1546 if (node == NULL) 1546 if (node == NULL)
1547 return; 1547 return;
1548 if (ggblist->tagged && (iter = g_list_find(ggblist->tagged, node)) != NULL) { 1548 if (ggblist->tagged && (iter = g_list_find(ggblist->tagged, node)) != NULL) {
1557 else 1557 else
1558 update_node_display(node, ggblist); 1558 update_node_display(node, ggblist);
1559 } 1559 }
1560 1560
1561 static void 1561 static void
1562 finch_blist_place_tagged(PurpleBlistNode *target) 1562 finch_blist_place_tagged(PurpleBListNode *target)
1563 { 1563 {
1564 PurpleGroup *tg = NULL; 1564 PurpleGroup *tg = NULL;
1565 PurpleContact *tc = NULL; 1565 PurpleContact *tc = NULL;
1566 1566
1567 if (target == NULL || 1567 if (target == NULL ||
1570 1570
1571 if (PURPLE_IS_GROUP(target)) 1571 if (PURPLE_IS_GROUP(target))
1572 tg = (PurpleGroup*)target; 1572 tg = (PurpleGroup*)target;
1573 else if (PURPLE_IS_BUDDY(target)) { 1573 else if (PURPLE_IS_BUDDY(target)) {
1574 tc = (PurpleContact*)purple_blist_node_get_parent(target); 1574 tc = (PurpleContact*)purple_blist_node_get_parent(target);
1575 tg = (PurpleGroup*)purple_blist_node_get_parent((PurpleBlistNode*)tc); 1575 tg = (PurpleGroup*)purple_blist_node_get_parent((PurpleBListNode*)tc);
1576 } else { 1576 } else {
1577 if (PURPLE_IS_CONTACT(target)) 1577 if (PURPLE_IS_CONTACT(target))
1578 tc = (PurpleContact*)target; 1578 tc = (PurpleContact*)target;
1579 tg = (PurpleGroup*)purple_blist_node_get_parent(target); 1579 tg = (PurpleGroup*)purple_blist_node_get_parent(target);
1580 } 1580 }
1581 1581
1582 if (ggblist->tagged) { 1582 if (ggblist->tagged) {
1583 GList *list = ggblist->tagged; 1583 GList *list = ggblist->tagged;
1584 ggblist->tagged = NULL; 1584 ggblist->tagged = NULL;
1585 while (list) { 1585 while (list) {
1586 PurpleBlistNode *node = list->data; 1586 PurpleBListNode *node = list->data;
1587 list = g_list_delete_link(list, list); 1587 list = g_list_delete_link(list, list);
1588 1588
1589 if (PURPLE_IS_GROUP(node)) { 1589 if (PURPLE_IS_GROUP(node)) {
1590 update_node_display(node, ggblist); 1590 update_node_display(node, ggblist);
1591 /* Add the group after the current group */ 1591 /* Add the group after the current group */
1592 purple_blist_add_group((PurpleGroup*)node, (PurpleBlistNode*)tg); 1592 purple_blist_add_group((PurpleGroup*)node, (PurpleBListNode*)tg);
1593 } else if (PURPLE_IS_CONTACT(node)) { 1593 } else if (PURPLE_IS_CONTACT(node)) {
1594 update_buddy_display(purple_contact_get_priority_buddy((PurpleContact*)node), ggblist); 1594 update_buddy_display(purple_contact_get_priority_buddy((PurpleContact*)node), ggblist);
1595 if (PURPLE_BLIST_NODE(tg) == target) { 1595 if (PURPLE_BLIST_NODE(tg) == target) {
1596 /* The target is a group, just add the contact to the group. */ 1596 /* The target is a group, just add the contact to the group. */
1597 purple_blist_add_contact((PurpleContact*)node, tg, NULL); 1597 purple_blist_add_contact((PurpleContact*)node, tg, NULL);
1598 } else if (tc) { 1598 } else if (tc) {
1599 /* The target is either a buddy, or a contact. Merge with that contact. */ 1599 /* The target is either a buddy, or a contact. Merge with that contact. */
1600 purple_blist_merge_contact((PurpleContact*)node, (PurpleBlistNode*)tc); 1600 purple_blist_merge_contact((PurpleContact*)node, (PurpleBListNode*)tc);
1601 } else { 1601 } else {
1602 /* The target is a chat. Add the contact to the group after this chat. */ 1602 /* The target is a chat. Add the contact to the group after this chat. */
1603 purple_blist_add_contact((PurpleContact*)node, NULL, target); 1603 purple_blist_add_contact((PurpleContact*)node, NULL, target);
1604 } 1604 }
1605 } else if (PURPLE_IS_BUDDY(node)) { 1605 } else if (PURPLE_IS_BUDDY(node)) {
1635 } 1635 }
1636 1636
1637 static void 1637 static void
1638 draw_context_menu(FinchBlist *ggblist) 1638 draw_context_menu(FinchBlist *ggblist)
1639 { 1639 {
1640 PurpleBlistNode *node = NULL; 1640 PurpleBListNode *node = NULL;
1641 GntWidget *context = NULL; 1641 GntWidget *context = NULL;
1642 GntTree *tree = NULL; 1642 GntTree *tree = NULL;
1643 int x, y, top, width; 1643 int x, y, top, width;
1644 char *title = NULL; 1644 char *title = NULL;
1645 1645
1791 } 1791 }
1792 1792
1793 static gboolean 1793 static gboolean
1794 draw_tooltip_real(FinchBlist *ggblist) 1794 draw_tooltip_real(FinchBlist *ggblist)
1795 { 1795 {
1796 PurpleBlistNode *node; 1796 PurpleBListNode *node;
1797 int x, y, top, width, w, h; 1797 int x, y, top, width, w, h;
1798 GString *str = NULL; 1798 GString *str = NULL;
1799 GntTree *tree; 1799 GntTree *tree;
1800 GntWidget *widget, *box, *tv; 1800 GntWidget *widget, *box, *tv;
1801 char *title = NULL; 1801 char *title = NULL;
1894 /* Escape was pressed */ 1894 /* Escape was pressed */
1895 if (gnt_tree_is_searching(GNT_TREE(ggblist->tree))) 1895 if (gnt_tree_is_searching(GNT_TREE(ggblist->tree)))
1896 gnt_bindable_perform_action_named(GNT_BINDABLE(ggblist->tree), "end-search", NULL); 1896 gnt_bindable_perform_action_named(GNT_BINDABLE(ggblist->tree), "end-search", NULL);
1897 remove_peripherals(ggblist); 1897 remove_peripherals(ggblist);
1898 } else if (strcmp(text, GNT_KEY_INS) == 0) { 1898 } else if (strcmp(text, GNT_KEY_INS) == 0) {
1899 PurpleBlistNode *node = gnt_tree_get_selection_data(GNT_TREE(ggblist->tree)); 1899 PurpleBListNode *node = gnt_tree_get_selection_data(GNT_TREE(ggblist->tree));
1900 purple_blist_request_add_buddy(NULL, NULL, 1900 purple_blist_request_add_buddy(NULL, NULL,
1901 node && PURPLE_IS_GROUP(node) ? purple_group_get_name(PURPLE_GROUP(node)) : NULL, 1901 node && PURPLE_IS_GROUP(node) ? purple_group_get_name(PURPLE_GROUP(node)) : NULL,
1902 NULL); 1902 NULL);
1903 } else if (!gnt_tree_is_searching(GNT_TREE(ggblist->tree))) { 1903 } else if (!gnt_tree_is_searching(GNT_TREE(ggblist->tree))) {
1904 if (strcmp(text, "t") == 0) { 1904 if (strcmp(text, "t") == 0) {
1913 1913
1914 return TRUE; 1914 return TRUE;
1915 } 1915 }
1916 1916
1917 static void 1917 static void
1918 update_node_display(PurpleBlistNode *node, FinchBlist *ggblist) 1918 update_node_display(PurpleBListNode *node, FinchBlist *ggblist)
1919 { 1919 {
1920 GntTextFormatFlags flag = get_blist_node_flag(node); 1920 GntTextFormatFlags flag = get_blist_node_flag(node);
1921 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), node, flag); 1921 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), node, flag);
1922 } 1922 }
1923 1923
1926 { 1926 {
1927 PurpleContact *contact; 1927 PurpleContact *contact;
1928 1928
1929 contact = purple_buddy_get_contact(buddy); 1929 contact = purple_buddy_get_contact(buddy);
1930 1930
1931 gnt_tree_change_text(GNT_TREE(ggblist->tree), buddy, 0, get_display_name((PurpleBlistNode*)buddy)); 1931 gnt_tree_change_text(GNT_TREE(ggblist->tree), buddy, 0, get_display_name((PurpleBListNode*)buddy));
1932 gnt_tree_change_text(GNT_TREE(ggblist->tree), contact, 0, get_display_name((PurpleBlistNode*)contact)); 1932 gnt_tree_change_text(GNT_TREE(ggblist->tree), contact, 0, get_display_name((PurpleBListNode*)contact));
1933 1933
1934 blist_update_row_flags((PurpleBlistNode *)buddy); 1934 blist_update_row_flags((PurpleBListNode *)buddy);
1935 if (buddy == purple_contact_get_priority_buddy(contact)) 1935 if (buddy == purple_contact_get_priority_buddy(contact))
1936 blist_update_row_flags((PurpleBlistNode *)contact); 1936 blist_update_row_flags((PurpleBListNode *)contact);
1937 1937
1938 if (ggblist->tnode == (PurpleBlistNode*)buddy) 1938 if (ggblist->tnode == (PurpleBListNode*)buddy)
1939 draw_tooltip(ggblist); 1939 draw_tooltip(ggblist);
1940 } 1940 }
1941 1941
1942 static void 1942 static void
1943 buddy_status_changed(PurpleBuddy *buddy, PurpleStatus *old, PurpleStatus *now, FinchBlist *ggblist) 1943 buddy_status_changed(PurpleBuddy *buddy, PurpleStatus *old, PurpleStatus *now, FinchBlist *ggblist)
1977 } 1977 }
1978 1978
1979 static void 1979 static void
1980 reset_blist_window(GntWidget *window, gpointer null) 1980 reset_blist_window(GntWidget *window, gpointer null)
1981 { 1981 {
1982 PurpleBlistNode *node; 1982 PurpleBListNode *node;
1983 purple_signals_disconnect_by_handle(finch_blist_get_handle()); 1983 purple_signals_disconnect_by_handle(finch_blist_get_handle());
1984 FINCH_SET_DATA(purple_get_blist(), NULL); 1984 FINCH_SET_DATA(purple_get_blist(), NULL);
1985 1985
1986 node = purple_blist_get_root(); 1986 node = purple_blist_get_root();
1987 while (node) { 1987 while (node) {
2005 } 2005 }
2006 2006
2007 static void 2007 static void
2008 populate_buddylist(void) 2008 populate_buddylist(void)
2009 { 2009 {
2010 PurpleBlistNode *node; 2010 PurpleBListNode *node;
2011 PurpleBuddyList *list; 2011 PurpleBuddyList *list;
2012 2012
2013 if (ggblist->manager->init) 2013 if (ggblist->manager->init)
2014 ggblist->manager->init(); 2014 ggblist->manager->init();
2015 2015
2097 } 2097 }
2098 2098
2099 static void 2099 static void
2100 redraw_blist(const char *name, PurplePrefType type, gconstpointer val, gpointer data) 2100 redraw_blist(const char *name, PurplePrefType type, gconstpointer val, gpointer data)
2101 { 2101 {
2102 PurpleBlistNode *node, *sel; 2102 PurpleBListNode *node, *sel;
2103 FinchBlistManager *manager; 2103 FinchBlistManager *manager;
2104 2104
2105 if (ggblist == NULL) 2105 if (ggblist == NULL)
2106 return; 2106 return;
2107 2107
2338 g_signal_handlers_unblock_matched(ggblist->statustext, G_SIGNAL_MATCH_FUNC, 2338 g_signal_handlers_unblock_matched(ggblist->statustext, G_SIGNAL_MATCH_FUNC,
2339 0, 0, NULL, status_text_changed, NULL); 2339 0, 0, NULL, status_text_changed, NULL);
2340 } 2340 }
2341 2341
2342 static int 2342 static int
2343 blist_node_compare_position(PurpleBlistNode *n1, PurpleBlistNode *n2) 2343 blist_node_compare_position(PurpleBListNode *n1, PurpleBListNode *n2)
2344 { 2344 {
2345 while ((n1 = purple_blist_node_get_sibling_prev(n1)) != NULL) 2345 while ((n1 = purple_blist_node_get_sibling_prev(n1)) != NULL)
2346 if (n1 == n2) 2346 if (n1 == n2)
2347 return 1; 2347 return 1;
2348 return -1; 2348 return -1;
2349 } 2349 }
2350 2350
2351 static int 2351 static int
2352 blist_node_compare_text(PurpleBlistNode *n1, PurpleBlistNode *n2) 2352 blist_node_compare_text(PurpleBListNode *n1, PurpleBListNode *n2)
2353 { 2353 {
2354 const char *s1, *s2; 2354 const char *s1, *s2;
2355 char *us1, *us2; 2355 char *us1, *us2;
2356 int ret; 2356 int ret;
2357 2357
2384 2384
2385 return ret; 2385 return ret;
2386 } 2386 }
2387 2387
2388 static int 2388 static int
2389 blist_node_compare_status(PurpleBlistNode *n1, PurpleBlistNode *n2) 2389 blist_node_compare_status(PurpleBListNode *n1, PurpleBListNode *n2)
2390 { 2390 {
2391 int ret; 2391 int ret;
2392 2392
2393 if (purple_blist_node_get_type(n1) != purple_blist_node_get_type(n2)) 2393 if (purple_blist_node_get_type(n1) != purple_blist_node_get_type(n2))
2394 return blist_node_compare_position(n1, n2); 2394 return blist_node_compare_position(n1, n2);
2414 2414
2415 return ret; 2415 return ret;
2416 } 2416 }
2417 2417
2418 static int 2418 static int
2419 get_contact_log_size(PurpleBlistNode *c) 2419 get_contact_log_size(PurpleBListNode *c)
2420 { 2420 {
2421 int log = 0; 2421 int log = 0;
2422 PurpleBlistNode *node; 2422 PurpleBListNode *node;
2423 2423
2424 for (node = purple_blist_node_get_first_child(c); node; node = purple_blist_node_get_sibling_next(node)) { 2424 for (node = purple_blist_node_get_first_child(c); node; node = purple_blist_node_get_sibling_next(node)) {
2425 PurpleBuddy *b = (PurpleBuddy*)node; 2425 PurpleBuddy *b = (PurpleBuddy*)node;
2426 log += purple_log_get_total_size(PURPLE_LOG_IM, purple_buddy_get_name(b), 2426 log += purple_log_get_total_size(PURPLE_LOG_IM, purple_buddy_get_name(b),
2427 purple_buddy_get_account(b)); 2427 purple_buddy_get_account(b));
2429 2429
2430 return log; 2430 return log;
2431 } 2431 }
2432 2432
2433 static int 2433 static int
2434 blist_node_compare_log(PurpleBlistNode *n1, PurpleBlistNode *n2) 2434 blist_node_compare_log(PurpleBListNode *n1, PurpleBListNode *n2)
2435 { 2435 {
2436 int ret; 2436 int ret;
2437 PurpleBuddy *b1, *b2; 2437 PurpleBuddy *b1, *b2;
2438 2438
2439 if (purple_blist_node_get_type(n1) != purple_blist_node_get_type(n2)) 2439 if (purple_blist_node_get_type(n1) != purple_blist_node_get_type(n2))
2493 } 2493 }
2494 2494
2495 static gboolean 2495 static gboolean
2496 buddy_recent_signed_on_off(gpointer data) 2496 buddy_recent_signed_on_off(gpointer data)
2497 { 2497 {
2498 PurpleBlistNode *node = data; 2498 PurpleBListNode *node = data;
2499 FinchBlistNode *fnode = purple_blist_node_get_ui_data(node); 2499 FinchBlistNode *fnode = purple_blist_node_get_ui_data(node);
2500 2500
2501 purple_timeout_remove(fnode->signed_timer); 2501 purple_timeout_remove(fnode->signed_timer);
2502 fnode->signed_timer = 0; 2502 fnode->signed_timer = 0;
2503 2503
2513 } 2513 }
2514 2514
2515 static gboolean 2515 static gboolean
2516 buddy_signed_on_off_cb(gpointer data) 2516 buddy_signed_on_off_cb(gpointer data)
2517 { 2517 {
2518 PurpleBlistNode *node = data; 2518 PurpleBListNode *node = data;
2519 FinchBlistNode *fnode = purple_blist_node_get_ui_data(node); 2519 FinchBlistNode *fnode = purple_blist_node_get_ui_data(node);
2520 if (!ggblist || !fnode) 2520 if (!ggblist || !fnode)
2521 return FALSE; 2521 return FALSE;
2522 2522
2523 if (fnode->signed_timer) 2523 if (fnode->signed_timer)
2627 } 2627 }
2628 2628
2629 static gboolean 2629 static gboolean
2630 auto_join_chats(gpointer data) 2630 auto_join_chats(gpointer data)
2631 { 2631 {
2632 PurpleBlistNode *node; 2632 PurpleBListNode *node;
2633 PurpleConnection *pc = data; 2633 PurpleConnection *pc = data;
2634 PurpleAccount *account = purple_connection_get_account(pc); 2634 PurpleAccount *account = purple_connection_get_account(pc);
2635 2635
2636 for (node = purple_blist_get_root(); node; 2636 for (node = purple_blist_get_root(); node;
2637 node = purple_blist_node_next(node, FALSE)) { 2637 node = purple_blist_node_next(node, FALSE)) {
3055 { 3055 {
3056 blist_show(purple_get_blist()); 3056 blist_show(purple_get_blist());
3057 } 3057 }
3058 3058
3059 static void 3059 static void
3060 group_collapsed(GntWidget *widget, PurpleBlistNode *node, gboolean collapsed, gpointer null) 3060 group_collapsed(GntWidget *widget, PurpleBListNode *node, gboolean collapsed, gpointer null)
3061 { 3061 {
3062 if (PURPLE_IS_GROUP(node)) 3062 if (PURPLE_IS_GROUP(node))
3063 purple_blist_node_set_bool(node, "collapsed", collapsed); 3063 purple_blist_node_set_bool(node, "collapsed", collapsed);
3064 } 3064 }
3065 3065

mercurial