[gnome-clocks/wip/geolocation] Add automatic locatios on position one



commit 2fb766d37b9677d0ca65eb41dbc35700702f3bf1
Author: Evgeny Bobkin <evgen ibqn gmail com>
Date:   Mon Aug 26 23:33:50 2013 +0200

    Add automatic locatios on position one

 src/widgets.vala |   11 +++++++++++
 src/world.vala   |    7 ++++---
 2 files changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/src/widgets.vala b/src/widgets.vala
index 26350da..c88ed4a 100644
--- a/src/widgets.vala
+++ b/src/widgets.vala
@@ -359,6 +359,13 @@ private class IconView : Gtk.IconView {
         store.set (i, Column.SELECTED, false, Column.ITEM, item);
     }
 
+    public void add_first (Object item) {
+        var store = (Gtk.ListStore) model;
+        Gtk.TreeIter i;
+        store.insert (out i, 0);
+        store.set (i, Column.SELECTED, false, Column.ITEM, item);
+    }
+
     // Redefine selection handling methods since we handle selection manually
 
     public new List<Gtk.TreePath> get_selected_items () {
@@ -584,6 +591,10 @@ public class ContentView : Gtk.Bin {
         icon_view.add_item (item);
     }
 
+    public void add_first (ContentItem item) {
+        icon_view.add_first (item);
+    }
+
     // Note: this is not efficient: we first walk the model to collect
     // a list then the caller has to walk this list and then it has to
     // delete the items from the view, which walks the model again...
diff --git a/src/world.vala b/src/world.vala
index 158fad1..7336d21 100644
--- a/src/world.vala
+++ b/src/world.vala
@@ -350,7 +350,7 @@ public class MainPanel : Gtk.Stack, Clocks.Clock {
         }
         settings.set_value ("world-clocks", builder.end ());
     }
-    
+
     private async void use_geolocation () {
         GeoInfo.LocationInfo? geo_location = null;
         GWeather.Location? found_location = null;
@@ -374,12 +374,13 @@ public class MainPanel : Gtk.Stack, Clocks.Clock {
                     not_included = false;
                 }
             }
-            
+
             if (not_included) {
                 var item = new Item (found_location);
+
                 item.automatic = true;
                 locations.append (item);
-                content_view.add_item (item);
+                content_view.add_first (item);
             }
         }
     }


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