/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 commands.py

  • Committer: Jelmer Vernooij
  • Date: 2010-02-28 15:19:15 UTC
  • mfrom: (674.1.1 bzr-gtk)
  • Revision ID: jelmer@samba.org-20100228151915-bvwflj8ongj2fwqd
Merge qense's indicator application work, but don't require appindicator to be installed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
from bzrlib import (
18
18
    branch,
19
 
    errors,
 
19
    builtins,
20
20
    workingtree,
21
21
    )
22
22
from bzrlib.commands import (
33
33
 
34
34
from bzrlib.plugins.gtk import (
35
35
    _i18n,
 
36
    open_display,
36
37
    import_pygtk,
37
38
    set_ui_factory,
38
39
    )
39
40
 
40
 
 
41
 
class NoDisplayError(errors.BzrCommandError):
42
 
    """gtk could not find a proper display"""
43
 
 
44
 
    def __str__(self):
45
 
        return "No DISPLAY. Unable to run GTK+ application."
46
 
 
47
 
 
48
 
def open_display():
49
 
    pygtk = import_pygtk()
50
 
    try:
51
 
        import gtk
52
 
    except RuntimeError, e:
53
 
        if str(e) == "could not open display":
54
 
            raise NoDisplayError
55
 
    set_ui_factory()
56
 
    return gtk
57
 
 
58
 
 
59
 
 
60
41
class GTKCommand(Command):
61
42
    """Abstract class providing GTK specific run commands."""
62
43
 
181
162
 
182
163
 
183
164
class cmd_visualise(Command):
184
 
    """Graphically visualise one or several branches.
185
 
 
186
 
    Opens a graphical window to allow you to see branches history and
187
 
    relationships between revisions in a visual manner,
188
 
 
189
 
    If no revision is specified, the branch last revision is taken as a
190
 
    starting point. When a revision is specified, the presented graph starts
191
 
    with it (as a side effect, when a shared repository is used, any revision
192
 
    can be used even if it's not part of the branch history).
 
165
    """Graphically visualise this branch.
 
166
 
 
167
    Opens a graphical window to allow you to see the history of the branch
 
168
    and relationships between revisions in a visual manner,
 
169
 
 
170
    The default starting point is latest revision on the branch, you can
 
171
    specify a starting point with -r revision.
193
172
    """
194
173
    takes_options = [
195
174
        "revision",
220
199
    """GTK+ annotate.
221
200
    
222
201
    Browse changes to FILENAME line by line in a GTK+ window.
223
 
 
224
 
    Within the annotate window, you can use Ctrl-F to search for text, and 
225
 
    Ctrl-G to jump to a line by number.
226
202
    """
227
203
 
228
204
    takes_args = ["filename", "line?"]
396
372
        dialog.run()
397
373
 
398
374
 
 
375
class cmd_ginfo(Command):
 
376
    """ GTK+ info dialog
 
377
    
 
378
    """
 
379
    def run(self):
 
380
        from bzrlib import workingtree
 
381
        from bzrlib.plugins.gtk.olive.info import InfoDialog
 
382
        wt = workingtree.WorkingTree.open_containing('.')[0]
 
383
        info = InfoDialog(wt.branch)
 
384
        info.display()
 
385
        info.window.run()
 
386
 
 
387
 
399
388
class cmd_gmerge(Command):
400
389
    """ GTK+ merge dialog
401
390
    
481
470
        window = TagsWindow(br)
482
471
        window.show()
483
472
        gtk.main()
 
473
 
 
474
 
 
475
class cmd_gselftest(GTKCommand):
 
476
    """Version of selftest that displays a notification at the end"""
 
477
 
 
478
    takes_args = builtins.cmd_selftest.takes_args
 
479
    takes_options = builtins.cmd_selftest.takes_options
 
480
    _see_also = ['selftest']
 
481
 
 
482
    def run(self, *args, **kwargs):
 
483
        import cgi
 
484
        import sys
 
485
        default_encoding = sys.getdefaultencoding()
 
486
        # prevent gtk from blowing up later
 
487
        gtk = import_pygtk()
 
488
        # prevent gtk from messing with default encoding
 
489
        import pynotify
 
490
        if sys.getdefaultencoding() != default_encoding:
 
491
            reload(sys)
 
492
            sys.setdefaultencoding(default_encoding)
 
493
        result = builtins.cmd_selftest().run(*args, **kwargs)
 
494
        if result == 0:
 
495
            summary = 'Success'
 
496
            body = 'Selftest succeeded in "%s"' % os.getcwd()
 
497
        if result == 1:
 
498
            summary = 'Failure'
 
499
            body = 'Selftest failed in "%s"' % os.getcwd()
 
500
        pynotify.init("bzr gselftest")
 
501
        note = pynotify.Notification(cgi.escape(summary), cgi.escape(body))
 
502
        note.set_timeout(pynotify.EXPIRES_NEVER)
 
503
        note.show()