ui: Don't use signal autoconnection magic
authorZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Thu, 4 Jun 2009 11:42:23 +0000 (14:42 +0300)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Thu, 4 Jun 2009 11:42:23 +0000 (14:42 +0300)
Vala currently doesn't support automatic signal connection to handlers in
multiple classes.

data/rygel-preferences.ui
src/ui/rygel-folder-pref-section.vala
src/ui/rygel-general-pref-section.vala

index e6b0e6a..aaf115b 100644 (file)
@@ -64,7 +64,6 @@
                             <property name="receives_default">False</property>
                             <property name="use_underline">True</property>
                             <property name="draw_indicator">True</property>
-                            <signal name="toggled" handler="rygel_general_pref_section_on_trans_check_toggled"/>
                           </object>
                           <packing>
                             <property name="y_options"></property>
                                 <property name="receives_default">True</property>
                                 <property name="use_underline">True</property>
                                 <property name="use_stock">True</property>
-                                <signal name="clicked" handler="rygel_folder_pref_section_on_add_button_clicked"/>
                               </object>
                               <packing>
                                 <property name="position">0</property>
                                 <property name="can_focus">True</property>
                                 <property name="receives_default">True</property>
                                 <property name="use_stock">True</property>
-                                <signal name="clicked" handler="rygel_folder_pref_section_on_remove_button_clicked"/>
                               </object>
                               <packing>
                                 <property name="position">1</property>
                                 <property name="receives_default">True</property>
                                 <property name="use_underline">True</property>
                                 <property name="use_stock">True</property>
-                                <signal name="clicked" handler="rygel_folder_pref_section_on_clear_button_clicked"/>
                               </object>
                               <packing>
                                 <property name="position">2</property>
     <property name="type_hint">dialog</property>
     <property name="transient_for">preferences-dialog</property>
     <property name="has_separator">False</property>
+    <property name="local_only">False</property>
     <property name="select_multiple">True</property>
     <property name="action">select-folder</property>
-    <property name="local_only">False</property>
     <child internal-child="vbox">
       <object class="GtkVBox" id="dialog-vbox2">
         <property name="visible">True</property>
index 344f212..9c4790f 100644 (file)
@@ -29,6 +29,9 @@ public class Rygel.FolderPrefSection : Rygel.PluginPrefSection {
     const string FOLDERS_TEXTVIEW = FOLDERS_KEY + "-treeview";
     const string FOLDERS_LISTSTORE = FOLDERS_KEY + "-liststore";
     const string FOLDERS_DIALOG = FOLDERS_KEY + "-dialog";
+    const string ADD_BUTTON = "add-button";
+    const string REMOVE_BUTTON = "remove-button";
+    const string CLEAR_BUTTON = "clear-button";
 
     private TreeView treeview;
     private ListStore liststore;
@@ -60,7 +63,14 @@ public class Rygel.FolderPrefSection : Rygel.PluginPrefSection {
             this.liststore.set (iter, 0, folder, -1);
         }
 
-        builder.connect_signals (this);
+        var button = (Button) builder.get_object (ADD_BUTTON);
+        button.clicked += this.on_add_button_clicked;
+
+        button = (Button) builder.get_object (REMOVE_BUTTON);
+        button.clicked += this.on_remove_button_clicked;
+
+        button = (Button) builder.get_object (CLEAR_BUTTON);
+        button.clicked += this.on_clear_button_clicked;
     }
 
     public override void save () {
@@ -88,8 +98,7 @@ public class Rygel.FolderPrefSection : Rygel.PluginPrefSection {
         this.treeview.sensitive = enabled_check.active;
     }
 
-    [CCode (instance_pos = -1)]
-    public void on_add_button_clicked (Button button) {
+    private void on_add_button_clicked (Button button) {
         if (this.dialog.run () == ResponseType.OK) {
             TreeIter iter;
 
@@ -104,8 +113,7 @@ public class Rygel.FolderPrefSection : Rygel.PluginPrefSection {
         this.dialog.hide ();
     }
 
-    [CCode (instance_pos = -1)]
-    public void on_remove_button_clicked (Button button) {
+    private void on_remove_button_clicked (Button button) {
         var selection = this.treeview.get_selection ();
         var rows = selection.get_selected_rows (null);
 
@@ -126,8 +134,7 @@ public class Rygel.FolderPrefSection : Rygel.PluginPrefSection {
         }
     }
 
-    [CCode (instance_pos = -1)]
-    public void on_clear_button_clicked (Button button) {
+    private void on_clear_button_clicked (Button button) {
         this.liststore.clear ();
     }
 }
index e9e65ab..7eccc43 100644 (file)
@@ -66,7 +66,7 @@ public class Rygel.GeneralPrefSection : PreferencesSection {
         this.mp2ts_check.active = this.config.mp2ts_transcoder;
         this.lpcm_check.active = this.config.lpcm_transcoder;
 
-        builder.connect_signals (this);
+        this.trans_check.toggled += this.on_trans_check_toggled;
     }
 
     public override void save () {
@@ -79,8 +79,7 @@ public class Rygel.GeneralPrefSection : PreferencesSection {
         this.config.lpcm_transcoder = this.lpcm_check.active;
     }
 
-    [CCode (instance_pos = -1)]
-    public void on_trans_check_toggled (CheckButton trans_check) {
+    private void on_trans_check_toggled (CheckButton trans_check) {
         this.mp3_check.sensitive =
         this.mp2ts_check.sensitive =
         this.lpcm_check.sensitive = trans_check.active;