comparison src/buddy.c @ 1396:df7c3cacac92

[gaim-migrate @ 1406] Un-Alias option in right-click edit list, and show alias next to name in edit list. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Tue, 09 Jan 2001 09:16:19 +0000
parents dc6ba774bfc5
children d2799e0672ee
comparison
equal deleted inserted replaced
1395:567758889707 1396:df7c3cacac92
472 472
473 /* Anything for other buttons? :) */ 473 /* Anything for other buttons? :) */
474 } 474 }
475 } 475 }
476 476
477 static void un_alias(GtkWidget *a, struct buddy *b)
478 {
479 struct group *g = find_group_by_buddy(b->gc, b->name);
480 struct group_show *gs = find_group_show(g->name);
481 struct buddy_show *bs;
482 GtkCTreeNode *node = gtk_ctree_find_by_row_data(GTK_CTREE(edittree), NULL, b);
483 g_snprintf(b->show, sizeof(b->show), "%s", b->name);
484 gtk_ctree_node_set_text(GTK_CTREE(edittree), node, 0, b->name);
485 if (gs) bs = find_buddy_show(gs, b->name);
486 if (bs) gtk_label_set(GTK_LABEL(bs->label), b->name);
487 do_export(0, 0);
488 }
477 489
478 static gboolean click_edit_tree(GtkWidget *widget, GdkEventButton *event, gpointer data) 490 static gboolean click_edit_tree(GtkWidget *widget, GdkEventButton *event, gpointer data)
479 { 491 {
480 GtkCTreeNode *node; 492 GtkCTreeNode *node;
481 GList *i; 493 GList *i;
506 518
507 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, 519 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL,
508 event->button, event->time); 520 event->button, event->time);
509 } else if (*type == EDIT_BUDDY) { 521 } else if (*type == EDIT_BUDDY) {
510 struct buddy *b = (struct buddy *)type; 522 struct buddy *b = (struct buddy *)type;
523 struct group *g = find_group_by_buddy(b->gc, b->name);
524 struct group_show *gs = find_group_show(g->name);
525 struct buddy_show *bs = find_buddy_show(gs, b->name);
511 menu = gtk_menu_new(); 526 menu = gtk_menu_new();
512 527
513 button = gtk_menu_item_new_with_label(_("Alias")); 528 button = gtk_menu_item_new_with_label(_("Alias"));
514 gtk_signal_connect(GTK_OBJECT(button), "activate", 529 gtk_signal_connect(GTK_OBJECT(button), "activate",
515 GTK_SIGNAL_FUNC(pressed_alias), b); 530 GTK_SIGNAL_FUNC(pressed_alias), bs);
516 gtk_menu_append(GTK_MENU(menu), button); 531 gtk_menu_append(GTK_MENU(menu), button);
517 gtk_widget_show(button); 532 gtk_widget_show(button);
533
534 if (strcmp(b->name, b->show)) {
535 button = gtk_menu_item_new_with_label(_("Un-Alias"));
536 gtk_signal_connect(GTK_OBJECT(button), "activate",
537 GTK_SIGNAL_FUNC(un_alias), b);
538 gtk_menu_append(GTK_MENU(menu), button);
539 gtk_widget_show(button);
540 }
518 541
519 button = gtk_menu_item_new_with_label(_("Add Buddy Pounce")); 542 button = gtk_menu_item_new_with_label(_("Add Buddy Pounce"));
520 gtk_signal_connect(GTK_OBJECT(button), "activate", 543 gtk_signal_connect(GTK_OBJECT(button), "activate",
521 GTK_SIGNAL_FUNC(new_bp_callback), b->name); 544 GTK_SIGNAL_FUNC(new_bp_callback), b->name);
522 gtk_menu_append(GTK_MENU(menu), button); 545 gtk_menu_append(GTK_MENU(menu), button);
929 n = NULL; 952 n = NULL;
930 953
931 mem = g->members; 954 mem = g->members;
932 955
933 while(mem) { 956 while(mem) {
957 char buf[256];
934 b = (struct buddy *)mem->data; 958 b = (struct buddy *)mem->data;
935 959 if (strcmp(b->name, b->show)) {
936 text[0] = b->name; 960 g_snprintf(buf, sizeof(buf), "%s (%s)", b->name, b->show);
961 text[0] = buf;
962 } else
963 text[0] = b->name;
937 964
938 n = gtk_ctree_insert_node(GTK_CTREE(edittree), 965 n = gtk_ctree_insert_node(GTK_CTREE(edittree),
939 p, NULL, text, 5, 966 p, NULL, text, 5,
940 NULL, NULL, 967 NULL, NULL,
941 NULL, NULL, 1, 1); 968 NULL, NULL, 1, 1);