Rev 426: Allow using the diff control as a widget in file:///data/jelmer/bzr-gtk/changes-below/

Jelmer Vernooij jelmer at samba.org
Sat Jan 26 23:48:20 GMT 2008


At file:///data/jelmer/bzr-gtk/changes-below/

------------------------------------------------------------
revno: 426
revision-id:jelmer at samba.org-20080126234818-q8tj21lrn588fg3c
parent: daniel.schierbeck at gmail.com-20080120204259-vvlke962mogun46l
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: changes-below
timestamp: Sun 2008-01-27 00:48:18 +0100
message:
  Allow using the diff control as a widget
modified:
  diff.py                        diffwin.py-20051017070234-cb5c6dc4960142f5
=== modified file 'diff.py'
--- a/diff.py	2007-11-07 14:19:09 +0000
+++ b/diff.py	2008-01-26 23:48:18 +0000
@@ -261,41 +261,18 @@
         self.buffer.set_text(decoded.encode('UTF-8'))
 
 
-class DiffWindow(Window):
-    """Diff window.
+class DiffWidget(gtk.HPaned):
+    """Diff widget
 
-    This object represents and manages a single window containing the
-    differences between two revisions on a branch.
     """
-
-    def __init__(self, parent=None):
-        Window.__init__(self, parent)
-        self.set_border_width(0)
-        self.set_title("bzrk diff")
-
-        # Use two thirds of the screen by default
-        screen = self.get_screen()
-        monitor = screen.get_monitor_geometry(0)
-        width = int(monitor.width * 0.66)
-        height = int(monitor.height * 0.66)
-        self.set_default_size(width, height)
-
-        self.construct()
-
-    def construct(self):
-        """Construct the window contents."""
-        # The   window  consists  of   a  pane   containing:  the
-        # hierarchical list  of files on  the left, and  the diff
-        # for the currently selected file on the right.
-        pane = gtk.HPaned()
-        self.add(pane)
-        pane.show()
+    def __init__(self):
+        super(DiffWidget, self).__init__()
 
         # The file hierarchy: a scrollable treeview
         scrollwin = gtk.ScrolledWindow()
         scrollwin.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
         scrollwin.set_shadow_type(gtk.SHADOW_IN)
-        pane.pack1(scrollwin)
+        self.pack1(scrollwin)
         scrollwin.show()
 
         self.model = gtk.TreeStore(str, str)
@@ -316,10 +293,10 @@
         # The diffs of the  selected file: a scrollable source or
         # text view
         self.diff_view = DiffView()
-        pane.pack2(self.diff_view)
+        self.pack2(self.diff_view)
         self.diff_view.show()
 
-    def set_diff(self, description, rev_tree, parent_tree):
+    def set_diff(self, rev_tree, parent_tree):
         """Set the differences showed by this window.
 
         Compares the two trees and populates the window with the
@@ -356,7 +333,6 @@
                 self.model.append(titer, [ path, path ])
 
         self.treeview.expand_all()
-        self.set_title(description + " - bzrk diff")
 
     def set_file(self, file_path):
         tv_path = None
@@ -382,6 +358,46 @@
         self.diff_view.show_diff(specific_files)
 
 
+class DiffWindow(Window):
+    """Diff window.
+
+    This object represents and manages a single window containing the
+    differences between two revisions on a branch.
+    """
+
+    def __init__(self, parent=None):
+        Window.__init__(self, parent)
+        self.set_border_width(0)
+        self.set_title("bzrk diff")
+
+        # Use two thirds of the screen by default
+        screen = self.get_screen()
+        monitor = screen.get_monitor_geometry(0)
+        width = int(monitor.width * 0.66)
+        height = int(monitor.height * 0.66)
+        self.set_default_size(width, height)
+
+        self.construct()
+
+    def construct(self):
+        """Construct the window contents."""
+        self.diff = DiffWidget()
+        self.add(self.diff)
+        self.diff.show_all()
+
+    def set_diff(self, description, rev_tree, parent_tree):
+        """Set the differences showed by this window.
+
+        Compares the two trees and populates the window with the
+        differences.
+        """
+        self.diff.set_diff(rev_tree, parent_tree)
+        self.set_title(description + " - bzrk diff")
+
+    def set_file(self, file_path):
+        self.diff.set_file(file_path)
+
+
 def _iter_changes_to_status(source, target):
     """Determine the differences between trees.
 




More information about the bazaar-commits mailing list