[rygel/rygel-0-18] ui: don't lose the interface setting



commit 8c21ad9b5f152a1509c23bdd00b5f09a04854ea3
Author: Andreas Henriksson <andreas fatal se>
Date:   Sat May 18 13:18:49 2013 +0200

    ui: don't lose the interface setting
    
    Just opening and closing rygel-preferences would result in
    the interface setting getting set to blank in the configuration.
    Fixing the TODO item in the source to set the active interface
    (last added item) was all that was needed.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=700570

 src/ui/rygel-network-pref-section.vala |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/src/ui/rygel-network-pref-section.vala b/src/ui/rygel-network-pref-section.vala
index f6dc1a0..77b7cf4 100644
--- a/src/ui/rygel-network-pref-section.vala
+++ b/src/ui/rygel-network-pref-section.vala
@@ -40,9 +40,11 @@ public class Rygel.NetworkPrefSection : PreferencesSection {
         this.context_manager = ContextManager.create (0);
 
         try {
+            int num_items;
+
             this.iface_entry.append_text (config.get_interface ());
-            // TODO: Set the current interface to be active.
-            this.iface_entry.set_active (0);
+            num_items = this.count_items (this.iface_entry.model);
+            this.iface_entry.set_active (num_items - 1);
         } catch (GLib.Error err) {
             // No problem if we fail to read the config, the default values
             // will do just fine. Same goes for rest of the keys.
@@ -103,4 +105,17 @@ public class Rygel.NetworkPrefSection : PreferencesSection {
 
         return more;
     }
+
+    private int count_items (TreeModel model) {
+        TreeIter iter;
+        int count = 0;
+        var more = model.get_iter_first (out iter);
+
+        while (more) {
+            count++;
+            more = model.iter_next (ref iter);
+        }
+
+        return count;
+    }
 }


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