[tracker] Prettify relationships uris.
- From: Robert James Taylor <robtaylor src gnome org>
- To: svn-commits-list gnome org
- Subject: [tracker] Prettify relationships uris.
- Date: Mon, 6 Jul 2009 17:44:11 +0000 (UTC)
commit 101e34946ca90013462e3136d81876af54297108
Author: Rob Taylor <rob taylor codethink co uk>
Date: Sun May 3 11:49:42 2009 +0100
Prettify relationships uris.
Fetch prefixes for known namespaces from tracker and subsitute namespaces with
prefixes when displaying the relationships.
configure.ac | 6 ++++++
src/tracker-explorer/Makefile.am | 2 ++
src/tracker-explorer/explorer.vala | 34 ++++++++++++++++++++++++++++------
3 files changed, 36 insertions(+), 6 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index b8e15db..437d150 100644
--- a/configure.ac
+++ b/configure.ac
@@ -198,6 +198,12 @@ PKG_CHECK_MODULES(LIBPNG, [libpng >= 1.2])
AC_SUBST(LIBPNG_CFLAGS)
AC_SUBST(LIBPNG_LIBS)
+# Check for libgee 0.1.3 or higher
+PKG_CHECK_MODULES(LIBGEE, [gee-1.0 >= 0.1.3])
+AC_SUBST(LIBGEE_CFLAGS)
+AC_SUBST(LIBGEE_LIBS)
+
+
# Check for GConf
PKG_CHECK_MODULES(GCONF, [gconf-2.0 >= 2.2.0], have_gconf=yes, have_gconf=no)
AC_SUBST(GCONF_CFLAGS)
diff --git a/src/tracker-explorer/Makefile.am b/src/tracker-explorer/Makefile.am
index 9ba0265..5327075 100644
--- a/src/tracker-explorer/Makefile.am
+++ b/src/tracker-explorer/Makefile.am
@@ -20,6 +20,7 @@ tracker_explorer_CFLAGS = \
$(GIO_CFLAGS) \
$(DBUS_CFLAGS) \
$(LIBTRACKERGTK_CFLAGS) \
+ $(LIBGEE_CFLAGS) \
$(NULL)
tracker_explorer_LDADD = \
@@ -28,6 +29,7 @@ tracker_explorer_LDADD = \
$(GCOV_LIBS) \
$(DBUS_LIBS) \
$(LIBTRACKERGTK_LIBS) \
+ $(LIBGEE_LIBS) \
$(NULL)
EXTRA_DIST = \
diff --git a/src/tracker-explorer/explorer.vala b/src/tracker-explorer/explorer.vala
index db74dbf..de26a4d 100644
--- a/src/tracker-explorer/explorer.vala
+++ b/src/tracker-explorer/explorer.vala
@@ -16,6 +16,7 @@ public class Explorer {
private ListStore uris;
private ListStore relationships;
private Label current_object;
+ private Gee.HashMap<string,string> namespaces = new Gee.HashMap<string,string>(str_hash, str_equal, str_equal);
public void show() {
try {
@@ -41,6 +42,8 @@ public class Explorer {
setup_relationships(relationshipsview);
current_object = builder.get_object ("current-object") as Label;
+ fetch_prefixes();
+
window.show_all();
} catch (GLib.Error e) {
var msg = new MessageDialog (null, DialogFlags.MODAL,
@@ -74,7 +77,18 @@ public class Explorer {
relationshipsview.row_activated += object_selected;
}
-
+ private void fetch_prefixes () {
+ string query = "SELECT ?s ?prefix WHERE { ?s a tracker:Namespace ; tracker:prefix ?prefix }";
+ try {
+ var result = tracker.SparqlQuery(query);
+ for (int i=0; i<result.length[0]; i++) {
+ string _namespace = result[i,0];
+ _namespace = _namespace.substring(0, _namespace.len() -1);
+ namespaces[_namespace] = result[i,1];
+ }
+ } catch (DBus.Error e) {
+ }
+ }
private void entry_changed (Editable editable) {
string query = "SELECT ?s WHERE { ?s fts:match \"%s*\" }".printf(((Entry)editable).text);
@@ -99,17 +113,25 @@ public class Explorer {
current_object.set_text (uri);
string query = "SELECT ?r ?o WHERE { <%s> ?r ?o }".printf(uri);
- //debug ("query = %s", query);
+ TreeIter iter;
try {
var result = tracker.SparqlQuery(query);
relationships.clear();
- //debug ("%d, %d", result.length[0], result.length[1]);
for (int i=0; i<result.length[0]; i++) {
- //debug ("%s, %s", result[i,0], result[i,1]);
- TreeIter iter;
+ //split at '#' and look up to see if we have
+ //a human-readable prefix
+ string[] parts = result[i,0].split("#");
+ string? prefix = namespaces[parts[0]];
+ string relationship;
+
+ if (prefix != null) {
+ relationship = string.join("#", prefix, parts[1]);
+ } else {
+ relationship = result[i,0];
+ }
relationships.append (out iter);
- relationships.set (iter, 0, result[i,0], -1);
+ relationships.set (iter, 0, relationship, -1);
relationships.set (iter, 1, result[i,1], -1);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]