[gnome-clocks/wip/geoinfo: 3/3] Add a generic property "title_icon" to ContentItem interface



commit ea0ef602a73f0fd2f4db845345bb203dcdc8e4f8
Author: Evgeny Bobkin <evgen ibqn gmail com>
Date:   Tue Sep 10 11:25:12 2013 +0200

    Add a generic property "title_icon" to ContentItem interface

 src/alarm.vala   |    2 +-
 src/widgets.vala |   10 +++++-----
 src/world.vala   |    3 +++
 3 files changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/src/alarm.vala b/src/alarm.vala
index 373bc06..af55ad8 100644
--- a/src/alarm.vala
+++ b/src/alarm.vala
@@ -31,7 +31,7 @@ private class Item : Object, ContentItem {
         SNOOZING
     }
 
-    public bool automatic { get; set; default = false; }
+    public string title_icon { get; set; default = null; }
 
     public string name {
         get {
diff --git a/src/widgets.vala b/src/widgets.vala
index ed74bab..0efa254 100644
--- a/src/widgets.vala
+++ b/src/widgets.vala
@@ -70,7 +70,7 @@ private class TitleRenderer : Gtk.CellRendererText {
         }
     }
 
-    public bool automatic { get; set; default = false; }
+    public string title_icon { get; set; default = null; }
 
     private string _title;
 
@@ -83,7 +83,7 @@ private class TitleRenderer : Gtk.CellRendererText {
     public override void render (Cairo.Context cr, Gtk.Widget widget, Gdk.Rectangle background_area, 
Gdk.Rectangle cell_area, Gtk.CellRendererState flags) {
         base.render (cr, widget, cell_area, cell_area, flags);
 
-        if (automatic) {
+        if (title_icon != null) {
             var context = widget.get_style_context ();
             context.save ();
 
@@ -108,7 +108,7 @@ private class TitleRenderer : Gtk.CellRendererText {
 
             Gtk.IconTheme icon_theme = Gtk.IconTheme.get_for_screen (Gdk.Screen.get_default ());
             try {
-                Gtk.IconInfo? icon_info = icon_theme.lookup_icon ("find-location-symbolic", ICON_SIZE, 0);
+                Gtk.IconInfo? icon_info = icon_theme.lookup_icon (title_icon, ICON_SIZE, 0);
                 assert (icon_info != null);
 
                 Gdk.Pixbuf pixbuf = icon_info.load_icon ();
@@ -242,7 +242,7 @@ private class DigitalClockRenderer : Gtk.CellRendererPixbuf {
 
 public interface ContentItem : GLib.Object {
     public abstract string name { get; set; }
-    public abstract bool automatic { get; set; default = false; }
+    public abstract string title_icon { get; set; default = null; }
 
     public abstract void get_thumb_properties (out string text, out string subtext, out Gdk.Pixbuf? pixbuf, 
out string css_class);
 }
@@ -325,7 +325,7 @@ private class IconView : Gtk.IconView {
             model.get (iter, IconView.Column.ITEM, out item);
             var renderer = (TitleRenderer) cell;
             renderer.title = GLib.Markup.escape_text (item.name);
-            renderer.automatic = item.automatic;
+            renderer.title_icon = item.title_icon;
         });
     }
 
diff --git a/src/world.vala b/src/world.vala
index 45f2d72..b47f87f 100644
--- a/src/world.vala
+++ b/src/world.vala
@@ -27,6 +27,8 @@ private class Item : Object, ContentItem {
 
     public bool automatic { get; set; default = false; }
 
+    public string title_icon { get; set; default = null; }
+
     public string name {
         get {
             // We store it in a _name member even if we overwrite it every time
@@ -376,6 +378,7 @@ public class MainPanel : Gtk.Stack, Clocks.Clock {
             var item = new Item (found_location);
 
             item.automatic = true;
+            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]