comparison src/gtkpounce.c @ 5153:ab0f12de3718

[gaim-migrate @ 5517] The return of the Remove Buddy Pounce menu (I think I accidentally killed it before? Anyhow, it's here now.) Also, pounce menu items now have the protocol icon. This made is extremely easier to figure out who I was looking for. Yay. Imma go beat up the mailman. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Thu, 17 Apr 2003 23:44:34 +0000
parents abc8489b2e8f
children b055ed64871f
comparison
equal deleted inserted replaced
5152:e637e36ee45c 5153:ab0f12de3718
705 { 705 {
706 gaim_gtkpounce_dialog_show(b, NULL); 706 gaim_gtkpounce_dialog_show(b, NULL);
707 } 707 }
708 708
709 static void 709 static void
710 delete_pounce_cb(GtkWidget *w, struct gaim_pounce *pounce)
711 {
712 gaim_pounce_destroy(pounce);
713 }
714
715 static void
710 edit_pounce_cb(GtkWidget *w, struct gaim_pounce *pounce) 716 edit_pounce_cb(GtkWidget *w, struct gaim_pounce *pounce)
711 { 717 {
712 struct buddy *buddy; 718 struct buddy *buddy;
713 719
714 buddy = gaim_find_buddy(gaim_pounce_get_pouncer(pounce), 720 buddy = gaim_find_buddy(gaim_pounce_get_pouncer(pounce),
715 gaim_pounce_get_pouncee(pounce)); 721 gaim_pounce_get_pouncee(pounce));
716 722
717 gaim_gtkpounce_dialog_show(buddy, pounce); 723 gaim_gtkpounce_dialog_show(buddy, pounce);
718 } 724 }
719 725
726 static void
727 fill_menu(GtkWidget *menu, GCallback cb)
728 {
729 GtkWidget *box;
730 GtkWidget *label;
731 GtkWidget *image;
732 GtkWidget *item;
733 GdkPixbuf *pixbuf, *scale;
734 struct gaim_pounce *pounce;
735 const char *buddy;
736 GtkSizeGroup *sg;
737 GList *bp;
738
739 sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
740
741 for (bp = gaim_get_pounces(); bp != NULL; bp = bp->next) {
742 pounce = (struct gaim_pounce *)bp->data;
743 buddy = gaim_pounce_get_pouncee(pounce);
744
745 /* Create a pixmap for the protocol icon. */
746 pixbuf = create_prpl_icon(gaim_pounce_get_pouncer(pounce));
747 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, GDK_INTERP_BILINEAR);
748
749 /* Now convert it to GtkImage */
750 if (pixbuf == NULL)
751 image = gtk_image_new();
752 else
753 image = gtk_image_new_from_pixbuf(scale);
754
755 gtk_size_group_add_widget(sg, image);
756
757 g_object_unref(G_OBJECT(scale));
758 g_object_unref(G_OBJECT(pixbuf));
759
760 /* Build the menu item */
761 item = gtk_menu_item_new_with_label(buddy);
762 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
763 gtk_widget_show(item);
764
765 /* Do some evil, see some evil, speak some evil, continued. */
766 box = gtk_hbox_new(FALSE, 0);
767
768 label = gtk_bin_get_child(GTK_BIN(item));
769 g_object_ref(label);
770 gtk_container_remove(GTK_CONTAINER(item), label);
771
772 gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0);
773 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 4);
774
775 g_object_unref(label);
776
777 gtk_container_add(GTK_CONTAINER(item), box);
778
779 gtk_widget_show(label);
780 gtk_widget_show(image);
781 gtk_widget_show(box);
782
783 /* Set our callbacks. */
784 g_signal_connect(G_OBJECT(item), "activate", cb, pounce);
785 }
786
787 g_object_unref(sg);
788 }
789
720 void 790 void
721 gaim_gtkpounce_menu_build(GtkWidget *menu) 791 gaim_gtkpounce_menu_build(GtkWidget *menu)
722 { 792 {
723 GtkWidget *remmenu, *item; 793 GtkWidget *remmenu;
794 GtkWidget *item;
724 GList *l; 795 GList *l;
725 GList *bp;
726 struct gaim_pounce *pounce;
727 const char *buddy;
728 796
729 for (l = gtk_container_get_children(GTK_CONTAINER(menu)); 797 for (l = gtk_container_get_children(GTK_CONTAINER(menu));
730 l != NULL; 798 l != NULL;
731 l = l->next) { 799 l = l->next) {
732 800
745 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); 813 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
746 814
747 /* "Remove Buddy Pounce" menu */ 815 /* "Remove Buddy Pounce" menu */
748 remmenu = gtk_menu_new(); 816 remmenu = gtk_menu_new();
749 817
750 for (bp = gaim_get_pounces(); bp != NULL; bp = bp->next) { 818 fill_menu(remmenu, G_CALLBACK(delete_pounce_cb));
751 pounce = (struct gaim_pounce *)bp->data;
752 buddy = gaim_pounce_get_pouncee(pounce);
753
754 item = gtk_menu_item_new_with_label(buddy);
755 gtk_menu_shell_append(GTK_MENU_SHELL(remmenu), item);
756 gtk_widget_show(item);
757
758 g_signal_connect(G_OBJECT(item), "activate",
759 G_CALLBACK(edit_pounce_cb), pounce);
760 }
761 819
762 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), remmenu); 820 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), remmenu);
763 gtk_widget_show(remmenu); 821 gtk_widget_show(remmenu);
764 gtk_widget_show(item); 822 gtk_widget_show(item);
765 823
766 /* Separator */ 824 /* Separator */
767 item = gtk_separator_menu_item_new(); 825 item = gtk_separator_menu_item_new();
768 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); 826 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
769 gtk_widget_show(item); 827 gtk_widget_show(item);
770 828
771 /* Pounces */ 829 fill_menu(menu, G_CALLBACK(edit_pounce_cb));
772 for (bp = gaim_get_pounces(); bp != NULL; bp = bp->next) { 830 }
773 struct gaim_gtkpounce_data *pounce_data; 831
774
775 pounce = (struct gaim_pounce *)bp->data;
776 buddy = gaim_pounce_get_pouncee(pounce);
777
778 pounce_data = GAIM_GTKPOUNCE(pounce);
779
780 item = gtk_menu_item_new_with_label(buddy);
781 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item);
782 gtk_widget_show(item);
783
784 g_signal_connect(G_OBJECT(item), "activate",
785 G_CALLBACK(edit_pounce_cb), pounce);
786 }
787 }
788