[gnome-control-center] applications: Connect signals with g_signal_connect_object in swapped form



commit b4922526c19b11d847119c73bacd5d7168fc53fe
Author: Robert Ancell <robert ancell canonical com>
Date:   Fri Nov 22 12:10:58 2019 +1300

    applications: Connect signals with g_signal_connect_object in swapped form

 panels/applications/cc-applications-panel.c  | 54 ++++++++++++----------------
 panels/applications/cc-applications-panel.ui | 32 ++++++++---------
 2 files changed, 38 insertions(+), 48 deletions(-)
---
diff --git a/panels/applications/cc-applications-panel.c b/panels/applications/cc-applications-panel.c
index eb622d1fc..b1a01568e 100644
--- a/panels/applications/cc-applications-panel.c
+++ b/panels/applications/cc-applications-panel.c
@@ -157,8 +157,7 @@ privacy_link_cb (CcApplicationsPanel *self)
 }
 
 static void
-open_software_cb (GtkButton           *button,
-                  CcApplicationsPanel *self)
+open_software_cb (CcApplicationsPanel *self)
 {
   const gchar *argv[] = { "gnome-software", "--details", "appid", NULL };
 
@@ -701,9 +700,8 @@ add_static_permission_row (CcApplicationsPanel *self,
 }
 
 static void
-permission_row_activated_cb (GtkListBox          *list,
-                             GtkListBoxRow       *list_row,
-                             CcApplicationsPanel *self)
+permission_row_activated_cb (CcApplicationsPanel *self,
+                             GtkListBoxRow       *list_row)
 {
   if (list_row == GTK_LIST_BOX_ROW (self->builtin))
     {
@@ -883,8 +881,8 @@ update_integration_section (CcApplicationsPanel *self,
 /* --- handler section --- */
 
 static void
-unset_cb (CcActionRow         *row,
-          CcApplicationsPanel *self)
+unset_cb (CcApplicationsPanel *self,
+          CcActionRow         *row)
 {
   const gchar *type;
   GtkListBoxRow *selected;
@@ -952,7 +950,7 @@ add_scheme (CcApplicationsPanel *self,
   g_signal_connect_object (row,
                            "activated",
                            G_CALLBACK (unset_cb),
-                           self, 0);
+                           self, G_CONNECT_SWAPPED);
 
   if (after)
     {
@@ -985,7 +983,7 @@ add_file_type (CcApplicationsPanel *self,
   cc_action_row_set_subtitle (row, glob ? glob : "");
   cc_action_row_set_action (row, _("Unset"), TRUE);
   g_object_set_data_full (G_OBJECT (row), "type", g_strdup (type), g_free);
-  g_signal_connect (row, "activated", G_CALLBACK (unset_cb), self);
+  g_signal_connect_object (row, "activated", G_CALLBACK (unset_cb), self, G_CONNECT_SWAPPED);
 
   if (after)
     {
@@ -1252,9 +1250,8 @@ add_handler_row (CcApplicationsPanel *self,
 }
 
 static void
-handler_row_activated_cb (GtkListBox          *list,
-                          GtkListBoxRow       *list_row,
-                          CcApplicationsPanel *self)
+handler_row_activated_cb (CcApplicationsPanel *self,
+                          GtkListBoxRow       *list_row)
 {
   CcInfoRow *row;
 
@@ -1302,8 +1299,7 @@ app_info_recommended_for (GAppInfo    *info,
 }
 
 static void
-handler_reset_cb (GtkButton           *button,
-                  CcApplicationsPanel *self)
+handler_reset_cb (CcApplicationsPanel *self)
 {
   GtkListBoxRow *selected;
   GAppInfo *info;
@@ -1378,9 +1374,8 @@ update_handler_sections (CcApplicationsPanel *self,
 /* --- usage section --- */
 
 static void
-storage_row_activated_cb (GtkListBox          *list,
-                          GtkListBoxRow       *list_row,
-                          CcApplicationsPanel *self)
+storage_row_activated_cb (CcApplicationsPanel *self,
+                          GtkListBoxRow       *list_row)
 {
   if (list_row == GTK_LIST_BOX_ROW (self->storage))
     {
@@ -1646,16 +1641,14 @@ filter_sidebar_rows (GtkListBoxRow *row,
 }
 
 static void
-apps_changed (GAppInfoMonitor     *monitor,
-              CcApplicationsPanel *self)
+apps_changed (CcApplicationsPanel *self)
 {
   populate_applications (self);
 }
 
 static void
-row_activated_cb (GtkListBox          *list,
-                  GtkListBoxRow       *row,
-                  CcApplicationsPanel *self)
+row_activated_cb (CcApplicationsPanel *self,
+                  GtkListBoxRow       *row)
 {
   update_panel (self, row);
   g_signal_emit_by_name (self, "sidebar-activated");
@@ -1705,8 +1698,7 @@ select_app (CcApplicationsPanel *self,
 }
 
 static void
-on_sidebar_search_entry_activated_cb (GtkSearchEntry      *search_entry,
-                                      CcApplicationsPanel *self)
+on_sidebar_search_entry_activated_cb (CcApplicationsPanel *self)
 {
   GtkListBoxRow *row;
 
@@ -1725,15 +1717,13 @@ on_sidebar_search_entry_activated_cb (GtkSearchEntry      *search_entry,
 }
 
 static void
-on_sidebar_search_entry_search_changed_cb (GtkSearchEntry      *search_entry,
-                                           CcApplicationsPanel *self)
+on_sidebar_search_entry_search_changed_cb (CcApplicationsPanel *self)
 {
   gtk_list_box_invalidate_filter (self->sidebar_listbox);
 }
 
 static void
-on_sidebar_search_entry_search_stopped_cb (GtkSearchEntry      *search_entry,
-                                           CcApplicationsPanel *self)
+on_sidebar_search_entry_search_stopped_cb (CcApplicationsPanel *self)
 {
   gtk_entry_set_text (self->sidebar_search_entry, "");
 }
@@ -1930,10 +1920,10 @@ cc_applications_panel_init (CcApplicationsPanel *self)
                                              provider,
                                              GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
 
-  g_signal_connect (self->sidebar_listbox, "row-activated",
-                    G_CALLBACK (row_activated_cb), self);
+  g_signal_connect_object (self->sidebar_listbox, "row-activated",
+                           G_CALLBACK (row_activated_cb), self, G_CONNECT_SWAPPED);
 
-  g_signal_connect (self->header_button, "clicked", G_CALLBACK (open_software_cb), self);
+  g_signal_connect_object (self->header_button, "clicked", G_CALLBACK (open_software_cb), self, 
G_CONNECT_SWAPPED);
 
   gtk_list_box_set_header_func (self->permission_list,
                                 cc_list_box_update_header_func,
@@ -1974,7 +1964,7 @@ cc_applications_panel_init (CcApplicationsPanel *self)
   populate_applications (self);
 
   self->monitor = g_app_info_monitor_get ();
-  self->monitor_id = g_signal_connect (self->monitor, "changed", G_CALLBACK (apps_changed), self);
+  self->monitor_id = g_signal_connect_object (self->monitor, "changed", G_CALLBACK (apps_changed), self, 
G_CONNECT_SWAPPED);
 
   g_dbus_proxy_new_for_bus (G_BUS_TYPE_SESSION,
                             G_DBUS_PROXY_FLAGS_NONE,
diff --git a/panels/applications/cc-applications-panel.ui b/panels/applications/cc-applications-panel.ui
index 8be041bdf..98eff3039 100644
--- a/panels/applications/cc-applications-panel.ui
+++ b/panels/applications/cc-applications-panel.ui
@@ -61,7 +61,7 @@
                         <property name="can-focus">1</property>
                         <property name="receives-default">1</property>
                         <property name="halign">center</property>
-                        <signal name="clicked" handler="open_software_cb"/>
+                        <signal name="clicked" handler="open_software_cb" object="CcApplicationsPanel" 
swapped="yes"/>
                       </object>
                       <packing>
                         <property name="fill">0</property>
@@ -117,11 +117,11 @@
                           <object class="GtkListBox" id="permission_list">
                             <property name="visible">1</property>
                             <property name="selection-mode">none</property>
-                            <signal name="row-activated" handler="permission_row_activated_cb"/>
+                            <signal name="row-activated" handler="permission_row_activated_cb" 
object="CcApplicationsPanel" swapped="yes"/>
                             <child>
                               <object class="CcToggleRow" id="camera">
                                 <property name="title" translatable="yes">Camera</property>
-                                <signal name="notify::allowed" handler="camera_cb" swapped="yes"/>
+                                <signal name="notify::allowed" handler="camera_cb" 
object="CcApplicationsPanel" swapped="yes"/>
                               </object>
                             </child>
                             <child>
@@ -133,7 +133,7 @@
                             <child>
                               <object class="CcToggleRow" id="microphone">
                                 <property name="title" translatable="yes">Microphone</property>
-                                <signal name="notify::allowed" handler="microphone_cb" swapped="yes"/>
+                                <signal name="notify::allowed" handler="microphone_cb" 
object="CcApplicationsPanel" swapped="yes"/>
                               </object>
                             </child>
                             <child>
@@ -145,7 +145,7 @@
                             <child>
                               <object class="CcToggleRow" id="location">
                                 <property name="title" translatable="yes">Location Services</property>
-                                <signal name="notify::allowed" handler="location_cb" swapped="yes"/>
+                                <signal name="notify::allowed" handler="location_cb" 
object="CcApplicationsPanel" swapped="yes"/>
                               </object>
                             </child>
                             <child>
@@ -176,7 +176,7 @@
                             <property name="max-width-chars">50</property>
                             <property name="label" translatable="yes">Individual permissions for 
applications can be reviewed in the &lt;a href=&quot;privacy&quot;&gt;Privacy&lt;/a&gt; Settings.</property>
                             <property name="use-markup">1</property>
-                            <signal name="activate-link" handler="privacy_link_cb" swapped="yes"/>
+                            <signal name="activate-link" handler="privacy_link_cb" 
object="CcApplicationsPanel" swapped="yes"/>
                           </object>
                         </child>
                       </object>
@@ -225,7 +225,7 @@
                             <child>
                               <object class="CcToggleRow" id="search">
                                 <property name="title" translatable="yes">Search</property>
-                                <signal name="notify::allowed" handler="search_cb" swapped="yes"/>
+                                <signal name="notify::allowed" handler="search_cb" 
object="CcApplicationsPanel" swapped="yes"/>
                               </object>
                             </child>
                             <child>
@@ -237,7 +237,7 @@
                             <child>
                               <object class="CcToggleRow" id="notification">
                                 <property name="title" translatable="yes">Notifications</property>
-                                <signal name="notify::allowed" handler="notification_cb" swapped="yes"/>
+                                <signal name="notify::allowed" handler="notification_cb" 
object="CcApplicationsPanel" swapped="yes"/>
                               </object>
                             </child>
                             <child>
@@ -255,7 +255,7 @@
                             <child>
                               <object class="CcToggleRow" id="sound">
                                 <property name="title" translatable="yes">Sounds</property>
-                                <signal name="notify::allowed" handler="sound_cb" swapped="yes"/>
+                                <signal name="notify::allowed" handler="sound_cb" 
object="CcApplicationsPanel" swapped="yes"/>
                               </object>
                             </child>
                             <child>
@@ -322,7 +322,7 @@
                                 <property name="halign">end</property>
                                 <property name="valign">center</property>
                                 <property name="label" translatable="yes">Reset</property>
-                                <signal name="clicked" handler="handler_reset_cb"/>
+                                <signal name="clicked" handler="handler_reset_cb" 
object="CcApplicationsPanel" swapped="yes"/>
                               </object>
                             </child>
                           </object>
@@ -331,7 +331,7 @@
                           <object class="GtkListBox" id="handler_list">
                             <property name="visible">1</property>
                             <property name="selection-mode">none</property>
-                            <signal name="row-activated" handler="handler_row_activated_cb"/>
+                            <signal name="row-activated" handler="handler_row_activated_cb" 
object="CcApplicationsPanel" swapped="yes"/>
                             <style>
                               <class name="view"/>
                               <class name="frame"/>
@@ -381,7 +381,7 @@
                           <object class="GtkListBox" id="usage_list">
                             <property name="visible">1</property>
                             <property name="selection-mode">none</property>
-                            <signal name="row-activated" handler="storage_row_activated_cb"/>
+                            <signal name="row-activated" handler="storage_row_activated_cb" 
object="CcApplicationsPanel" swapped="yes"/>
                             <child>
                               <object class="CcInfoRow" id="storage">
                                 <property name="title" translatable="yes">Storage</property>
@@ -430,9 +430,9 @@
         <property name="has-focus">True</property>
         <property name="margin">12</property>
         <property name="margin-bottom">6</property>
-        <signal name="activate" handler="on_sidebar_search_entry_activated_cb" object="CcApplicationsPanel" 
swapped="no" />
-        <signal name="search-changed" handler="on_sidebar_search_entry_search_changed_cb" 
object="CcApplicationsPanel" swapped="no" />
-        <signal name="stop-search" handler="on_sidebar_search_entry_search_stopped_cb" 
object="CcApplicationsPanel" swapped="no" />
+        <signal name="activate" handler="on_sidebar_search_entry_activated_cb" object="CcApplicationsPanel" 
swapped="yes" />
+        <signal name="search-changed" handler="on_sidebar_search_entry_search_changed_cb" 
object="CcApplicationsPanel" swapped="yes" />
+        <signal name="stop-search" handler="on_sidebar_search_entry_search_stopped_cb" 
object="CcApplicationsPanel" swapped="yes" />
       </object>
     </child>
     <child>
@@ -590,7 +590,7 @@
               <object class="GtkButton" id="clear_cache_button">
                 <property name="visible">1</property>
                 <property name="label" translatable="yes">Clear Cacheā€¦</property>
-                <signal name="clicked" handler="clear_cache_cb" swapped="yes"/>
+                <signal name="clicked" handler="clear_cache_cb" object="CcApplicationsPanel" swapped="yes"/>
               </object>
               <packing>
                 <property name="pack-type">end</property>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]