28
28
import bzrlib.errors as errors
29
from bzrlib import osutils
30
31
from dialog import error_dialog
31
from olive import gladefile
32
from guifiles import GLADEFILENAME
33
35
class CommitDialog:
34
36
""" Display Commit dialog and perform the needed actions. """
35
def __init__(self, wt, wtpath):
36
""" Initialize the Commit dialog. """
37
self.glade = gtk.glade.XML(gladefile, 'window_commit', 'olive-gtk')
37
def __init__(self, wt, wtpath, standalone=False):
38
""" Initialize the Commit dialog.
39
@param wt: bzr working tree object
40
@param wtpath: path to working tree root
41
@param standalone: when used in gcommit command as standalone window
42
this argument should be True
44
self.glade = gtk.glade.XML(GLADEFILENAME, 'window_commit', 'olive-gtk')
40
47
self.wtpath = wtpath
49
self.standalone = standalone
42
51
# Get some important widgets
43
52
self.window = self.glade.get_widget('window_commit')
44
53
self.checkbutton_local = self.glade.get_widget('checkbutton_commit_local')
64
73
# Dictionary for signal_autoconnect
65
74
dic = { "on_button_commit_commit_clicked": self.commit,
66
75
"on_button_commit_cancel_clicked": self.close }
78
dic["on_button_commit_cancel_clicked"] = self.quit
79
self.window.connect("delete_event", gtk.main_quit)
68
81
# Connect the signals to the handlers
69
82
self.glade.signal_autoconnect(dic)
98
111
def _create_file_view(self):
99
self.file_store = gtk.ListStore(gobject.TYPE_BOOLEAN,
112
self.file_store = gtk.ListStore(gobject.TYPE_BOOLEAN, # [0] checkbox
113
gobject.TYPE_STRING, # [1] path to display
114
gobject.TYPE_STRING, # [2] changes type
115
gobject.TYPE_STRING) # [3] real path
102
116
self.file_view.set_model(self.file_store)
103
117
crt = gtk.CellRendererToggle()
104
118
crt.set_property("activatable", True)
111
125
gtk.CellRendererText(), text=2))
113
127
for path, id, kind in self.delta.added:
114
self.file_store.append([ True, path, _('added') ])
128
marker = osutils.kind_marker(kind)
129
self.file_store.append([ True, path+marker, _('added'), path ])
116
131
for path, id, kind in self.delta.removed:
117
self.file_store.append([ True, path, _('removed') ])
132
marker = osutils.kind_marker(kind)
133
self.file_store.append([ True, path+marker, _('removed'), path ])
119
135
for oldpath, newpath, id, kind, text_modified, meta_modified in self.delta.renamed:
120
self.file_store.append([ True, oldpath, _('renamed') ])
136
marker = osutils.kind_marker(kind)
137
if text_modified or meta_modified:
138
changes = _('renamed and modified')
140
changes = _('renamed')
141
self.file_store.append([ True,
142
oldpath+marker + ' => ' + newpath+marker,
122
147
for path, id, kind, text_modified, meta_modified in self.delta.modified:
123
self.file_store.append([ True, path, _('modified') ])
148
marker = osutils.kind_marker(kind)
149
self.file_store.append([ True, path+marker, _('modified'), path ])
125
151
def _create_pending_merges(self):
126
152
liststore = gtk.ListStore(gobject.TYPE_STRING,
148
174
it = self.file_store.get_iter_first()
150
176
if self.file_store.get_value(it, 0):
151
ret.append(self.file_store.get_value(it, 1))
177
# get real path from hidden column 3
178
ret.append(self.file_store.get_value(it, 3))
152
179
it = self.file_store.iter_next(it)
224
251
def commit(self, widget):
225
252
textbuffer = self.textview.get_buffer()
226
253
start, end = textbuffer.get_bounds()
227
message = textbuffer.get_text(start, end)
254
message = textbuffer.get_text(start, end).decode('utf-8')
229
256
checkbutton_strict = self.glade.get_widget('checkbutton_commit_strict')
230
257
checkbutton_force = self.glade.get_widget('checkbutton_commit_force')