comparison console/gntblist.c @ 14399:28baa42b5ac2

[gaim-migrate @ 17107] Add an option to 'Show offline buddies'. committer: Tailor Script <tailor@pidgin.im>
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Fri, 01 Sep 2006 07:09:40 +0000
parents 9e9699792bb9
children 8375ecb6152b
comparison
equal deleted inserted replaced
14398:2377498b4698 14399:28baa42b5ac2
107 return; 107 return;
108 108
109 gnt_tree_remove(GNT_TREE(ggblist->tree), node); 109 gnt_tree_remove(GNT_TREE(ggblist->tree), node);
110 node->ui_data = NULL; 110 node->ui_data = NULL;
111 111
112 if (GAIM_BLIST_NODE_IS_BUDDY(node)) 112 if (GAIM_BLIST_NODE_IS_BUDDY(node)) {
113 {
114 GaimContact *contact = (GaimContact*)node->parent; 113 GaimContact *contact = (GaimContact*)node->parent;
115 if (contact->online < 1) 114 if (contact->online < 1)
116 node_remove(list, (GaimBlistNode*)contact); 115 node_remove(list, (GaimBlistNode*)contact);
116 } else if (GAIM_BLIST_NODE_IS_CONTACT(node)) {
117 GaimGroup *group = (GaimGroup*)node->parent;
118 if ((!gaim_prefs_get_bool(PREF_ROOT "/showoffline") && group->online < 1) ||
119 group->currentsize < 1)
120 node_remove(list, node->parent);
117 } 121 }
118 draw_tooltip(ggblist); 122 draw_tooltip(ggblist);
119 } 123 }
120 124
121 static void 125 static void
134 0, get_display_name(node)); 138 0, get_display_name(node));
135 } 139 }
136 140
137 if (GAIM_BLIST_NODE_IS_BUDDY(node)) { 141 if (GAIM_BLIST_NODE_IS_BUDDY(node)) {
138 GaimBuddy *buddy = (GaimBuddy*)node; 142 GaimBuddy *buddy = (GaimBuddy*)node;
139 if (gaim_presence_is_online(gaim_buddy_get_presence(buddy))) 143 if (gaim_account_is_connected(buddy->account) &&
144 (GAIM_BUDDY_IS_ONLINE(buddy) || gaim_prefs_get_bool(PREF_ROOT "/showoffline")))
140 add_node((GaimBlistNode*)buddy, list->ui_data); 145 add_node((GaimBlistNode*)buddy, list->ui_data);
141 else 146 else
142 node_remove(gaim_get_blist(), node); 147 node_remove(gaim_get_blist(), node);
143 148
144 node_update(list, node->parent); 149 node_update(list, node->parent);
341 add_group(GaimGroup *group, GGBlist *ggblist) 346 add_group(GaimGroup *group, GGBlist *ggblist)
342 { 347 {
343 GaimBlistNode *node = (GaimBlistNode *)group; 348 GaimBlistNode *node = (GaimBlistNode *)group;
344 if (node->ui_data) 349 if (node->ui_data)
345 return; 350 return;
346 gnt_tree_remove(GNT_TREE(ggblist->tree), group);
347 node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), group, 351 node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), group,
348 gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)), NULL, NULL); 352 gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)), NULL, NULL);
349 } 353 }
350 354
351 static const char * 355 static const char *
414 return; 418 return;
415 419
416 group = gaim_chat_get_group(chat); 420 group = gaim_chat_get_group(chat);
417 add_node((GaimBlistNode*)group, ggblist); 421 add_node((GaimBlistNode*)group, ggblist);
418 422
419 gnt_tree_remove(GNT_TREE(ggblist->tree), chat);
420 node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), chat, 423 node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), chat,
421 gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)), 424 gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)),
422 group, NULL); 425 group, NULL);
423 426
424 if (gaim_blist_node_get_bool((GaimBlistNode*)chat, "gnt-autojoin")) 427 if (gaim_blist_node_get_bool((GaimBlistNode*)chat, "gnt-autojoin"))
428 static void 431 static void
429 add_contact(GaimContact *contact, GGBlist *ggblist) 432 add_contact(GaimContact *contact, GGBlist *ggblist)
430 { 433 {
431 GaimGroup *group; 434 GaimGroup *group;
432 GaimBlistNode *node = (GaimBlistNode*)contact; 435 GaimBlistNode *node = (GaimBlistNode*)contact;
436 const char *name;
433 437
434 if (node->ui_data) 438 if (node->ui_data)
439 return;
440
441 name = get_display_name(node);
442 if (name == NULL)
435 return; 443 return;
436 444
437 group = (GaimGroup*)node->parent; 445 group = (GaimGroup*)node->parent;
438 add_node((GaimBlistNode*)group, ggblist); 446 add_node((GaimBlistNode*)group, ggblist);
439 447
440 node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), contact, 448 node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), contact,
441 gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)), 449 gnt_tree_create_row(GNT_TREE(ggblist->tree), name),
442 group, NULL); 450 group, NULL);
443 451
444 gnt_tree_set_expanded(GNT_TREE(ggblist->tree), contact, FALSE); 452 gnt_tree_set_expanded(GNT_TREE(ggblist->tree), contact, FALSE);
445 } 453 }
446 454
453 return; 461 return;
454 462
455 contact = (GaimContact*)node->parent; 463 contact = (GaimContact*)node->parent;
456 add_node((GaimBlistNode*)contact, ggblist); 464 add_node((GaimBlistNode*)contact, ggblist);
457 465
458 gnt_tree_remove(GNT_TREE(ggblist->tree), buddy);
459 node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), buddy, 466 node->ui_data = gnt_tree_add_row_after(GNT_TREE(ggblist->tree), buddy,
460 gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)), 467 gnt_tree_create_row(GNT_TREE(ggblist->tree), get_display_name(node)),
461 contact, NULL); 468 contact, NULL);
462 if (gaim_presence_is_idle(gaim_buddy_get_presence(buddy))) { 469 if (gaim_presence_is_idle(gaim_buddy_get_presence(buddy))) {
463 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), buddy, GNT_TEXT_FLAG_DIM); 470 gnt_tree_set_row_flags(GNT_TREE(ggblist->tree), buddy, GNT_TEXT_FLAG_DIM);
1193 GaimBlistNode *node; 1200 GaimBlistNode *node;
1194 gaim_signals_disconnect_by_handle(gg_blist_get_handle()); 1201 gaim_signals_disconnect_by_handle(gg_blist_get_handle());
1195 gaim_get_blist()->ui_data = NULL; 1202 gaim_get_blist()->ui_data = NULL;
1196 1203
1197 node = gaim_blist_get_root(); 1204 node = gaim_blist_get_root();
1198 while (node) 1205 while (node) {
1199 {
1200 node->ui_data = NULL; 1206 node->ui_data = NULL;
1201 node = gaim_blist_node_next(node, TRUE); 1207 node = gaim_blist_node_next(node, TRUE);
1202 } 1208 }
1203 1209
1204 if (ggblist->typing) 1210 if (ggblist->typing)
1280 /* The keys for the combobox are created here, and never used 1286 /* The keys for the combobox are created here, and never used
1281 * anywhere else. So make sure the keys are freed when the widget 1287 * anywhere else. So make sure the keys are freed when the widget
1282 * is destroyed. */ 1288 * is destroyed. */
1283 g_object_set_data_full(G_OBJECT(ggblist->status), "list of statuses", 1289 g_object_set_data_full(G_OBJECT(ggblist->status), "list of statuses",
1284 items, (GDestroyNotify)destroy_status_list); 1290 items, (GDestroyNotify)destroy_status_list);
1291 }
1292
1293 static void
1294 redraw_blist(const char *name, GaimPrefType type, gconstpointer val, gpointer data)
1295 {
1296 GaimBlistNode *node;
1297 if (ggblist == NULL)
1298 return;
1299
1300 gnt_tree_remove_all(GNT_TREE(ggblist->tree));
1301 node = gaim_blist_get_root();
1302 for (; node; node = gaim_blist_node_next(node, TRUE))
1303 node->ui_data = NULL;
1304 populate_buddylist();
1285 } 1305 }
1286 1306
1287 void gg_blist_init() 1307 void gg_blist_init()
1288 { 1308 {
1289 gaim_prefs_add_none(PREF_ROOT); 1309 gaim_prefs_add_none(PREF_ROOT);
1291 gaim_prefs_add_int(PREF_ROOT "/size/width", 20); 1311 gaim_prefs_add_int(PREF_ROOT "/size/width", 20);
1292 gaim_prefs_add_int(PREF_ROOT "/size/height", 17); 1312 gaim_prefs_add_int(PREF_ROOT "/size/height", 17);
1293 gaim_prefs_add_none(PREF_ROOT "/position"); 1313 gaim_prefs_add_none(PREF_ROOT "/position");
1294 gaim_prefs_add_int(PREF_ROOT "/position/x", 0); 1314 gaim_prefs_add_int(PREF_ROOT "/position/x", 0);
1295 gaim_prefs_add_int(PREF_ROOT "/position/y", 0); 1315 gaim_prefs_add_int(PREF_ROOT "/position/y", 0);
1316 gaim_prefs_add_bool(PREF_ROOT "/idletime", TRUE);
1317 gaim_prefs_add_bool(PREF_ROOT "/showoffline", FALSE);
1296 1318
1297 gg_blist_show(); 1319 gg_blist_show();
1320
1321 gaim_prefs_connect_callback(gg_blist_get_handle(),
1322 PREF_ROOT "/showoffline", redraw_blist, NULL);
1298 1323
1299 return; 1324 return;
1300 } 1325 }
1301 1326
1302 static gboolean 1327 static gboolean