29
from bzrlib import errors, osutils
30
from bzrlib.trace import mutter
29
import bzrlib.errors as errors
30
from bzrlib import osutils
32
32
from dialog import error_dialog, question_dialog
33
33
from errors import show_bzr_error
38
bus = dbus.SystemBus()
39
proxy_obj = bus.get_object('org.freedesktop.NetworkManager',
40
'/org/freedesktop/NetworkManager')
41
dbus_iface = dbus.Interface(proxy_obj, 'org.freedesktop.NetworkManager')
39
43
except ImportError:
43
46
class CommitDialog(gtk.Dialog):
44
47
""" New implementation of the Commit dialog. """
86
89
self._is_pending = True
88
91
# 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()
92
92
self._button_commit = gtk.Button(_("Comm_it"), use_underline=True)
93
self._check_strict = gtk.CheckButton(_("_Allow unknown files"),
93
95
self._expander_files = gtk.Expander(_("File(s) to commit"))
94
96
self._vpaned_main = gtk.VPaned()
95
97
self._scrolledwindow_files = gtk.ScrolledWindow()
109
111
self._button_commit.connect('clicked', self._on_commit_clicked)
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)
112
self._treeview_files.connect('row_activated', self._on_treeview_files_row_activated)
114
115
self._scrolledwindow_files.set_policy(gtk.POLICY_AUTOMATIC,
148
149
self._vpaned_main.add2(self._vbox_message)
150
self._hpane.pack1(self._vpaned_main)
151
self.vbox.pack_start(self._hpane, expand=True, fill=True)
151
self.vbox.pack_start(self._vpaned_main, True, True)
152
152
if self._is_checkout:
153
153
self._check_local = gtk.CheckButton(_("_Only commit locally"),
154
154
use_underline=True)
155
155
self.vbox.pack_start(self._check_local, False, False)
157
bus = dbus.SystemBus()
158
proxy_obj = bus.get_object('org.freedesktop.NetworkManager',
159
'/org/freedesktop/NetworkManager')
160
dbus_iface = dbus.Interface(
161
proxy_obj, 'org.freedesktop.NetworkManager')
163
# 3 is the enum value for STATE_CONNECTED
164
self._check_local.set_active(dbus_iface.state() != 3)
165
except dbus.DBusException, e:
166
# Silently drop errors. While DBus may be
167
# available, NetworkManager doesn't necessarily have to be
168
mutter("unable to get networkmanager state: %r" % e)
157
# 3 is the enum value for STATE_CONNECTED
158
self._check_local.set_active(dbus_iface.state() != 3)
159
self.vbox.pack_start(self._check_strict, False, False)
170
161
# Create the file list
171
162
self._create_file_view()
172
163
# Create the pending merges
173
164
self._create_pending_merges()
174
self._create_diff_view()
176
166
# Expand the corresponding expander
177
167
if self._is_pending:
185
175
# Default to Commit button
186
176
self._button_commit.grab_default()
188
def _show_diff_view(self, treeview):
178
def _on_treeview_files_row_activated(self, treeview, path, view_column):
189
179
# FIXME: the diff window freezes for some reason
190
180
treeselection = treeview.get_selection()
191
181
(model, iter) = treeselection.get_selected()
193
183
if iter is not None:
194
selected = model.get_value(iter, 3) # Get the real_path attribute
195
self._diff_display.show_diff([selected])
197
def _on_treeview_files_cursor_changed(self, treeview):
198
self._show_diff_view(treeview)
200
def _on_treeview_files_row_activated(self, treeview, path, view_column):
201
self._show_diff_view(treeview)
184
from diff import DiffWindow
186
_selected = model.get_value(iter, 1)
189
diff.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
191
parent_tree = self.wt.branch.repository.revision_tree(self.wt.branch.last_revision())
192
diff.set_diff(self.wt.branch.nick, self.wt, parent_tree)
194
diff.set_file(_selected)
195
except errors.NoSuchFile:
204
200
def _on_commit_clicked(self, button):
224
220
local = self._check_local.get_active()
228
if list(self.wt.unknowns()) != []:
229
response = question_dialog(_("Commit with unknowns?"),
230
_("Unknown files exist in the working tree. Commit anyway?"))
231
if response == gtk.RESPONSE_NO:
235
225
self.wt.commit(message,
236
226
allow_pointless=False,
227
strict=self._check_strict.get_active(),
239
229
specific_files=specific_files)
240
230
except errors.PointlessCommit:
243
233
if response == gtk.RESPONSE_YES:
244
234
self.wt.commit(message,
245
235
allow_pointless=True,
236
strict=self._check_strict.get_active(),
248
238
specific_files=specific_files)
249
239
self.response(gtk.RESPONSE_OK)
405
395
item['committer'],
406
396
item['summary'] ])
409
def _create_diff_view(self):
410
from diff import DiffDisplay
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)
418
398
def _get_specific_files(self):
420
400
it = self._file_store.get_iter_first()