pidgin/gtkdebug.c

branch
cpw.qulogic.gtk3
changeset 32375
9ccb07c70f2a
parent 29694
4efd5d82fef3
parent 32367
57b77b20301a
child 32377
885ae4f931f1
equal deleted inserted replaced
29737:0adc09e12a5a 32375:9ccb07c70f2a
41 # include <regex.h> 41 # include <regex.h>
42 #endif /* HAVE_REGEX_H */ 42 #endif /* HAVE_REGEX_H */
43 43
44 #include <gdk/gdkkeysyms.h> 44 #include <gdk/gdkkeysyms.h>
45 45
46 /* TODO: I'm too lazy to change all these until we bump required GTK+ version */
47 #if GTK_CHECK_VERSION(2,4,0)
48 #undef GTK_TOGGLE_BUTTON
49 #undef gtk_toggle_button_get_active
50 #undef gtk_toggle_button_set_active
51 #undef GtkToggleButton
52
53 #define GTK_TOGGLE_BUTTON GTK_TOGGLE_TOOL_BUTTON
54 #define gtk_toggle_button_get_active gtk_toggle_tool_button_get_active
55 #define gtk_toggle_button_set_active gtk_toggle_tool_button_set_active
56 #define GtkToggleButton GtkToggleToolButton
57 #endif
58
46 typedef struct 59 typedef struct
47 { 60 {
48 GtkWidget *window; 61 GtkWidget *window;
49 GtkWidget *text; 62 GtkWidget *text;
50 63
675 { 688 {
676 DebugWindow *win; 689 DebugWindow *win;
677 GtkWidget *vbox; 690 GtkWidget *vbox;
678 GtkWidget *toolbar; 691 GtkWidget *toolbar;
679 GtkWidget *frame; 692 GtkWidget *frame;
680 GtkWidget *image;
681 gint width, height; 693 gint width, height;
682 void *handle; 694 void *handle;
695 #if GTK_CHECK_VERSION(2,4,0)
696 GtkToolItem *item;
697 #if !GTK_CHECK_VERSION(2,12,0)
698 GtkTooltips *tooltips;
699 #endif
700 #else
701 GtkWidget *image;
702 #endif
683 703
684 win = g_new0(DebugWindow, 1); 704 win = g_new0(DebugWindow, 1);
685 705
686 width = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/debug/width"); 706 width = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/debug/width");
687 height = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/debug/height"); 707 height = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/debug/height");
718 gtk_container_add(GTK_CONTAINER(win->window), vbox); 738 gtk_container_add(GTK_CONTAINER(win->window), vbox);
719 739
720 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/debug/toolbar")) { 740 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/debug/toolbar")) {
721 /* Setup our top button bar thingie. */ 741 /* Setup our top button bar thingie. */
722 toolbar = gtk_toolbar_new(); 742 toolbar = gtk_toolbar_new();
743 #if GTK_CHECK_VERSION(2,4,0) && !GTK_CHECK_VERSION(2,12,0)
744 tooltips = gtk_tooltips_new();
745 #endif
746 #if !GTK_CHECK_VERSION(2,14,0)
723 gtk_toolbar_set_tooltips(GTK_TOOLBAR(toolbar), TRUE); 747 gtk_toolbar_set_tooltips(GTK_TOOLBAR(toolbar), TRUE);
748 #endif
724 gtk_toolbar_set_show_arrow(GTK_TOOLBAR(toolbar), TRUE); 749 gtk_toolbar_set_show_arrow(GTK_TOOLBAR(toolbar), TRUE);
725 g_signal_connect(G_OBJECT(toolbar), "button-press-event", G_CALLBACK(toolbar_context), win); 750 g_signal_connect(G_OBJECT(toolbar), "button-press-event", G_CALLBACK(toolbar_context), win);
726 751
727 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), 752 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar),
728 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/debug/style")); 753 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/debug/style"));
733 758
734 gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0); 759 gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0);
735 760
736 #ifndef HAVE_REGEX_H 761 #ifndef HAVE_REGEX_H
737 /* Find button */ 762 /* Find button */
763 #if GTK_CHECK_VERSION(2,4,0)
764 item = gtk_tool_button_new_from_stock(GTK_STOCK_FIND);
765 #if GTK_CHECK_VERSION(2,12,0)
766 gtk_tool_item_set_tooltip_text(item, _("Find"));
767 #else
768 gtk_tool_item_set_tooltip(item, tooltips, _("Find"), NULL);
769 #endif
770 g_signal_connect(G_OBJECT(item), "clicked", G_CALLBACK(find_cb), win);
771 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
772 #else
738 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_FIND, 773 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_FIND,
739 _("Find"), NULL, G_CALLBACK(find_cb), 774 _("Find"), NULL, G_CALLBACK(find_cb),
740 win, -1); 775 win, -1);
776 #endif
741 #endif /* HAVE_REGEX_H */ 777 #endif /* HAVE_REGEX_H */
742 778
743 /* Save */ 779 /* Save */
780 #if GTK_CHECK_VERSION(2,4,0)
781 item = gtk_tool_button_new_from_stock(GTK_STOCK_SAVE);
782 #if GTK_CHECK_VERSION(2,12,0)
783 gtk_tool_item_set_tooltip_text(item, _("Save"));
784 #else
785 gtk_tool_item_set_tooltip(item, tooltips, _("Save"), NULL);
786 #endif
787 g_signal_connect(G_OBJECT(item), "clicked", G_CALLBACK(save_cb), win);
788 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
789 #else
744 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_SAVE, 790 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_SAVE,
745 _("Save"), NULL, G_CALLBACK(save_cb), 791 _("Save"), NULL, G_CALLBACK(save_cb),
746 win, -1); 792 win, -1);
793 #endif
747 794
748 /* Clear button */ 795 /* Clear button */
796 #if GTK_CHECK_VERSION(2,4,0)
797 item = gtk_tool_button_new_from_stock(GTK_STOCK_CLEAR);
798 #if GTK_CHECK_VERSION(2,12,0)
799 gtk_tool_item_set_tooltip_text(item, _("Clear"));
800 #else
801 gtk_tool_item_set_tooltip(item, tooltips, _("Clear"), NULL);
802 #endif
803 g_signal_connect(G_OBJECT(item), "clicked", G_CALLBACK(clear_cb), win);
804 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
805 #else
749 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_CLEAR, 806 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_CLEAR,
750 _("Clear"), NULL, G_CALLBACK(clear_cb), 807 _("Clear"), NULL, G_CALLBACK(clear_cb),
751 win, -1); 808 win, -1);
752 809 #endif
810
811 #if GTK_CHECK_VERSION(2,4,0)
812 item = gtk_separator_tool_item_new();
813 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
814 #else
753 gtk_toolbar_insert_space(GTK_TOOLBAR(toolbar), -1); 815 gtk_toolbar_insert_space(GTK_TOOLBAR(toolbar), -1);
816 #endif
754 817
755 /* Pause */ 818 /* Pause */
819 #if GTK_CHECK_VERSION(2,4,0)
820 item = gtk_toggle_tool_button_new_from_stock(PIDGIN_STOCK_PAUSE);
821 #if GTK_CHECK_VERSION(2,12,0)
822 gtk_tool_item_set_tooltip_text(item, _("Pause"));
823 #else
824 gtk_tool_item_set_tooltip(item, tooltips, _("Pause"), NULL);
825 #endif
826 g_signal_connect(G_OBJECT(item), "clicked", G_CALLBACK(pause_cb), win);
827 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
828 #else
756 image = gtk_image_new_from_stock(PIDGIN_STOCK_PAUSE, GTK_ICON_SIZE_MENU); 829 image = gtk_image_new_from_stock(PIDGIN_STOCK_PAUSE, GTK_ICON_SIZE_MENU);
757 gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), 830 gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
758 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, 831 GTK_TOOLBAR_CHILD_TOGGLEBUTTON,
759 NULL, _("Pause"), _("Pause"), 832 NULL, _("Pause"), _("Pause"),
760 NULL, image, 833 NULL, image,
761 G_CALLBACK(pause_cb), win); 834 G_CALLBACK(pause_cb), win);
835 #endif
762 836
763 #ifdef HAVE_REGEX_H 837 #ifdef HAVE_REGEX_H
764 /* regex stuff */ 838 /* regex stuff */
839 #if GTK_CHECK_VERSION(2,4,0)
840 item = gtk_separator_tool_item_new();
841 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
842 #else
765 gtk_toolbar_insert_space(GTK_TOOLBAR(toolbar), -1); 843 gtk_toolbar_insert_space(GTK_TOOLBAR(toolbar), -1);
844 #endif
766 845
767 /* regex toggle button */ 846 /* regex toggle button */
847 #if GTK_CHECK_VERSION(2,4,0)
848 item = gtk_toggle_tool_button_new_from_stock(GTK_STOCK_FIND);
849 gtk_tool_button_set_label(GTK_TOOL_BUTTON(win->filter), _("Filter"));
850 #if GTK_CHECK_VERSION(2,12,0)
851 gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(win->filter), _("Filter"));
852 #else
853 gtk_tooltips_set_tip(tooltips, win->filter, _("Filter"), NULL);
854 #endif
855 g_signal_connect(G_OBJECT(win->filter), "clicked", G_CALLBACK(regex_filter_toggled_cb), win);
856 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(win->filter));
857 win->filter = GTK_WIDGET(item);
858 #else
768 image = gtk_image_new_from_stock(GTK_STOCK_FIND, GTK_ICON_SIZE_MENU); 859 image = gtk_image_new_from_stock(GTK_STOCK_FIND, GTK_ICON_SIZE_MENU);
769 win->filter = 860 win->filter =
770 gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), 861 gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
771 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, 862 GTK_TOOLBAR_CHILD_TOGGLEBUTTON,
772 NULL, _("Filter"), _("Filter"), 863 NULL, _("Filter"), _("Filter"),
773 NULL, image, 864 NULL, image,
774 G_CALLBACK(regex_filter_toggled_cb), 865 G_CALLBACK(regex_filter_toggled_cb),
775 win); 866 win);
867 #endif
868
776 /* we purposely disable the toggle button here in case 869 /* we purposely disable the toggle button here in case
777 * /purple/gtk/debug/expression has an empty string. If it does not have 870 * /purple/gtk/debug/expression has an empty string. If it does not have
778 * an empty string, the change signal will get called and make the 871 * an empty string, the change signal will get called and make the
779 * toggle button sensitive. 872 * toggle button sensitive.
780 */ 873 */
784 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/debug/filter", 877 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/debug/filter",
785 regex_pref_filter_cb, win); 878 regex_pref_filter_cb, win);
786 879
787 /* regex entry */ 880 /* regex entry */
788 win->expression = gtk_entry_new(); 881 win->expression = gtk_entry_new();
882 #if GTK_CHECK_VERSION(2,4,0)
883 item = gtk_tool_item_new();
884 #if GTK_CHECK_VERSION(2,12,0)
885 gtk_widget_set_tooltip_text(win->expression, _("Right click for more options."));
886 #else
887 gtk_tooltips_set_tip(tooltips, win->expression, _("Right click for more options."), NULL);
888 #endif
889 gtk_container_add(GTK_CONTAINER(item), GTK_WIDGET(win->expression));
890 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
891 #else
789 gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), 892 gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
790 GTK_TOOLBAR_CHILD_WIDGET, win->expression, 893 GTK_TOOLBAR_CHILD_WIDGET, win->expression,
791 NULL, _("Right click for more options."), 894 NULL, _("Right click for more options."),
792 NULL, NULL, NULL, NULL); 895 NULL, NULL, NULL, NULL);
896 #endif
793 /* this needs to be before the text is set from the pref if we want it 897 /* this needs to be before the text is set from the pref if we want it
794 * to colorize a stored expression. 898 * to colorize a stored expression.
795 */ 899 */
796 g_signal_connect(G_OBJECT(win->expression), "changed", 900 g_signal_connect(G_OBJECT(win->expression), "changed",
797 G_CALLBACK(regex_changed_cb), win); 901 G_CALLBACK(regex_changed_cb), win);
813 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/debug/highlight", 917 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/debug/highlight",
814 regex_pref_highlight_cb, win); 918 regex_pref_highlight_cb, win);
815 919
816 #endif /* HAVE_REGEX_H */ 920 #endif /* HAVE_REGEX_H */
817 921
922 #if GTK_CHECK_VERSION(2,4,0)
923 item = gtk_separator_tool_item_new();
924 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
925 #else
818 gtk_toolbar_insert_space(GTK_TOOLBAR(toolbar), -1); 926 gtk_toolbar_insert_space(GTK_TOOLBAR(toolbar), -1);
819 927 #endif
928
929 #if GTK_CHECK_VERSION(2,4,0)
930 item = gtk_tool_item_new();
931 gtk_container_add(GTK_CONTAINER(item), gtk_label_new(_("Level ")));
932 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
933 #else
820 gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), 934 gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
821 GTK_TOOLBAR_CHILD_WIDGET, gtk_label_new(_("Level ")), 935 GTK_TOOLBAR_CHILD_WIDGET, gtk_label_new(_("Level ")),
822 NULL, _("Select the debug filter level."), 936 NULL, _("Select the debug filter level."),
823 NULL, NULL, NULL, NULL); 937 NULL, NULL, NULL, NULL);
824 938 #endif
825 win->filterlevel = gtk_combo_box_new_text(); 939 win->filterlevel = gtk_combo_box_new_text();
940 #if GTK_CHECK_VERSION(2,4,0)
941 item = gtk_tool_item_new();
942 #if GTK_CHECK_VERSION(2,12,0)
943 gtk_widget_set_tooltip_text(win->filterlevel, _("Select the debug filter level."));
944 #else
945 gtk_tooltips_set_tip(tooltips, win->filterlevel, _("Select the debug filter level."), NULL);
946 #endif
947 gtk_container_add(GTK_CONTAINER(item), win->filterlevel);
948 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
949 #else
826 gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), 950 gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
827 GTK_TOOLBAR_CHILD_WIDGET, win->filterlevel, 951 GTK_TOOLBAR_CHILD_WIDGET, win->filterlevel,
828 NULL, _("Select the debug filter level."), 952 NULL, _("Select the debug filter level."),
829 NULL, NULL, NULL, NULL); 953 NULL, NULL, NULL, NULL);
954 #endif
830 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("All")); 955 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("All"));
831 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Misc")); 956 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Misc"));
832 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Info")); 957 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Info"));
833 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Warning")); 958 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Warning"));
834 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Error ")); 959 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Error "));

mercurial