| 393 |
391 |
| 394 static void |
392 static void |
| 395 regex_menu_cb(GtkWidget *item, const gchar *pref) { |
393 regex_menu_cb(GtkWidget *item, const gchar *pref) { |
| 396 gboolean active; |
394 gboolean active; |
| 397 |
395 |
| 398 #if GTK_CHECK_VERSION(3,12,0) |
|
| 399 active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(item)); |
396 active = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(item)); |
| 400 #else |
|
| 401 active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(item)); |
|
| 402 #endif |
|
| 403 |
397 |
| 404 purple_prefs_set_bool(pref, active); |
398 purple_prefs_set_bool(pref, active); |
| 405 } |
399 } |
| 406 |
400 |
| 407 static void |
401 static void |
| 408 regex_popup_cb(GtkEntry *entry, GtkEntryIconPosition icon_pos, GdkEvent *event, |
402 regex_popup_cb(GtkEntry *entry, GtkEntryIconPosition icon_pos, GdkEvent *event, |
| 409 PidginDebugWindow *win) |
403 PidginDebugWindow *win) |
| 410 { |
404 { |
| 411 #if GTK_CHECK_VERSION(3,12,0) |
|
| 412 GdkRectangle rect; |
405 GdkRectangle rect; |
| 413 gtk_entry_get_icon_area(entry, icon_pos, &rect); |
406 gtk_entry_get_icon_area(entry, icon_pos, &rect); |
| 414 gtk_popover_set_pointing_to(GTK_POPOVER(win->popover), &rect); |
407 gtk_popover_set_pointing_to(GTK_POPOVER(win->popover), &rect); |
| 415 #if GTK_CHECK_VERSION(3,22,0) |
408 #if GTK_CHECK_VERSION(3,22,0) |
| 416 gtk_popover_popup(GTK_POPOVER(win->popover)); |
409 gtk_popover_popup(GTK_POPOVER(win->popover)); |
| 417 #else |
410 #else |
| 418 gtk_widget_show(win->popover); |
411 gtk_widget_show(win->popover); |
| 419 #endif |
|
| 420 #else |
|
| 421 GtkWidget *menu; |
|
| 422 |
|
| 423 menu = gtk_menu_new(); |
|
| 424 pidgin_new_check_item(menu, _("Invert"), |
|
| 425 G_CALLBACK(regex_menu_cb), |
|
| 426 PIDGIN_PREFS_ROOT "/debug/invert", win->invert); |
|
| 427 pidgin_new_check_item(menu, _("Highlight matches"), |
|
| 428 G_CALLBACK(regex_menu_cb), |
|
| 429 PIDGIN_PREFS_ROOT "/debug/highlight", win->highlight); |
|
| 430 |
|
| 431 #if GTK_CHECK_VERSION(3,22,0) |
|
| 432 gtk_menu_popup_at_widget(GTK_MENU(menu), GTK_WIDGET(entry), |
|
| 433 GDK_GRAVITY_SOUTH_WEST, GDK_GRAVITY_NORTH_WEST, event); |
|
| 434 #else |
|
| 435 gtk_menu_popup_at_pointer(GTK_MENU(menu), event); |
|
| 436 #endif |
|
| 437 #endif |
412 #endif |
| 438 } |
413 } |
| 439 |
414 |
| 440 static void |
415 static void |
| 441 regex_filter_toggled_cb(GtkToggleToolButton *button, PidginDebugWindow *win) |
416 regex_filter_toggled_cb(GtkToggleToolButton *button, PidginDebugWindow *win) |
| 605 "color: @question_fg_color;" |
580 "color: @question_fg_color;" |
| 606 "text-shadow: 0 1px @question_text_shadow;" |
581 "text-shadow: 0 1px @question_text_shadow;" |
| 607 "background-image: none;" |
582 "background-image: none;" |
| 608 "background-color: @success_color;" |
583 "background-color: @success_color;" |
| 609 "}"; |
584 "}"; |
| 610 #if GTK_CHECK_VERSION(3,12,0) |
|
| 611 GtkBuilder *builder; |
585 GtkBuilder *builder; |
| 612 GtkWidget *popover_invert; |
586 GtkWidget *popover_invert; |
| 613 GtkWidget *popover_highlight; |
587 GtkWidget *popover_highlight; |
| 614 #endif |
|
| 615 |
588 |
| 616 gtk_widget_init_template(GTK_WIDGET(win)); |
589 gtk_widget_init_template(GTK_WIDGET(win)); |
| 617 |
590 |
| 618 width = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/debug/width"); |
591 width = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/debug/width"); |
| 619 height = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/debug/height"); |
592 height = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/debug/height"); |
| 674 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/debug/filterlevel")); |
647 purple_prefs_get_int(PIDGIN_PREFS_ROOT "/debug/filterlevel")); |
| 675 |
648 |
| 676 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/debug/filterlevel", |
649 purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/debug/filterlevel", |
| 677 filter_level_pref_changed, win); |
650 filter_level_pref_changed, win); |
| 678 |
651 |
| 679 #if GTK_CHECK_VERSION(3,12,0) |
|
| 680 builder = gtk_builder_new_from_resource( |
652 builder = gtk_builder_new_from_resource( |
| 681 "/im/pidgin/Pidgin/Debug/filter-popover.ui"); |
653 "/im/pidgin/Pidgin/Debug/filter-popover.ui"); |
| 682 win->popover = GTK_WIDGET(gtk_builder_get_object(builder, |
654 win->popover = GTK_WIDGET(gtk_builder_get_object(builder, |
| 683 "popover")); |
655 "popover")); |
| 684 gtk_popover_set_relative_to(GTK_POPOVER(win->popover), |
656 gtk_popover_set_relative_to(GTK_POPOVER(win->popover), |
| 699 g_signal_connect(G_OBJECT(popover_highlight), "toggled", |
671 g_signal_connect(G_OBJECT(popover_highlight), "toggled", |
| 700 G_CALLBACK(regex_menu_cb), |
672 G_CALLBACK(regex_menu_cb), |
| 701 PIDGIN_PREFS_ROOT "/debug/highlight"); |
673 PIDGIN_PREFS_ROOT "/debug/highlight"); |
| 702 |
674 |
| 703 g_object_unref(builder); |
675 g_object_unref(builder); |
| 704 #endif |
|
| 705 } |
676 } |
| 706 |
677 |
| 707 /* The *start* and *end* marks bound the beginning and end of an |
678 /* The *start* and *end* marks bound the beginning and end of an |
| 708 insertion, used for filtering. The *end* mark is also used for |
679 insertion, used for filtering. The *end* mark is also used for |
| 709 auto-scrolling. */ |
680 auto-scrolling. */ |