1
# Copyright (C) 2006 Jelmer Vernooij <jelmer@samba.org>
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
from bzrlib.delta import compare_trees
24
class GCommitDialog(gtk.Dialog):
27
def __init__(self, tree):
28
gtk.Dialog.__init__(self)
30
self.set_default_size(400, 400)
32
self.old_tree = tree.branch.repository.revision_tree(tree.branch.last_revision())
33
self.pending_merges = tree.pending_merges()
34
self.delta = compare_trees(self.old_tree, tree)
38
def _create_file_view(self):
39
self.file_store = gtk.ListStore(gobject.TYPE_BOOLEAN, gobject.TYPE_STRING, gobject.TYPE_STRING)
40
self.file_view = gtk.TreeView(self.file_store)
41
self.file_view.append_column(gtk.TreeViewColumn("Commit",
42
gtk.CellRendererToggle(), active=0))
43
self.file_view.append_column(gtk.TreeViewColumn("Path",
44
gtk.CellRendererText(), text=1))
45
self.file_view.append_column(gtk.TreeViewColumn("Type",
46
gtk.CellRendererText(), text=2))
48
for path, _, _ in self.delta.added:
49
self.file_store.append([ True, path, "Added" ])
51
for path, _, _ in self.delta.removed:
52
self.file_store.append([ True, path, "Removed" ])
54
for oldpath, _, _, _, _, _ in self.delta.renamed:
55
self.file_store.append([ True, oldpath, "Renamed"])
57
for path, _, _, _, _ in self.delta.modified:
58
self.file_store.append([ True, path, "Modified"])
62
def _get_specific_files(self):
64
it = self.file_store.get_iter_first()
66
if self.file_store.get_value(it, 0):
67
ret.append(self.file_store.get_value(it, 1))
68
it = self.file_store.iter_next(it)
72
specific_files = property(_get_specific_files)
74
def _create_pending_merge_view(self, merges):
75
self.pending_merge_store = gtk.ListStore(gobject.TYPE_STRING)
77
self.pending_merge_store.append([revid])
78
self.pending_merge_view = gtk.TreeView(self.pending_merge_store)
79
self.pending_merge_view.show()
81
def _create_message_box(self):
82
self.message_entry = gtk.TextView()
83
self.message_entry.show()
84
return self.message_entry
86
def _get_message(self):
87
buffer = self.message_entry.get_buffer()
88
return buffer.get_text(buffer.get_start_iter(), buffer.get_end_iter())
90
message = property(_get_message)
93
# Show list of changed files with checkboxes
94
self._create_file_view()
95
self.vbox.set_spacing(2)
96
self.vbox.pack_start(self.file_view, expand=True, fill=True)
98
# If_ there are any pending merges, show list of pending merges
99
if self.pending_merges:
100
self._create_pending_merge_view(self.pending_merges)
101
self.vbox.pack_start(self.pending_merge_view, expand=True, fill=True)
103
# Show box where user can add comments
104
self._create_message_box()
105
self.vbox.pack_start(self.message_entry, expand=True, fill=True)
107
# Commit, Cancel buttons
108
self.add_buttons(gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL, "_Commit", gtk.RESPONSE_OK)