Mercurial > pidgin
comparison src/gtkpounce.c @ 8259:4f9f68ab8770
[gaim-migrate @ 8982]
This should fix some buddy pounce menu issues when signing off the last
account and back on. Also, the Remove Buddy Pounce menu is now greyed out
if empty. Hopefully the issues are dealt with now.
committer: Tailor Script <tailor@pidgin.im>
author | Christian Hammond <chipx86@chipx86.com> |
---|---|
date | Sun, 15 Feb 2004 04:44:00 +0000 |
parents | 10a41e67a800 |
children | 721899998983 |
comparison
equal
deleted
inserted
replaced
8258:cbdef2dcc581 | 8259:4f9f68ab8770 |
---|---|
107 { | 107 { |
108 delete_win_cb(NULL, NULL, dialog); | 108 delete_win_cb(NULL, NULL, dialog); |
109 } | 109 } |
110 | 110 |
111 static void | 111 static void |
112 pounce_update_entryfields(GtkWidget *w, gpointer data) | 112 pounce_update_entry_fields(GtkWidget *w, gpointer data) |
113 { | 113 { |
114 const char *filename; | 114 const char *filename; |
115 GHashTable *args; | 115 GHashTable *args; |
116 GtkFileSelection *filesel; | 116 GtkFileSelection *filesel; |
117 | 117 |
150 g_hash_table_insert(args, "filesel", filesel); | 150 g_hash_table_insert(args, "filesel", filesel); |
151 g_hash_table_insert(args, "entry", entry); | 151 g_hash_table_insert(args, "entry", entry); |
152 | 152 |
153 g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filesel)->ok_button), | 153 g_signal_connect(GTK_OBJECT(GTK_FILE_SELECTION(filesel)->ok_button), |
154 "clicked", | 154 "clicked", |
155 G_CALLBACK(pounce_update_entryfields), args); | 155 G_CALLBACK(pounce_update_entry_fields), args); |
156 g_signal_connect_swapped(G_OBJECT(GTK_FILE_SELECTION(filesel)->cancel_button), | 156 g_signal_connect_swapped(G_OBJECT(GTK_FILE_SELECTION(filesel)->cancel_button), |
157 "clicked", | 157 "clicked", |
158 G_CALLBACK(g_hash_table_destroy), args); | 158 G_CALLBACK(g_hash_table_destroy), args); |
159 g_signal_connect_swapped(G_OBJECT(GTK_FILE_SELECTION(filesel)->cancel_button), | 159 g_signal_connect_swapped(G_OBJECT(GTK_FILE_SELECTION(filesel)->cancel_button), |
160 "clicked", | 160 "clicked", |
683 edit_pounce_cb(GtkWidget *w, GaimPounce *pounce) | 683 edit_pounce_cb(GtkWidget *w, GaimPounce *pounce) |
684 { | 684 { |
685 gaim_gtkpounce_dialog_show(NULL, NULL, pounce); | 685 gaim_gtkpounce_dialog_show(NULL, NULL, pounce); |
686 } | 686 } |
687 | 687 |
688 static void | 688 static gboolean |
689 fill_menu(GtkWidget *menu, GCallback cb) | 689 fill_menu(GtkWidget *menu, GCallback cb) |
690 { | 690 { |
691 GtkWidget *image; | 691 GtkWidget *image; |
692 GtkWidget *item; | 692 GtkWidget *item; |
693 GdkPixbuf *pixbuf, *scale; | 693 GdkPixbuf *pixbuf, *scale; |
694 GaimPounce *pounce; | 694 GaimPounce *pounce; |
695 const char *buddy; | 695 const char *buddy; |
696 gboolean has_items = FALSE; | |
696 GList *bp; | 697 GList *bp; |
697 | 698 |
698 for (bp = gaim_pounces_get_all(); bp != NULL; bp = bp->next) { | 699 for (bp = gaim_pounces_get_all(); bp != NULL; bp = bp->next) { |
699 pounce = (GaimPounce *)bp->data; | 700 pounce = (GaimPounce *)bp->data; |
700 buddy = gaim_pounce_get_pouncee(pounce); | 701 buddy = gaim_pounce_get_pouncee(pounce); |
701 | 702 |
702 /* Check if account is online, if not skip it */ | 703 /* Check if account is online, if not skip it */ |
703 if(!gaim_account_is_connected(pounce->pouncer)) | 704 if (!gaim_account_is_connected(pounce->pouncer)) |
704 continue; | 705 continue; |
705 | 706 |
707 has_items = TRUE; | |
708 | |
706 /* Build the menu item */ | 709 /* Build the menu item */ |
707 item = gtk_image_menu_item_new_with_label(buddy); | 710 item = gtk_image_menu_item_new_with_label(buddy); |
708 | 711 |
709 /* Create a pixmap for the protocol icon. */ | 712 /* Create a pixmap for the protocol icon. */ |
710 pixbuf = create_prpl_icon(gaim_pounce_get_pouncer(pounce)); | 713 pixbuf = create_prpl_icon(gaim_pounce_get_pouncer(pounce)); |
725 gtk_widget_show(item); | 728 gtk_widget_show(item); |
726 | 729 |
727 /* Set our callbacks. */ | 730 /* Set our callbacks. */ |
728 g_signal_connect(G_OBJECT(item), "activate", cb, pounce); | 731 g_signal_connect(G_OBJECT(item), "activate", cb, pounce); |
729 } | 732 } |
733 | |
734 return has_items; | |
730 } | 735 } |
731 | 736 |
732 void | 737 void |
733 gaim_gtkpounce_menu_build(GtkWidget *menu) | 738 gaim_gtkpounce_menu_build(GtkWidget *menu) |
734 { | 739 { |
735 GtkWidget *remmenu; | 740 GtkWidget *remmenu; |
736 GtkWidget *item; | 741 GtkWidget *item; |
737 GList *l; | 742 GList *children, *l; |
738 | 743 gboolean has_items; |
739 if(!menu) | 744 |
740 return; | 745 g_return_if_fail(menu != NULL); |
741 | 746 |
742 for (l = gtk_container_get_children(GTK_CONTAINER(menu)); | 747 if ((children = gtk_container_get_children(GTK_CONTAINER(menu))) != NULL) |
743 l != NULL; | 748 { |
744 l = l->next) { | 749 for (l = children; l != NULL; l = l->next) |
745 | 750 gtk_widget_destroy(GTK_WIDGET(l->data)); |
746 gtk_widget_destroy(GTK_WIDGET(l->data)); | 751 |
747 } | 752 g_list_free(children); |
748 g_list_free(l); | 753 } |
749 | 754 |
750 /* "New Buddy Pounce" */ | 755 /* "New Buddy Pounce" */ |
751 item = gtk_menu_item_new_with_label(_("New Buddy Pounce")); | 756 item = gtk_menu_item_new_with_label(_("New Buddy Pounce")); |
752 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | 757 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
753 gtk_widget_show(item); | 758 gtk_widget_show(item); |
759 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | 764 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
760 | 765 |
761 /* "Remove Buddy Pounce" menu */ | 766 /* "Remove Buddy Pounce" menu */ |
762 remmenu = gtk_menu_new(); | 767 remmenu = gtk_menu_new(); |
763 | 768 |
764 fill_menu(remmenu, G_CALLBACK(delete_pounce_cb)); | 769 has_items = fill_menu(remmenu, G_CALLBACK(delete_pounce_cb)); |
770 | |
771 if (!has_items) | |
772 gtk_widget_set_sensitive(item, FALSE); | |
765 | 773 |
766 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), remmenu); | 774 gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), remmenu); |
767 gtk_widget_show(remmenu); | 775 gtk_widget_show(remmenu); |
768 gtk_widget_show(item); | 776 gtk_widget_show(item); |
769 | 777 |