[tracker] make some inroads into displaying reverse relationships by class.



commit bf721755a21acd5f23baa608460a17c02ed19402
Author: Rob Taylor <rob taylor codethink co uk>
Date:   Wed May 13 12:08:36 2009 +0100

    make some inroads into displaying reverse relationships by class.
    
    Also introduces forwards and back buttons, though these infrastructure for history still needs to be written.

 src/tracker-explorer/explorer.ui   |  113 ++++++++++++++++++-----------------
 src/tracker-explorer/explorer.vala |   67 ++++++++++++++-------
 2 files changed, 102 insertions(+), 78 deletions(-)
---
diff --git a/src/tracker-explorer/explorer.ui b/src/tracker-explorer/explorer.ui
index adb63fa..65638e0 100644
--- a/src/tracker-explorer/explorer.ui
+++ b/src/tracker-explorer/explorer.ui
@@ -69,94 +69,97 @@
           </packing>
         </child>
         <child>
-          <object class="GtkVPaned" id="vpaned2">
+          <object class="GtkVBox" id="vbox2">
             <property name="visible">True</property>
-            <property name="can_focus">True</property>
             <property name="orientation">vertical</property>
             <child>
-              <object class="GtkFrame" id="frame1">
+              <object class="GtkHBox" id="hbox1">
                 <property name="visible">True</property>
-                <property name="label_xalign">0</property>
-                <property name="shadow_type">none</property>
                 <child>
-                  <object class="GtkAlignment" id="alignment1">
+                  <object class="GtkButton" id="button1">
+                    <property name="label" translatable="yes">gtk-go-back</property>
                     <property name="visible">True</property>
-                    <property name="left_padding">12</property>
-                    <child>
-                      <object class="GtkScrolledWindow" id="scrolledwindow2">
-                        <property name="visible">True</property>
-                        <property name="can_focus">True</property>
-                        <property name="hscrollbar_policy">automatic</property>
-                        <property name="vscrollbar_policy">automatic</property>
-                        <child>
-                          <object class="GtkTreeView" id="relationshipsview">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="search_column">0</property>
-                          </object>
-                        </child>
-                      </object>
-                    </child>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="use_stock">True</property>
+                    <property name="focus_on_click">False</property>
+                    <property name="image_position">top</property>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkButton" id="button2">
+                    <property name="label" translatable="yes">gtk-go-forward</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">True</property>
+                    <property name="use_stock">True</property>
+                    <property name="focus_on_click">False</property>
+                    <property name="image_position">top</property>
                   </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">1</property>
+                  </packing>
                 </child>
-                <child type="label">
+                <child>
                   <object class="GtkLabel" id="current-object">
                     <property name="visible">True</property>
-                    <property name="label" translatable="yes">&lt;b&gt;No object selected&lt;/b&gt;</property>
-                    <property name="use_markup">True</property>
-                    <property name="justify">fill</property>
+                    <property name="label" translatable="yes">label</property>
                     <property name="ellipsize">start</property>
-                    <property name="single_line_mode">True</property>
-                    <property name="max_width_chars">50</property>
                   </object>
+                  <packing>
+                    <property name="position">2</property>
+                  </packing>
                 </child>
               </object>
               <packing>
-                <property name="resize">True</property>
-                <property name="shrink">True</property>
+                <property name="expand">False</property>
+                <property name="fill">False</property>
+                <property name="position">0</property>
               </packing>
             </child>
             <child>
-              <object class="GtkFrame" id="frame2">
+              <object class="GtkVPaned" id="vpaned2">
                 <property name="visible">True</property>
-                <property name="label_xalign">0</property>
-                <property name="shadow_type">none</property>
+                <property name="can_focus">True</property>
+                <property name="orientation">vertical</property>
                 <child>
-                  <object class="GtkAlignment" id="alignment2">
+                  <object class="GtkScrolledWindow" id="scrolledwindow3">
                     <property name="visible">True</property>
-                    <property name="left_padding">12</property>
+                    <property name="can_focus">True</property>
+                    <property name="hscrollbar_policy">automatic</property>
+                    <property name="vscrollbar_policy">automatic</property>
                     <child>
-                      <object class="GtkScrolledWindow" id="scrolledwindow3">
+                      <object class="GtkTreeView" id="relationshipsview">
                         <property name="visible">True</property>
                         <property name="can_focus">True</property>
-                        <property name="hscrollbar_policy">automatic</property>
-                        <property name="vscrollbar_policy">automatic</property>
-                        <child>
-                          <object class="GtkTreeView" id="reverserelationshipsview">
-                            <property name="visible">True</property>
-                            <property name="can_focus">True</property>
-                            <property name="search_column">0</property>
-                          </object>
-                        </child>
                       </object>
                     </child>
                   </object>
+                  <packing>
+                    <property name="resize">False</property>
+                    <property name="shrink">True</property>
+                  </packing>
                 </child>
-                <child type="label">
-                  <object class="GtkLabel" id="current-object-reverse">
+                <child>
+                  <object class="GtkNotebook" id="types">
                     <property name="visible">True</property>
-                    <property name="label" translatable="yes">&lt;b&gt;No object selected&lt;/b&gt;</property>
-                    <property name="use_markup">True</property>
-                    <property name="justify">fill</property>
-                    <property name="ellipsize">start</property>
-                    <property name="single_line_mode">True</property>
-                    <property name="max_width_chars">50</property>
+                    <property name="can_focus">True</property>
                   </object>
+                  <packing>
+                    <property name="resize">True</property>
+                    <property name="shrink">True</property>
+                  </packing>
                 </child>
               </object>
               <packing>
-                <property name="resize">True</property>
-                <property name="shrink">True</property>
+                <property name="position">1</property>
               </packing>
             </child>
           </object>
diff --git a/src/tracker-explorer/explorer.vala b/src/tracker-explorer/explorer.vala
index 5855b5d..bb8af2c 100644
--- a/src/tracker-explorer/explorer.vala
+++ b/src/tracker-explorer/explorer.vala
@@ -22,9 +22,8 @@ public class Explorer {
 	private ListStore uris;
 	private ListStore relationships;
 	private Label current_object;
-	private ListStore reverserelationships;
-	private Label current_object_reverse;
 	private Gee.HashMap<string,string> namespaces = new Gee.HashMap<string,string>(str_hash, str_equal, str_equal);
+	private Notebook types;
 
 	public void show() {
 
@@ -73,10 +72,8 @@ public class Explorer {
 		setup_relationships(relationshipsview);
 
 		current_object = builder.get_object ("current-object") as Label;
-		var reverserelationshipsview = builder.get_object ("reverserelationshipsview") as TreeView;
-		setup_reverserelationships(reverserelationshipsview);
 
-		current_object_reverse = builder.get_object ("current-object-reverse") as Label;
+		types = builder.get_object ("types") as Notebook;
 
 		fetch_prefixes();
 
@@ -100,13 +97,16 @@ public class Explorer {
 		relationshipsview.row_activated += object_selected;
 	}
 
-	private void setup_reverserelationships(TreeView reverserelationshipsview) {
-		reverserelationships = new ListStore (2, typeof(string), typeof(string));
+	private TreeView setup_reverserelationships() {
+		ListStore reverserelationships = new ListStore (2, typeof(string), typeof(string));
+		TreeView reverserelationshipsview = new TreeView.with_model (reverserelationships);
 		reverserelationshipsview.set_model(reverserelationships);
 
 		reverserelationshipsview.insert_column_with_attributes (-1, "Subject", new CellRendererText (), "text", 1, null);
 		reverserelationshipsview.insert_column_with_attributes (-1, "Relationship", new CellRendererText (), "text", 0, null);
 		reverserelationshipsview.row_activated += object_selected;
+
+		return reverserelationshipsview;
 	}
 
 
@@ -149,43 +149,64 @@ public class Explorer {
 		string relationship;
 
 		if (prefix != null) {
-			relationship = string.join("#", prefix, parts[1]);
+			relationship = string.join(":", prefix, parts[1]);
 		} else {
 			relationship = uri;
+		} return relationship;
+	}
+
+	private void clear_types() {
+		for (int i = 0; i < types.get_n_pages(); i++) {
+			types.remove_page (i);
+		}
+	}
+
+	private void add_type(string type) {
+		Label tab_label = new Label(type);
+		ScrolledWindow child = new ScrolledWindow(null, null);
+		TreeView tv = setup_reverserelationships();
+		child.add(tv);
+		types.append_page(child, tab_label);
+		child.show_all();
+/*
+		try {
+			query = "SELECT ?s ?r WHERE { ?s ?r  <%s> }".printf(uri);
+			result = tracker.SparqlQuery(query);
+			reverserelationships.clear();
+
+			for (int i=0; i<result.length[0]; i++) {
+				var relationship = subst_prefix(result[i,1]);
+				reverserelationships.append (out iter);
+				reverserelationships.set (iter, 0, result[i,0], -1);
+				reverserelationships.set (iter, 1, relationship, -1);
+			}
+		} catch (DBus.Error e) {
 		}
-		return relationship;
+		*/
 	}
 
 	private void update_pane(string uri) {
 		//debug ("updating pane: %s", uri);
 		current_object.set_text (uri);
-		current_object_reverse.set_text (uri);
 
 		try {
 			string query = "SELECT ?r ?o  WHERE { <%s> ?r ?o }".printf(uri);
 			TreeIter iter;
 			var result = tracker.SparqlQuery(query);
 			relationships.clear();
+			clear_types();
 
 			for (int i=0; i<result.length[0]; i++) {
 				var relationship = subst_prefix(result[i,0]);
+				var obj = subst_prefix(result[i,1]);
 				relationships.append (out iter);
 				relationships.set (iter, 0, relationship, -1);
-				relationships.set (iter, 1, result[i,1], -1);
-			}
-/*
-			query = "SELECT ?s ?r WHERE { ?s ?r  <%s> }".printf(uri);
-			result = tracker.SparqlQuery(query);
-			reverserelationships.clear();
+				relationships.set (iter, 1, obj, -1);
 
-			for (int i=0; i<result.length[0]; i++) {
-				var relationship = subst_prefix(result[i,1]);
-				reverserelationships.append (out iter);
-				reverserelationships.set (iter, 0, result[i,0], -1);
-				reverserelationships.set (iter, 1, relationship, -1);
+				if (relationship == "rdf:type") {
+					add_type (obj);
+				}
 			}
-
-*/
 		} catch (DBus.Error e) {
 		}
 	}



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