/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: Szilveszter Farkas (Phanatic)
  • Date: 2007-03-15 16:23:15 UTC
  • mfrom: (170 trunk)
  • mto: (170.1.3 trunk)
  • mto: This revision was merged to the branch mainline in revision 172.
  • Revision ID: szilveszter.farkas@gmail.com-20070315162315-rs1sbxjh31n314zc
MergeĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
import os.path
28
28
 
29
 
from bzrlib import errors, osutils
30
 
from bzrlib.trace import mutter
 
29
import bzrlib.errors as errors
 
30
from bzrlib import osutils
31
31
 
32
32
from dialog import error_dialog, question_dialog
33
33
from errors import show_bzr_error
35
35
try:
36
36
    import dbus
37
37
    import dbus.glib
38
 
    have_dbus = True
 
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')
 
42
    have_nm = True
39
43
except ImportError:
40
 
    have_dbus = False
41
 
 
 
44
    have_nm = False
42
45
 
43
46
class CommitDialog(gtk.Dialog):
44
47
    """ New implementation of the Commit dialog. """
86
89
                self._is_pending = True
87
90
        
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"),
 
94
                                             use_underline=True)
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()
107
109
 
108
110
        # Set callbacks
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)
112
113
        
113
114
        # Set properties
114
115
        self._scrolledwindow_files.set_policy(gtk.POLICY_AUTOMATIC,
147
148
 
148
149
        self._vpaned_main.add2(self._vbox_message)
149
150
        
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)
156
 
            if have_dbus:
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')
162
 
                try:
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)
169
 
                
 
156
            if have_nm:
 
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)
 
160
        
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()
175
165
        
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()
187
177
    
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()
192
 
 
 
182
        
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])
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)
 
184
            from diff import DiffWindow
 
185
            
 
186
            _selected = model.get_value(iter, 1)
 
187
            
 
188
            diff = DiffWindow()
 
189
            diff.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
 
190
            diff.set_modal(True)
 
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)
 
193
            try:
 
194
                diff.set_file(_selected)
 
195
            except errors.NoSuchFile:
 
196
                pass
 
197
            diff.show()
202
198
    
203
199
    @show_bzr_error
204
200
    def _on_commit_clicked(self, button):
224
220
            local = self._check_local.get_active()
225
221
        else:
226
222
            local = False
227
 
 
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:
232
 
                return
233
223
        
234
224
        try:
235
225
            self.wt.commit(message,
236
226
                       allow_pointless=False,
237
 
                       strict=False,
 
227
                       strict=self._check_strict.get_active(),
238
228
                       local=local,
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,
246
 
                               strict=False,
 
236
                               strict=self._check_strict.get_active(),
247
237
                               local=local,
248
238
                               specific_files=specific_files)
249
239
        self.response(gtk.RESPONSE_OK)
405
395
                               item['committer'],
406
396
                               item['summary'] ])
407
397
    
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
 
 
418
398
    def _get_specific_files(self):
419
399
        ret = []
420
400
        it = self._file_store.get_iter_first()