Port prefs to AdwSwitchRow

Tue, 15 Oct 2024 00:47:42 -0500

author
Elliott Sales de Andrade <quantum.analyst@gmail.com>
date
Tue, 15 Oct 2024 00:47:42 -0500
changeset 43011
ce3144e2bc33
parent 43010
9a3485b096c8
child 43012
e34bd482a051

Port prefs to AdwSwitchRow

Now that we depend on Adwaita 1.4, we can flip the switch on using these (pun intended).

This also simplifies some extra tracking we needed to do for activations and focus, since the Adwaita widgets do that for us.

Testing Done:
Opened prefs, confirmed all the switches were there, and toggled them all without any warnings.

Also used the mnemonics to toggle the switches from the keyboard.

Reviewed at https://reviews.imfreedom.org/r/3582/

pidgin/prefs/pidginconversationprefs.c file | annotate | diff | comparison | revisions
pidgin/prefs/pidginnetworkprefs.c file | annotate | diff | comparison | revisions
pidgin/resources/Prefs/away.ui file | annotate | diff | comparison | revisions
pidgin/resources/Prefs/conversation.ui file | annotate | diff | comparison | revisions
pidgin/resources/Prefs/network.ui file | annotate | diff | comparison | revisions
--- a/pidgin/prefs/pidginconversationprefs.c	Tue Oct 15 00:03:58 2024 -0500
+++ b/pidgin/prefs/pidginconversationprefs.c	Tue Oct 15 00:47:42 2024 -0500
@@ -38,7 +38,6 @@
 		GtkWidget *send_typing;
 	} im;
 	struct {
-		GtkWidget *blink_im_row;
 		GtkWidget *blink_im;
 	} win32;
 	GtkWidget *minimum_entry_lines;
@@ -68,9 +67,6 @@
 			im.send_typing);
 	gtk_widget_class_bind_template_child(
 			widget_class, PidginConversationPrefs,
-			win32.blink_im_row);
-	gtk_widget_class_bind_template_child(
-			widget_class, PidginConversationPrefs,
 			win32.blink_im);
 	gtk_widget_class_bind_template_child(
 			widget_class, PidginConversationPrefs,
@@ -100,7 +96,7 @@
 	pidgin_prefs_bind_switch(PIDGIN_PREFS_ROOT "/win32/blink_im",
 	                         prefs->win32.blink_im);
 #else
-	gtk_widget_set_visible(prefs->win32.blink_im_row, FALSE);
+	gtk_widget_set_visible(prefs->win32.blink_im, FALSE);
 #endif
 
 	pidgin_prefs_bind_spin_button(
--- a/pidgin/prefs/pidginnetworkprefs.c	Tue Oct 15 00:03:58 2024 -0500
+++ b/pidgin/prefs/pidginnetworkprefs.c	Tue Oct 15 00:47:42 2024 -0500
@@ -33,7 +33,6 @@
 	AdwPreferencesPage parent;
 
 	GtkWidget *stun_server;
-	GtkWidget *auto_ip_row;
 	GtkWidget *auto_ip;
 	GtkWidget *public_ip;
 	GtkWidget *map_ports;
@@ -91,7 +90,7 @@
 	}
 
 	auto_ip_text = g_strdup_printf(_("Use _automatically detected IP address: %s"), ip);
-	adw_preferences_row_set_title(ADW_PREFERENCES_ROW(prefs->auto_ip_row),
+	adw_preferences_row_set_title(ADW_PREFERENCES_ROW(prefs->auto_ip),
 	                              auto_ip_text);
 	g_free(auto_ip_text);
 	g_list_free_full(list, g_free);
@@ -114,8 +113,6 @@
 	gtk_widget_class_bind_template_child(widget_class, PidginNetworkPrefs,
 	                                     stun_server);
 	gtk_widget_class_bind_template_child(widget_class, PidginNetworkPrefs,
-	                                     auto_ip_row);
-	gtk_widget_class_bind_template_child(widget_class, PidginNetworkPrefs,
 	                                     auto_ip);
 	gtk_widget_class_bind_template_child(widget_class, PidginNetworkPrefs,
 	                                     public_ip);
--- a/pidgin/resources/Prefs/away.ui	Tue Oct 15 00:03:58 2024 -0500
+++ b/pidgin/resources/Prefs/away.ui	Tue Oct 15 00:47:42 2024 -0500
@@ -127,16 +127,9 @@
       <object class="AdwPreferencesGroup">
         <property name="title" translatable="1">Status at Startup</property>
         <child>
-          <object class="AdwActionRow">
-            <property name="activatable-widget">startup_current_status</property>
+          <object class="AdwSwitchRow" id="startup_current_status">
             <property name="title" translatable="1">Use status from last _exit at startup</property>
             <property name="use-underline">1</property>
-            <child>
-              <object class="GtkSwitch" id="startup_current_status">
-                <property name="focusable">1</property>
-                <property name="valign">center</property>
-              </object>
-            </child>
           </object>
         </child>
         <child>
--- a/pidgin/resources/Prefs/conversation.ui	Tue Oct 15 00:03:58 2024 -0500
+++ b/pidgin/resources/Prefs/conversation.ui	Tue Oct 15 00:47:42 2024 -0500
@@ -36,42 +36,21 @@
       <object class="AdwPreferencesGroup">
         <property name="title" translatable="1">Conversations</property>
         <child>
-          <object class="AdwActionRow">
-            <property name="activatable-widget">show_incoming_formatting</property>
+          <object class="AdwSwitchRow" id="show_incoming_formatting">
             <property name="title" translatable="1">Show _formatting on incoming messages</property>
             <property name="use-underline">1</property>
-            <child>
-              <object class="GtkSwitch" id="show_incoming_formatting">
-                <property name="focusable">1</property>
-                <property name="valign">center</property>
-              </object>
-            </child>
           </object>
         </child>
         <child>
-          <object class="AdwActionRow">
-            <property name="activatable-widget">im.send_typing</property>
+          <object class="AdwSwitchRow" id="im.send_typing">
             <property name="title" translatable="1">_Notify buddies that you are typing to them</property>
             <property name="use-underline">1</property>
-            <child>
-              <object class="GtkSwitch" id="im.send_typing">
-                <property name="focusable">1</property>
-                <property name="valign">center</property>
-              </object>
-            </child>
           </object>
         </child>
         <child>
-          <object class="AdwActionRow" id="win32.blink_im_row">
-            <property name="activatable-widget">win32.blink_im</property>
+          <object class="AdwSwitchRow" id="win32.blink_im">
             <property name="title" translatable="1">F_lash window when IMs are received</property>
             <property name="use-underline">1</property>
-            <child>
-              <object class="GtkSwitch" id="win32.blink_im">
-                <property name="focusable">1</property>
-                <property name="valign">center</property>
-              </object>
-            </child>
           </object>
         </child>
         <child>
--- a/pidgin/resources/Prefs/network.ui	Tue Oct 15 00:03:58 2024 -0500
+++ b/pidgin/resources/Prefs/network.ui	Tue Oct 15 00:47:42 2024 -0500
@@ -45,18 +45,10 @@
           </object>
         </child>
         <child>
-          <object class="AdwActionRow" id="auto_ip_row">
-            <property name="activatable-widget">auto_ip</property>
+          <object class="AdwSwitchRow" id="auto_ip">
             <property name="title" translatable="1">Use _automatically detected IP address</property>
             <property name="use-underline">1</property>
-            <property name="focusable">0</property>
-            <child>
-              <object class="GtkSwitch" id="auto_ip">
-                <property name="focusable">1</property>
-                <property name="valign">center</property>
-                <signal name="notify::active" handler="auto_ip_button_clicked_cb" after="yes" swapped="no"/>
-              </object>
-            </child>
+            <signal name="notify::active" handler="auto_ip_button_clicked_cb" after="yes" swapped="no"/>
           </object>
         </child>
         <child>
@@ -73,17 +65,9 @@
       <object class="AdwPreferencesGroup">
         <property name="title" translatable="1">Ports</property>
         <child>
-          <object class="AdwActionRow">
-            <property name="activatable-widget">map_ports</property>
+          <object class="AdwSwitchRow" id="map_ports">
             <property name="title" translatable="1">_Enable automatic router port forwarding</property>
             <property name="use-underline">1</property>
-            <property name="focusable">0</property>
-            <child>
-              <object class="GtkSwitch" id="map_ports">
-                <property name="focusable">1</property>
-                <property name="valign">center</property>
-              </object>
-            </child>
           </object>
         </child>
         <child>

mercurial