[tracker/tracker-0.8] Fixes GB#621987, Correctly handle applications in results
- From: Martyn James Russell <mr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/tracker-0.8] Fixes GB#621987, Correctly handle applications in results
- Date: Thu, 24 Jun 2010 15:27:35 +0000 (UTC)
commit d0f60bf212624de4aa41a01ab6d5cd7257e5ea50
Author: Vincent Untz <vuntz gnome org>
Date: Thu Jun 24 09:31:34 2010 +0100
Fixes GB#621987, Correctly handle applications in results
Improves Application category support in tracker-search-tool
configure.ac | 1 +
src/tracker-search-tool/Makefile.am | 2 +-
src/tracker-search-tool/tracker-metadata-tile.gs | 37 ++++++++++++++++-
src/tracker-search-tool/tracker-result-grid.gs | 47 ++++++++++++++++------
src/tracker-search-tool/tracker-utils.gs | 21 ++++++++++
5 files changed, 92 insertions(+), 16 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 6efb4dd..2b21c60 100644
--- a/configure.ac
+++ b/configure.ac
@@ -923,6 +923,7 @@ AM_CONDITIONAL(HAVE_MINER_RSS, test "x$have_miner_rss" = "xyes")
####################################################################
APP_REQUIREMENTS="glib-2.0 >= $GLIB_REQUIRED
+ gio-unix-2.0 >= $GLIB_REQUIRED
gthread-2.0 >= $GLIB_REQUIRED
gmodule-2.0 >= $GLIB_REQUIRED
gtk+-2.0 >= $GTK_REQUIRED
diff --git a/src/tracker-search-tool/Makefile.am b/src/tracker-search-tool/Makefile.am
index 5a8b561..c03239d 100644
--- a/src/tracker-search-tool/Makefile.am
+++ b/src/tracker-search-tool/Makefile.am
@@ -17,7 +17,7 @@ tracker_search_tool_SOURCES = \
$(tracker_search_tool_VALASOURCES:.gs=.c)
tracker_search_tool.gs.stamp: $(tracker_search_tool_VALASOURCES)
- $(VALAC) -C -g --pkg dbus-glib-1 --pkg gee-1.0 --pkg gtk+-2.0 $^
+ $(VALAC) -C -g --pkg dbus-glib-1 --pkg gee-1.0 --pkg gio-unix-2.0 --pkg gtk+-2.0 $^
touch tracker_search_tool.gs.stamp
tracker_search_tool_CFLAGS = \
diff --git a/src/tracker-search-tool/tracker-metadata-tile.gs b/src/tracker-search-tool/tracker-metadata-tile.gs
index ee80832..6af3111 100644
--- a/src/tracker-search-tool/tracker-metadata-tile.gs
+++ b/src/tracker-search-tool/tracker-metadata-tile.gs
@@ -206,6 +206,7 @@ class TrackerMetadataTile : EventBox
info_value4.set_text ("")
info_value5.set_text ("")
info_value6.set_text ("")
+ info_label1.set_text (N_("Type:"))
info_label4.set_text ("")
info_label5.set_text ("")
info_label6.set_text ("")
@@ -216,7 +217,13 @@ class TrackerMetadataTile : EventBox
path_link.label = ""
name_link.set_sensitive (false)
- path_link.set_sensitive (false);
+ path_link.set_sensitive (false)
+
+ name_label.show ()
+ path_label.show ()
+ info_label1.show ()
+ info_label2.show ()
+ info_label3.show ()
def SetLabelValue (label : Label, val : string)
@@ -359,7 +366,31 @@ class TrackerMetadataTile : EventBox
SetLabelValue (info_value4, result[0])
SetLabelValue (info_value5, result[1])
SetLabelValue (info_value6, result[2])
+
+
+ def private DisplayApplicationDetails (uri : string)
+ app_info : AppInfo
+
+ var file = File.new_for_uri (uri)
+ app_info = new DesktopAppInfo.from_filename (file.get_path ())
+ if app_info is null
+ DisplayFileDetails (uri, "")
+ return
+ //name_link.set_sensitive (false)
+ path_link.set_sensitive (false)
+ path_label.hide ()
+ info_label2.hide ()
+ info_label3.hide ()
+
+ name_link.uri = uri
+ name_link.label = app_info.get_display_name ()
+ info_label1.set_text (N_("Description:"))
+
+ var description = app_info.get_description ()
+ if description is not null
+ SetLabelValue (info_value1, description)
+
def LoadUri (path : TreePath?)
ClearLabels ()
@@ -378,17 +409,19 @@ class TrackerMetadataTile : EventBox
_result_grid.store.get_iter (out iter, path)
_result_grid.store.get (iter, ResultColumns.Id, out id, ResultColumns.Uri, out uri, ResultColumns.Mime, out mime, ResultColumns.Icon, out icon)
+ image.set_from_pixbuf (icon)
+
/* determine category type */
var cat = GetCategory (uri)
if cat is not Categories.Application
DisplayFileDetails (uri, mime)
- image.set_from_pixbuf (icon)
case cat
when Categories.Audio do DisplayAudioDetails (uri)
when Categories.Video do DisplayVideoDetails (uri)
when Categories.Image do DisplayImageDetails (uri)
when Categories.Document do DisplayDocumentDetails (uri)
+ when Categories.Application do DisplayApplicationDetails (uri)
default do return
diff --git a/src/tracker-search-tool/tracker-result-grid.gs b/src/tracker-search-tool/tracker-result-grid.gs
index f1ee1ff..d25571b 100644
--- a/src/tracker-search-tool/tracker-result-grid.gs
+++ b/src/tracker-search-tool/tracker-result-grid.gs
@@ -137,21 +137,37 @@ class TrackerResultGrid : ScrolledWindow
if uri.has_prefix ("file://")
has_results = true
+ var handled = false
var file = File.new_for_uri (uri)
- try
- var info = file.query_info ("standard::display-name,standard::icon,thumbnail::path", \
- FileQueryInfoFlags.NONE, null)
-
- var filetype = info.get_file_type ()
- store.append (out iter);
- store.set (iter, ResultColumns.Id, id, ResultColumns.Uri, uri, ResultColumns.Mime, mime, ResultColumns.Icon, GetThumbNail (info, 64, 48, get_screen()), \
- ResultColumns.DisplayName, info.get_display_name(), ResultColumns.IsDirectory, \
- (filetype is FileType.DIRECTORY) , -1)
-
- except e:Error
- print "Could not get file info for %s", uri
+ var query = "SELECT rdf:type(?s) where { ?s nie:url \"%s\" }".printf(uri)
+ var qresults = Query.Query (query)
+
+ if qresults is not null and qresults[0].contains ("nfo#Software")
+ app_info : AppInfo
+ app_info = new DesktopAppInfo.from_filename (file.get_path ())
+
+ if app_info is not null
+ store.append (out iter);
+ store.set (iter, ResultColumns.Id, id, ResultColumns.Uri, uri, ResultColumns.Mime, mime, ResultColumns.Icon, GetThemeIconPixbuf (app_info.get_icon (), 48, get_screen()), \
+ ResultColumns.DisplayName, app_info.get_display_name(), ResultColumns.IsDirectory, \
+ false , -1)
+ handled = true
+
+ if not handled
+ try
+ var info = file.query_info ("standard::display-name,standard::icon,thumbnail::path", \
+ FileQueryInfoFlags.NONE, null)
+
+ var filetype = info.get_file_type ()
+ store.append (out iter);
+ store.set (iter, ResultColumns.Id, id, ResultColumns.Uri, uri, ResultColumns.Mime, mime, ResultColumns.Icon, GetThumbNail (info, 64, 48, get_screen()), \
+ ResultColumns.DisplayName, info.get_display_name(), ResultColumns.IsDirectory, \
+ (filetype is FileType.DIRECTORY) , -1)
+
+ except e:Error
+ print "Could not get file info for %s", uri
/* select first result */
if has_results
@@ -171,4 +187,9 @@ class TrackerResultGrid : ScrolledWindow
store.get (iter, ResultColumns.Uri, out uri);
store.get (iter, ResultColumns.IsDirectory, out is_dir);
- OpenUri (uri, is_dir)
+ var query = "SELECT rdf:type(?s) where { ?s nie:url \"%s\" }".printf(uri)
+ var results = Query.Query (query)
+ if results is not null and results[0].contains ("nfo#Software")
+ LaunchApp (uri)
+ else
+ OpenUri (uri, is_dir)
diff --git a/src/tracker-search-tool/tracker-utils.gs b/src/tracker-search-tool/tracker-utils.gs
index 4df2c28..1cdc2ba 100644
--- a/src/tracker-search-tool/tracker-utils.gs
+++ b/src/tracker-search-tool/tracker-utils.gs
@@ -83,6 +83,27 @@ class TrackerUtils
+ def static LaunchApp (uri : string) : bool
+ app_info : AppInfo
+ context : AppLaunchContext
+
+ var file = File.new_for_uri (uri)
+
+ app_info = new DesktopAppInfo.from_filename (file.get_path ())
+ if app_info is null
+ return OpenUri (uri, false)
+
+ context = new Gdk.AppLaunchContext ()
+ try
+ app_info.launch (null, context)
+ except e:Error
+ var msg = new MessageDialog (null, DialogFlags.MODAL, MessageType.ERROR, ButtonsType.OK, \
+ N_("Could not launch \"%s\"\nError: %s\n"), app_info.get_display_name (), e.message)
+ msg.run ();
+ return false
+
+ return true
+
def static OpenUri (uri : string, is_dir :bool) : bool
app_info : AppInfo
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]