[tracker] TST- made metadata tile labels category specific
- From: Jamie McCracken <jamiemcc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] TST- made metadata tile labels category specific
- Date: Thu, 18 Feb 2010 16:09:50 +0000 (UTC)
commit 1c7eaee6b684e8a2b5df47727966dc9f896b5319
Author: Jamie McCracken <jamiemcc gnome org>
Date: Thu Feb 18 10:57:17 2010 -0500
TST- made metadata tile labels category specific
src/tracker-search-tool/tracker-category-view.gs | 4 -
src/tracker-search-tool/tracker-metadata-tile.gs | 190 +++++++++++++++++-----
2 files changed, 151 insertions(+), 43 deletions(-)
---
diff --git a/src/tracker-search-tool/tracker-category-view.gs b/src/tracker-search-tool/tracker-category-view.gs
index 8e16765..e4f8742 100644
--- a/src/tracker-search-tool/tracker-category-view.gs
+++ b/src/tracker-search-tool/tracker-category-view.gs
@@ -58,10 +58,6 @@ class TrackerCategoryView : ScrolledWindow
CategoryColumns.Name, "nfo:Document", CategoryColumns.DisplayName, N_("Office Documents") , -1);
store.append (out iter);
- store.set (iter, CategoryColumns.Icon, GetThemePixbufByName ("text-x-generic", icon_size, get_screen ()), \
- CategoryColumns.Name, "nfo:TextDocument", CategoryColumns.DisplayName, N_("Text Documents") , -1);
-
- store.append (out iter);
store.set (iter, CategoryColumns.Icon, GetThemePixbufByName ("image-x-generic", icon_size, get_screen ()), \
CategoryColumns.Name, "nfo:Image", CategoryColumns.DisplayName, N_("Images") , -1);
diff --git a/src/tracker-search-tool/tracker-metadata-tile.gs b/src/tracker-search-tool/tracker-metadata-tile.gs
index d3ff7cf..f656e9a 100644
--- a/src/tracker-search-tool/tracker-metadata-tile.gs
+++ b/src/tracker-search-tool/tracker-metadata-tile.gs
@@ -90,7 +90,7 @@ class TrackerMetadataTile : EventBox
table = new Table (5, 7, false)
table.set_col_spacings (3)
- table.set_row_spacings (1)
+ table.set_row_spacings (3)
@@ -221,31 +221,68 @@ class TrackerMetadataTile : EventBox
info_value4.set_text ("")
info_value5.set_text ("")
info_value6.set_text ("")
+ info_label4.set_text ("")
+ info_label5.set_text ("")
+ info_label6.set_text ("")
+
name_link.uri = ""
name_link.label = ""
+ path_link.uri = ""
+ path_link.label = ""
+
+
+ def SetLabelValue (label : Label, val : string)
+ var val1 = "<b>%s</b>".printf (val)
+ label.set_markup (val1)
+ label.xalign = 0
+
+ def SetLabelSizeValue (label : Label, size: int64)
+ var val1 = "<b>%s</b>".printf (FormatFileSize (size))
+ label.set_markup (val1)
+ label.xalign = 0
+
+
+ def SetLabelUrnValue (label : Label, val : string)
+ var value = val
+
+ var values = val.split (":")
+ for s in values
+ value = s
+ var escapes = value.split ("%20")
+ value = ""
+ for s in escapes
+ value += s + " "
+ var val1 = "<b>%s</b>".printf (value)
+ label.set_markup (val1)
+ label.xalign = 0
+
+
- def LoadUri (path : TreePath?)
- ClearLabels ()
-
- if path is null
- image.set_from_icon_name ("text-x-generic", IconSize.DIALOG)
- return
-
- iter : TreeIter
- id, uri, mime, display_name : weak string
- icon : Gdk.Pixbuf
-
- _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, ResultColumns.DisplayName, out display_name)
-
- image.set_from_pixbuf (icon)
+ def private GetCategory (uri : string) : Categories
+ var query = "select rdf:type(?s) where { ?s nie:url \"%s\" }".printf(uri)
+ var results = Query.Query (query)
+ var res = ""
+ for s in results
+ res += s
+
+ if res.contains ("nfo#Video") do return Categories.Video
+ if res.contains ("nfo#Image") do return Categories.Image
+ if res.contains ("nfo#Audio") do return Categories.Music
+ if res.contains ("nfo#Document") do return Categories.Document
+ if res.contains ("nfo#Software") do return Categories.Application
+ if res.contains ("nfo#Folder") do return Categories.Folder
+
+ return Categories.File
+
+
+ def private DisplayFileDetails (uri : string, mime : string)
var file = File.new_for_uri (uri)
var filepath = file.get_basename ()
- var displaypath = file.get_parent ();
+ var displaypath = file.get_parent ()
name_link.uri = uri
name_link.label = filepath
@@ -253,34 +290,109 @@ class TrackerMetadataTile : EventBox
path_link.label = displaypath.get_path ()
-
- var val1 = "<b>%s</b>".printf (mime)
- info_value1.set_markup (val1)
- info_value1.xalign = 0
+ SetLabelValue (info_value1, mime)
+
+ try
+ var info = file.query_info ("standard::size,time::modified", \
+ FileQueryInfoFlags.NONE, null)
+
+ SetLabelSizeValue (info_value2, info.get_size())
+
+ tm : TimeVal
+ info.get_modification_time (out tm)
+
+ var val3 = "<b>%s</b>".printf (tm.to_iso8601 ())
- // get metadata
- // var query = "SELECT ?mimetype ?size ?mtime WHERE {<%s> nie:byteSize ?size; nie:contentLastModified ?mtime; nie:mimeType ?mimeType.}".printf(uri)
- var query = sparql.printf(uri)
- if Query is not null
- var result = Query.Query (query)
+ info_value3.set_markup (val3)
- if result is not null
- mime = result[0]
+ except e:Error
+ print "Could not get file info for %s", uri
- try
- var info = file.query_info ("standard::size,time::modified", \
- FileQueryInfoFlags.NONE, null)
+
+ def private DisplayImageDetails (uri : string)
+ var query = "select nfo:height(?s) nfo:width(?s) Where { ?s nie:url \"%s\" }".printf(uri)
+ var result = Query.Query (query)
- var val2 = "<b>%s</b>".printf (FormatFileSize (info.get_size ()))
+ info_label4.set_text (N_("Height:"))
+ info_label5.set_text (N_("Width:"))
- info_value2.set_markup (val2)
+ if result is not null
+ SetLabelValue (info_value4, result[0])
+ SetLabelValue (info_value5, result[1])
+
- tm : TimeVal
- info.get_modification_time (out tm)
+
+ def private DisplayMusicDetails (uri : string)
+ var query = "select nie:title(?s) nmm:performer(?s) nmm:musicAlbum(?s) Where { ?s nie:url \"%s\" }".printf(uri)
+ var result = Query.Query (query)
+
+ info_label4.set_text (N_("Title:"))
+ info_label5.set_text (N_("Artist:"))
+ info_label6.set_text (N_("Album:"))
+
+ if result is not null
+ SetLabelValue (info_value4, result[0])
+ SetLabelUrnValue (info_value5, result[1])
+ SetLabelUrnValue (info_value6, result[2])
+
+ def private DisplayVideoDetails (uri : string)
+ var query = "select nfo:height(?s) nfo:width(?s) nfo:duration (?s) Where { ?s nie:url \"%s\" }".printf(uri)
+ var result = Query.Query (query)
+
+ info_label4.set_text (N_("Height:"))
+ info_label5.set_text (N_("Width:"))
+ info_label6.set_text (N_("Duration:"))
+
+ if result is not null
+ SetLabelValue (info_value4, result[0])
+ SetLabelValue (info_value5, result[1])
+ SetLabelValue (info_value6, result[2])
+
+ def private DisplayDocumentDetails (uri : string)
+ var query = "select nie:title(?s) nco:creator(?s) nfo:pageCount (?s) Where { ?s nie:url \"%s\" }".printf(uri)
+ var result = Query.Query (query)
+
+ info_label4.set_text (N_("Title:"))
+ info_label5.set_text (N_("Author:"))
+ info_label6.set_text (N_("Page count:"))
+
+ if result is not null
+ SetLabelValue (info_value4, result[0])
+ SetLabelValue (info_value5, result[1])
+ SetLabelValue (info_value6, result[2])
+
+ def private DisplayApplicationDetails (uri : string)
+ return
+
+ def LoadUri (path : TreePath?)
+ ClearLabels ()
- var val3 = "<b>%s</b>".printf (tm.to_iso8601 ())
+ if path is null
+ image.set_from_icon_name ("text-x-generic", IconSize.DIALOG)
+ return
- info_value3.set_markup (val3)
+ iter : TreeIter
+ id, uri, mime: weak string
+ icon : Gdk.Pixbuf
- except e:Error
- print "Could not get file info for %s", uri
+ _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)
+
+
+ /* 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.Application do DisplayApplicationDetails (uri)
+ when Categories.Music do DisplayMusicDetails (uri)
+ when Categories.Video do DisplayVideoDetails (uri)
+ when Categories.Image do DisplayImageDetails (uri)
+ when Categories.Document do DisplayDocumentDetails (uri)
+ default do return
+
+
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]