/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: Daniel Schierbeck
  • Date: 2007-10-14 15:54:57 UTC
  • mto: This revision was merged to the branch mainline in revision 317.
  • Revision ID: daniel.schierbeck@gmail.com-20071014155457-m3ek29p4ima8ev7d
Added the new Window base class.

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
import os.path
28
28
 
29
 
import bzrlib.errors as errors
30
 
from bzrlib import osutils
 
29
from bzrlib import errors, osutils
 
30
from bzrlib.trace import mutter
31
31
 
32
32
from dialog import error_dialog, question_dialog
33
33
from errors import show_bzr_error
34
 
from guifiles import GLADEFILENAME
 
34
 
 
35
try:
 
36
    import dbus
 
37
    import dbus.glib
 
38
    have_dbus = True
 
39
except ImportError:
 
40
    have_dbus = False
35
41
 
36
42
class CommitDialog(gtk.Dialog):
37
43
    """ New implementation of the Commit dialog. """
80
86
        
81
87
        # Create the widgets
82
88
        self._button_commit = gtk.Button(_("Comm_it"), use_underline=True)
83
 
        if self._is_checkout:
84
 
            self._check_local = gtk.CheckButton(_("_Local only commit (works in checkouts)"),
85
 
                                                use_underline=True)
86
 
        self._check_strict = gtk.CheckButton(_("_Strict commit (fails if unknown files are present)"),
87
 
                                             use_underline=True)
88
 
        self._expander_files = gtk.Expander(_("Please select the file(s) to commit"))
 
89
        self._expander_files = gtk.Expander(_("File(s) to commit"))
89
90
        self._vpaned_main = gtk.VPaned()
90
91
        self._scrolledwindow_files = gtk.ScrolledWindow()
91
92
        self._scrolledwindow_message = gtk.ScrolledWindow()
92
93
        self._treeview_files = gtk.TreeView()
93
94
        self._vbox_message = gtk.VBox()
94
 
        self._label_message = gtk.Label(_("Please specify a commit message:"))
 
95
        self._label_message = gtk.Label(_("Commit message:"))
95
96
        self._textview_message = gtk.TextView()
96
97
        
97
98
        if self._is_pending:
112
113
        self._textview_message.modify_font(pango.FontDescription("Monospace"))
113
114
        self.set_default_size(500, 500)
114
115
        self._vpaned_main.set_position(200)
 
116
        self._button_commit.set_flags(gtk.CAN_DEFAULT)
115
117
 
116
118
        if self._is_pending:
117
119
            self._scrolledwindow_merges.set_policy(gtk.POLICY_AUTOMATIC,
141
143
        self._vpaned_main.add2(self._vbox_message)
142
144
        
143
145
        self.vbox.pack_start(self._vpaned_main, True, True)
144
 
        if self._is_checkout:
 
146
        if self._is_checkout: 
 
147
            self._check_local = gtk.CheckButton(_("_Only commit locally"),
 
148
                                                use_underline=True)
145
149
            self.vbox.pack_start(self._check_local, False, False)
146
 
        self.vbox.pack_start(self._check_strict, False, False)
147
 
        
 
150
            if have_dbus:
 
151
                bus = dbus.SystemBus()
 
152
                proxy_obj = bus.get_object('org.freedesktop.NetworkManager', 
 
153
                              '/org/freedesktop/NetworkManager')
 
154
                dbus_iface = dbus.Interface(
 
155
                        proxy_obj, 'org.freedesktop.NetworkManager')
 
156
                try:
 
157
                    # 3 is the enum value for STATE_CONNECTED
 
158
                    self._check_local.set_active(dbus_iface.state() != 3)
 
159
                except dbus.DBusException, e:
 
160
                    # Silently drop errors. While DBus may be 
 
161
                    # available, NetworkManager doesn't necessarily have to be
 
162
                    mutter("unable to get networkmanager state: %r" % e)
 
163
                
148
164
        # Create the file list
149
165
        self._create_file_view()
150
166
        # Create the pending merges
158
174
        
159
175
        # Display dialog
160
176
        self.vbox.show_all()
 
177
        
 
178
        # Default to Commit button
 
179
        self._button_commit.grab_default()
161
180
    
162
181
    def _on_treeview_files_row_activated(self, treeview, path, view_column):
163
182
        # FIXME: the diff window freezes for some reason
165
184
        (model, iter) = treeselection.get_selected()
166
185
        
167
186
        if iter is not None:
168
 
            from olive import DiffWindow
 
187
            from diff import DiffWindow
169
188
            
170
189
            _selected = model.get_value(iter, 1)
171
190
            
172
191
            diff = DiffWindow()
 
192
            diff.set_type_hint(gtk.gdk.WINDOW_TYPE_HINT_DIALOG)
 
193
            diff.set_modal(True)
173
194
            parent_tree = self.wt.branch.repository.revision_tree(self.wt.branch.last_revision())
174
195
            diff.set_diff(self.wt.branch.nick, self.wt, parent_tree)
175
196
            try:
202
223
            local = self._check_local.get_active()
203
224
        else:
204
225
            local = False
 
226
 
 
227
        if list(self.wt.unknowns()) != []:
 
228
            response = question_dialog(_("Commit with unknowns?"),
 
229
               _("Unknown files exist in the working tree. Commit anyway?"))
 
230
            if response == gtk.RESPONSE_NO:
 
231
                return
205
232
        
206
233
        try:
207
234
            self.wt.commit(message,
208
235
                       allow_pointless=False,
209
 
                       strict=self._check_strict.get_active(),
 
236
                       strict=False,
210
237
                       local=local,
211
238
                       specific_files=specific_files)
212
239
        except errors.PointlessCommit:
215
242
            if response == gtk.RESPONSE_YES:
216
243
                self.wt.commit(message,
217
244
                               allow_pointless=True,
218
 
                               strict=self._check_strict.get_active(),
 
245
                               strict=False,
219
246
                               local=local,
220
247
                               specific_files=specific_files)
221
248
        self.response(gtk.RESPONSE_OK)