[nautilus/wip/antoniof/gtk4-pre-switch-simplification: 2/4] compress-dialog-controller: Drop signals from UI file




commit ba4688295f05ea8efce7a2870cc2f44981ff60c2
Author: António Fernandes <antoniof gnome org>
Date:   Wed Dec 22 16:52:08 2021 +0000

    compress-dialog-controller: Drop signals from UI file
    
    We have signals defined in the GtkBuilder UI XML file. However, as we
    are not using it as a template (we are not subclassing GtkDialog), we
    still need to manually bind the callback symbols and even explicitly
    bind them with gtk_builder_connect_signals().
    
    In GTK 4 gtk_builder_connect_signals() is gone and the alternative is
    setting the signal data (in this case, 'self') before loading the
    UI definition.
    
    However, we need to load the UI definition before we create 'self',
    because some widgets are requires as construct-only properties. Given
    this circular dependency, doing it the GTK 4 way is impossibile.
    
    Therefore, just connect signals in code and remove them from the UI
    file. This is compatible with GTK 4. And even under GTK 3 its simpler!

 src/nautilus-compress-dialog-controller.c    | 35 +++++++++++++---------------
 src/resources/ui/nautilus-compress-dialog.ui |  8 -------
 2 files changed, 16 insertions(+), 27 deletions(-)
---
diff --git a/src/nautilus-compress-dialog-controller.c b/src/nautilus-compress-dialog-controller.c
index 3f7711ccb..687cb5558 100644
--- a/src/nautilus-compress-dialog-controller.c
+++ b/src/nautilus-compress-dialog-controller.c
@@ -486,25 +486,22 @@ nautilus_compress_dialog_controller_new (GtkWindow         *parent_window,
                                                   (GCallback) compress_dialog_controller_on_response,
                                                   self);
 
-    gtk_builder_add_callback_symbols (builder,
-                                      "zip_row_on_activated",
-                                      G_CALLBACK (zip_row_on_activated),
-                                      "encrypted_zip_row_on_activated",
-                                      G_CALLBACK (encrypted_zip_row_on_activated),
-                                      "tar_xz_row_on_activated",
-                                      G_CALLBACK (tar_xz_row_on_activated),
-                                      "seven_zip_row_on_activated",
-                                      G_CALLBACK (seven_zip_row_on_activated),
-                                      "passphrase_entry_on_changed",
-                                      G_CALLBACK (passphrase_entry_on_changed),
-                                      "passphrase_entry_on_icon_press",
-                                      G_CALLBACK (passphrase_entry_on_icon_press),
-                                      "activate_button_on_sensitive_notify",
-                                      G_CALLBACK (activate_button_on_sensitive_notify),
-                                      "popover_on_show",
-                                      G_CALLBACK (popover_on_show),
-                                      NULL);
-    gtk_builder_connect_signals (builder, self);
+    g_signal_connect (self->zip_row, "activated",
+                      G_CALLBACK (zip_row_on_activated), self);
+    g_signal_connect (self->encrypted_zip_row, "activated",
+                      G_CALLBACK (encrypted_zip_row_on_activated), self);
+    g_signal_connect (self->tar_xz_row, "activated",
+                      G_CALLBACK (tar_xz_row_on_activated), self);
+    g_signal_connect (self->seven_zip_row, "activated",
+                      G_CALLBACK (seven_zip_row_on_activated), self);
+    g_signal_connect (self->passphrase_entry, "changed",
+                      G_CALLBACK (passphrase_entry_on_changed), self);
+    g_signal_connect (self->passphrase_entry, "icon-press",
+                      G_CALLBACK (passphrase_entry_on_icon_press), self);
+    g_signal_connect (self->activate_button, "notify::sensitive",
+                      G_CALLBACK (activate_button_on_sensitive_notify), self);
+    g_signal_connect (self->extension_popover, "show",
+                      G_CALLBACK (popover_on_show), self);
 
     format = g_settings_get_enum (nautilus_compression_preferences,
                                   NAUTILUS_PREFERENCES_DEFAULT_COMPRESSION_FORMAT);
diff --git a/src/resources/ui/nautilus-compress-dialog.ui b/src/resources/ui/nautilus-compress-dialog.ui
index bc4bf1e1b..4ba8236e3 100644
--- a/src/resources/ui/nautilus-compress-dialog.ui
+++ b/src/resources/ui/nautilus-compress-dialog.ui
@@ -2,7 +2,6 @@
 <interface>
   <requires lib="gtk+" version="3.14"/>
   <object class="GtkPopover" id="extension_popover">
-    <signal name="show" handler="popover_on_show"/>
     <property name="position">bottom</property>
     <property name="constrain-to">none</property>
     <child>
@@ -18,7 +17,6 @@
             <property name="activatable">True</property>
             <property name="title" translatable="no">.zip</property>
             <property name="subtitle" translatable="yes">Compatible with all operating systems.</property>
-            <signal name="activated" handler="zip_row_on_activated"/>
             <child>
               <object class="GtkImage" id="zip_checkmark">
                 <property name="visible">True</property>
@@ -35,7 +33,6 @@
             <property name="activatable">True</property>
             <property name="title" translatable="no">.zip</property>
             <property name="subtitle" translatable="yes">Password protected .zip, must be installed on 
Windows and Mac.</property>
-            <signal name="activated" handler="encrypted_zip_row_on_activated"/>
             <style>
               <class name="encrypted_zip"/>
             </style>
@@ -55,7 +52,6 @@
             <property name="activatable">True</property>
             <property name="title" translatable="no">.tar.xz</property>
             <property name="subtitle" translatable="yes">Smaller archives but Linux and Mac only.</property>
-            <signal name="activated" handler="tar_xz_row_on_activated"/>
             <child>
               <object class="GtkImage" id="tar_xz_checkmark">
                 <property name="visible">True</property>
@@ -72,7 +68,6 @@
             <property name="activatable">True</property>
             <property name="title" translatable="no">.7z</property>
             <property name="subtitle" translatable="yes">Smaller archives but must be installed on Windows 
and Mac.</property>
-            <signal name="activated" handler="seven_zip_row_on_activated"/>
             <child>
               <object class="GtkImage" id="seven_zip_checkmark">
                 <property name="visible">True</property>
@@ -215,8 +210,6 @@
             <property name="input-purpose">password</property>
             <property name="visibility">False</property>
             <property name="secondary-icon-name">view-conceal</property>
-            <signal name="changed" handler="passphrase_entry_on_changed"/>
-            <signal name="icon-press" handler="passphrase_entry_on_icon_press"/>
           </object>
           <packing>
             <property name="position">5</property>
@@ -240,7 +233,6 @@
         <property name="can_default">True</property>
         <property name="receives_default">True</property>
         <property name="sensitive">False</property>
-        <signal name="notify::sensitive" handler="activate_button_on_sensitive_notify"/>
       </object>
     </child>
     <action-widgets>


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