[tracker/needle: 30/34] tracker-needle: Added odd/even hinting but by category not every row
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/needle: 30/34] tracker-needle: Added odd/even hinting but by category not every row
- Date: Wed, 8 Sep 2010 23:02:15 +0000 (UTC)
commit a0a0b920cc31ba1c1cdfaa85d8f4e79b52c7c418
Author: Martyn Russell <martyn lanedo com>
Date: Mon Aug 16 13:40:25 2010 +0100
tracker-needle: Added odd/even hinting but by category not every row
src/tracker-needle/tracker-cell-renderer-text.vala | 5 +-
src/tracker-needle/tracker-needle.vala | 69 ++++++++++++++++++--
2 files changed, 65 insertions(+), 9 deletions(-)
---
diff --git a/src/tracker-needle/tracker-cell-renderer-text.vala b/src/tracker-needle/tracker-cell-renderer-text.vala
index a6fd603..a3dbf9c 100644
--- a/src/tracker-needle/tracker-cell-renderer-text.vala
+++ b/src/tracker-needle/tracker-cell-renderer-text.vala
@@ -21,6 +21,7 @@ class Tracker.CellRendererText : Gtk.CellRendererText {
// FIXME: Chain text and set is_valid to false when changes
//public string text { get; set; }
public string subtext { get; set; }
+ public bool show_row_hint { get; set; }
public bool show_subtext { get; set; }
private bool is_selected;
private bool is_valid;
@@ -45,7 +46,7 @@ class Tracker.CellRendererText : Gtk.CellRendererText {
bool selected = Gtk.CellRendererState.SELECTED in flags;
update_text (widget, selected);
-
+
base.render (window, widget, background_area, cell_area, expose_area, flags);
}
@@ -54,7 +55,7 @@ class Tracker.CellRendererText : Gtk.CellRendererText {
if (is_valid && is_selected == selected) {
return;
}
- //subtext = "foo";
+
var style = widget.get_style ();
var attr_list = new Pango.AttrList ();
diff --git a/src/tracker-needle/tracker-needle.vala b/src/tracker-needle/tracker-needle.vala
index 592c15f..b497343 100644
--- a/src/tracker-needle/tracker-needle.vala
+++ b/src/tracker-needle/tracker-needle.vala
@@ -113,9 +113,34 @@ public class TrackerNeedle {
view_list.set_active (true);
}
+ private void cell_renderer_func (Gtk.CellLayout cell_layout,
+ Gtk.CellRenderer cell,
+ Gtk.TreeModel tree_model,
+ Gtk.TreeIter iter) {
+ Gdk.Color color;
+ bool show_row_hint;
+
+ tree_model.get (iter, 9, out show_row_hint, -1);
+
+ // Set odd/even colours
+ if (show_row_hint) {
+ Gdk.Color.parse ("light gray", out color);
+ cell.set ("cell-background-gdk", &color);
+
+// widget.style_get ("odd-row-color", out color, null);
+// cell.set ("cell-background-gdk", &color);
+ } else {
+// Gdk.Color.parse ("blue", out color);
+ cell.set ("cell-background-gdk", null);
+
+// widget.style_get ("even-row-color", out color, null);
+// cell.set ("cell-background-gdk", &color);
+ }
+ }
+
private void setup_ui_results (TreeView treeview, IconView iconview) {
// Setup treeview
- store = new ListStore (9,
+ store = new ListStore (10,
typeof (Gdk.Pixbuf), // Icon small
typeof (Gdk.Pixbuf), // Icon big
typeof (string), // URN
@@ -124,29 +149,49 @@ public class TrackerNeedle {
typeof (string), // Subtitle
typeof (string), // Column 2
typeof (string), // Column 3
- typeof (string)); // Tooltip
+ typeof (string), // Tooltip
+ typeof (bool)); // Category hint
treeview.set_model (store);
treeview.set_tooltip_column (8);
+ treeview.set_rules_hint (false);
- var col = new Gtk.TreeViewColumn ();
+ Gtk.TreeViewColumn col;
var renderer1 = new CellRendererPixbuf ();
+ var renderer2 = new Tracker.CellRendererText ();
+
+ col = new Gtk.TreeViewColumn ();
col.pack_start (renderer1, false);
col.add_attribute (renderer1, "pixbuf", 0);
- var renderer2 = new Tracker.CellRendererText ();
col.pack_start (renderer2, true);
col.add_attribute (renderer2, "text", 4);
col.add_attribute (renderer2, "subtext", 5);
- col.set_title ("File");
+ col.set_title (_("File"));
col.set_resizable (true);
col.set_expand (true);
col.set_sizing (Gtk.TreeViewColumnSizing.AUTOSIZE);
+ col.set_cell_data_func (renderer1, cell_renderer_func);
+ col.set_cell_data_func (renderer2, cell_renderer_func);
+ treeview.append_column (col);
+
+ var renderer3 = new Tracker.CellRendererText ();
+ col = new Gtk.TreeViewColumn ();
+ col.pack_start (renderer3, true);
+ col.add_attribute (renderer3, "text", 6);
+ col.set_title (_("Last Changed"));
+ col.set_cell_data_func (renderer3, cell_renderer_func);
+ treeview.append_column (col);
+
+ var renderer4 = new Tracker.CellRendererText ();
+ col = new Gtk.TreeViewColumn ();
+ col.pack_start (renderer4, true);
+ col.add_attribute (renderer4, "text", 7);
+ col.set_title (_("Size"));
+ col.set_cell_data_func (renderer4, cell_renderer_func);
treeview.append_column (col);
- treeview.insert_column_with_attributes (-1, "Last Changed", new CellRendererText (), "text", 6, null);
- treeview.insert_column_with_attributes (-1, "Size", new CellRendererText (), "text", 7, null);
treeview.row_activated.connect (view_row_selected);
// Setup iconview
@@ -250,8 +295,11 @@ public class TrackerNeedle {
var screen = window.get_screen ();
var theme = IconTheme.get_for_screen (screen);
+ bool odd = false;
foreach (Tracker.Query.Type type in categories) {
+ int count = 0;
+
Tracker.Sparql.Cursor cursor;
query.limit = 100;
@@ -326,12 +374,19 @@ public class TrackerNeedle {
6, column2, // Column2
7, column3, // Column3
8, tooltip, // Tooltip
+ 9, odd, // Category hint
-1);
+
+ count++;
}
} catch (GLib.Error e) {
warning ("Could not iterate query results: %s", e.message);
return;
}
+
+ if (count > 0) {
+ odd = !odd;
+ }
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]