[tracker] tracker-search-tool: Added metadata tile



commit ae02de3e408e71eea40465c0ebfcb30fd3218226
Author: Jamie McCracken <jamiemcc gnome org>
Date:   Thu Sep 24 00:58:23 2009 -0400

    tracker-search-tool: Added metadata tile

 src/tracker-search-tool/Makefile.am              |    1 +
 src/tracker-search-tool/tracker-category-view.gs |    2 +
 src/tracker-search-tool/tracker-metadata-tile.gs |  193 ++++++++++++++++++++++
 src/tracker-search-tool/tracker-query.gs         |    2 +-
 src/tracker-search-tool/tracker-result-grid.gs   |   62 +++++--
 src/tracker-search-tool/tracker-search-tool.gs   |   11 +-
 src/tracker-search-tool/tracker-utils.gs         |   26 +++
 src/tracker-search-tool/tst.ui                   |   35 ++--
 8 files changed, 289 insertions(+), 43 deletions(-)
---
diff --git a/src/tracker-search-tool/Makefile.am b/src/tracker-search-tool/Makefile.am
index 9425a4e..754efb6 100644
--- a/src/tracker-search-tool/Makefile.am
+++ b/src/tracker-search-tool/Makefile.am
@@ -10,6 +10,7 @@ tracker_search_tool_VALASOURCES = \
 	tracker-result-grid.gs \	
     tracker-search-tool.gs \
     tracker-category-view.gs \
+    tracker-metadata-tile.gs \
     tracker-utils.gs \
 	$(NULL)
 
diff --git a/src/tracker-search-tool/tracker-category-view.gs b/src/tracker-search-tool/tracker-category-view.gs
index 5684f49..4d2f6ed 100644
--- a/src/tracker-search-tool/tracker-category-view.gs
+++ b/src/tracker-search-tool/tracker-category-view.gs
@@ -17,6 +17,8 @@ const icon_size : int = 16
 class TrackerCategoryView : ScrolledWindow
     store : ListStore
     treeview : TreeView
+    lab : Label
+    catergory : Categories
     
     prop Query : TrackerQuery
     
diff --git a/src/tracker-search-tool/tracker-metadata-tile.gs b/src/tracker-search-tool/tracker-metadata-tile.gs
new file mode 100644
index 0000000..985a17c
--- /dev/null
+++ b/src/tracker-search-tool/tracker-metadata-tile.gs
@@ -0,0 +1,193 @@
+[indent=4]
+
+uses
+    Gtk
+    TrackerUtils
+ 
+    
+class TrackerMetadataTile : HBox
+    uri : string
+    category : Categories 
+    image : Image
+    name_link : LinkButton
+    table : Table
+    
+    
+    /* metadata fields */
+    info_label1 : Label
+    info_value1 : Label
+    
+    info_label2 : Label
+    info_value2 : Label
+    
+    info_label3 : Label
+    info_value3 : Label
+    
+    info_label4 : Label
+    info_value4 : Label
+    
+    info_label5 : Label
+    info_value5 : Label
+    
+    info_label6 : Label
+    info_value6 : Label
+
+    info_label7 : Label
+    info_value7 : Label
+
+    info_label8 : Label
+    info_value8 : Label
+    
+    _result_grid : TrackerResultGrid
+    
+    
+    prop Query : TrackerQuery
+    
+    prop ResultGrid : TrackerResultGrid
+        get
+            return _result_grid
+        set
+            if value is not null
+                _result_grid = value
+                
+                _result_grid.SelectionChanged += def (path)
+                    LoadUri (path)    
+   
+                                                
+    init
+        border_width = 8
+    
+        table = new Table (3, 7, true)
+        
+        table.column_spacing = 0
+        table.row_spacing = 1
+
+        add (table)
+
+        image = new Image.from_icon_name ("text-x-generic", IconSize.DIALOG)
+        table.attach_defaults (image, 0, 1, 0, 3)
+        
+        name_link = new LinkButton ("")
+        name_link.xalign = 0
+        table.attach_defaults (name_link, 1, 7, 0, 1)
+        
+        info_label1 = CreateLabel (N_("Type : "))
+        AttachToTable (info_label1, 1, 2, 1, 2)
+        
+        info_value1 = CreateLabel ("")
+        AttachToTable (info_value1, 2, 3, 1, 2)
+        
+        info_label2 = CreateLabel (N_("Size : "))
+        AttachToTable (info_label2, 3, 4, 1, 2)
+        
+        info_value2 = CreateLabel ("")        
+        AttachToTable (info_value2, 4, 5, 1, 2)
+        
+        info_label3 = CreateLabel (N_("Modified : "))        
+        AttachToTable (info_label3, 5, 6, 1, 2)
+        
+        info_value3 = CreateLabel ("")        
+        AttachToTable (info_value3, 6, 7, 1, 2)
+        
+        info_label4 = CreateLabel (N_("Title : "))
+        AttachToTable (info_label4, 1, 2, 2, 3)
+        
+        info_value4 = CreateLabel ("")        
+        AttachToTable (info_value4, 2, 3, 2, 3)
+        
+        info_label5 = CreateLabel (N_("Author/Artist : "))        
+        AttachToTable (info_label5, 3, 4, 2, 3)
+        
+        info_value5 = CreateLabel ("")        
+        AttachToTable (info_value5, 4, 5, 2, 3)
+        
+        info_label6 = CreateLabel ("Comments : ")        
+        AttachToTable (info_label6, 5, 6, 2, 3)
+        
+        info_value6 = CreateLabel ("")        
+        AttachToTable (info_value6, 6, 7, 2, 3)
+        
+        show_all ()
+        
+        
+        
+    def private AttachToTable (lab : Label, l : int, r : int, t : int, b : int)
+        table.attach (lab, l, r, t, b, AttachOptions.FILL | AttachOptions.SHRINK , AttachOptions.FILL, 0, 0)
+        
+        
+    def private CreateLabel (s : string) : Label
+        var l = new Label (s)
+        l.xalign = 0
+        l.set_use_markup (true)
+        
+        if s is ""
+            l.ellipsize = Pango.EllipsizeMode.END
+        
+        return l
+        
+        
+    def ClearLabels ()
+        info_value1.set_text ("")
+        info_value2.set_text ("")
+        info_value3.set_text ("")
+        info_value4.set_text ("")
+        info_value5.set_text ("")
+        info_value6.set_text ("")
+        name_link.uri = ""
+        name_link.label = ""
+        
+
+        
+                
+    def LoadUri (path : TreePath?)
+        ClearLabels ()
+    
+        if path is null
+            image.set_from_icon_name ("text-x-generic", IconSize.DIALOG)
+            return
+           
+        iter : TreeIter
+        uri : weak string
+        display_name : weak string
+        icon : Gdk.Pixbuf      
+        
+        _result_grid.store.get_iter (out iter, path)
+        _result_grid.store.get (iter, ResultColumns.Uri, out uri, ResultColumns.Icon, out icon, ResultColumns.DisplayName, out display_name)
+
+        image.set_from_pixbuf (icon)
+        
+        var file = File.new_for_uri (uri)
+        var filepath = file.get_path ()
+        name_link.uri = uri
+        name_link.label = filepath
+        
+        // get metadata
+        // var query = "SELECT ?mimetype ?size ?mtime WHERE {<%s> nie:byteSize ?size; nie:contentLastModified ?mtime; nie:mimeType ?mimeType.}".printf(uri)
+        var query = "SELECT ?mimetype WHERE {<%s> nie:mimeType ?mimeType.}".printf(uri)
+        if Query is not null
+            var result = Query.Query (query)
+            
+            if result is not null and  result [0,0] is not null
+                var val1 = "<b>%s</b>".printf (result [0,0])
+            
+                info_value1.set_markup (val1)
+                info_value1.xalign = 0
+                
+            try
+                var info =  file.query_info ("standard::size,time::modified", \
+                                              FileQueryInfoFlags.NONE, null) 
+                
+                var val2 = "<b>%s</b>".printf (info.get_size ().to_string ())
+                
+                info_value2.set_markup (val2)
+                
+                tm : TimeVal
+                info.get_modification_time (out tm)
+                
+                var val3 = "<b>%s</b>".printf (tm.to_iso8601 ())
+                
+                info_value3.set_markup (val3)
+                                                 
+            except e:Error
+                print "Could not get file info for %s", uri     
+        
diff --git a/src/tracker-search-tool/tracker-query.gs b/src/tracker-search-tool/tracker-query.gs
index 22c205a..fd07c11 100644
--- a/src/tracker-search-tool/tracker-query.gs
+++ b/src/tracker-search-tool/tracker-query.gs
@@ -56,7 +56,7 @@ class TrackerQuery : Object
 
         // to do : add Fields, Category and SortField
         return tracker.SparqlQuery (query)
-        
+
         
     def Query (sparql : string) : array of string[,] 
         return tracker.SparqlQuery (sparql)
diff --git a/src/tracker-search-tool/tracker-result-grid.gs b/src/tracker-search-tool/tracker-result-grid.gs
index 9e7973e..941e042 100644
--- a/src/tracker-search-tool/tracker-result-grid.gs
+++ b/src/tracker-search-tool/tracker-result-grid.gs
@@ -13,6 +13,7 @@ enum ResultColumns
     Category
     Snippet
     IsDirectory
+    Path
     NumOfCols
 
 
@@ -24,7 +25,7 @@ class TrackerResultGrid : ScrolledWindow
     iconview: IconView
     _query : TrackerQuery
     
-    event SelectedUriChanged ()    
+    event SelectionChanged (path : TreePath?)    
     
     prop Query : TrackerQuery
         get
@@ -36,16 +37,39 @@ class TrackerResultGrid : ScrolledWindow
                     RefreshQuery ()
                 _query.ClearSearchResults += def ()
                     store.clear ()
-                        
+        
+    def GetSelectedPath () : TreePath?
+        l :  weak GLib.List of TreePath
+
+        l = iconview.get_selected_items ()
 
+        if l is not null and l.data is not null
+            return l.data
+            
+        return null
+            
+            
+    def GetSelectedUri () : weak string
+        iter : TreeIter
+        uri : weak string
+        
+        var path = GetSelectedPath ()
+        if path is not null
+            store.get_iter (out iter, path)
+            store.get (iter, ResultColumns.Uri, out uri);
+            return uri
+            
+        return ""    
+    
+    
     init
     
-        hscrollbar_policy = PolicyType.NEVER
+        hscrollbar_policy = PolicyType.AUTOMATIC
         vscrollbar_policy = PolicyType.AUTOMATIC
         shadow_type = ShadowType.ETCHED_OUT
            
         store = new ListStore (ResultColumns.NumOfCols, typeof (string), typeof (Gdk.Pixbuf), typeof (string), \
-                               typeof (string), typeof (string), typeof (string), typeof (bool))
+                               typeof (int), typeof (string), typeof (string), typeof (bool), typeof (string))
 
         // to do add treeview        
 						
@@ -59,39 +83,35 @@ class TrackerResultGrid : ScrolledWindow
         iconview.item_activated += ActivateUri 
 
         iconview.selection_changed += def ()
-            SelectedUriChanged ()
+            var path = GetSelectedPath ()
+            SelectionChanged (path)
 
         /* set correct uri for drag drop  */
         iconview.drag_data_get +=  def (context, data, info, time)
-            l :  weak GLib.List of TreePath
-            l = iconview.get_selected_items ()
-            if l is not null and l.data is not null
-                iter : TreeIter
-                uri : weak string
-                path : TreePath = l.data
-                store.get_iter (out iter, path)
-                store.get (iter, ResultColumns.Uri, out uri);
+            var uri = GetSelectedUri ()
+            if uri is not null
                 var s = new array of string [1]
                 s[0] = uri
                 data.set_uris (s) 
-          
-        
-      
-		
+
         add (iconview)
-		
         show_all ()
 
                 
     def RefreshQuery ()
         if _query is not null
             var results = _query.Search ()
+            var has_results = false
             iter : TreeIter
 
             store.clear ()
             
+            if results is null do return
+            
             for uri in results
                 if uri.has_prefix ("file://")
+                
+                    has_results = true
                     
                     var file = File.new_for_uri (uri)
                     
@@ -106,6 +126,12 @@ class TrackerResultGrid : ScrolledWindow
                                   (filetype is FileType.DIRECTORY) , -1);
                     except e:Error
                         print "Could not get file info for %s", uri
+                        
+            /* select first result */
+            if has_results
+                var path = new TreePath.from_string ("0:0:0")
+                if path is not null
+                    iconview.select_path (path)
             
                     
     
diff --git a/src/tracker-search-tool/tracker-search-tool.gs b/src/tracker-search-tool/tracker-search-tool.gs
index 5ffcc6b..abb473e 100644
--- a/src/tracker-search-tool/tracker-search-tool.gs
+++ b/src/tracker-search-tool/tracker-search-tool.gs
@@ -3,11 +3,6 @@
 uses
     Gtk
 
-[CCode (cname = "TRACKER_UI_DIR")]
-const  extern static  UIDIR : string
-    
-[CCode (cname = "SRCDIR")]
-const  extern static  SRCDIR : string
 
 init  
     Gtk.init (ref args)
@@ -41,10 +36,12 @@ init
         entry = new TrackerSearchEntry ()
         grid = new TrackerResultGrid ()
         categories = new TrackerCategoryView ()
+        tile = new TrackerMetadataTile ()
         
         entry_box = builder.get_object ("EntryBox") as Container
         grid_box = builder.get_object ("GridBox") as Container
         category_box = builder.get_object ("CategoryBox") as Container
+        detail_box = builder.get_object ("DetailBox") as Container
         
         
     query.Connect ()    
@@ -56,6 +53,10 @@ init
     
     categories.Query = query
     category_box.add (categories)
+    
+    tile.ResultGrid = grid
+    tile.Query = query
+    detail_box.add (tile)
 
     window.show_all ()
         
diff --git a/src/tracker-search-tool/tracker-utils.gs b/src/tracker-search-tool/tracker-utils.gs
index 8b4cebd..f04a782 100644
--- a/src/tracker-search-tool/tracker-utils.gs
+++ b/src/tracker-search-tool/tracker-utils.gs
@@ -3,10 +3,36 @@
 uses
     Gtk
     
+
+enum Categories
+    Application
+    Contact
+    Email
+    EmailAttachment
+    File
+    Folder
+    Music
+    Video
+    Image
+    Document
+    Text
+    Development
+    Web
+    WebHistory    
+    
+[CCode (cname = "TRACKER_UI_DIR")]
+const  extern static  UIDIR : string
+    
+[CCode (cname = "SRCDIR")]
+const  extern static  SRCDIR : string
+
     
 class TrackerUtils
 /* static methods only as this is a utility class that wont ever get substantiated */
 
+
+
+
     def static OpenUri (uri : string, is_dir :bool) : bool
         command : string
         app_info : AppInfo
diff --git a/src/tracker-search-tool/tst.ui b/src/tracker-search-tool/tst.ui
index 3d71f68..01bd36c 100644
--- a/src/tracker-search-tool/tst.ui
+++ b/src/tracker-search-tool/tst.ui
@@ -64,45 +64,42 @@
               </packing>
             </child>
             <child>
-              <object class="GtkVPaned" id="vpaned1">
+              <object class="GtkVBox" id="vbox2">
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
                 <property name="orientation">vertical</property>
-                <property name="position">600</property>
-                <property name="position_set">True</property>
+                <child>
+                  <placeholder/>
+                </child>
                 <child>
                   <object class="GtkVBox" id="GridBox">
                     <property name="visible">True</property>
                     <property name="orientation">vertical</property>
                     <child>
-                      <object class="GtkToolbar" id="toolbar1">
-                        <property name="visible">True</property>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="position">0</property>
-                      </packing>
-                    </child>
-                    <child>
                       <placeholder/>
                     </child>
                   </object>
                   <packing>
-                    <property name="resize">True</property>
-                    <property name="shrink">True</property>
+                    <property name="position">1</property>
                   </packing>
                 </child>
                 <child>
-                  <object class="GtkVBox" id="DetailBox">
+                  <object class="GtkExpander" id="DetailBox">
                     <property name="visible">True</property>
-                    <property name="orientation">vertical</property>
+                    <property name="can_focus">True</property>
+                    <property name="expanded">True</property>
                     <child>
                       <placeholder/>
                     </child>
+                    <child type="label">
+                      <object class="GtkLabel" id="label2">
+                        <property name="visible">True</property>
+                        <property name="label" translatable="yes">Details</property>
+                      </object>
+                    </child>
                   </object>
                   <packing>
-                    <property name="resize">False</property>
-                    <property name="shrink">False</property>
+                    <property name="expand">False</property>
+                    <property name="position">2</property>
                   </packing>
                 </child>
               </object>



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