/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: Vincent Ladeuil
  • Date: 2008-05-05 18:16:46 UTC
  • mto: (487.1.1 gtk)
  • mto: This revision was merged to the branch mainline in revision 490.
  • Revision ID: v.ladeuil+lp@free.fr-20080505181646-n95l8ltw2u6jtr26
Fix bug #187283 fix replacing _() by _i18n().

* genpot.sh 
Remove duplication. Add the ability to specify the genrated pot
file on command-line for debugging purposes.

* po/olive-gtk.pot:
Regenerated.

* __init__.py, branch.py, branchview/treeview.py, checkout.py,
commit.py, conflicts.py, diff.py, errors.py, initialize.py,
merge.py, nautilus-bzr.py, olive/__init__.py, olive/add.py,
olive/bookmark.py, olive/guifiles.py, olive/info.py,
olive/menu.py, olive/mkdir.py, olive/move.py, olive/remove.py,
olive/rename.py, push.py, revbrowser.py, status.py, tags.py:
Replace all calls to _() by calls to _i18n(), the latter being
defined in __init__.py and imported in the other modules from
there. This fix the problem encountered countless times when
running bzr selftest and getting silly error messages about
boolean not being callables.

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
17
18
 
18
19
from bzrlib.plugin import load_plugins
19
20
load_plugins()
20
21
 
21
 
from bzrlib.plugins.gtk import cmd_visualise, cmd_gannotate
 
22
from bzrlib.plugins.gtk import _i18n, cmd_visualise, cmd_gannotate
22
23
 
23
24
class BzrExtension(nautilus.MenuProvider, nautilus.ColumnProvider, nautilus.InfoProvider):
24
25
    def __init__(self):
221
222
    def get_background_items(self, window, vfs_file):
222
223
        items = []
223
224
        file = vfs_file.get_uri()
 
225
 
224
226
        try:
225
227
            tree, path = WorkingTree.open_containing(file)
 
228
            disabled_flag = self.check_branch_enabled(tree.branch)
226
229
        except UnsupportedProtocol:
227
230
            return
228
231
        except NotBranchError:
 
232
            disabled_flag = self.check_branch_enabled()
229
233
            item = nautilus.MenuItem('BzrNautilus::newtree',
230
234
                                 'Make directory versioned',
231
235
                                 'Create new Bazaar tree in this folder')
241
245
            return items
242
246
        except NoWorkingTree:
243
247
            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)
244
261
 
245
262
        item = nautilus.MenuItem('BzrNautilus::log',
246
263
                             'Log',
270
287
 
271
288
    def get_file_items(self, window, files):
272
289
        items = []
273
 
 
 
290
        
274
291
        wtfiles = {}
275
292
        for vfs_file in files:
276
293
            # We can only cope with local files
280
297
            file = vfs_file.get_uri()
281
298
            try:
282
299
                tree, path = WorkingTree.open_containing(file)
 
300
                disabled_flag = self.check_branch_enabled(tree.branch)
283
301
            except NotBranchError:
 
302
                disabled_flag = self.check_branch_enabled()
284
303
                if not vfs_file.is_directory():
285
304
                    continue
 
305
 
 
306
                if disabled_flag == 'False':
 
307
                    return
 
308
 
286
309
                item = nautilus.MenuItem('BzrNautilus::newtree',
287
310
                                     'Make directory versioned',
288
311
                                     'Create new Bazaar tree in %s' % vfs_file.get_name())
356
379
                               "Version control status"),
357
380
 
358
381
    def update_file_info(self, file):
 
382
 
359
383
        if file.get_uri_scheme() != 'file':
360
384
            return
361
385
        
364
388
        except NotBranchError:
365
389
            return
366
390
        except NoWorkingTree:
 
391
            return   
 
392
 
 
393
        disabled_flag = self.check_branch_enabled(tree.branch)
 
394
        if disabled_flag == 'False':
367
395
            return
368
396
 
369
397
        emblem = None
370
398
        status = None
371
399
 
372
400
        if tree.has_filename(path):
373
 
            emblem = 'cvs-controlled'
 
401
            emblem = 'bzr-controlled'
374
402
            status = 'unchanged'
375
403
            id = tree.path2id(path)
376
404
 
377
405
            delta = tree.changes_from(tree.branch.basis_tree())
378
406
            if delta.touches_file_id(id):
379
 
                emblem = 'cvs-modified'
 
407
                emblem = 'bzr-modified'
380
408
                status = 'modified'
381
409
            for f, _, _ in delta.added:
382
410
                if f == path:
383
 
                    emblem = 'cvs-added'
 
411
                    emblem = 'bzr-added'
384
412
                    status = 'added'
385
413
 
386
414
            for of, f, _, _, _, _ in delta.renamed:
388
416
                    status = 'renamed from %s' % f
389
417
 
390
418
        elif tree.branch.basis_tree().has_filename(path):
391
 
            emblem = 'cvs-removed'
 
419
            emblem = 'bzr-removed'
392
420
            status = 'removed'
393
421
        else:
394
422
            # FIXME: Check for ignored files
397
425
        if emblem is not None:
398
426
            file.add_emblem(emblem)
399
427
        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