Rev 526: Switch to found revision when clicking ok in search window. in file:///data/jelmer/bzr-gtk/trunk/

Jelmer Vernooij jelmer at samba.org
Tue Jul 1 15:52:33 BST 2008


At file:///data/jelmer/bzr-gtk/trunk/

------------------------------------------------------------
revno: 526
revision-id: jelmer at samba.org-20080701145231-dxgzwwypmhjo53lr
parent: jelmer at samba.org-20080701144256-x17f3oumt80tgl9j
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: trunk
timestamp: Tue 2008-07-01 16:52:31 +0200
message:
  Switch to found revision when clicking ok in search window.
modified:
  search.py                      search.py-20080701140205-dvpvrtf7n1qp2t8a-1
  viz/branchwin.py               branchwin.py-20051016222514-15fd120652fcf25c
=== modified file 'search.py'
--- a/search.py	2008-07-01 14:42:56 +0000
+++ b/search.py	2008-07-01 14:52:31 +0000
@@ -35,7 +35,8 @@
         gtk.Dialog.__init__(self, title="Search Revisions",
                                   parent=parent,
                                   flags=gtk.DIALOG_MODAL,
-                                  buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
+                                  buttons=(gtk.STOCK_OK, gtk.RESPONSE_OK,
+                                           gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL))
     
         # Get arguments
         self.branch = branch
@@ -49,7 +50,7 @@
         self.searchbar.add(self.searchentry)
         self.vbox.pack_start(self.searchbar, expand=False, fill=False)
 
-        self.results_model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
+        self.results_model = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING, gobject.TYPE_PYOBJECT)
         self.results_treeview = gtk.TreeView(self.results_model)
 
         documentname_column = gtk.TreeViewColumn("Document", gtk.CellRendererText(), text=0)
@@ -68,12 +69,25 @@
         # Show the dialog
         self.show_all()
 
+    def get_revision(self):
+        (path, focus) = self.results_treeview.get_cursor()
+        if path is None:
+            return None
+        iter = self.results_model.get_iter(path)
+        return self.results_model.get_value(iter, 2)
+
     def _searchentry_activate(self, entry):
         self.results_model.clear()
         self.index._branch.lock_read()
         try:
             query = [(query_item,) for query_item in self.searchentry.get_text().split(" ")]
             for result in self.index.search(query):
-                self.results_model.append([result.document_name(), result.summary()])
+                if isinstance(result, _mod_index.FileTextHit):
+                    revid = result.text_key[-1]
+                elif isinstance(result, _mod_index.RevisionHit):
+                    revid = result.revision_key[0]
+                else:
+                    raise AssertionError()
+                self.results_model.append([result.document_name(), result.summary(), revid])
         finally:
             self.index._branch.unlock()

=== modified file 'viz/branchwin.py'
--- a/viz/branchwin.py	2008-07-01 14:42:56 +0000
+++ b/viz/branchwin.py	2008-07-01 14:52:31 +0000
@@ -234,6 +234,8 @@
         except ImportError:
             mutter("Didn't find search plugin")
         else:
+            branch_menu.add(gtk.SeparatorMenuItem())
+
             branch_index_menuitem = gtk.MenuItem("_Index")
             branch_index_menuitem.connect('activate', self._branch_index_cb)
             branch_menu.add(branch_index_menuitem)
@@ -476,7 +478,12 @@
 
     def _branch_search_cb(self, w):
         from bzrlib.plugins.gtk.search import SearchDialog
-        SearchDialog(self.branch).run()
+        dialog = SearchDialog(self.branch)
+        
+        if dialog.run() == gtk.RESPONSE_OK:
+            self.set_revision(dialog.get_revision())
+
+        dialog.destroy()
 
     def _about_dialog_cb(self, w):
         from bzrlib.plugins.gtk.about import AboutDialog




More information about the bazaar-commits mailing list