/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to commit.py

  • Committer: John Arbash Meinel
  • Date: 2007-09-27 22:16:26 UTC
  • mto: (322.1.1 trunk) (330.3.3 trunk)
  • mto: This revision was merged to the branch mainline in revision 368.
  • Revision ID: john@arbash-meinel.com-20070927221626-tlpljk85fnavtmiu
Just playing around. 
Moved the diff contents into a separate class, so that we
could reuse it without having another top level window.
Playing around with how to lay that out in the gcommit view.

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
except ImportError:
40
40
    have_dbus = False
41
41
 
 
42
 
42
43
class CommitDialog(gtk.Dialog):
43
44
    """ New implementation of the Commit dialog. """
44
45
    def __init__(self, wt, wtpath, notbranch, selected=None, parent=None):
85
86
                self._is_pending = True
86
87
        
87
88
        # Create the widgets
 
89
        # This is the main horizontal box, which is used to separate the commit
 
90
        # info from the diff window.
 
91
        self._hpane = gtk.HPaned()
88
92
        self._button_commit = gtk.Button(_("Comm_it"), use_underline=True)
89
93
        self._expander_files = gtk.Expander(_("File(s) to commit"))
90
94
        self._vpaned_main = gtk.VPaned()
103
107
 
104
108
        # Set callbacks
105
109
        self._button_commit.connect('clicked', self._on_commit_clicked)
106
 
        self._treeview_files.connect('row_activated', self._on_treeview_files_row_activated)
 
110
        self._treeview_files.connect('cursor-changed', self._on_treeview_files_cursor_changed)
 
111
        self._treeview_files.connect('row-activated', self._on_treeview_files_row_activated)
107
112
        
108
113
        # Set properties
109
114
        self._scrolledwindow_files.set_policy(gtk.POLICY_AUTOMATIC,
142
147
 
143
148
        self._vpaned_main.add2(self._vbox_message)
144
149
        
145
 
        self.vbox.pack_start(self._vpaned_main, True, True)
 
150
        self._hpane.pack1(self._vpaned_main)
 
151
        self.vbox.pack_start(self._hpane, expand=True, fill=True)
146
152
        if self._is_checkout: 
147
153
            self._check_local = gtk.CheckButton(_("_Only commit locally"),
148
154
                                                use_underline=True)
165
171
        self._create_file_view()
166
172
        # Create the pending merges
167
173
        self._create_pending_merges()
 
174
        self._create_diff_view()
168
175
        
169
176
        # Expand the corresponding expander
170
177
        if self._is_pending:
178
185
        # Default to Commit button
179
186
        self._button_commit.grab_default()
180
187
    
181
 
    def _on_treeview_files_row_activated(self, treeview, path, view_column):
 
188
    def _show_diff_view(self, treeview):
182
189
        # FIXME: the diff window freezes for some reason
183
190
        treeselection = treeview.get_selection()
184
191
        (model, iter) = treeselection.get_selected()
185
 
        
 
192
 
186
193
        if iter is not None:
187
 
            from diff import DiffWindow
188
 
            
189
 
            _selected = model.get_value(iter, 1)
190
 
            
191
 
            diff = DiffWindow()
192
 
            diff.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
193
 
            diff.set_modal(True)
194
 
            parent_tree = self.wt.branch.repository.revision_tree(self.wt.branch.last_revision())
195
 
            diff.set_diff(self.wt.branch.nick, self.wt, parent_tree)
196
 
            try:
197
 
                diff.set_file(_selected)
198
 
            except errors.NoSuchFile:
199
 
                pass
200
 
            diff.show()
 
194
            selected = model.get_value(iter, 3) # Get the real_path attribute
 
195
            self._diff_display.show_diff([selected])
 
196
 
 
197
    def _on_treeview_files_cursor_changed(self, treeview):
 
198
        self._show_diff_view(treeview)
 
199
        
 
200
    def _on_treeview_files_row_activated(self, treeview, path, view_column):
 
201
        self._show_diff_view(treeview)
201
202
    
202
203
    @show_bzr_error
203
204
    def _on_commit_clicked(self, button):
404
405
                               item['committer'],
405
406
                               item['summary'] ])
406
407
    
 
408
 
 
409
    def _create_diff_view(self):
 
410
        from diff import DiffDisplay
 
411
 
 
412
        self._diff_display = DiffDisplay()
 
413
        self._diff_display.set_trees(self.wt, self.wt.basis_tree())
 
414
        self._diff_display.show_diff(None)
 
415
        self._diff_display.show()
 
416
        self._hpane.pack2(self._diff_display)
 
417
 
407
418
    def _get_specific_files(self):
408
419
        ret = []
409
420
        it = self._file_store.get_iter_first()