[gnome-clocks/wip/vala] Remove world clocks



commit 3d3406b10b028467c572c3817dbeb9ee582d4ddf
Author: Paolo Borelli <pborelli gnome org>
Date:   Sun Feb 17 15:59:37 2013 +0100

    Remove world clocks

 src/widgets.vala |   10 ++++++++++
 src/world.vala   |   12 ++++++++++++
 2 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/src/widgets.vala b/src/widgets.vala
index 528169f..b9ad14e 100644
--- a/src/widgets.vala
+++ b/src/widgets.vala
@@ -319,6 +319,16 @@ public class IconView : Gtk.IconView {
         });
         selection_changed ();
     }
+
+    public void remove_selected () {
+        foreach (Gtk.TreePath path in get_selected_items ()) {
+            Gtk.TreeIter i;
+            if (((Gtk.ListStore) model).get_iter (out i, path)) {
+                ((Gtk.ListStore) model).remove (i);
+            }
+        }
+        selection_changed ();
+    }
 }
 
 public class ContentView : Gtk.Bin {
diff --git a/src/world.vala b/src/world.vala
index a6f06c2..d722069 100644
--- a/src/world.vala
+++ b/src/world.vala
@@ -279,6 +279,18 @@ public class MainPanel : Gd.Stack, Clocks.Clock {
         add (content_view);
 
         content_view.delete_selected.connect (() => {
+            // FIXME: this is not efficient, but we have few itesm and
+            // we are probably going to drop the TreeModel soon
+            foreach (Gtk.TreePath path in icon_view.get_selected_items ()) {
+                Gtk.TreeIter i;
+                if (list_store.get_iter (out i, path)) {
+                    Item location;
+                    list_store.get (i, Column.ITEM, out location);
+                    locations.remove (location);
+                }
+            }
+            icon_view.remove_selected ();
+            save ();
         });
 
         standalone = new StandalonePanel ();


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