[Pkg-bazaar-commits] ./bzr-gtk/unstable r571: Merge addition of word wrap control to gdiff and visualise windows

Jasper Groenewegen colbrac at xs4all.nl
Fri Apr 10 07:44:32 UTC 2009


------------------------------------------------------------
revno: 571
committer: Jasper Groenewegen <colbrac at xs4all.nl>
branch nick: trunk
timestamp: Fri 2008-07-25 15:32:06 +0200
message:
  Merge addition of word wrap control to gdiff and visualise windows
modified:
  NEWS
  diff.py
  viz/branchwin.py
    ------------------------------------------------------------
    revno: 555.2.1
    committer: Jasper Groenewegen <colbrac at xs4all.nl>
    branch nick: wrapped-diffs
    timestamp: Sun 2008-07-20 14:53:30 +0200
    message:
      Modify DiffWidget to include a checkbutton to wrap long lines in the diff view
    modified:
      diff.py
      viz/branchwin.py
    ------------------------------------------------------------
    revno: 555.2.2
    committer: Jasper Groenewegen <colbrac at xs4all.nl>
    branch nick: wrapped-diffs
    timestamp: Fri 2008-07-25 10:04:02 +0200
    message:
      Change from checkbox to menu item in bzr vis, add menu bar + item in gdiff
    modified:
      diff.py
      viz/branchwin.py
-------------- next part --------------
=== modified file 'NEWS'
--- a/NEWS	2008-07-22 22:25:30 +0000
+++ b/NEWS	2008-07-25 13:32:06 +0000
@@ -20,6 +20,8 @@
   * Made bzr vis remember window and panel sizes.  (Scott Scriven)
 
   * Sort Olive bookmarks by title (Jasper Groenewegen)
+  
+  * Add controls to wrap long lines in gdiff and diff in visualise. (Jasper Groenewegen, #229789)
 
  BUG FIXES
 

=== modified file 'diff.py'
--- a/diff.py	2008-07-17 11:24:26 +0000
+++ b/diff.py	2008-07-25 13:32:06 +0000
@@ -73,15 +73,15 @@
             self.buffer.set_language(gsl)
             self.buffer.set_highlight(True)
 
-            sourceview = gtksourceview.SourceView(self.buffer)
+            self.sourceview = gtksourceview.SourceView(self.buffer)
         else:
             self.buffer = gtk.TextBuffer()
-            sourceview = gtk.TextView(self.buffer)
+            self.sourceview = gtk.TextView(self.buffer)
 
-        sourceview.set_editable(False)
-        sourceview.modify_font(pango.FontDescription("Monospace"))
-        self.add(sourceview)
-        sourceview.show()
+        self.sourceview.set_editable(False)
+        self.sourceview.modify_font(pango.FontDescription("Monospace"))
+        self.add(self.sourceview)
+        self.sourceview.show()
 
     @staticmethod
     def apply_gedit_colors(lang):
@@ -305,7 +305,7 @@
         scrollwin.set_shadow_type(gtk.SHADOW_IN)
         self.pack1(scrollwin)
         scrollwin.show()
-
+        
         self.model = gtk.TreeStore(str, str)
         self.treeview = gtk.TreeView(self.model)
         self.treeview.set_headers_visible(False)
@@ -405,9 +405,15 @@
             return
         elif specific_files == [ "" ]:
             specific_files = None
-
+        
         self.diff_view.show_diff(specific_files)
-
+    
+    def _on_wraplines_toggled(self, widget=None, wrap=False):
+        """Callback for when the wrap lines checkbutton is toggled"""
+        if wrap or widget.get_active():
+            self.diff_view.sourceview.set_wrap_mode(gtk.WRAP_WORD)
+        else:
+            self.diff_view.sourceview.set_wrap_mode(gtk.WRAP_NONE)
 
 class DiffWindow(Window):
     """Diff window.
@@ -434,13 +440,33 @@
         self.vbox = gtk.VBox()
         self.add(self.vbox)
         self.vbox.show()
+        self.diff = DiffWidget()
+        self.vbox.pack_end(self.diff, True, True, 0)
+        self.diff.show_all()
+        # Build after DiffWidget to connect signals
+        menubar = self._get_menu_bar()
+        self.vbox.pack_start(menubar, False, False, 0)
         hbox = self._get_button_bar(operations)
         if hbox is not None:
-            self.vbox.pack_start(hbox, expand=False, fill=True)
-        self.diff = DiffWidget()
-        self.vbox.add(self.diff)
-        self.diff.show_all()
-
+            self.vbox.pack_start(hbox, False, True, 0)
+        
+    
+    def _get_menu_bar(self):
+        menubar = gtk.MenuBar()
+        # View menu
+        mb_view = gtk.MenuItem(_i18n("_View"))
+        mb_view_menu = gtk.Menu()
+        mb_view_wrapsource = gtk.CheckMenuItem(_i18n("Wrap _Long Lines"))
+        mb_view_wrapsource.connect('activate', self.diff._on_wraplines_toggled)
+        mb_view_wrapsource.show()
+        mb_view_menu.append(mb_view_wrapsource)
+        mb_view.show()
+        mb_view.set_submenu(mb_view_menu)
+        mb_view.show()
+        menubar.append(mb_view)
+        menubar.show()
+        return menubar
+    
     def _get_button_bar(self, operations):
         """Return a button bar to use.
 

=== modified file 'viz/branchwin.py'
--- a/viz/branchwin.py	2008-07-18 15:19:21 +0000
+++ b/viz/branchwin.py	2008-07-25 13:32:06 +0000
@@ -57,15 +57,16 @@
 
         self.set_title(branch.nick + " - revision history")
 
-        # Use three-quarters of the screen by default
-        screen = self.get_screen()
-        monitor = screen.get_monitor_geometry(0)
-        width = int(monitor.width * 0.75)
-        height = int(monitor.height * 0.75)
         # user-configured window size
         size = self._load_size('viz-window-size')
         if size:
             width, height = size
+        else:
+            # Use three-quarters of the screen by default
+            screen = self.get_screen()
+            monitor = screen.get_monitor_geometry(0)
+            width = int(monitor.width * 0.75)
+            height = int(monitor.height * 0.75)
         self.set_default_size(width, height)
         self.set_size_request(width/3, height/3)
         self.connect("size-allocate", self._on_size_allocate, 'viz-window-size')
@@ -125,7 +126,7 @@
         vbox.set_focus_child(self.paned)
 
         vbox.show()
-
+    
     def construct_menubar(self):
         menubar = gtk.MenuBar()
 
@@ -176,23 +177,31 @@
         view_menu_compact = gtk.CheckMenuItem("Show Compact Graph")
         view_menu_compact.set_active(self.compact_view)
         view_menu_compact.connect('activate', self._brokenlines_toggled_cb)
-
+        
         view_menu_diffs = gtk.CheckMenuItem("Show Diffs")
         view_menu_diffs.set_active(False)
         if self.config.get_user_option('viz-show-diffs') == 'True':
             view_menu_diffs.set_active(True)
         view_menu_diffs.connect('toggled', self._diff_visibility_changed)
-
+        
         view_menu_wide_diffs = gtk.CheckMenuItem("Wide Diffs")
         view_menu_wide_diffs.set_active(False)
         if self.config.get_user_option('viz-wide-diffs') == 'True':
             view_menu_wide_diffs.set_active(True)
         view_menu_wide_diffs.connect('toggled', self._diff_placement_changed)
-
+        
+        view_menu_wrap_diffs = gtk.CheckMenuItem("Wrap _Long Lines in Diffs")
+        view_menu_wrap_diffs.set_active(False)
+        if self.config.get_user_option('viz-wrap-diffs') == 'True':
+            view_menu_wrap_diffs.set_active(True)
+        view_menu_wrap_diffs.connect('toggled', self._diff_wrap_changed)
+                
         view_menu.add(view_menu_toolbar)
         view_menu.add(view_menu_compact)
+        view_menu.add(gtk.SeparatorMenuItem())
         view_menu.add(view_menu_diffs)
         view_menu.add(view_menu_wide_diffs)
+        view_menu.add(view_menu_wrap_diffs)
         view_menu.add(gtk.SeparatorMenuItem())
 
         self.mnu_show_revno_column = gtk.CheckMenuItem("Show Revision _Number Column")
@@ -422,7 +431,6 @@
 
             self.revisionview.set_revision(revision)
             self.revisionview.set_children(children)
-
             self.update_diff_panel(revision, parents)
 
     def _tree_revision_activated(self, widget, path, col):
@@ -545,7 +553,12 @@
         self._make_diff_nonzero_size()
 
         self.treeview.emit('revision-selected')
-
+    
+    def _diff_wrap_changed(self, widget):
+        """Toggle word wrap in the diff widget."""
+        self.config.set_user_option('viz-wrap-diffs', widget.get_active())
+        self.diff._on_wraplines_toggled(widget)
+    
     def _show_about_cb(self, w):
         dialog = AboutDialog()
         dialog.connect('response', lambda d,r: d.destroy())
@@ -640,4 +653,6 @@
         parent_tree = self.branch.repository.revision_tree(parent_id)
 
         self.diff.set_diff(rev_tree, parent_tree)
+        if self.config.get_user_option('viz-wrap-diffs') == 'True':
+            self.diff._on_wraplines_toggled(wrap=True)
         self.diff.show_all()



More information about the Pkg-bazaar-commits mailing list