pidgin/pidgin

Modernize debug window a little

21 months ago, Elliott Sales de Andrade
eaf836c5f87b
Parents ff6dff2228e1
Children f7af70658fe5
Modernize debug window a little

Convert `GtkComboBox` to `GtkDropDown`.

Drop the `toolbar` pref, as it was not being used (and hiding the toolbar would make for a somewhat useless window anyway).

Inline the tag table, as `` can now contain children, and drop unused `id`s.

Testing Done:
Opened debug window, picked different filter levels, and typed in a regex or two.

Reviewed at https://reviews.imfreedom.org/r/1715/
--- a/pidgin/pidgindebug.c Mon Sep 05 20:14:00 2022 -0500
+++ b/pidgin/pidgindebug.c Mon Sep 05 20:22:34 2022 -0500
@@ -42,7 +42,6 @@
struct _PidginDebugWindow {
GtkWindow parent;
- GtkWidget *toolbar;
GtkWidget *textview;
GtkTextBuffer *buffer;
GtkTextMark *start_mark;
@@ -236,8 +235,9 @@
GtkTextIter match_start, match_end;
gchar *text;
- if (!win->regex)
+ if (!win->regex) {
return;
+ }
initial_position = gtk_text_iter_get_offset(start);
@@ -320,8 +320,9 @@
PidginDebugWindow *win = (PidginDebugWindow *)data;
gboolean active = GPOINTER_TO_INT(val), current;
- if (!win)
+ if (!win) {
return;
+ }
current = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter));
if (active != current) {
@@ -374,8 +375,7 @@
return;
}
- if (win->regex)
- g_regex_unref(win->regex);
+ g_clear_pointer(&win->regex, g_regex_unref);
win->regex = g_regex_new(text, G_REGEX_CASELESS|G_REGEX_JAVASCRIPT_COMPAT, 0, NULL);
@@ -453,8 +453,9 @@
gboolean scroll;
int i;
- if (level != gtk_combo_box_get_active(GTK_COMBO_BOX(win->filterlevel)))
- gtk_combo_box_set_active(GTK_COMBO_BOX(win->filterlevel), level);
+ if (level != gtk_drop_down_get_selected(GTK_DROP_DOWN(win->filterlevel))) {
+ gtk_drop_down_set_selected(GTK_DROP_DOWN(win->filterlevel), level);
+ }
scroll = view_near_bottom(win);
for (i = 0; i <= PURPLE_DEBUG_FATAL; i++) {
@@ -478,10 +479,12 @@
}
static void
-filter_level_changed_cb(GtkWidget *combo, gpointer null)
+filter_level_changed_cb(GObject *obj, G_GNUC_UNUSED GParamSpec *pspec)
{
+ GtkDropDown *dropdown = GTK_DROP_DOWN(obj);
+
purple_prefs_set_int(PIDGIN_PREFS_ROOT "/debug/filterlevel",
- gtk_combo_box_get_active(GTK_COMBO_BOX(combo)));
+ gtk_drop_down_get_selected(dropdown));
}
static void
@@ -523,8 +526,6 @@
);
gtk_widget_class_bind_template_child(
- widget_class, PidginDebugWindow, toolbar);
- gtk_widget_class_bind_template_child(
widget_class, PidginDebugWindow, textview);
gtk_widget_class_bind_template_child(
widget_class, PidginDebugWindow, buffer);
@@ -603,43 +604,40 @@
handle = pidgin_debug_get_handle();
- /* Setup our top button bar thingie. */
- if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/debug/toolbar")) {
- /* we purposely disable the toggle button here in case
- * /purple/gtk/debug/expression has an empty string. If it does not have
- * an empty string, the change signal will get called and make the
- * toggle button sensitive.
- */
- gtk_widget_set_sensitive(win->filter, FALSE);
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(win->filter),
- purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/debug/filter"));
- purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/debug/filter",
- regex_pref_filter_cb, win);
+ /* we purposely disable the toggle button here in case
+ * /purple/gtk/debug/expression has an empty string. If it does not have
+ * an empty string, the change signal will get called and make the
+ * toggle button sensitive.
+ */
+ gtk_widget_set_sensitive(win->filter, FALSE);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(win->filter),
+ purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/debug/filter"));
+ purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/debug/filter",
+ regex_pref_filter_cb, win);
- /* regex entry */
- gtk_editable_set_text(GTK_EDITABLE(win->expression),
- purple_prefs_get_string(PIDGIN_PREFS_ROOT "/debug/regex"));
+ /* regex entry */
+ gtk_editable_set_text(GTK_EDITABLE(win->expression),
+ purple_prefs_get_string(PIDGIN_PREFS_ROOT "/debug/regex"));
- /* connect the rest of our pref callbacks */
- win->invert = purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/debug/invert");
- purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/debug/invert",
- regex_pref_invert_cb, win);
+ /* connect the rest of our pref callbacks */
+ win->invert = purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/debug/invert");
+ purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/debug/invert",
+ regex_pref_invert_cb, win);
- win->highlight = purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/debug/highlight");
- purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/debug/highlight",
- regex_pref_highlight_cb, win);
+ win->highlight = purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/debug/highlight");
+ purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/debug/highlight",
+ regex_pref_highlight_cb, win);
- gtk_combo_box_set_active(GTK_COMBO_BOX(win->filterlevel),
- purple_prefs_get_int(PIDGIN_PREFS_ROOT "/debug/filterlevel"));
-
- purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/debug/filterlevel",
- filter_level_pref_changed, win);
+ gtk_drop_down_set_selected(GTK_DROP_DOWN(win->filterlevel),
+ purple_prefs_get_int(PIDGIN_PREFS_ROOT "/debug/filterlevel"));
- gtk_check_button_set_active(GTK_CHECK_BUTTON(win->popover_invert),
- win->invert);
- gtk_check_button_set_active(GTK_CHECK_BUTTON(win->popover_highlight),
- win->highlight);
- }
+ purple_prefs_connect_callback(handle, PIDGIN_PREFS_ROOT "/debug/filterlevel",
+ filter_level_pref_changed, win);
+
+ gtk_check_button_set_active(GTK_CHECK_BUTTON(win->popover_invert),
+ win->invert);
+ gtk_check_button_set_active(GTK_CHECK_BUTTON(win->popover_highlight),
+ win->highlight);
/* The *start* and *end* marks bound the beginning and end of an
insertion, used for filtering. The *end* mark is also used for
@@ -887,7 +885,6 @@
purple_prefs_add_int(PIDGIN_PREFS_ROOT "/debug/filterlevel",
PURPLE_DEBUG_ALL);
- purple_prefs_add_bool(PIDGIN_PREFS_ROOT "/debug/toolbar", TRUE);
purple_prefs_add_int(PIDGIN_PREFS_ROOT "/debug/width", 450);
purple_prefs_add_int(PIDGIN_PREFS_ROOT "/debug/height", 250);
--- a/pidgin/resources/Debug/debug.ui Mon Sep 05 20:14:00 2022 -0500
+++ b/pidgin/resources/Debug/debug.ui Mon Sep 05 20:22:34 2022 -0500
@@ -66,68 +66,69 @@
<!-- interface-name Pidgin -->
<!-- interface-description Internet Messenger -->
<!-- interface-copyright Pidgin Developers <devel@pidgin.im> -->
- <object class="GtkTextTagTable" id="message-format">
- <child type="tag">
- <object class="GtkTextTag" id="tags.level[0]">
- <property name="foreground">rgb(0,0,0)</property>
- </object>
- </child>
- <child type="tag">
- <object class="GtkTextTag" id="tags.level[1]">
- <property name="foreground">rgb(102,102,102)</property>
- </object>
- </child>
- <child type="tag">
- <object class="GtkTextTag" id="tags.level[2]">
- <property name="foreground">rgb(0,0,0)</property>
- </object>
- </child>
- <child type="tag">
- <object class="GtkTextTag" id="tags.level[3]">
- <property name="foreground">rgb(102,0,0)</property>
- </object>
- </child>
- <child type="tag">
- <object class="GtkTextTag" id="tags.level[4]">
- <property name="foreground">rgb(255,0,0)</property>
- </object>
- </child>
- <child type="tag">
- <object class="GtkTextTag" id="tags.level[5]">
- <property name="foreground">rgb(255,0,0)</property>
- <property name="weight">700</property>
+ <object class="GtkTextBuffer" id="buffer">
+ <property name="tag-table">
+ <object class="GtkTextTagTable">
+ <child type="tag">
+ <object class="GtkTextTag" id="tags.level[0]">
+ <property name="foreground">rgb(0,0,0)</property>
+ </object>
+ </child>
+ <child type="tag">
+ <object class="GtkTextTag" id="tags.level[1]">
+ <property name="foreground">rgb(102,102,102)</property>
+ </object>
+ </child>
+ <child type="tag">
+ <object class="GtkTextTag" id="tags.level[2]">
+ <property name="foreground">rgb(0,0,0)</property>
+ </object>
+ </child>
+ <child type="tag">
+ <object class="GtkTextTag" id="tags.level[3]">
+ <property name="foreground">rgb(102,0,0)</property>
+ </object>
+ </child>
+ <child type="tag">
+ <object class="GtkTextTag" id="tags.level[4]">
+ <property name="foreground">rgb(255,0,0)</property>
+ </object>
+ </child>
+ <child type="tag">
+ <object class="GtkTextTag" id="tags.level[5]">
+ <property name="foreground">rgb(255,0,0)</property>
+ <property name="weight">700</property>
+ </object>
+ </child>
+ <child type="tag">
+ <object class="GtkTextTag" id="tags.category">
+ <property name="weight">700</property>
+ </object>
+ </child>
+ <child type="tag">
+ <object class="GtkTextTag" id="tags.filtered_invisible">
+ <property name="invisible">1</property>
+ </object>
+ </child>
+ <child type="tag">
+ <object class="GtkTextTag" id="tags.filtered_visible">
+ <property name="invisible">0</property>
+ <property name="invisible-set">1</property>
+ </object>
+ </child>
+ <child type="tag">
+ <object class="GtkTextTag" id="tags.match">
+ <property name="background">rgb(255,175,175)</property>
+ <property name="weight">700</property>
+ </object>
+ </child>
+ <child type="tag">
+ <object class="GtkTextTag" id="tags.paused">
+ <property name="invisible">1</property>
+ </object>
+ </child>
</object>
- </child>
- <child type="tag">
- <object class="GtkTextTag" id="tags.category">
- <property name="weight">700</property>
- </object>
- </child>
- <child type="tag">
- <object class="GtkTextTag" id="tags.filtered_invisible">
- <property name="invisible">1</property>
- </object>
- </child>
- <child type="tag">
- <object class="GtkTextTag" id="tags.filtered_visible">
- <property name="invisible">0</property>
- <property name="invisible-set">1</property>
- </object>
- </child>
- <child type="tag">
- <object class="GtkTextTag" id="tags.match">
- <property name="background">rgb(255,175,175)</property>
- <property name="weight">700</property>
- </object>
- </child>
- <child type="tag">
- <object class="GtkTextTag" id="tags.paused">
- <property name="invisible">1</property>
- </object>
- </child>
- </object>
- <object class="GtkTextBuffer" id="buffer">
- <property name="tag-table">message-format</property>
+ </property>
</object>
<template class="PidginDebugWindow" parent="GtkWindow">
<property name="title" translatable="1">Debug Window</property>
@@ -137,12 +138,10 @@
<object class="GtkBox">
<property name="orientation">vertical</property>
<child>
- <object class="GtkBox" id="toolbar">
- <style>
- <class name="toolbar"/>
- </style>
+ <object class="GtkBox">
+ <property name="css-classes">toolbar</property>
<child>
- <object class="GtkButton" id="save">
+ <object class="GtkButton">
<property name="tooltip-text" translatable="1">Save</property>
<property name="label" translatable="1">_Save...</property>
<property name="use-underline">1</property>
@@ -151,7 +150,7 @@
</object>
</child>
<child>
- <object class="GtkButton" id="clear">
+ <object class="GtkButton">
<property name="tooltip-text" translatable="1">Clear</property>
<property name="label" translatable="1">_Clear</property>
<property name="use-underline">1</property>
@@ -165,7 +164,7 @@
</object>
</child>
<child>
- <object class="GtkToggleButton" id="pause">
+ <object class="GtkToggleButton">
<property name="tooltip-text" translatable="1">Pause</property>
<property name="label" translatable="1">_Pause</property>
<property name="use-underline">1</property>
@@ -215,18 +214,22 @@
</object>
</child>
<child>
- <object class="GtkComboBoxText" id="filterlevel">
+ <object class="GtkDropDown" id="filterlevel">
<property name="tooltip-text" translatable="1">Select the debug filter level.</property>
- <property name="active">0</property>
- <items>
- <item translatable="yes">All</item>
- <item translatable="yes">Misc</item>
- <item translatable="yes">Info</item>
- <item translatable="yes">Warning</item>
- <item translatable="yes">Error</item>
- <item translatable="yes">Fatal Error</item>
- </items>
- <signal name="changed" handler="filter_level_changed_cb" object="PidginDebugWindow" swapped="no"/>
+ <property name="selected">0</property>
+ <property name="model">
+ <object class="GtkStringList">
+ <items>
+ <item translatable="yes">All</item>
+ <item translatable="yes">Misc</item>
+ <item translatable="yes">Info</item>
+ <item translatable="yes">Warning</item>
+ <item translatable="yes">Error</item>
+ <item translatable="yes">Fatal Error</item>
+ </items>
+ </object>
+ </property>
+ <signal name="notify::selected" handler="filter_level_changed_cb" object="PidginDebugWindow" swapped="no"/>
<accessibility>
<relation name="labelled-by">filterlevel-label</relation>
</accessibility>