[Pkg-bazaar-commits] ./bzr-gtk/unstable r353: Merged changes to the toolbar.

Daniel Schierbeck daniel.schierbeck at gmail.com
Fri Apr 10 07:45:14 UTC 2009


------------------------------------------------------------
revno: 353
committer: Daniel Schierbeck <daniel.schierbeck at gmail.com>
branch nick: menubar
timestamp: Sun 2007-11-04 19:59:13 +0100
message:
  Merged changes to the toolbar.
modified:
  viz/branchwin.py
    ------------------------------------------------------------
    revno: 352.1.1
    committer: Daniel Schierbeck <daniel.schierbeck at gmail.com>
    branch nick: toolbar
    timestamp: Sun 2007-11-04 19:53:17 +0100
    message:
      Added dropdown menu to Back button.
    modified:
      viz/branchwin.py
    ------------------------------------------------------------
    revno: 352.1.2
    committer: Daniel Schierbeck <daniel.schierbeck at gmail.com>
    branch nick: toolbar
    timestamp: Sun 2007-11-04 19:58:33 +0100
    message:
      Added dropdown menu to Forward button.
    modified:
      viz/branchwin.py
-------------- next part --------------
=== modified file 'viz/branchwin.py'
--- a/viz/branchwin.py	2007-11-04 16:41:30 +0000
+++ b/viz/branchwin.py	2007-11-04 18:58:33 +0000
@@ -15,6 +15,7 @@
 
 from bzrlib.plugins.gtk.window import Window
 from bzrlib.plugins.gtk.preferences import PreferencesWindow
+from bzrlib.revision import Revision
 from treeview import TreeView
 
 class BranchWindow(Window):
@@ -202,7 +203,7 @@
         self.toolbar = gtk.Toolbar()
         self.toolbar.set_style(gtk.TOOLBAR_BOTH_HORIZ)
 
-        self.back_button = gtk.ToolButton(stock_id=gtk.STOCK_GO_BACK)
+        self.back_button = gtk.MenuToolButton(stock_id=gtk.STOCK_GO_BACK)
         self.back_button.set_is_important(True)
         self.back_button.add_accelerator("clicked", self.accel_group, ord('['),
                                          0, 0)
@@ -210,7 +211,7 @@
         self.toolbar.insert(self.back_button, -1)
         self.back_button.show()
 
-        self.fwd_button = gtk.ToolButton(stock_id=gtk.STOCK_GO_FORWARD)
+        self.fwd_button = gtk.MenuToolButton(stock_id=gtk.STOCK_GO_FORWARD)
         self.fwd_button.set_is_important(True)
         self.fwd_button.add_accelerator("clicked", self.accel_group, ord(']'),
                                         0, 0)
@@ -243,8 +244,36 @@
         children = self.treeview.get_children()
 
         if revision is not None:
-            self.back_button.set_sensitive(len(parents) > 0)
-            self.fwd_button.set_sensitive(len(children) > 0)
+            back_menu = gtk.Menu()
+            if len(parents) > 0:
+                self.back_button.set_sensitive(True)
+                for parent_id in parents:
+                    parent = self.branch.repository.get_revision(parent_id)
+                    item = gtk.MenuItem(parent.message.split("\n")[0])
+                    item.connect('activate', self._set_revision_cb, parent_id)
+                    back_menu.add(item)
+                back_menu.show_all()
+            else:
+                self.back_button.set_sensitive(False)
+                back_menu.hide()
+
+            self.back_button.set_menu(back_menu)
+
+            fwd_menu = gtk.Menu()
+            if len(children) > 0:
+                self.fwd_button.set_sensitive(True)
+                for child_id in children:
+                    child = self.branch.repository.get_revision(child_id)
+                    item = gtk.MenuItem(child.message.split("\n")[0])
+                    item.connect('activate', self._set_revision_cb, child_id)
+                    fwd_menu.add(item)
+                fwd_menu.show_all()
+            else:
+                self.fwd_button.set_sensitive(False)
+                fwd_menu.hide()
+
+            self.fwd_button.set_menu(fwd_menu)
+
             tags = []
             if self.branch.supports_tags():
                 tagdict = self.branch.tags.get_reverse_tag_dict()
@@ -269,6 +298,9 @@
         self.treeview.show_diff(self.branch, revid, parentid)
         self.treeview.grab_focus()
 
+    def _set_revision_cb(self, w, revision_id):
+        self.treeview.set_revision(revision_id)
+
     def _col_visibility_changed(self, col, property):
         self.treeview.set_property(property + '-column-visible', col.get_active())
 



More information about the Pkg-bazaar-commits mailing list