[rygel: 5/6] ui: don't lose the interface setting



commit 4f37dc3aee12c270d155a82961f37bab11cc8e11
Author: Andreas Henriksson <andreas fatal se>
Date:   Sat May 18 13:10:52 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 d0b440a..0c4d8d5 100644
--- a/src/ui/rygel-network-pref-section.vala
+++ b/src/ui/rygel-network-pref-section.vala
@@ -42,9 +42,11 @@ public class Rygel.NetworkPrefSection : PreferencesSection {
         try {
             var interfaces = config.get_interfaces ();
             if (interfaces != null) {
+                int num_items;
+
                 this.iface_entry.append_text (interfaces[0]);
-                // 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
@@ -106,4 +108,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]