/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: Jelmer Vernooij
  • Date: 2007-07-13 20:34:04 UTC
  • Revision ID: jelmer@samba.org-20070713203404-fu32vmlonujfl6fu
Move notification area code into separate file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
464
464
    """
465
465
 
466
466
    def run(self):
467
 
        def toggle_lan_gateway(item):
468
 
            if item.get_active():
469
 
                langateway.start()
470
 
            else:
471
 
                langateway.stop()
472
 
 
473
 
        def toggle_announce_branches(item):
474
 
            if item.get_active():
475
 
                zeroconfserver.start()
476
 
            else:
477
 
                zeroconfserver.close()
478
 
 
479
 
        def show_preferences(item):
480
 
            # FIXME
481
 
            pass 
482
 
 
483
 
        def make_menu(icon, event_button, event_time):
484
 
            menu.popup(None, None, gtk.status_icon_position_menu, 
485
 
                       event_button, event_time, icon)
486
 
 
 
467
        from notify import NotifyPopupMenu
487
468
        gtk = self.open_display()
488
 
        t = gtk.status_icon_new_from_file("bzr-icon-64.png")
489
 
        t.connect('popup-menu', make_menu)
490
 
        menu = gtk.Menu()
491
 
        try:
492
 
            from bzrlib.plugins.dbus.activity import LanGateway
493
 
            langateway = LanGateway()
494
 
            item = gtk.CheckMenuItem('_Gateway to LAN')
495
 
            item.connect('toggled', toggle_lan_gateway)
496
 
            menu.append(item)
497
 
            menu.append(gtk.SeparatorMenuItem())
498
 
        except ImportError:
499
 
            langateway = None
500
 
 
501
 
        try:
502
 
            from bzrlib.plugins.avahi.share import ZeroConfServer
503
 
            from bzrlib import urlutils
504
 
            zeroconfserver = ZeroConfServer(urlutils.normalize_url('.'))
505
 
            item = gtk.CheckMenuItem('Announce _branches on LAN')
506
 
            item.connect('toggled', toggle_announce_branches)
507
 
            menu.append(item)
508
 
            menu.append(gtk.SeparatorMenuItem())
509
 
        except ImportError:
510
 
            zeroconfserver = None
511
 
 
512
 
        item = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES, None)
513
 
        menu.append(item)
514
 
        menu.append(gtk.SeparatorMenuItem())
515
 
        item = gtk.MenuItem('_Close')
516
 
        item.connect('activate', gtk.main_quit)
517
 
        menu.append(item)
518
 
        menu.show_all()
519
 
 
520
 
        gtk.main()
 
469
        menu = NotifyPopupMenu()
 
470
        icon = gtk.status_icon_new_from_file("bzr-icon-64.png")
 
471
        icon.connect('popup-menu', menu.display)
521
472
 
522
473
        import cgi
523
474
        import dbus
535
486
        broadcast_service = bus.get_object(
536
487
            activity.Broadcast.DBUS_NAME,
537
488
            activity.Broadcast.DBUS_PATH)
 
489
 
538
490
        def catch_branch(revision_id, urls):
539
491
            # TODO: show all the urls, or perhaps choose the 'best'.
540
492
            url = urls[0]