[tracker/needle] tracker-needle: Add some polish



commit ebc35f47c20ec48a7487497ecf889822964618d9
Author: Martyn Russell <martyn lanedo com>
Date:   Mon Aug 16 21:48:51 2010 +0100

    tracker-needle: Add some polish
    
    - Add padding around images in left column
    - Only display one image per category
    - Update icons in toolbar to be more sensible
    - Make category search the default
    - Calculate the row hint - still not perfect

 src/tracker-needle/tracker-needle.ui   |   23 ++++++------
 src/tracker-needle/tracker-needle.vala |   60 +++++++++++++++++++++++++-------
 src/tracker-needle/tracker-utils.vala  |   22 ++++++++----
 3 files changed, 74 insertions(+), 31 deletions(-)
---
diff --git a/src/tracker-needle/tracker-needle.ui b/src/tracker-needle/tracker-needle.ui
index 1000061..af50f2a 100644
--- a/src/tracker-needle/tracker-needle.ui
+++ b/src/tracker-needle/tracker-needle.ui
@@ -14,12 +14,12 @@
           <object class="GtkToolbar" id="toolbar_main">
             <property name="visible">True</property>
             <child>
-              <object class="GtkRadioToolButton" id="toolbutton_view_list">
+              <object class="GtkRadioToolButton" id="toolbutton_view_details">
                 <property name="visible">True</property>
-                <property name="tooltip_text" translatable="yes">Display results in a list view</property>
+                <property name="tooltip_text" translatable="yes">Display results by category, for example, Music, Videos, Applications, etc.</property>
                 <property name="is_important">True</property>
                 <property name="use_underline">True</property>
-                <property name="icon_name">gtk-index</property>
+                <property name="icon_name">help-faq</property>
                 <property name="active">True</property>
                 <property name="group">toolbutton_view_icons</property>
               </object>
@@ -29,13 +29,14 @@
               </packing>
             </child>
             <child>
-              <object class="GtkRadioToolButton" id="toolbutton_view_icons">
+              <object class="GtkRadioToolButton" id="toolbutton_view_list">
                 <property name="visible">True</property>
-                <property name="tooltip_text" translatable="yes">Display results in an icon view</property>
+                <property name="tooltip_text" translatable="yes">Display results by files found in a list</property>
                 <property name="is_important">True</property>
                 <property name="use_underline">True</property>
-                <property name="icon_name">gtk-orientation-portrait</property>
+                <property name="icon_name">document-open</property>
                 <property name="active">True</property>
+                <property name="group">toolbutton_view_icons</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -43,14 +44,13 @@
               </packing>
             </child>
             <child>
-              <object class="GtkRadioToolButton" id="toolbutton_view_details">
+              <object class="GtkRadioToolButton" id="toolbutton_view_icons">
                 <property name="visible">True</property>
-                <property name="tooltip_text" translatable="yes">Display results for all categories</property>
+                <property name="tooltip_text" translatable="yes">Display results by files found in a grid view</property>
                 <property name="is_important">True</property>
                 <property name="use_underline">True</property>
-                <property name="icon_name">help-faq</property>
+                <property name="icon_name">emblem-photos</property>
                 <property name="active">True</property>
-                <property name="group">toolbutton_view_icons</property>
               </object>
               <packing>
                 <property name="expand">False</property>
@@ -110,6 +110,7 @@
                 <child>
                   <object class="GtkLabel" id="label_search">
                     <property name="visible">True</property>
+                    <property name="xpad">4</property>
                     <property name="label" translatable="yes">_Search:</property>
                     <property name="use_underline">True</property>
                     <property name="mnemonic_widget">entry_search</property>
@@ -180,7 +181,7 @@
                   <object class="GtkTreeView" id="treeview_results">
                     <property name="can_focus">True</property>
                     <property name="model">liststore_results</property>
-                    <property name="enable_grid_lines">vertical</property>
+                    <property name="enable_search">False</property>
                     <property name="tooltip_column">2</property>
                   </object>
                 </child>
diff --git a/src/tracker-needle/tracker-needle.vala b/src/tracker-needle/tracker-needle.vala
index b497343..fc6c915 100644
--- a/src/tracker-needle/tracker-needle.vala
+++ b/src/tracker-needle/tracker-needle.vala
@@ -110,7 +110,7 @@ public class TrackerNeedle {
 		iconview = builder.get_object ("iconview_results") as IconView;
 		setup_ui_results (treeview, iconview);
 
-		view_list.set_active (true);
+		view_details.set_active (true);
 	}
 
 	private void cell_renderer_func (Gtk.CellLayout   cell_layout,
@@ -118,23 +118,38 @@ public class TrackerNeedle {
 	                                 Gtk.TreeModel    tree_model,
 	                                 Gtk.TreeIter     iter) {
 		Gdk.Color color;
+		Gtk.Style style;
 		bool show_row_hint;
 
 		tree_model.get (iter, 9, out show_row_hint, -1);
 
+		style = ((Widget) treeview).get_style ();
+
+		color = style.base[Gtk.StateType.SELECTED];
+		int sum_normal = color.red + color.green + color.blue;
+		color = style.base[Gtk.StateType.NORMAL];
+		int sum_selected = color.red + color.green + color.blue;
+		color = style.text_aa[Gtk.StateType.INSENSITIVE];
+
+		if (sum_normal < sum_selected) {
+			/* Found a light theme */
+			color.red = (color.red + (style.white).red) / 2;
+			color.green = (color.green + (style.white).green) / 2;
+			color.blue = (color.blue + (style.white).blue) / 2;
+		} else {
+			/* Found a dark theme */
+			color.red = (color.red + (style.black).red) / 2;
+			color.green = (color.green + (style.black).green) / 2;
+			color.blue = (color.blue + (style.black).blue) / 2;
+		}
+
 		// Set odd/even colours
 		if (show_row_hint) {
-			Gdk.Color.parse ("light gray", out color);
+//			((Widget) treeview).style_get ("odd-row-color", out color, null);
 			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);
+//			((Widget) treeview).style_get ("even-row-color", out color, null);
 			cell.set ("cell-background-gdk", null);
-
-//			widget.style_get ("even-row-color", out color, null);
-//			cell.set ("cell-background-gdk", &color);
 		}
 	}
 
@@ -163,6 +178,8 @@ public class TrackerNeedle {
 		col = new Gtk.TreeViewColumn ();
 		col.pack_start (renderer1, false);
 		col.add_attribute (renderer1, "pixbuf", 0);
+		renderer1.xpad = 5;
+		renderer1.ypad = 5;
 
 		col.pack_start (renderer2, true);
 		col.add_attribute (renderer2, "text", 4);
@@ -324,8 +341,6 @@ public class TrackerNeedle {
 						}
 					}
 
-					bool is_image = type == Tracker.Query.Type.IMAGES;
-
 					string urn = cursor.get_string (0);
 					string _file = cursor.get_string (1);
 					string title = cursor.get_string (2);
@@ -333,20 +348,39 @@ public class TrackerNeedle {
 					string column2 = null;
 					string column3 = null;
 					string tooltip = cursor.get_string (5);
-					Gdk.Pixbuf pixbuf_small = tracker_pixbuf_new_from_file (theme, _file, size_medium, is_image);
+					Gdk.Pixbuf pixbuf_small = null; 
 
 					// Special cases
 					switch (type) {
+					case Tracker.Query.Type.APPLICATIONS:
+						if (count == 0) {
+							pixbuf_small = tracker_pixbuf_new_from_name (theme, "package-x-generic", size_medium);
+						}
+						break;
 					case Tracker.Query.Type.MUSIC:
+						if (count == 0) {
+							pixbuf_small = tracker_pixbuf_new_from_name (theme, "audio-x-generic", size_medium);
+						}
 						column2 = tracker_time_format_from_seconds (cursor.get_string (4));
 						break;
 					case Tracker.Query.Type.IMAGES:
+						if (count == 0) {
+							pixbuf_small = tracker_pixbuf_new_from_name (theme, "image-x-generic", size_medium);
+						}
 						column2 = GLib.format_size_for_display (cursor.get_string (4).to_int ());
 						break;
 					case Tracker.Query.Type.VIDEOS:
+						if (count == 0) {
+							pixbuf_small = tracker_pixbuf_new_from_name (theme, "video-x-generic", size_medium);
+						}
 						column2 = tracker_time_format_from_seconds (cursor.get_string (4));
 						break;
-						
+					case Tracker.Query.Type.DOCUMENTS:
+						if (count == 0) {
+							pixbuf_small = tracker_pixbuf_new_from_name (theme, "x-office-presentation", size_medium);
+						}
+						break;
+
 					default:
 						break;
 					}
diff --git a/src/tracker-needle/tracker-utils.vala b/src/tracker-needle/tracker-utils.vala
index c24809c..d402b88 100644
--- a/src/tracker-needle/tracker-utils.vala
+++ b/src/tracker-needle/tracker-utils.vala
@@ -152,13 +152,21 @@ public Gdk.Pixbuf tracker_pixbuf_new_from_file (IconTheme theme, string filename
 		}
 	}
 
-	if (pixbuf == null) {
-		try {
-			// pixbuf = theme.load_icon (theme.get_example_icon_name (), 48, IconLookupFlags.USE_BUILTIN);
-			pixbuf = theme.load_icon ("text-x-generic", size, IconLookupFlags.USE_BUILTIN);
-		} catch (GLib.Error e) {
-			warning ("Could not load default icon pixbuf from theme for 'text-x-generic': " + e.message);
-		}
+	if (pixbuf != null) {
+		return pixbuf;
+	}
+
+	return tracker_pixbuf_new_from_name (theme, "text-x-generic", size);
+}
+
+public Gdk.Pixbuf tracker_pixbuf_new_from_name (IconTheme theme, string name, int size) {
+	// Get Icon
+	var pixbuf = null as Gdk.Pixbuf;
+
+	try {
+		pixbuf = theme.load_icon (name, size, IconLookupFlags.USE_BUILTIN);
+	} catch (GLib.Error e) {
+		warning ("Could not load default icon pixbuf from theme for '%s': %s", name, e.message);
 	}
 
 	return pixbuf;



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