# HG changeset patch
# Node ID a2d5a3663c16
# Parent  d9bf1d3a62f1
diff --git a/pidgin/pidgindebug.c b/pidgin/pidgindebug.c
--- a/pidgin/pidgindebug.c
+++ b/pidgin/pidgindebug.c
@@ -101,11 +101,14 @@ debug_window_destroy(GtkWidget *w, GdkEv
 }
 
 static gboolean
-configure_cb(GtkWidget *w, GdkEventConfigure *event, void *unused)
+save_default_size_cb(GObject *gobject, G_GNUC_UNUSED GParamSpec *pspec,
+                     G_GNUC_UNUSED gpointer data)
 {
-	if (gtk_widget_get_visible(w)) {
-		purple_prefs_set_int(PIDGIN_PREFS_ROOT "/debug/width",  event->width);
-		purple_prefs_set_int(PIDGIN_PREFS_ROOT "/debug/height", event->height);
+	if (gtk_widget_get_visible(GTK_WIDGET(gobject))) {
+		gint width, height;
+		gtk_window_get_default_size(GTK_WINDOW(gobject), &width, &height);
+		purple_prefs_set_int(PIDGIN_PREFS_ROOT "/debug/width",  width);
+		purple_prefs_set_int(PIDGIN_PREFS_ROOT "/debug/height", height);
 	}
 
 	return FALSE;
@@ -159,7 +162,7 @@ clear_cb(GtkWidget *w, PidginDebugWindow
 static void
 pause_cb(GtkWidget *w, PidginDebugWindow *win)
 {
-	win->paused = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(w));
+	win->paused = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(w));
 
 	if (!win->paused) {
 		GtkTextIter start, end;
@@ -291,9 +294,10 @@ regex_pref_filter_cb(const gchar *name, 
 	if (!win)
 		return;
 
-	current = gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(win->filter));
-	if (active != current)
-		gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(win->filter), active);
+	current = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter));
+	if (active != current) {
+		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(win->filter), active);
+	}
 }
 
 static void
@@ -315,8 +319,9 @@ regex_pref_invert_cb(const gchar *name, 
 
 	win->invert = active;
 
-	if (gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(win->filter)))
+	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter))) {
 		regex_toggle_filter(win, TRUE);
+	}
 }
 
 static void
@@ -328,17 +333,17 @@ regex_pref_highlight_cb(const gchar *nam
 
 	win->highlight = active;
 
-	if (gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(win->filter)))
+	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter))) {
 		regex_toggle_filter(win, TRUE);
+	}
 }
 
 static void
 regex_changed_cb(GtkWidget *w, PidginDebugWindow *win) {
 	const gchar *text;
 
-	if (gtk_toggle_tool_button_get_active(GTK_TOGGLE_TOOL_BUTTON(win->filter))) {
-		gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(win->filter),
-									 FALSE);
+	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(win->filter))) {
+		gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(win->filter), FALSE);
 	}
 
 	text = gtk_editable_get_text(GTK_EDITABLE(win->expression));
@@ -367,18 +372,21 @@ regex_changed_cb(GtkWidget *w, PidginDeb
 }
 
 static void
-regex_key_release_cb(GtkWidget *w, GdkEventKey *e, PidginDebugWindow *win) {
+regex_key_released_cb(G_GNUC_UNUSED GtkEventControllerKey *controller,
+                      guint keyval, G_GNUC_UNUSED guint keycode,
+                      G_GNUC_UNUSED GdkModifierType state, gpointer data)
+{
+	PidginDebugWindow *win = data;
+
 	if (gtk_widget_is_sensitive(win->filter)) {
-		GtkToggleToolButton *tb = GTK_TOGGLE_TOOL_BUTTON(win->filter);
-		if ((e->keyval == GDK_KEY_Return || e->keyval == GDK_KEY_KP_Enter) &&
-			!gtk_toggle_tool_button_get_active(tb))
+		GtkToggleButton *tb = GTK_TOGGLE_BUTTON(win->filter);
+		if ((keyval == GDK_KEY_Return || keyval == GDK_KEY_KP_Enter) &&
+			!gtk_toggle_button_get_active(tb))
 		{
-			gtk_toggle_tool_button_set_active(tb, TRUE);
+			gtk_toggle_button_set_active(tb, TRUE);
 		}
-		if (e->keyval == GDK_KEY_Escape &&
-			gtk_toggle_tool_button_get_active(tb))
-		{
-			gtk_toggle_tool_button_set_active(tb, FALSE);
+		if (keyval == GDK_KEY_Escape && gtk_toggle_button_get_active(tb)) {
+			gtk_toggle_button_set_active(tb, FALSE);
 		}
 	}
 }
@@ -397,6 +405,8 @@ regex_menu_cb(GtkWidget *item, PidginDeb
 	}
 }
 
+#if 0
+/* FIXME: may not work with GTK4's SearchEntry */
 static void
 regex_popup_cb(GtkEntry *entry, GtkEntryIconPosition icon_pos, GdkEvent *event,
 		PidginDebugWindow *win)
@@ -410,13 +420,14 @@ regex_popup_cb(GtkEntry *entry, GtkEntry
 	gtk_popover_set_pointing_to(GTK_POPOVER(win->popover), &rect);
 	gtk_popover_popup(GTK_POPOVER(win->popover));
 }
+#endif
 
 static void
-regex_filter_toggled_cb(GtkToggleToolButton *button, PidginDebugWindow *win)
+regex_filter_toggled_cb(GtkToggleButton *button, PidginDebugWindow *win)
 {
 	gboolean active;
 
-	active = gtk_toggle_tool_button_get_active(button);
+	active = gtk_toggle_button_get_active(button);
 
 	purple_prefs_set_bool(PIDGIN_PREFS_ROOT "/debug/filter", active);
 
@@ -516,10 +527,12 @@ pidgin_debug_window_class_init(PidginDeb
 			regex_filter_toggled_cb);
 	gtk_widget_class_bind_template_callback(widget_class,
 			regex_changed_cb);
+#if 0
 	gtk_widget_class_bind_template_callback(widget_class, regex_popup_cb);
+#endif
 	gtk_widget_class_bind_template_callback(widget_class, regex_menu_cb);
 	gtk_widget_class_bind_template_callback(widget_class,
-			regex_key_release_cb);
+			regex_key_released_cb);
 	gtk_widget_class_bind_template_callback(widget_class,
 			filter_level_changed_cb);
 }
@@ -546,8 +559,10 @@ pidgin_debug_window_init(PidginDebugWind
 
 	g_signal_connect(G_OBJECT(win), "delete_event",
 	                 G_CALLBACK(debug_window_destroy), NULL);
-	g_signal_connect(G_OBJECT(win), "configure_event",
-	                 G_CALLBACK(configure_cb), NULL);
+	g_signal_connect(G_OBJECT(win), "notify::default-width",
+	                 G_CALLBACK(save_default_size_cb), NULL);
+	g_signal_connect(G_OBJECT(win), "notify::default-height",
+	                 G_CALLBACK(save_default_size_cb), NULL);
 
 	handle = pidgin_debug_get_handle();
 
@@ -559,8 +574,8 @@ pidgin_debug_window_init(PidginDebugWind
 		 * toggle button sensitive.
 		 */
 		gtk_widget_set_sensitive(win->filter, FALSE);
-		gtk_toggle_tool_button_set_active(GTK_TOGGLE_TOOL_BUTTON(win->filter),
-									 purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/debug/filter"));
+		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);
 
@@ -811,7 +826,7 @@ void
 pidgin_debug_window_hide(void)
 {
 	if (debug_win != NULL) {
-		gtk_widget_destroy(GTK_WIDGET(debug_win));
+		gtk_window_destroy(GTK_WINDOW(debug_win));
 		debug_window_destroy(NULL, NULL, NULL);
 	}
 }
diff --git a/pidgin/resources/Debug/debug.ui b/pidgin/resources/Debug/debug.ui
--- a/pidgin/resources/Debug/debug.ui
+++ b/pidgin/resources/Debug/debug.ui
@@ -1,6 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.38.2 
-
+<!--
 Pidgin - Internet Messenger
 Copyright (C) Pidgin Developers <devel@pidgin.im>
 
@@ -15,9 +14,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICU
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
-
+along with this library; if not, see <https://www.gnu.org/licenses/>.
 -->
 <!--
                                ▀
@@ -46,8 +43,8 @@ With this:
 
     <child type="tag">
       <object class="GtkTextTag" id="tags.filtered_visible">
-        <property name="invisible">False</property>
-        <property name="invisible-set">True</property>
+        <property name="invisible">0</property>
+        <property name="invisible-set">1</property>
       </object>
     </child>
 
@@ -64,7 +61,7 @@ funky is going on. The raw text is below
 
 -->
 <interface>
-  <requires lib="gtk+" version="3.22"/>
+  <requires lib="gtk" version="4.0"/>
   <!-- interface-license-type gplv2 -->
   <!-- interface-name Pidgin -->
   <!-- interface-description Internet Messenger -->
@@ -108,13 +105,13 @@ funky is going on. The raw text is below
     </child>
     <child type="tag">
       <object class="GtkTextTag" id="tags.filtered_invisible">
-        <property name="invisible">True</property>
+        <property name="invisible">1</property>
       </object>
     </child>
     <child type="tag">
       <object class="GtkTextTag" id="tags.filtered_visible">
-        <property name="invisible">False</property>
-        <property name="invisible-set">True</property>
+        <property name="invisible">0</property>
+        <property name="invisible-set">1</property>
       </object>
     </child>
     <child type="tag">
@@ -125,7 +122,7 @@ funky is going on. The raw text is below
     </child>
     <child type="tag">
       <object class="GtkTextTag" id="tags.paused">
-        <property name="invisible">True</property>
+        <property name="invisible">1</property>
       </object>
     </child>
   </object>
@@ -133,252 +130,141 @@ funky is going on. The raw text is below
     <property name="tag-table">message-format</property>
   </object>
   <template class="PidginDebugWindow" parent="GtkWindow">
-    <property name="can-focus">False</property>
     <property name="title" translatable="yes">Debug Window</property>
-    <child>
+    <property name="child">
       <object class="GtkBox">
-        <property name="visible">True</property>
-        <property name="can-focus">False</property>
         <property name="orientation">vertical</property>
         <child>
-          <object class="GtkToolbar" id="toolbar">
-            <property name="visible">True</property>
-            <property name="can-focus">False</property>
-            <property name="icon_size">2</property>
+          <object class="GtkBox" id="toolbar">
+            <style>
+              <class name="toolbar"/>
+            </style>
             <child>
-              <object class="GtkToolButton" id="save">
-                <property name="visible">True</property>
-                <property name="can-focus">False</property>
+              <object class="GtkButton" id="save">
                 <property name="tooltip-text" translatable="yes">Save</property>
-                <property name="is-important">True</property>
                 <property name="label" translatable="yes">_Save...</property>
-                <property name="use-underline">True</property>
+                <property name="use-underline">1</property>
                 <property name="icon-name">document-save</property>
                 <signal name="clicked" handler="save_cb" object="PidginDebugWindow" swapped="no"/>
               </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="homogeneous">True</property>
-              </packing>
             </child>
             <child>
-              <object class="GtkToolButton" id="clear">
-                <property name="visible">True</property>
-                <property name="can-focus">False</property>
+              <object class="GtkButton" id="clear">
                 <property name="tooltip-text" translatable="yes">Clear</property>
-                <property name="is-important">True</property>
                 <property name="label" translatable="yes">_Clear</property>
-                <property name="use-underline">True</property>
+                <property name="use-underline">1</property>
                 <property name="icon-name">edit-clear</property>
                 <signal name="clicked" handler="clear_cb" object="PidginDebugWindow" swapped="no"/>
               </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="homogeneous">True</property>
-              </packing>
             </child>
             <child>
-              <object class="GtkSeparatorToolItem">
-                <property name="visible">True</property>
-                <property name="can-focus">False</property>
+              <object class="GtkSeparator">
+                <property name="orientation">vertical</property>
               </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="homogeneous">True</property>
-              </packing>
             </child>
             <child>
-              <object class="GtkToggleToolButton" id="pause">
-                <property name="visible">True</property>
-                <property name="can-focus">False</property>
+              <object class="GtkToggleButton" id="pause">
                 <property name="tooltip-text" translatable="yes">Pause</property>
-                <property name="is-important">True</property>
                 <property name="label" translatable="yes">_Pause</property>
-                <property name="use-underline">True</property>
+                <property name="use-underline">1</property>
                 <property name="icon-name">media-playback-pause</property>
                 <signal name="clicked" handler="pause_cb" object="PidginDebugWindow" swapped="no"/>
               </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="homogeneous">True</property>
-              </packing>
             </child>
             <child>
-              <object class="GtkSeparatorToolItem">
-                <property name="visible">True</property>
-                <property name="can-focus">False</property>
+              <object class="GtkSeparator">
+                <property name="orientation">vertical</property>
               </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="homogeneous">True</property>
-              </packing>
             </child>
             <child>
-              <object class="GtkToggleToolButton" id="filter">
-                <property name="visible">True</property>
-                <property name="can-focus">False</property>
+              <object class="GtkToggleButton" id="filter">
                 <property name="tooltip-text" translatable="yes">Filter</property>
-                <property name="is-important">True</property>
                 <property name="label" translatable="yes">_Filter</property>
-                <property name="use-underline">True</property>
+                <property name="use-underline">1</property>
                 <property name="icon-name">edit-find</property>
                 <signal name="clicked" handler="regex_filter_toggled_cb" object="PidginDebugWindow" swapped="no"/>
               </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="homogeneous">True</property>
-              </packing>
             </child>
             <child>
-              <object class="GtkToolItem">
-                <property name="visible">True</property>
-                <property name="can-focus">False</property>
+              <object class="GtkSearchEntry" id="expression">
                 <child>
-                  <object class="GtkSearchEntry" id="expression">
-                    <property name="visible">True</property>
-                    <property name="can-focus">True</property>
-                    <property name="primary-icon-name">edit-find-symbolic</property>
-                    <property name="primary-icon-activatable">True</property>
-                    <property name="primary-icon-sensitive">True</property>
-                    <property name="primary-icon-tooltip-text" translatable="yes">Click for more options.</property>
-                    <signal name="icon-press" handler="regex_popup_cb" object="PidginDebugWindow" swapped="no"/>
-                    <signal name="key-release-event" handler="regex_key_release_cb" object="PidginDebugWindow" swapped="no"/>
-                    <signal name="search-changed" handler="regex_changed_cb" object="PidginDebugWindow" swapped="no"/>
+                  <object class="GtkEventControllerKey">
+                    <signal name="key-released" handler="regex_key_released_cb" object="PidginDebugWindow" swapped="no"/>
                   </object>
                 </child>
+                <property name="focusable">1</property>
+                <property name="primary-icon-tooltip-text" translatable="yes">Click for more options.</property>
+                <!--<signal name="icon-press" handler="regex_popup_cb" object="PidginDebugWindow" swapped="no"/>-->
+                <property name="sensitive">0</property>
+                <signal name="search-changed" handler="regex_changed_cb" object="PidginDebugWindow" swapped="no"/>
               </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="homogeneous">True</property>
-              </packing>
             </child>
             <child>
-              <object class="GtkSeparatorToolItem">
-                <property name="visible">True</property>
-                <property name="can-focus">False</property>
+              <object class="GtkSeparator">
+                <property name="orientation">vertical</property>
               </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="homogeneous">True</property>
-              </packing>
             </child>
             <child>
-              <object class="GtkToolItem">
-                <property name="visible">True</property>
-                <property name="can-focus">False</property>
-                <child>
-                  <object class="GtkLabel">
-                    <property name="visible">True</property>
-                    <property name="can-focus">False</property>
-                    <property name="label" translatable="yes">Level </property>
-                    <accessibility>
-                      <relation type="label-for" target="filterlevel"/>
-                    </accessibility>
-                  </object>
-                </child>
+              <object class="GtkLabel">
+                <property name="label" translatable="yes">Level </property>
+                <accessibility>
+                  <relation type="label-for" target="filterlevel"/>
+                </accessibility>
               </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="homogeneous">True</property>
-              </packing>
             </child>
             <child>
-              <object class="GtkToolItem">
-                <property name="visible">True</property>
-                <property name="can-focus">False</property>
-                <child>
-                  <object class="GtkComboBoxText" id="filterlevel">
-                    <property name="visible">True</property>
-                    <property name="can-focus">False</property>
-                    <property name="tooltip-text" translatable="yes">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"/>
-                  </object>
-                </child>
+            <object class="GtkComboBoxText" id="filterlevel">
+                <property name="tooltip-text" translatable="yes">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"/>
               </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="homogeneous">True</property>
-              </packing>
             </child>
           </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">0</property>
-          </packing>
         </child>
         <child>
           <object class="GtkScrolledWindow">
-            <property name="visible">True</property>
-            <property name="can-focus">True</property>
-            <property name="shadow-type">in</property>
-            <child>
+            <property name="vexpand">1</property>
+            <property name="focusable">1</property>
+            <property name="child">
               <object class="GtkTextView" id="textview">
-                <property name="visible">True</property>
-                <property name="can-focus">True</property>
-                <property name="editable">False</property>
+                <property name="focusable">1</property>
+                <property name="editable">0</property>
                 <property name="wrap-mode">word</property>
                 <property name="buffer">buffer</property>
               </object>
-            </child>
+            </property>
           </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="position">1</property>
-          </packing>
         </child>
       </object>
-    </child>
+    </property>
   </template>
   <object class="GtkPopover" id="popover">
-    <property name="can-focus">False</property>
-    <property name="relative-to">expression</property>
-    <child>
+    <property name="child">
       <object class="GtkBox">
-        <property name="visible">True</property>
-        <property name="can-focus">False</property>
         <property name="orientation">vertical</property>
         <child>
           <object class="GtkCheckButton" id="popover_invert">
             <property name="label" translatable="yes">Invert</property>
-            <property name="visible">True</property>
-            <property name="can-focus">True</property>
-            <property name="receives-default">False</property>
-            <property name="draw-indicator">True</property>
+            <property name="focusable">1</property>
             <signal name="toggled" handler="regex_menu_cb" object="PidginDebugWindow" swapped="no"/>
           </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">0</property>
-          </packing>
         </child>
         <child>
           <object class="GtkCheckButton" id="popover_highlight">
             <property name="label" translatable="yes">Highlight matches</property>
-            <property name="visible">True</property>
-            <property name="can-focus">True</property>
-            <property name="receives-default">False</property>
-            <property name="draw-indicator">True</property>
+            <property name="focusable">1</property>
             <signal name="toggled" handler="regex_menu_cb" object="PidginDebugWindow" swapped="no"/>
           </object>
-          <packing>
-            <property name="expand">False</property>
-            <property name="fill">True</property>
-            <property name="position">1</property>
-          </packing>
         </child>
       </object>
-    </child>
+    </property>
   </object>
 </interface>
