/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 nautilus-bzr.py

  • Committer: Jelmer Vernooij
  • Date: 2008-06-29 18:12:29 UTC
  • mto: This revision was merged to the branch mainline in revision 519.
  • Revision ID: jelmer@samba.org-20080629181229-1l2m4cf7vvbyh8qg
Simplify progress bar code, use embedded progress bar inside viz window.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
#
7
7
# Published under the GNU GPL
8
8
 
9
 
from gi.repository import Gtk
 
9
import gtk
10
10
import nautilus
 
11
import bzrlib
11
12
from bzrlib.branch import Branch
12
13
from bzrlib.bzrdir import BzrDir
13
 
from bzrlib.errors import (
14
 
    NotBranchError,
15
 
    NoWorkingTree,
16
 
    UnsupportedProtocol,
17
 
    )
 
14
from bzrlib.errors import NotBranchError, NoWorkingTree, UnsupportedProtocol
 
15
from bzrlib.tree import file_status
18
16
from bzrlib.workingtree import WorkingTree
19
17
from bzrlib.config import GlobalConfig
20
18
 
21
19
from bzrlib.plugin import load_plugins
22
20
load_plugins()
23
21
 
24
 
from bzrlib.plugins.gtk.commands import (
25
 
    cmd_gannotate,
26
 
    start_viz_window,
27
 
    )
28
 
 
29
 
print "Bazaar nautilus module initialized"
30
 
 
 
22
from bzrlib.plugins.gtk import _i18n, cmd_visualise, cmd_gannotate
31
23
 
32
24
class BzrExtension(nautilus.MenuProvider, nautilus.ColumnProvider, nautilus.InfoProvider):
33
 
 
34
25
    def __init__(self):
35
26
        pass
36
27
 
92
83
 
93
84
        from bzrlib.plugins.gtk.diff import DiffWindow
94
85
        window = DiffWindow()
95
 
        window.set_diff(tree.branch._get_nick(local=True), tree, 
96
 
                        tree.branch.basis_tree())
 
86
        window.set_diff(tree.branch.nick, tree, tree.branch.basis_tree())
97
87
        window.show()
98
88
 
99
89
        return
143
133
        
144
134
        dialog = BranchDialog(vfs_file.get_name())
145
135
        response = dialog.run()
146
 
        if response != Gtk.ResponseType.NONE:
 
136
        if response != gtk.RESPONSE_NONE:
147
137
            dialog.hide()
148
138
            dialog.destroy()
149
139
 
171
161
        from bzrlib.plugins.gtk.commit import CommitDialog
172
162
        dialog = CommitDialog(tree, path)
173
163
        response = dialog.run()
174
 
        if response != Gtk.ResponseType.NONE:
 
164
        if response != gtk.RESPONSE_NONE:
175
165
            dialog.hide()
176
166
            dialog.destroy()
177
167
 
184
174
 
185
175
        # We only want to continue here if we get a NotBranchError
186
176
        try:
187
 
            branch, path = Branch.open_containing(file)
 
177
            tree, path = WorkingTree.open_containing(file)
188
178
        except NotBranchError:
189
179
            return
190
180
 
191
 
        pp = start_viz_window(branch, [branch.last_revision()])
192
 
        pp.show()
193
 
        Gtk.main()
 
181
        vis = cmd_visualise()
 
182
        vis.run(file)
 
183
 
 
184
        return
194
185
 
195
186
    def pull_cb(self, menu, vfs_file):
196
187
        # We can only cope with local files
208
199
        from bzrlib.plugins.gtk.pull import PullDialog
209
200
        dialog = PullDialog(tree, path)
210
201
        dialog.display()
211
 
        Gtk.main()
 
202
        gtk.main()
212
203
 
213
204
    def merge_cb(self, menu, vfs_file):
214
205
        # We can only cope with local files
225
216
 
226
217
        from bzrlib.plugins.gtk.merge import MergeDialog
227
218
        dialog = MergeDialog(tree, path)
228
 
        dialog.run()
229
 
        dialog.destroy()
 
219
        dialog.display()
 
220
        gtk.main()
230
221
 
231
222
    def get_background_items(self, window, vfs_file):
232
223
        items = []
246
237
            items.append(item)
247
238
 
248
239
            item = nautilus.MenuItem('BzrNautilus::clone',
249
 
                                 'Checkout Bazaar branch ...',
 
240
                                 'Checkout Bazaar branch',
250
241
                                 'Checkout Existing Bazaar Branch')
251
242
            item.connect('activate', self.clone_cb, vfs_file)
252
243
            items.append(item)
263
254
            return item,
264
255
        else:
265
256
            item = nautilus.MenuItem('BzrNautilus::disable',
266
 
                                      'Disable Bazaar Plugin this Branch',
 
257
                                      'Disable Bazaar Plugin for the Branch',
267
258
                                      'Disable Bazaar plugin for nautilus')
268
259
            item.connect('activate', self.toggle_integration, 'False', vfs_file)
269
260
            items.append(item)
270
261
 
271
262
        item = nautilus.MenuItem('BzrNautilus::log',
272
 
                             'History ...',
 
263
                             'Log',
273
264
                             'Show Bazaar history')
274
265
        item.connect('activate', self.log_cb, vfs_file)
275
266
        items.append(item)
276
267
 
277
268
        item = nautilus.MenuItem('BzrNautilus::pull',
278
 
                             'Pull ...',
 
269
                             'Pull',
279
270
                             'Pull from another branch')
280
271
        item.connect('activate', self.pull_cb, vfs_file)
281
272
        items.append(item)
282
273
 
283
274
        item = nautilus.MenuItem('BzrNautilus::merge',
284
 
                             'Merge ...',
 
275
                             'Merge',
285
276
                             'Merge from another branch')
286
277
        item.connect('activate', self.merge_cb, vfs_file)
287
278
        items.append(item)
288
279
 
289
280
        item = nautilus.MenuItem('BzrNautilus::commit',
290
 
                             'Commit ...',
 
281
                             'Commit',
291
282
                             'Commit Changes')
292
283
        item.connect('activate', self.commit_cb, vfs_file)
293
284
        items.append(item)
350
341
                items.append(item)
351
342
            elif wtfiles[path] == 'V':
352
343
                item = nautilus.MenuItem('BzrNautilus::log',
353
 
                                 'History ...',
 
344
                                 'Log',
354
345
                                 'List changes')
355
346
                item.connect('activate', self.log_cb, vfs_file)
356
347
                items.append(item)
357
348
 
358
349
                item = nautilus.MenuItem('BzrNautilus::diff',
359
 
                                 'View Changes ...',
 
350
                                 'Diff',
360
351
                                 'Show differences')
361
352
                item.connect('activate', self.diff_cb, vfs_file)
362
353
                items.append(item)
368
359
                items.append(item)
369
360
 
370
361
                item = nautilus.MenuItem('BzrNautilus::annotate',
371
 
                             'Annotate ...',
 
362
                             'Annotate',
372
363
                             'Annotate File Data')
373
364
                item.connect('activate', self.annotate_cb, vfs_file)
374
365
                items.append(item)
375
366
 
376
367
                item = nautilus.MenuItem('BzrNautilus::commit',
377
 
                             'Commit ...',
 
368
                             'Commit',
378
369
                             'Commit Changes')
379
370
                item.connect('activate', self.commit_cb, vfs_file)
380
371
                items.append(item)
406
397
        emblem = None
407
398
        status = None
408
399
 
409
 
        id = tree.path2id(path)
410
 
        if id == None:
411
 
            if tree.is_ignored(path):
412
 
                status = 'ignored'
413
 
                emblem = 'bzr-ignored'
414
 
            else:
415
 
                status = 'unversioned'
416
 
                        
417
 
        elif tree.has_filename(path):
 
400
        if tree.has_filename(path):
418
401
            emblem = 'bzr-controlled'
419
402
            status = 'unchanged'
 
403
            id = tree.path2id(path)
420
404
 
421
405
            delta = tree.changes_from(tree.branch.basis_tree())
422
406
            if delta.touches_file_id(id):