comparison pidgin/gtknotify.c @ 19366:bd18c02bba9f

Use GtkDialog more often. Thanks nix_nix. Fixes #2618
author Sean Egan <seanegan@gmail.com>
date Wed, 22 Aug 2007 23:27:38 +0000
parents c5898e7d70fa
children 941965d6fd88
comparison
equal deleted inserted replaced
19365:756dad225d90 19366:bd18c02bba9f
587 GtkWidget *imhtml; 587 GtkWidget *imhtml;
588 GtkWidget *frame; 588 GtkWidget *frame;
589 char label_text[2048]; 589 char label_text[2048];
590 char *linked_text, *primary_esc, *secondary_esc; 590 char *linked_text, *primary_esc, *secondary_esc;
591 591
592 window = pidgin_create_window(title, PIDGIN_HIG_BORDER, NULL, TRUE); 592 window = gtk_dialog_new();
593 gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_DIALOG); 593 gtk_window_set_title(GTK_WINDOW(window), title);
594 gtk_container_set_border_width(GTK_CONTAINER(window), PIDGIN_HIG_BORDER);
595 gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
594 596
595 g_signal_connect(G_OBJECT(window), "delete_event", 597 g_signal_connect(G_OBJECT(window), "delete_event",
596 G_CALLBACK(formatted_close_cb), NULL); 598 G_CALLBACK(formatted_close_cb), NULL);
597 599
598 /* Setup the main vbox */ 600 /* Setup the main vbox */
599 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER); 601 vbox = GTK_DIALOG(window)->vbox;
600 gtk_container_add(GTK_CONTAINER(window), vbox);
601 gtk_widget_show(vbox);
602 602
603 /* Setup the descriptive label */ 603 /* Setup the descriptive label */
604 primary_esc = g_markup_escape_text(primary, -1); 604 primary_esc = g_markup_escape_text(primary, -1);
605 secondary_esc = (secondary != NULL) ? g_markup_escape_text(secondary, -1) : NULL; 605 secondary_esc = (secondary != NULL) ? g_markup_escape_text(secondary, -1) : NULL;
606 g_snprintf(label_text, sizeof(label_text), 606 g_snprintf(label_text, sizeof(label_text),
628 gtk_widget_set_size_request(imhtml, 300, 250); 628 gtk_widget_set_size_request(imhtml, 300, 250);
629 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); 629 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0);
630 gtk_widget_show(frame); 630 gtk_widget_show(frame);
631 631
632 /* Add the Close button. */ 632 /* Add the Close button. */
633 button = gtk_button_new_from_stock(GTK_STOCK_CLOSE); 633 button = gtk_dialog_add_button(GTK_DIALOG(window), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
634 gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0);
635 gtk_widget_show(button);
636 gtk_widget_grab_focus(button); 634 gtk_widget_grab_focus(button);
637 635
638 g_signal_connect_swapped(G_OBJECT(button), "clicked", 636 g_signal_connect_swapped(G_OBJECT(button), "clicked",
639 G_CALLBACK(gtk_widget_destroy), window); 637 G_CALLBACK(gtk_widget_destroy), window);
640 g_signal_connect(G_OBJECT(window), "key_press_event", 638 g_signal_connect(G_OBJECT(window), "key_press_event",
706 GtkCellRenderer *renderer; 704 GtkCellRenderer *renderer;
707 guint col_num; 705 guint col_num;
708 guint i; 706 guint i;
709 707
710 GtkWidget *vbox; 708 GtkWidget *vbox;
711 GtkWidget *button_area;
712 GtkWidget *label; 709 GtkWidget *label;
713 GtkWidget *sw; 710 GtkWidget *sw;
714 PidginNotifySearchResultsData *data; 711 PidginNotifySearchResultsData *data;
715 char *label_text; 712 char *label_text;
716 char *primary_esc, *secondary_esc; 713 char *primary_esc, *secondary_esc;
721 data = g_malloc(sizeof(PidginNotifySearchResultsData)); 718 data = g_malloc(sizeof(PidginNotifySearchResultsData));
722 data->user_data = user_data; 719 data->user_data = user_data;
723 data->results = results; 720 data->results = results;
724 721
725 /* Create the window */ 722 /* Create the window */
726 window = pidgin_create_window(title ? title :_("Search Results"), PIDGIN_HIG_BORDER, NULL, TRUE); 723 window = gtk_dialog_new();
727 gtk_window_set_type_hint(GTK_WINDOW(window), GDK_WINDOW_TYPE_HINT_DIALOG); 724 gtk_window_set_title(GTK_WINDOW(window), title ? title :_("Search Results"));
725 gtk_container_set_border_width(GTK_CONTAINER(window), PIDGIN_HIG_BORDER);
726 gtk_window_set_resizable(GTK_WINDOW(window), TRUE);
728 727
729 g_signal_connect_swapped(G_OBJECT(window), "delete_event", 728 g_signal_connect_swapped(G_OBJECT(window), "delete_event",
730 G_CALLBACK(searchresults_close_cb), data); 729 G_CALLBACK(searchresults_close_cb), data);
731 730
732 /* Setup the main vbox */ 731 /* Setup the main vbox */
733 vbox = gtk_vbox_new(FALSE, PIDGIN_HIG_BORDER); 732 vbox = GTK_DIALOG(window)->vbox;
734 gtk_container_add(GTK_CONTAINER(window), vbox);
735 gtk_widget_show(vbox);
736 733
737 /* Setup the descriptive label */ 734 /* Setup the descriptive label */
738 primary_esc = (primary != NULL) ? g_markup_escape_text(primary, -1) : NULL; 735 primary_esc = (primary != NULL) ? g_markup_escape_text(primary, -1) : NULL;
739 secondary_esc = (secondary != NULL) ? g_markup_escape_text(secondary, -1) : NULL; 736 secondary_esc = (secondary != NULL) ? g_markup_escape_text(secondary, -1) : NULL;
740 label_text = g_strdup_printf( 737 label_text = g_strdup_printf(
794 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treeview), -1, 791 gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(treeview), -1,
795 purple_notify_searchresults_column_get_title(results, i-1), 792 purple_notify_searchresults_column_get_title(results, i-1),
796 renderer, "text", i, NULL); 793 renderer, "text", i, NULL);
797 } 794 }
798 795
799 /* Setup the button area */
800 button_area = gtk_hbutton_box_new();
801 gtk_box_pack_start(GTK_BOX(vbox), button_area, FALSE, FALSE, 0);
802 gtk_button_box_set_layout(GTK_BUTTON_BOX(button_area), GTK_BUTTONBOX_END);
803 gtk_box_set_spacing(GTK_BOX(button_area), PIDGIN_HIG_BORDER);
804 gtk_widget_show(button_area);
805
806 for (i = 0; i < g_list_length(results->buttons); i++) { 796 for (i = 0; i < g_list_length(results->buttons); i++) {
807 PurpleNotifySearchButton *b = g_list_nth_data(results->buttons, i); 797 PurpleNotifySearchButton *b = g_list_nth_data(results->buttons, i);
808 GtkWidget *button = NULL; 798 GtkWidget *button = NULL;
809 switch (b->type) { 799 switch (b->type) {
810 case PURPLE_NOTIFY_BUTTON_LABELED: 800 case PURPLE_NOTIFY_BUTTON_LABELED:
813 } else { 803 } else {
814 purple_debug_warning("gtknotify", "Missing button label"); 804 purple_debug_warning("gtknotify", "Missing button label");
815 } 805 }
816 break; 806 break;
817 case PURPLE_NOTIFY_BUTTON_CONTINUE: 807 case PURPLE_NOTIFY_BUTTON_CONTINUE:
818 button = gtk_button_new_from_stock(GTK_STOCK_GO_FORWARD); 808 button = gtk_dialog_add_button(GTK_DIALOG(window), GTK_STOCK_GO_FORWARD, GTK_RESPONSE_NONE);
819 break; 809 break;
820 case PURPLE_NOTIFY_BUTTON_ADD: 810 case PURPLE_NOTIFY_BUTTON_ADD:
821 button = gtk_button_new_from_stock(GTK_STOCK_ADD); 811 button = gtk_dialog_add_button(GTK_DIALOG(window), GTK_STOCK_ADD, GTK_RESPONSE_NONE);
822 break; 812 break;
823 case PURPLE_NOTIFY_BUTTON_INFO: 813 case PURPLE_NOTIFY_BUTTON_INFO:
824 button = gtk_button_new_from_stock(PIDGIN_STOCK_TOOLBAR_USER_INFO); 814 button = gtk_dialog_add_button(GTK_DIALOG(window), PIDGIN_STOCK_TOOLBAR_USER_INFO, GTK_RESPONSE_NONE);
825 break; 815 break;
826 case PURPLE_NOTIFY_BUTTON_IM: 816 case PURPLE_NOTIFY_BUTTON_IM:
827 button = gtk_button_new_from_stock(PIDGIN_STOCK_TOOLBAR_MESSAGE_NEW); 817 button = gtk_dialog_add_button(GTK_DIALOG(window), PIDGIN_STOCK_TOOLBAR_MESSAGE_NEW, GTK_RESPONSE_NONE);
828 break; 818 break;
829 case PURPLE_NOTIFY_BUTTON_JOIN: 819 case PURPLE_NOTIFY_BUTTON_JOIN:
830 button = gtk_button_new_from_stock(PIDGIN_STOCK_CHAT); 820 button = gtk_dialog_add_button(GTK_DIALOG(window), PIDGIN_STOCK_CHAT, GTK_RESPONSE_NONE);
831 break; 821 break;
832 case PURPLE_NOTIFY_BUTTON_INVITE: 822 case PURPLE_NOTIFY_BUTTON_INVITE:
833 button = gtk_button_new_from_stock(PIDGIN_STOCK_INVITE); 823 button = gtk_dialog_add_button(GTK_DIALOG(window), PIDGIN_STOCK_INVITE, GTK_RESPONSE_NONE);
834 break; 824 break;
835 default: 825 default:
836 purple_debug_warning("gtknotify", "Incorrect button type: %d\n", b->type); 826 purple_debug_warning("gtknotify", "Incorrect button type: %d\n", b->type);
837 } 827 }
838 if (button != NULL) { 828 if (button != NULL) {
839 PidginNotifySearchResultsButtonData *bd; 829 PidginNotifySearchResultsButtonData *bd;
840 830
841 gtk_box_pack_start(GTK_BOX(button_area), button, FALSE, FALSE, 0);
842 gtk_widget_show(button);
843
844 bd = g_new0(PidginNotifySearchResultsButtonData, 1); 831 bd = g_new0(PidginNotifySearchResultsButtonData, 1);
845 bd->button = b; 832 bd->button = b;
846 bd->data = data; 833 bd->data = data;
847 834
848 g_signal_connect(G_OBJECT(button), "clicked", 835 g_signal_connect(G_OBJECT(button), "clicked",
850 g_signal_connect_swapped(G_OBJECT(button), "destroy", G_CALLBACK(g_free), bd); 837 g_signal_connect_swapped(G_OBJECT(button), "destroy", G_CALLBACK(g_free), bd);
851 } 838 }
852 } 839 }
853 840
854 /* Add the Close button */ 841 /* Add the Close button */
855 close_button = gtk_button_new_from_stock(GTK_STOCK_CLOSE); 842 close_button = gtk_dialog_add_button(GTK_DIALOG(window), GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE);
856 gtk_box_pack_start(GTK_BOX(button_area), close_button, FALSE, FALSE, 0);
857 gtk_widget_show(close_button);
858 843
859 g_signal_connect_swapped(G_OBJECT(close_button), "clicked", 844 g_signal_connect_swapped(G_OBJECT(close_button), "clicked",
860 G_CALLBACK(searchresults_close_cb), data); 845 G_CALLBACK(searchresults_close_cb), data);
861 846
862 data->account = gc->account; 847 data->account = gc->account;