pidgin/gtkdebug.c

branch
cpw.qulogic.gtk3
changeset 32367
57b77b20301a
parent 29321
c089a3e0092e
parent 32357
d9c2ab53f77a
child 32375
9ccb07c70f2a
equal deleted inserted replaced
29373:481ec7d852d7 32367:57b77b20301a
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 #if GTK_CHECK_VERSION(2,4,0) 749 #if GTK_CHECK_VERSION(2,4,0)
725 gtk_toolbar_set_show_arrow(GTK_TOOLBAR(toolbar), TRUE); 750 gtk_toolbar_set_show_arrow(GTK_TOOLBAR(toolbar), TRUE);
726 #endif 751 #endif
727 g_signal_connect(G_OBJECT(toolbar), "button-press-event", G_CALLBACK(toolbar_context), win); 752 g_signal_connect(G_OBJECT(toolbar), "button-press-event", G_CALLBACK(toolbar_context), win);
728 753
735 760
736 gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0); 761 gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0);
737 762
738 #ifndef HAVE_REGEX_H 763 #ifndef HAVE_REGEX_H
739 /* Find button */ 764 /* Find button */
765 #if GTK_CHECK_VERSION(2,4,0)
766 item = gtk_tool_button_new_from_stock(GTK_STOCK_FIND);
767 #if GTK_CHECK_VERSION(2,12,0)
768 gtk_tool_item_set_tooltip_text(item, _("Find"));
769 #else
770 gtk_tool_item_set_tooltip(item, tooltips, _("Find"), NULL);
771 #endif
772 g_signal_connect(G_OBJECT(item), "clicked", G_CALLBACK(find_cb), win);
773 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
774 #else
740 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_FIND, 775 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_FIND,
741 _("Find"), NULL, G_CALLBACK(find_cb), 776 _("Find"), NULL, G_CALLBACK(find_cb),
742 win, -1); 777 win, -1);
778 #endif
743 #endif /* HAVE_REGEX_H */ 779 #endif /* HAVE_REGEX_H */
744 780
745 /* Save */ 781 /* Save */
782 #if GTK_CHECK_VERSION(2,4,0)
783 item = gtk_tool_button_new_from_stock(GTK_STOCK_SAVE);
784 #if GTK_CHECK_VERSION(2,12,0)
785 gtk_tool_item_set_tooltip_text(item, _("Save"));
786 #else
787 gtk_tool_item_set_tooltip(item, tooltips, _("Save"), NULL);
788 #endif
789 g_signal_connect(G_OBJECT(item), "clicked", G_CALLBACK(save_cb), win);
790 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
791 #else
746 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_SAVE, 792 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_SAVE,
747 _("Save"), NULL, G_CALLBACK(save_cb), 793 _("Save"), NULL, G_CALLBACK(save_cb),
748 win, -1); 794 win, -1);
795 #endif
749 796
750 /* Clear button */ 797 /* Clear button */
798 #if GTK_CHECK_VERSION(2,4,0)
799 item = gtk_tool_button_new_from_stock(GTK_STOCK_CLEAR);
800 #if GTK_CHECK_VERSION(2,12,0)
801 gtk_tool_item_set_tooltip_text(item, _("Clear"));
802 #else
803 gtk_tool_item_set_tooltip(item, tooltips, _("Clear"), NULL);
804 #endif
805 g_signal_connect(G_OBJECT(item), "clicked", G_CALLBACK(clear_cb), win);
806 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
807 #else
751 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_CLEAR, 808 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_CLEAR,
752 _("Clear"), NULL, G_CALLBACK(clear_cb), 809 _("Clear"), NULL, G_CALLBACK(clear_cb),
753 win, -1); 810 win, -1);
754 811 #endif
812
813 #if GTK_CHECK_VERSION(2,4,0)
814 item = gtk_separator_tool_item_new();
815 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
816 #else
755 gtk_toolbar_insert_space(GTK_TOOLBAR(toolbar), -1); 817 gtk_toolbar_insert_space(GTK_TOOLBAR(toolbar), -1);
818 #endif
756 819
757 /* Pause */ 820 /* Pause */
821 #if GTK_CHECK_VERSION(2,4,0)
822 item = gtk_toggle_tool_button_new_from_stock(PIDGIN_STOCK_PAUSE);
823 #if GTK_CHECK_VERSION(2,12,0)
824 gtk_tool_item_set_tooltip_text(item, _("Pause"));
825 #else
826 gtk_tool_item_set_tooltip(item, tooltips, _("Pause"), NULL);
827 #endif
828 g_signal_connect(G_OBJECT(item), "clicked", G_CALLBACK(pause_cb), win);
829 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
830 #else
758 image = gtk_image_new_from_stock(PIDGIN_STOCK_PAUSE, GTK_ICON_SIZE_MENU); 831 image = gtk_image_new_from_stock(PIDGIN_STOCK_PAUSE, GTK_ICON_SIZE_MENU);
759 gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), 832 gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
760 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, 833 GTK_TOOLBAR_CHILD_TOGGLEBUTTON,
761 NULL, _("Pause"), _("Pause"), 834 NULL, _("Pause"), _("Pause"),
762 NULL, image, 835 NULL, image,
763 G_CALLBACK(pause_cb), win); 836 G_CALLBACK(pause_cb), win);
837 #endif
764 838
765 #ifdef HAVE_REGEX_H 839 #ifdef HAVE_REGEX_H
766 /* regex stuff */ 840 /* regex stuff */
841 #if GTK_CHECK_VERSION(2,4,0)
842 item = gtk_separator_tool_item_new();
843 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
844 #else
767 gtk_toolbar_insert_space(GTK_TOOLBAR(toolbar), -1); 845 gtk_toolbar_insert_space(GTK_TOOLBAR(toolbar), -1);
846 #endif
768 847
769 /* regex toggle button */ 848 /* regex toggle button */
849 #if GTK_CHECK_VERSION(2,4,0)
850 item = gtk_toggle_tool_button_new_from_stock(GTK_STOCK_FIND);
851 gtk_tool_button_set_label(GTK_TOOL_BUTTON(win->filter), _("Filter"));
852 #if GTK_CHECK_VERSION(2,12,0)
853 gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(win->filter), _("Filter"));
854 #else
855 gtk_tooltips_set_tip(tooltips, win->filter, _("Filter"), NULL);
856 #endif
857 g_signal_connect(G_OBJECT(win->filter), "clicked", G_CALLBACK(regex_filter_toggled_cb), win);
858 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(win->filter));
859 win->filter = GTK_WIDGET(item);
860 #else
770 image = gtk_image_new_from_stock(GTK_STOCK_FIND, GTK_ICON_SIZE_MENU); 861 image = gtk_image_new_from_stock(GTK_STOCK_FIND, GTK_ICON_SIZE_MENU);
771 win->filter = 862 win->filter =
772 gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), 863 gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
773 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, 864 GTK_TOOLBAR_CHILD_TOGGLEBUTTON,
774 NULL, _("Filter"), _("Filter"), 865 NULL, _("Filter"), _("Filter"),
775 NULL, image, 866 NULL, image,
776 G_CALLBACK(regex_filter_toggled_cb), 867 G_CALLBACK(regex_filter_toggled_cb),
777 win); 868 win);
869 #endif
870
778 /* we purposely disable the toggle button here in case 871 /* we purposely disable the toggle button here in case
779 * /purple/gtk/debug/expression has an empty string. If it does not have 872 * /purple/gtk/debug/expression has an empty string. If it does not have
780 * an empty string, the change signal will get called and make the 873 * an empty string, the change signal will get called and make the
781 * toggle button sensitive. 874 * toggle button sensitive.
782 */ 875 */
786 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/debug/filter", 879 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/debug/filter",
787 regex_pref_filter_cb, win); 880 regex_pref_filter_cb, win);
788 881
789 /* regex entry */ 882 /* regex entry */
790 win->expression = gtk_entry_new(); 883 win->expression = gtk_entry_new();
884 #if GTK_CHECK_VERSION(2,4,0)
885 item = gtk_tool_item_new();
886 #if GTK_CHECK_VERSION(2,12,0)
887 gtk_widget_set_tooltip_text(win->expression, _("Right click for more options."));
888 #else
889 gtk_tooltips_set_tip(tooltips, win->expression, _("Right click for more options."), NULL);
890 #endif
891 gtk_container_add(GTK_CONTAINER(item), GTK_WIDGET(win->expression));
892 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
893 #else
791 gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), 894 gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
792 GTK_TOOLBAR_CHILD_WIDGET, win->expression, 895 GTK_TOOLBAR_CHILD_WIDGET, win->expression,
793 NULL, _("Right click for more options."), 896 NULL, _("Right click for more options."),
794 NULL, NULL, NULL, NULL); 897 NULL, NULL, NULL, NULL);
898 #endif
795 /* this needs to be before the text is set from the pref if we want it 899 /* this needs to be before the text is set from the pref if we want it
796 * to colorize a stored expression. 900 * to colorize a stored expression.
797 */ 901 */
798 g_signal_connect(G_OBJECT(win->expression), "changed", 902 g_signal_connect(G_OBJECT(win->expression), "changed",
799 G_CALLBACK(regex_changed_cb), win); 903 G_CALLBACK(regex_changed_cb), win);
815 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/debug/highlight", 919 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/debug/highlight",
816 regex_pref_highlight_cb, win); 920 regex_pref_highlight_cb, win);
817 921
818 #endif /* HAVE_REGEX_H */ 922 #endif /* HAVE_REGEX_H */
819 923
924 #if GTK_CHECK_VERSION(2,4,0)
925 item = gtk_separator_tool_item_new();
926 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
927 #else
820 gtk_toolbar_insert_space(GTK_TOOLBAR(toolbar), -1); 928 gtk_toolbar_insert_space(GTK_TOOLBAR(toolbar), -1);
821 929 #endif
930
931 #if GTK_CHECK_VERSION(2,4,0)
932 item = gtk_tool_item_new();
933 gtk_container_add(GTK_CONTAINER(item), gtk_label_new(_("Level ")));
934 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
935 #else
822 gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), 936 gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
823 GTK_TOOLBAR_CHILD_WIDGET, gtk_label_new(_("Level ")), 937 GTK_TOOLBAR_CHILD_WIDGET, gtk_label_new(_("Level ")),
824 NULL, _("Select the debug filter level."), 938 NULL, _("Select the debug filter level."),
825 NULL, NULL, NULL, NULL); 939 NULL, NULL, NULL, NULL);
826 940 #endif
827 win->filterlevel = gtk_combo_box_new_text(); 941 win->filterlevel = gtk_combo_box_new_text();
942 #if GTK_CHECK_VERSION(2,4,0)
943 item = gtk_tool_item_new();
944 #if GTK_CHECK_VERSION(2,12,0)
945 gtk_widget_set_tooltip_text(win->filterlevel, _("Select the debug filter level."));
946 #else
947 gtk_tooltips_set_tip(tooltips, win->filterlevel, _("Select the debug filter level."), NULL);
948 #endif
949 gtk_container_add(GTK_CONTAINER(item), win->filterlevel);
950 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
951 #else
828 gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), 952 gtk_toolbar_append_element(GTK_TOOLBAR(toolbar),
829 GTK_TOOLBAR_CHILD_WIDGET, win->filterlevel, 953 GTK_TOOLBAR_CHILD_WIDGET, win->filterlevel,
830 NULL, _("Select the debug filter level."), 954 NULL, _("Select the debug filter level."),
831 NULL, NULL, NULL, NULL); 955 NULL, NULL, NULL, NULL);
956 #endif
832 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("All")); 957 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("All"));
833 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Misc")); 958 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Misc"));
834 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Info")); 959 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Info"));
835 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Warning")); 960 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Warning"));
836 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Error ")); 961 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Error "));

mercurial