/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-10-02 17:03:44 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-20071002170344-20tg0gldveoc73bb
Start tracking the per-file commit messages.
Add tests that switching selections saves the current value, and
restores the value for the new selection.

Show diffs side-by-side

added added

removed removed

Lines of Context:
163
163
        kind_changed = _('kind changed')
164
164
 
165
165
        # The store holds:
166
 
        # [file_id, real path, checkbox, display path, changes type]
 
166
        # [file_id, real path, checkbox, display path, changes type, message]
167
167
        # _iter_changes returns:
168
168
        # (file_id, (path_in_source, path_in_target),
169
169
        #  changed_content, versioned, parent, name, kind,
170
170
        #  executable)
171
171
 
172
172
        # The first entry is always the 'whole tree'
173
 
        store.append([None, None, True, 'All Files', ''])
 
173
        store.append([None, None, True, 'All Files', '', ''])
174
174
        # should we pass specific_files?
175
175
        self._wt.lock_read()
176
176
        self._basis_tree.lock_read()
225
225
                else:
226
226
                    assert False, "How did we get here?"
227
227
 
228
 
                store.append([file_id, real_path, True, display_path, change_type])
 
228
                store.append([file_id, real_path, True, display_path,
 
229
                              change_type, ''])
229
230
        finally:
230
231
            self._basis_tree.unlock()
231
232
            self._wt.unlock()
232
233
 
233
234
        self._treeview_files.set_model(store)
 
235
        self._last_selected_file = None
234
236
        self._treeview_files.set_cursor(0)
235
237
 
236
238
    def _fill_in_diff(self):
335
337
            gobject.TYPE_BOOLEAN, # [2] checkbox
336
338
            gobject.TYPE_STRING,  # [3] display path
337
339
            gobject.TYPE_STRING,  # [4] changes type
 
340
            gobject.TYPE_STRING,  # [5] commit message
338
341
            )
339
342
        self._files_store = liststore
340
343
        self._treeview_files.set_model(liststore)
432
435
        self._file_message_text_view.set_accepts_tab(False)
433
436
        self._file_message_text_view.show()
434
437
 
435
 
        self._file_message_expander = gtk.Expander(_('Per File Message'))
 
438
        self._file_message_expander = gtk.Expander(_('File commit message'))
436
439
        self._file_message_expander.add(file_message_box)
437
440
        file_message_box.show()
438
441
        self._add_to_right_table(self._file_message_expander, 1, False)
461
464
 
462
465
    def _on_treeview_files_cursor_changed(self, treeview):
463
466
        treeselection = treeview.get_selection()
464
 
        (model, iterable) = treeselection.get_selected()
 
467
        (model, selection) = treeselection.get_selected()
465
468
 
466
 
        if iterable is not None:
467
 
            path, display_path = model.get(iterable, 1, 3) # Get the real_path attribute
 
469
        if selection is not None:
 
470
            path, display_path = model.get(selection, 1, 3)
468
471
            self._diff_label.set_text(_('Diff for ') + display_path)
469
472
            if path is None:
470
473
                self._diff_view.show_diff(None)
471
474
            else:
472
475
                self._diff_view.show_diff([path])
 
476
            self._update_per_file_info(selection)
 
477
 
 
478
    def _save_current_file_message(self):
 
479
        if self._last_selected_file is None:
 
480
            return # Nothing to save
 
481
        text_buffer = self._file_message_text_view.get_buffer()
 
482
        cur_text = text_buffer.get_text(text_buffer.get_start_iter(),
 
483
                                        text_buffer.get_end_iter())
 
484
        last_selected = self._files_store.get_iter(self._last_selected_file)
 
485
        self._files_store.set_value(last_selected, 5, cur_text)
 
486
 
 
487
    def _update_per_file_info(self, selection):
 
488
        # The node is changing, so cache the current message
 
489
        self._save_current_file_message()
 
490
        text_buffer = self._file_message_text_view.get_buffer()
 
491
        file_id, display_path, message = self._files_store.get(selection, 0, 3, 5)
 
492
        if file_id is None: # Whole tree
 
493
            self._file_message_expander.set_label(_('File commit message'))
 
494
            self._file_message_expander.set_expanded(False)
 
495
            self._file_message_expander.set_sensitive(False)
 
496
            text_buffer.set_text('')
 
497
            self._last_selected_file = None
 
498
        else:
 
499
            self._file_message_expander.set_label(_('Commit message for ')
 
500
                                                  + display_path)
 
501
            self._file_message_expander.set_expanded(True)
 
502
            self._file_message_expander.set_sensitive(True)
 
503
            text_buffer.set_text(message)
 
504
            self._last_selected_file = self._files_store.get_path(selection)
473
505
 
474
506
    @staticmethod
475
507
    def _rev_to_pending_info(rev):