comparison pidgin/gtkdebug.c @ 30229:6d3a90b49dba

propagate from branch 'im.pidgin.pidgin' (head 8587687655d4e11f0965358e8a4378cfa3d1e4e7) to branch 'im.pidgin.cpw.malu.ft_thumbnails' (head 14eca8a36cf4d5e66226c1d94d6d44b5219b1476)
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sun, 28 Feb 2010 04:07:39 +0000
parents 693e54b7d62b
children bedc5715ab5f
comparison
equal deleted inserted replaced
30228:221cebbc35d8 30229:6d3a90b49dba
248 } 248 }
249 249
250 static void 250 static void
251 pause_cb(GtkWidget *w, DebugWindow *win) 251 pause_cb(GtkWidget *w, DebugWindow *win)
252 { 252 {
253 win->paused = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w)); 253 win->paused = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(w));
254 254
255 #ifdef HAVE_REGEX_H 255 #ifdef HAVE_REGEX_H
256 if(!win->paused) { 256 if(!win->paused) {
257 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter))) 257 if(gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(win->filter)))
258 regex_filter_all(win); 258 regex_filter_all(win);
259 else 259 else
260 regex_show_all(win); 260 regex_show_all(win);
261 } 261 }
262 #endif /* HAVE_REGEX_H */ 262 #endif /* HAVE_REGEX_H */
443 } 443 }
444 444
445 /* we check if the filter is on in case it was only of the options that 445 /* we check if the filter is on in case it was only of the options that
446 * got changed, and not the expression. 446 * got changed, and not the expression.
447 */ 447 */
448 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter))) 448 if(gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(win->filter)))
449 regex_filter_all(win); 449 regex_filter_all(win);
450 } 450 }
451 451
452 static void 452 static void
453 regex_pref_filter_cb(const gchar *name, PurplePrefType type, 453 regex_pref_filter_cb(const gchar *name, PurplePrefType type,
457 gboolean active = GPOINTER_TO_INT(val), current; 457 gboolean active = GPOINTER_TO_INT(val), current;
458 458
459 if(!win || !win->window) 459 if(!win || !win->window)
460 return; 460 return;
461 461
462 current = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter)); 462 current = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(win->filter));
463 if(active != current) 463 if(active != current)
464 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(win->filter), active); 464 gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(win->filter), active);
465 } 465 }
466 466
467 static void 467 static void
468 regex_pref_expression_cb(const gchar *name, PurplePrefType type, 468 regex_pref_expression_cb(const gchar *name, PurplePrefType type,
469 gconstpointer val, gpointer data) 469 gconstpointer val, gpointer data)
481 DebugWindow *win = (DebugWindow *)data; 481 DebugWindow *win = (DebugWindow *)data;
482 gboolean active = GPOINTER_TO_INT(val); 482 gboolean active = GPOINTER_TO_INT(val);
483 483
484 win->invert = active; 484 win->invert = active;
485 485
486 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter))) 486 if(gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(win->filter)))
487 regex_filter_all(win); 487 regex_filter_all(win);
488 } 488 }
489 489
490 static void 490 static void
491 regex_pref_highlight_cb(const gchar *name, PurplePrefType type, 491 regex_pref_highlight_cb(const gchar *name, PurplePrefType type,
494 DebugWindow *win = (DebugWindow *)data; 494 DebugWindow *win = (DebugWindow *)data;
495 gboolean active = GPOINTER_TO_INT(val); 495 gboolean active = GPOINTER_TO_INT(val);
496 496
497 win->highlight = active; 497 win->highlight = active;
498 498
499 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter))) 499 if(gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(win->filter)))
500 regex_filter_all(win); 500 regex_filter_all(win);
501 } 501 }
502 502
503 static void 503 static void
504 regex_row_changed_cb(GtkTreeModel *model, GtkTreePath *path, 504 regex_row_changed_cb(GtkTreeModel *model, GtkTreePath *path,
520 return; 520 return;
521 521
522 gtk_tree_model_get(model, iter, 0, &text, 1, &level, -1); 522 gtk_tree_model_get(model, iter, 0, &text, 1, &level, -1);
523 523
524 if (level >= purple_prefs_get_int(PIDGIN_PREFS_ROOT "/debug/filterlevel")) { 524 if (level >= purple_prefs_get_int(PIDGIN_PREFS_ROOT "/debug/filterlevel")) {
525 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter))) { 525 if(gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(win->filter))) {
526 regex_match(win, text); 526 regex_match(win, text);
527 } else { 527 } else {
528 gtk_imhtml_append_text(GTK_IMHTML(win->text), text, 0); 528 gtk_imhtml_append_text(GTK_IMHTML(win->text), text, 0);
529 } 529 }
530 } 530 }
544 return FALSE; 544 return FALSE;
545 } 545 }
546 546
547 static void 547 static void
548 regex_changed_cb(GtkWidget *w, DebugWindow *win) { 548 regex_changed_cb(GtkWidget *w, DebugWindow *win) {
549 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter))) { 549 if(gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(win->filter))) {
550 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(win->filter), 550 gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(win->filter),
551 FALSE); 551 FALSE);
552 } 552 }
553 553
554 if(win->timer == 0) 554 if(win->timer == 0)
555 win->timer = purple_timeout_add_seconds(5, (GSourceFunc)regex_timer_cb, win); 555 win->timer = purple_timeout_add_seconds(5, (GSourceFunc)regex_timer_cb, win);
559 559
560 static void 560 static void
561 regex_key_release_cb(GtkWidget *w, GdkEventKey *e, DebugWindow *win) { 561 regex_key_release_cb(GtkWidget *w, GdkEventKey *e, DebugWindow *win) {
562 if(e->keyval == GDK_Return && 562 if(e->keyval == GDK_Return &&
563 GTK_WIDGET_IS_SENSITIVE(win->filter) && 563 GTK_WIDGET_IS_SENSITIVE(win->filter) &&
564 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter))) 564 !gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(win->filter)))
565 { 565 {
566 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(win->filter), TRUE); 566 gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(win->filter), TRUE);
567 } 567 }
568 } 568 }
569 569
570 static void 570 static void
571 regex_menu_cb(GtkWidget *item, const gchar *pref) { 571 regex_menu_cb(GtkWidget *item, const gchar *pref) {
586 G_CALLBACK(regex_menu_cb), 586 G_CALLBACK(regex_menu_cb),
587 PIDGIN_PREFS_ROOT "/debug/highlight", win->highlight); 587 PIDGIN_PREFS_ROOT "/debug/highlight", win->highlight);
588 } 588 }
589 589
590 static void 590 static void
591 regex_filter_toggled_cb(GtkToggleButton *button, DebugWindow *win) { 591 regex_filter_toggled_cb(GtkToggleToolButton *button, DebugWindow *win) {
592 gboolean active; 592 gboolean active;
593 593
594 active = gtk_toggle_button_get_active(button); 594 active = gtk_toggle_tool_button_get_active(button);
595 595
596 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/debug/filter", active); 596 purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/debug/filter", active);
597 597
598 if(!GTK_IS_IMHTML(win->text)) 598 if(!GTK_IS_IMHTML(win->text))
599 return; 599 return;
609 { 609 {
610 DebugWindow *win = data; 610 DebugWindow *win = data;
611 611
612 if (GPOINTER_TO_INT(value) != gtk_combo_box_get_active(GTK_COMBO_BOX(win->filterlevel))) 612 if (GPOINTER_TO_INT(value) != gtk_combo_box_get_active(GTK_COMBO_BOX(win->filterlevel)))
613 gtk_combo_box_set_active(GTK_COMBO_BOX(win->filterlevel), GPOINTER_TO_INT(value)); 613 gtk_combo_box_set_active(GTK_COMBO_BOX(win->filterlevel), GPOINTER_TO_INT(value));
614 if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter))) 614 if(gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(win->filter)))
615 regex_filter_all(win); 615 regex_filter_all(win);
616 else 616 else
617 regex_show_all(win); 617 regex_show_all(win);
618 } 618 }
619 #endif /* HAVE_REGEX_H */ 619 #endif /* HAVE_REGEX_H */
675 { 675 {
676 DebugWindow *win; 676 DebugWindow *win;
677 GtkWidget *vbox; 677 GtkWidget *vbox;
678 GtkWidget *toolbar; 678 GtkWidget *toolbar;
679 GtkWidget *frame; 679 GtkWidget *frame;
680 GtkWidget *image;
681 gint width, height; 680 gint width, height;
682 void *handle; 681 void *handle;
682 GtkToolItem *item;
683 #if !GTK_CHECK_VERSION(2,12,0)
684 GtkTooltips *tooltips;
685 #endif
683 686
684 win = g_new0(DebugWindow, 1); 687 win = g_new0(DebugWindow, 1);
685 688
686 width = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/debug/width"); 689 width = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/debug/width");
687 height = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/debug/height"); 690 height = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/debug/height");
718 gtk_container_add(GTK_CONTAINER(win->window), vbox); 721 gtk_container_add(GTK_CONTAINER(win->window), vbox);
719 722
720 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/debug/toolbar")) { 723 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/debug/toolbar")) {
721 /* Setup our top button bar thingie. */ 724 /* Setup our top button bar thingie. */
722 toolbar = gtk_toolbar_new(); 725 toolbar = gtk_toolbar_new();
726 #if !GTK_CHECK_VERSION(2,12,0)
727 tooltips = gtk_tooltips_new();
728 #endif
729 #if !GTK_CHECK_VERSION(2,14,0)
723 gtk_toolbar_set_tooltips(GTK_TOOLBAR(toolbar), TRUE); 730 gtk_toolbar_set_tooltips(GTK_TOOLBAR(toolbar), TRUE);
731 #endif
724 gtk_toolbar_set_show_arrow(GTK_TOOLBAR(toolbar), TRUE); 732 gtk_toolbar_set_show_arrow(GTK_TOOLBAR(toolbar), TRUE);
725 g_signal_connect(G_OBJECT(toolbar), "button-press-event", G_CALLBACK(toolbar_context), win); 733 g_signal_connect(G_OBJECT(toolbar), "button-press-event", G_CALLBACK(toolbar_context), win);
726 734
727 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar), 735 gtk_toolbar_set_style(GTK_TOOLBAR(toolbar),
728 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/debug/style")); 736 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/debug/style"));
733 741
734 gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0); 742 gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 0);
735 743
736 #ifndef HAVE_REGEX_H 744 #ifndef HAVE_REGEX_H
737 /* Find button */ 745 /* Find button */
738 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_FIND, 746 item = gtk_tool_button_new_from_stock(GTK_STOCK_FIND);
739 _("Find"), NULL, G_CALLBACK(find_cb), 747 gtk_tool_item_set_is_important(item, TRUE);
740 win, -1); 748 #if GTK_CHECK_VERSION(2,12,0)
749 gtk_tool_item_set_tooltip_text(item, _("Find"));
750 #else
751 gtk_tool_item_set_tooltip(item, tooltips, _("Find"), NULL);
752 #endif
753 g_signal_connect(G_OBJECT(item), "clicked", G_CALLBACK(find_cb), win);
754 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
741 #endif /* HAVE_REGEX_H */ 755 #endif /* HAVE_REGEX_H */
742 756
743 /* Save */ 757 /* Save */
744 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_SAVE, 758 item = gtk_tool_button_new_from_stock(GTK_STOCK_SAVE);
745 _("Save"), NULL, G_CALLBACK(save_cb), 759 gtk_tool_item_set_is_important(item, TRUE);
746 win, -1); 760 #if GTK_CHECK_VERSION(2,12,0)
761 gtk_tool_item_set_tooltip_text(item, _("Save"));
762 #else
763 gtk_tool_item_set_tooltip(item, tooltips, _("Save"), NULL);
764 #endif
765 g_signal_connect(G_OBJECT(item), "clicked", G_CALLBACK(save_cb), win);
766 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
747 767
748 /* Clear button */ 768 /* Clear button */
749 gtk_toolbar_insert_stock(GTK_TOOLBAR(toolbar), GTK_STOCK_CLEAR, 769 item = gtk_tool_button_new_from_stock(GTK_STOCK_CLEAR);
750 _("Clear"), NULL, G_CALLBACK(clear_cb), 770 gtk_tool_item_set_is_important(item, TRUE);
751 win, -1); 771 #if GTK_CHECK_VERSION(2,12,0)
752 772 gtk_tool_item_set_tooltip_text(item, _("Clear"));
753 gtk_toolbar_insert_space(GTK_TOOLBAR(toolbar), -1); 773 #else
774 gtk_tool_item_set_tooltip(item, tooltips, _("Clear"), NULL);
775 #endif
776 g_signal_connect(G_OBJECT(item), "clicked", G_CALLBACK(clear_cb), win);
777 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
778
779 item = gtk_separator_tool_item_new();
780 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
754 781
755 /* Pause */ 782 /* Pause */
756 image = gtk_image_new_from_stock(PIDGIN_STOCK_PAUSE, GTK_ICON_SIZE_MENU); 783 item = gtk_toggle_tool_button_new_from_stock(PIDGIN_STOCK_PAUSE);
757 gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), 784 gtk_tool_item_set_is_important(item, TRUE);
758 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, 785 #if GTK_CHECK_VERSION(2,12,0)
759 NULL, _("Pause"), _("Pause"), 786 gtk_tool_item_set_tooltip_text(item, _("Pause"));
760 NULL, image, 787 #else
761 G_CALLBACK(pause_cb), win); 788 gtk_tool_item_set_tooltip(item, tooltips, _("Pause"), NULL);
789 #endif
790 g_signal_connect(G_OBJECT(item), "clicked", G_CALLBACK(pause_cb), win);
791 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
762 792
763 #ifdef HAVE_REGEX_H 793 #ifdef HAVE_REGEX_H
764 /* regex stuff */ 794 /* regex stuff */
765 gtk_toolbar_insert_space(GTK_TOOLBAR(toolbar), -1); 795 item = gtk_separator_tool_item_new();
796 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
766 797
767 /* regex toggle button */ 798 /* regex toggle button */
768 image = gtk_image_new_from_stock(GTK_STOCK_FIND, GTK_ICON_SIZE_MENU); 799 item = gtk_toggle_tool_button_new_from_stock(GTK_STOCK_FIND);
769 win->filter = 800 gtk_tool_item_set_is_important(item, TRUE);
770 gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), 801 win->filter = GTK_WIDGET(item);
771 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, 802 gtk_tool_button_set_label(GTK_TOOL_BUTTON(win->filter), _("Filter"));
772 NULL, _("Filter"), _("Filter"), 803 #if GTK_CHECK_VERSION(2,12,0)
773 NULL, image, 804 gtk_tool_item_set_tooltip_text(GTK_TOOL_ITEM(win->filter), _("Filter"));
774 G_CALLBACK(regex_filter_toggled_cb), 805 #else
775 win); 806 gtk_tooltips_set_tip(tooltips, win->filter, _("Filter"), NULL);
807 #endif
808 g_signal_connect(G_OBJECT(win->filter), "clicked", G_CALLBACK(regex_filter_toggled_cb), win);
809 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(win->filter));
810
776 /* we purposely disable the toggle button here in case 811 /* we purposely disable the toggle button here in case
777 * /purple/gtk/debug/expression has an empty string. If it does not have 812 * /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 813 * an empty string, the change signal will get called and make the
779 * toggle button sensitive. 814 * toggle button sensitive.
780 */ 815 */
781 gtk_widget_set_sensitive(win->filter, FALSE); 816 gtk_widget_set_sensitive(win->filter, FALSE);
782 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(win->filter), 817 gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(win->filter),
783 purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/debug/filter")); 818 purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/debug/filter"));
784 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/debug/filter", 819 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/debug/filter",
785 regex_pref_filter_cb, win); 820 regex_pref_filter_cb, win);
786 821
787 /* regex entry */ 822 /* regex entry */
788 win->expression = gtk_entry_new(); 823 win->expression = gtk_entry_new();
789 gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), 824 item = gtk_tool_item_new();
790 GTK_TOOLBAR_CHILD_WIDGET, win->expression, 825 #if GTK_CHECK_VERSION(2,12,0)
791 NULL, _("Right click for more options."), 826 gtk_widget_set_tooltip_text(win->expression, _("Right click for more options."));
792 NULL, NULL, NULL, NULL); 827 #else
828 gtk_tooltips_set_tip(tooltips, win->expression, _("Right click for more options."), NULL);
829 #endif
830 gtk_container_add(GTK_CONTAINER(item), GTK_WIDGET(win->expression));
831 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
832
793 /* this needs to be before the text is set from the pref if we want it 833 /* this needs to be before the text is set from the pref if we want it
794 * to colorize a stored expression. 834 * to colorize a stored expression.
795 */ 835 */
796 g_signal_connect(G_OBJECT(win->expression), "changed", 836 g_signal_connect(G_OBJECT(win->expression), "changed",
797 G_CALLBACK(regex_changed_cb), win); 837 G_CALLBACK(regex_changed_cb), win);
813 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/debug/highlight", 853 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/debug/highlight",
814 regex_pref_highlight_cb, win); 854 regex_pref_highlight_cb, win);
815 855
816 #endif /* HAVE_REGEX_H */ 856 #endif /* HAVE_REGEX_H */
817 857
818 gtk_toolbar_insert_space(GTK_TOOLBAR(toolbar), -1); 858 item = gtk_separator_tool_item_new();
819 859 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
820 gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), 860
821 GTK_TOOLBAR_CHILD_WIDGET, gtk_label_new(_("Level ")), 861 item = gtk_tool_item_new();
822 NULL, _("Select the debug filter level."), 862 gtk_container_add(GTK_CONTAINER(item), gtk_label_new(_("Level ")));
823 NULL, NULL, NULL, NULL); 863 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
824 864
825 win->filterlevel = gtk_combo_box_new_text(); 865 win->filterlevel = gtk_combo_box_new_text();
826 gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), 866 item = gtk_tool_item_new();
827 GTK_TOOLBAR_CHILD_WIDGET, win->filterlevel, 867 #if GTK_CHECK_VERSION(2,12,0)
828 NULL, _("Select the debug filter level."), 868 gtk_widget_set_tooltip_text(win->filterlevel, _("Select the debug filter level."));
829 NULL, NULL, NULL, NULL); 869 #else
870 gtk_tooltips_set_tip(tooltips, win->filterlevel, _("Select the debug filter level."), NULL);
871 #endif
872 gtk_container_add(GTK_CONTAINER(item), win->filterlevel);
873 gtk_container_add(GTK_CONTAINER(toolbar), GTK_WIDGET(item));
874
830 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("All")); 875 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("All"));
831 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Misc")); 876 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Misc"));
832 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Info")); 877 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Info"));
833 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Warning")); 878 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Warning"));
834 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Error ")); 879 gtk_combo_box_append_text(GTK_COMBO_BOX(win->filterlevel), _("Error "));