Mercurial > pidgin
comparison src/buddy.c @ 5000:17f5e6628b37
[gaim-migrate @ 5335]
javabsp wrote a patch to optionally show empty groups again. I cleaned it
up a bit, and fixed all the trouble people have been having with buddies not
showing up when showing offline buddies, and other assorted weirdness
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Fri, 04 Apr 2003 22:19:29 +0000 |
parents | abe9720a0615 |
children | f78b24df83d5 |
comparison
equal
deleted
inserted
replaced
4999:abe9720a0615 | 5000:17f5e6628b37 |
---|---|
375 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv)); | 375 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tv)); |
376 gtk_tree_selection_select_path(sel, path); | 376 gtk_tree_selection_select_path(sel, path); |
377 gtk_tree_path_free(path); | 377 gtk_tree_path_free(path); |
378 return TRUE; | 378 return TRUE; |
379 #endif | 379 #endif |
380 } | |
381 | |
382 static void gaim_gtk_blist_show_empty_groups_cb(gpointer data, guint action, GtkWidget *item) | |
383 { | |
384 if(gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item))) | |
385 blist_options &= ~OPT_BLIST_NO_MT_GRP; | |
386 else | |
387 blist_options |= OPT_BLIST_NO_MT_GRP; | |
388 save_prefs(); | |
389 gaim_gtk_blist_refresh(gaim_get_blist()); | |
380 } | 390 } |
381 | 391 |
382 static void gaim_gtk_blist_edit_mode_cb(gpointer callback_data, guint callback_action, | 392 static void gaim_gtk_blist_edit_mode_cb(gpointer callback_data, guint callback_action, |
383 GtkWidget *checkitem) { | 393 GtkWidget *checkitem) { |
384 GdkCursor *cursor = gdk_cursor_new(GDK_WATCH); | 394 GdkCursor *cursor = gdk_cursor_new(GDK_WATCH); |
643 { "/Buddies/sep1", NULL, NULL, 0, "<Separator>" }, | 653 { "/Buddies/sep1", NULL, NULL, 0, "<Separator>" }, |
644 { N_("/Buddies/Get _User Info..."), "<CTL>J", show_info_dialog, 0, | 654 { N_("/Buddies/Get _User Info..."), "<CTL>J", show_info_dialog, 0, |
645 "<StockItem>", GAIM_STOCK_INFO }, | 655 "<StockItem>", GAIM_STOCK_INFO }, |
646 { "/Buddies/sep2", NULL, NULL, 0, "<Separator>" }, | 656 { "/Buddies/sep2", NULL, NULL, 0, "<Separator>" }, |
647 { N_("/Buddies/_Show Offline Buddies"), NULL, gaim_gtk_blist_edit_mode_cb, 1, "<CheckItem>"}, | 657 { N_("/Buddies/_Show Offline Buddies"), NULL, gaim_gtk_blist_edit_mode_cb, 1, "<CheckItem>"}, |
658 { N_("/Buddies/Show _Empty Groups"), NULL, gaim_gtk_blist_show_empty_groups_cb, 1, "<CheckItem>"}, | |
648 { N_("/Buddies/_Add a Buddy..."), NULL, gaim_gtk_blist_add_buddy_cb, 0, "<StockItem>", GTK_STOCK_ADD }, | 659 { N_("/Buddies/_Add a Buddy..."), NULL, gaim_gtk_blist_add_buddy_cb, 0, "<StockItem>", GTK_STOCK_ADD }, |
649 { N_("/Buddies/Add a _Group..."), NULL, show_add_group, 0, NULL}, | 660 { N_("/Buddies/Add a _Group..."), NULL, show_add_group, 0, NULL}, |
650 { "/Buddies/sep3", NULL, NULL, 0, "<Separator>" }, | 661 { "/Buddies/sep3", NULL, NULL, 0, "<Separator>" }, |
651 { N_("/Buddies/_Signoff"), "<CTL>D", signoff_all, 0, NULL }, | 662 { N_("/Buddies/_Signoff"), "<CTL>D", signoff_all, 0, NULL }, |
652 { N_("/Buddies/_Quit"), "<CTL>Q", do_quit, 0, | 663 { N_("/Buddies/_Quit"), "<CTL>Q", do_quit, 0, |
1233 gaim_gtk_blist_update_columns(); | 1244 gaim_gtk_blist_update_columns(); |
1234 | 1245 |
1235 /* set the Show Offline Buddies option. must be done | 1246 /* set the Show Offline Buddies option. must be done |
1236 * after the treeview or faceprint gets mad. -Robot101 | 1247 * after the treeview or faceprint gets mad. -Robot101 |
1237 */ | 1248 */ |
1238 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (ift, N_("/Edit/Show Offline Buddies"))), | 1249 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (ift, N_("/Buddies/Show Offline Buddies"))), |
1239 blist_options & OPT_BLIST_SHOW_OFFLINE); | 1250 blist_options & OPT_BLIST_SHOW_OFFLINE); |
1251 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtk_item_factory_get_item (ift, N_("/Buddies/Show Empty Groups"))), | |
1252 !(blist_options & OPT_BLIST_NO_MT_GRP)); | |
1240 | 1253 |
1241 /* OK... let's show this bad boy. */ | 1254 /* OK... let's show this bad boy. */ |
1242 gaim_gtk_blist_refresh(list); | 1255 gaim_gtk_blist_refresh(list); |
1243 gaim_gtk_blist_restore_position(); | 1256 gaim_gtk_blist_restore_position(); |
1244 gtk_widget_show_all(gtkblist->window); | 1257 gtk_widget_show_all(gtkblist->window); |
1408 | 1421 |
1409 if (get_iter_from_node(node, &iter)) { | 1422 if (get_iter_from_node(node, &iter)) { |
1410 gtk_tree_store_remove(gtkblist->treemodel, &iter); | 1423 gtk_tree_store_remove(gtkblist->treemodel, &iter); |
1411 if(GAIM_BLIST_NODE_IS_BUDDY(node) && | 1424 if(GAIM_BLIST_NODE_IS_BUDDY(node) && |
1412 !(blist_options & OPT_BLIST_SHOW_OFFLINE) && | 1425 !(blist_options & OPT_BLIST_SHOW_OFFLINE) && |
1413 gaim_blist_get_group_online_count((struct group *)node->parent) == 0) { | 1426 (blist_options & OPT_BLIST_NO_MT_GRP) && |
1427 !gaim_blist_get_group_online_count((struct group *)node->parent)) { | |
1414 GtkTreeIter groupiter; | 1428 GtkTreeIter groupiter; |
1415 if(get_iter_from_node(node->parent, &groupiter)) | 1429 if(get_iter_from_node(node->parent, &groupiter)) |
1416 gtk_tree_store_remove(gtkblist->treemodel, &groupiter); | 1430 gtk_tree_store_remove(gtkblist->treemodel, &groupiter); |
1417 } | 1431 } |
1418 } | 1432 } |
1493 | 1507 |
1494 | 1508 |
1495 if (!get_iter_from_node(node, &iter)) { /* This is a newly added node */ | 1509 if (!get_iter_from_node(node, &iter)) { /* This is a newly added node */ |
1496 new_entry = TRUE; | 1510 new_entry = TRUE; |
1497 if (GAIM_BLIST_NODE_IS_BUDDY(node)) { | 1511 if (GAIM_BLIST_NODE_IS_BUDDY(node)) { |
1498 if (((struct buddy*)node)->present || (blist_options & OPT_BLIST_SHOW_OFFLINE && ((struct buddy*)node)->account->gc)) { | 1512 if (((struct buddy*)node)->present || ((blist_options & OPT_BLIST_SHOW_OFFLINE) && ((struct buddy*)node)->account->gc)) { |
1499 GtkTreeIter groupiter; | 1513 GtkTreeIter groupiter; |
1500 GaimBlistNode *oldersibling; | 1514 GaimBlistNode *oldersibling; |
1501 GtkTreeIter oldersiblingiter; | 1515 GtkTreeIter oldersiblingiter; |
1502 | 1516 |
1503 if(node->parent && | 1517 if(node->parent && |
1504 !get_iter_from_node(node->parent, &groupiter)) { | 1518 !get_iter_from_node(node->parent, &groupiter)) { |
1505 /* This buddy's group has not yet been added. | 1519 /* This buddy's group has not yet been added. |
1506 * We do that here */ | 1520 * We do that here */ |
1507 make_a_group(node->parent, &groupiter); | 1521 make_a_group(node->parent, &groupiter); |
1522 } | |
1523 if(!gtk_tree_model_iter_has_child(GTK_TREE_MODEL(gtkblist->treemodel), &groupiter)) | |
1508 expand = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &groupiter); | 1524 expand = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &groupiter); |
1509 } | |
1510 | 1525 |
1511 oldersibling = node->prev; | 1526 oldersibling = node->prev; |
1512 while (oldersibling && !get_iter_from_node(oldersibling, &oldersiblingiter)) { | 1527 while (oldersibling && !get_iter_from_node(oldersibling, &oldersiblingiter)) { |
1513 oldersibling = oldersibling->prev; | 1528 oldersibling = oldersibling->prev; |
1514 } | 1529 } |
1518 if (blist_options & OPT_BLIST_POPUP) | 1533 if (blist_options & OPT_BLIST_POPUP) |
1519 gtk_window_present(GTK_WINDOW(gtkblist->window)); | 1534 gtk_window_present(GTK_WINDOW(gtkblist->window)); |
1520 | 1535 |
1521 } | 1536 } |
1522 } | 1537 } |
1523 else if (GAIM_BLIST_NODE_IS_GROUP(node) && (blist_options & OPT_BLIST_SHOW_OFFLINE)) { | 1538 else if (GAIM_BLIST_NODE_IS_GROUP(node) && |
1539 ((blist_options & OPT_BLIST_SHOW_OFFLINE) || | |
1540 !(blist_options & OPT_BLIST_NO_MT_GRP))) { | |
1524 make_a_group(node, &iter); | 1541 make_a_group(node, &iter); |
1525 expand = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &iter); | 1542 expand = gtk_tree_model_get_path(GTK_TREE_MODEL(gtkblist->treemodel), &iter); |
1526 } | 1543 } |
1527 } else if (GAIM_BLIST_NODE_IS_GROUP(node)) { | 1544 } else if (GAIM_BLIST_NODE_IS_GROUP(node)) { |
1528 if ((gaim_blist_get_group_online_count((struct group *)node) == 0) || | 1545 if((blist_options & OPT_BLIST_NO_MT_GRP) && !(blist_options & OPT_BLIST_SHOW_OFFLINE) && !gaim_blist_get_group_online_count((struct group *)node)) { |
1529 (!gtk_tree_model_iter_has_child(GTK_TREE_MODEL(gtkblist->treemodel), &iter) && !(blist_options & OPT_BLIST_SHOW_OFFLINE))) { | |
1530 gtk_tree_store_remove(gtkblist->treemodel, &iter); | 1546 gtk_tree_store_remove(gtkblist->treemodel, &iter); |
1531 } else { | 1547 } else { |
1532 struct group *group = (struct group *)node; | 1548 struct group *group = (struct group *)node; |
1533 char *esc = g_markup_escape_text(group->name, -1); | 1549 char *esc = g_markup_escape_text(group->name, -1); |
1534 char *mark; | 1550 char *mark; |
1544 -1); | 1560 -1); |
1545 g_free(mark); | 1561 g_free(mark); |
1546 } | 1562 } |
1547 } | 1563 } |
1548 | 1564 |
1549 if (GAIM_BLIST_NODE_IS_BUDDY(node) && (((struct buddy*)node)->present || (blist_options & OPT_BLIST_SHOW_OFFLINE && ((struct buddy*)node)->account->gc))) { | 1565 if (GAIM_BLIST_NODE_IS_BUDDY(node) && (((struct buddy*)node)->present || ((blist_options & OPT_BLIST_SHOW_OFFLINE) && ((struct buddy*)node)->account->gc))) { |
1550 GdkPixbuf *status, *avatar; | 1566 GdkPixbuf *status, *avatar; |
1551 char *mark; | 1567 char *mark; |
1552 char *warning = NULL, *idle = NULL; | 1568 char *warning = NULL, *idle = NULL; |
1553 | 1569 |
1554 gboolean selected = (gtkblist->selected_node == node); | 1570 gboolean selected = (gtkblist->selected_node == node); |