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

  • Committer: Gary van der Merwe
  • Date: 2007-08-10 10:45:06 UTC
  • mto: This revision was merged to the branch mainline in revision 256.
  • Revision ID: garyvdm@gmail.com-20070810104506-wo2mp9zfkh338axe
Make icon locations consistant between source and installed version. Let glade nkow where to find the icons with a project file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
gbranch           GTK+ branching. 
21
21
gcheckout         GTK+ checkout. 
22
22
gcommit           GTK+ commit dialog 
23
 
gconflicts        GTK+ push. 
 
23
gconflicts        GTK+ conflicts. 
24
24
gdiff             Show differences in working tree in a GTK+ Window. 
25
25
ginit             Initialise a new branch.
26
26
gmissing          GTK+ missing revisions dialog. 
66
66
                % (bzrlib.__version__, bzrlib_version[0], bzrlib_version[1]))
67
67
 
68
68
 
69
 
## check_bzrlib_version(version_info[:2]) REMOVE
 
69
check_bzrlib_version(version_info[:2])
70
70
 
71
71
from bzrlib.trace import warning
72
72
if __name__ != 'bzrlib.plugins.gtk':
76
76
lazy_import(globals(), """
77
77
from bzrlib import (
78
78
    branch,
 
79
    builtins,
79
80
    errors,
80
81
    workingtree,
81
82
    )
103
104
    bzrlib.ui.ui_factory = GtkUIFactory()
104
105
 
105
106
 
 
107
def data_path():
 
108
    return os.path.dirname(__file__)
 
109
 
 
110
 
106
111
class GTKCommand(Command):
107
112
    """Abstract class providing GTK specific run commands."""
108
113
 
379
384
 
380
385
 
381
386
class cmd_gconflicts(GTKCommand):
382
 
    """ GTK+ push.
 
387
    """ GTK+ conflicts.
383
388
    
 
389
    Select files from the list of conflicts and run an external utility to
 
390
    resolve them.
384
391
    """
385
392
    def run(self):
386
393
        (wt, path) = workingtree.WorkingTree.open_containing('.')
489
496
        from notify import NotifyPopupMenu
490
497
        gtk = self.open_display()
491
498
        menu = NotifyPopupMenu()
492
 
        icon = gtk.status_icon_new_from_file("bzr-icon-64.png")
 
499
        icon = gtk.status_icon_new_from_file(os.path.join(data_path(), "bzr-icon-64.png"))
493
500
        icon.connect('popup-menu', menu.display)
494
501
 
495
502
        import cgi
552
559
register_command(cmd_commit_notify)
553
560
 
554
561
 
 
562
class cmd_gselftest(GTKCommand):
 
563
    """Version of selftest that displays a notification at the end"""
 
564
 
 
565
    takes_args = builtins.cmd_selftest.takes_args
 
566
    takes_options = builtins.cmd_selftest.takes_options
 
567
    _see_also = ['selftest']
 
568
 
 
569
    def run(self, *args, **kwargs):
 
570
        import cgi
 
571
        import sys
 
572
        default_encoding = sys.getdefaultencoding()
 
573
        # prevent gtk from blowing up later
 
574
        gtk = import_pygtk()
 
575
        # prevent gtk from messing with default encoding
 
576
        import pynotify
 
577
        if sys.getdefaultencoding() != default_encoding:
 
578
            reload(sys)
 
579
            sys.setdefaultencoding(default_encoding)
 
580
        result = builtins.cmd_selftest().run(*args, **kwargs)
 
581
        if result == 0:
 
582
            summary = 'Success'
 
583
            body = 'Selftest succeeded in "%s"' % os.getcwd()
 
584
        if result == 1:
 
585
            summary = 'Failure'
 
586
            body = 'Selftest failed in "%s"' % os.getcwd()
 
587
        pynotify.init("bzr gselftest")
 
588
        note = pynotify.Notification(cgi.escape(summary), cgi.escape(body))
 
589
        note.set_timeout(pynotify.EXPIRES_NEVER)
 
590
        note.show()
 
591
 
 
592
 
 
593
register_command(cmd_gselftest)
 
594
 
 
595
 
555
596
import gettext
556
597
gettext.install('olive-gtk')
557
598