/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-03-14 02:19:21 UTC
  • mto: (452.2.3 trunk)
  • mto: This revision was merged to the branch mainline in revision 453.
  • Revision ID: jelmer@samba.org-20080314021921-2dgptk62dhp7pd91
Honor child_submit_to in the submit_branch if no email address was specified.
Consistent with the changes in bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
from bzrlib.errors import NotBranchError, NoWorkingTree, UnsupportedProtocol
15
15
from bzrlib.tree import file_status
16
16
from bzrlib.workingtree import WorkingTree
17
 
from bzrlib.config import GlobalConfig
18
17
 
19
18
from bzrlib.plugin import load_plugins
20
19
load_plugins()
21
20
 
22
 
from bzrlib.plugins.gtk import _i18n, cmd_visualise, cmd_gannotate
 
21
from bzrlib.plugins.gtk import cmd_visualise, cmd_gannotate
23
22
 
24
23
class BzrExtension(nautilus.MenuProvider, nautilus.ColumnProvider, nautilus.InfoProvider):
25
24
    def __init__(self):
222
221
    def get_background_items(self, window, vfs_file):
223
222
        items = []
224
223
        file = vfs_file.get_uri()
225
 
 
226
224
        try:
227
225
            tree, path = WorkingTree.open_containing(file)
228
 
            disabled_flag = self.check_branch_enabled(tree.branch)
229
226
        except UnsupportedProtocol:
230
227
            return
231
228
        except NotBranchError:
232
 
            disabled_flag = self.check_branch_enabled()
233
229
            item = nautilus.MenuItem('BzrNautilus::newtree',
234
230
                                 'Make directory versioned',
235
231
                                 'Create new Bazaar tree in this folder')
245
241
            return items
246
242
        except NoWorkingTree:
247
243
            return
248
 
        
249
 
        if disabled_flag == 'False':
250
 
            item = nautilus.MenuItem('BzrNautilus::enable',
251
 
                                     'Enable Bazaar Plugin for this Branch',
252
 
                                     'Enable Bazaar plugin for nautilus')
253
 
            item.connect('activate', self.toggle_integration, 'True', vfs_file)
254
 
            return item,
255
 
        else:
256
 
            item = nautilus.MenuItem('BzrNautilus::disable',
257
 
                                      'Disable Bazaar Plugin for the Branch',
258
 
                                      'Disable Bazaar plugin for nautilus')
259
 
            item.connect('activate', self.toggle_integration, 'False', vfs_file)
260
 
            items.append(item)
261
244
 
262
245
        item = nautilus.MenuItem('BzrNautilus::log',
263
246
                             'Log',
287
270
 
288
271
    def get_file_items(self, window, files):
289
272
        items = []
290
 
        
 
273
 
291
274
        wtfiles = {}
292
275
        for vfs_file in files:
293
276
            # We can only cope with local files
297
280
            file = vfs_file.get_uri()
298
281
            try:
299
282
                tree, path = WorkingTree.open_containing(file)
300
 
                disabled_flag = self.check_branch_enabled(tree.branch)
301
283
            except NotBranchError:
302
 
                disabled_flag = self.check_branch_enabled()
303
284
                if not vfs_file.is_directory():
304
285
                    continue
305
 
 
306
 
                if disabled_flag == 'False':
307
 
                    return
308
 
 
309
286
                item = nautilus.MenuItem('BzrNautilus::newtree',
310
287
                                     'Make directory versioned',
311
288
                                     'Create new Bazaar tree in %s' % vfs_file.get_name())
379
356
                               "Version control status"),
380
357
 
381
358
    def update_file_info(self, file):
382
 
 
383
359
        if file.get_uri_scheme() != 'file':
384
360
            return
385
361
        
388
364
        except NotBranchError:
389
365
            return
390
366
        except NoWorkingTree:
391
 
            return   
392
 
 
393
 
        disabled_flag = self.check_branch_enabled(tree.branch)
394
 
        if disabled_flag == 'False':
395
367
            return
396
368
 
397
369
        emblem = None
421
393
        else:
422
394
            # FIXME: Check for ignored files
423
395
            status = 'unversioned'
 
396
            emblem = 'bzr-unversioned'
424
397
        
425
398
        if emblem is not None:
426
399
            file.add_emblem(emblem)
427
400
        file.add_string_attribute('bzr_status', status)
428
 
 
429
 
    def check_branch_enabled(self, branch=None):
430
 
        # Supports global disable, but there is currently no UI to do this
431
 
        config = GlobalConfig()
432
 
        disabled_flag = config.get_user_option('nautilus_integration')
433
 
        if disabled_flag != 'False':
434
 
            if branch is not None:
435
 
                config = branch.get_config()
436
 
                disabled_flag = config.get_user_option('nautilus_integration')
437
 
        return disabled_flag
438
 
 
439
 
    def toggle_integration(self, menu, action, vfs_file=None):
440
 
        try:
441
 
            tree, path = WorkingTree.open_containing(vfs_file.get_uri())
442
 
        except NotBranchError:
443
 
            return
444
 
        except NoWorkingTree:
445
 
            return
446
 
        branch = tree.branch
447
 
        if branch is None:
448
 
            config = GlobalConfig()
449
 
        else:
450
 
            config = branch.get_config()
451
 
        config.set_user_option('nautilus_integration', action)
452