[gnome-clocks/wip/geoinfo] Do not allow selection for automatic locations



commit 0c24114142cfd0a76e7156fdae7b8a447951bf16
Author: Evgeny Bobkin <evgen ibqn gmail com>
Date:   Tue Sep 10 18:43:21 2013 +0200

    Do not allow selection for automatic locations

 src/alarm.vala   |    2 ++
 src/widgets.vala |   20 +++++++++++++++-----
 src/world.vala   |    3 +++
 3 files changed, 20 insertions(+), 5 deletions(-)
---
diff --git a/src/alarm.vala b/src/alarm.vala
index af55ad8..7c0aa77 100644
--- a/src/alarm.vala
+++ b/src/alarm.vala
@@ -33,6 +33,8 @@ private class Item : Object, ContentItem {
 
     public string title_icon { get; set; default = null; }
 
+    public bool selectable { get; set; default = true; }
+
     public string name {
         get {
             return _name;
diff --git a/src/widgets.vala b/src/widgets.vala
index 0efa254..a597e39 100644
--- a/src/widgets.vala
+++ b/src/widgets.vala
@@ -134,6 +134,7 @@ private class DigitalClockRenderer : Gtk.CellRendererPixbuf {
     public string css_class { get; set; }
     public bool active { get; set; default = false; }
     public bool toggle_visible { get; set; default = false; }
+    public bool selectable { get; set; default = true; }
 
     public DigitalClockRenderer () {
     }
@@ -211,7 +212,7 @@ private class DigitalClockRenderer : Gtk.CellRendererPixbuf {
         context.restore ();
 
         // draw the overlayed checkbox
-        if (toggle_visible) {
+        if (selectable && toggle_visible) {
             int xpad, ypad, x_offset;
             get_padding (out xpad, out ypad);
 
@@ -243,6 +244,7 @@ private class DigitalClockRenderer : Gtk.CellRendererPixbuf {
 public interface ContentItem : GLib.Object {
     public abstract string name { get; set; }
     public abstract string title_icon { get; set; default = null; }
+    public abstract bool selectable { get; set; default = true; }
 
     public abstract void get_thumb_properties (out string text, out string subtext, out Gdk.Pixbuf? pixbuf, 
out string css_class);
 }
@@ -307,6 +309,7 @@ private class IconView : Gtk.IconView {
             Gdk.Pixbuf? pixbuf;
             string css_class;
             item.get_thumb_properties (out text, out subtext, out pixbuf, out css_class);
+            renderer.selectable = item.selectable;
             renderer.text = text;
             renderer.subtext = subtext;
             renderer.pixbuf = pixbuf;
@@ -342,9 +345,12 @@ private class IconView : Gtk.IconView {
                 Gtk.TreeIter i;
                 if (store.get_iter (out i, path)) {
                     bool selected;
-                    store.get (i, Column.SELECTED, out selected);
-                    store.set (i, Column.SELECTED, !selected);
-                    selection_changed ();
+                    ContentItem item;
+                    store.get (i, Column.SELECTED, out selected, Column.ITEM, out item);
+                    if (item.selectable) {
+                        store.set (i, Column.SELECTED, !selected);
+                        selection_changed ();
+                    }
                 }
             } else {
                 item_activated (path);
@@ -387,7 +393,11 @@ private class IconView : Gtk.IconView {
     public new void select_all () {
         var model = get_model () as Gtk.ListStore;
         model.foreach ((model, path, iter) => {
-            ((Gtk.ListStore) model).set (iter, Column.SELECTED, true);
+            ContentItem item;
+            ((Gtk.ListStore) model).get (iter, Column.ITEM, out item);
+            if (item.selectable) {
+                ((Gtk.ListStore) model).set (iter, Column.SELECTED, true);
+            }
             return false;
         });
         selection_changed ();
diff --git a/src/world.vala b/src/world.vala
index b47f87f..39ca2c9 100644
--- a/src/world.vala
+++ b/src/world.vala
@@ -29,6 +29,8 @@ private class Item : Object, ContentItem {
 
     public string title_icon { get; set; default = null; }
 
+    public bool selectable { get; set; default = true; }
+
     public string name {
         get {
             // We store it in a _name member even if we overwrite it every time
@@ -378,6 +380,7 @@ public class MainPanel : Gtk.Stack, Clocks.Clock {
             var item = new Item (found_location);
 
             item.automatic = true;
+            item.selectable = false;
             item.title_icon = "find-location-symbolic";
             locations.append (item);
             content_view.prepend (item);


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