Return to Snippet

Revision: 61021
at November 22, 2012 22:37 by ssoton


Updated Code
#!/usr/bin/env python


import gobject
import pygtk
pygtk.require('2.0')
import gtk
import appindicator
import sys


class AppIndicatorExample:
    def __init__(self):
        self.ind = appindicator.Indicator ("example-simple-client", 
                                           "indicator-messages", 
                                           appindicator.CATEGORY_APPLICATION_STATUS)
        self.ind.set_attention_icon ("indicator-messages-new")
        self.ind.set_icon("distributor-logo")
        self.inicialice()

    def inicialice(self):
        # create a menu
        self.menu = gtk.Menu()

        # create items for the menu - labels, checkboxes, radio buttons and images 
        # are supported:
        item = gtk.MenuItem("Regular Menu Item")
        item.show()
        self.menu.append(item)

        check = gtk.CheckMenuItem("Check Menu Item")
        check.show()
        self.menu.append(check)

        radio = gtk.RadioMenuItem(None, "Radio Menu Item")
        radio.show()
        self.menu.append(radio)

        image = gtk.ImageMenuItem(gtk.STOCK_QUIT)
        image.connect("activate", self.quit)
        image.show()
        self.menu.append(image)
                    
        self.menu.show()

        self.ind.set_menu(self.menu)

    def show(self):
        self.ind.set_status (appindicator.STATUS_ACTIVE)

    def quit(self, widget=None, data=None):
        self.ind.set_status(appindicator.STATUS_PASSIVE)
        self.menu.destroy()
        gtk.main_quit()


def quit_in_5(indicator):
    indicator.quit()
    print "Executing quit"
    return 0
    

if __name__ == "__main__":
    indicator = AppIndicatorExample()
    indicator.show()

    # this timeout help us to reproduce the problem. It gives you 5 seconds
    # to display the indator menu making clic on the icon
    gobject.timeout_add(5000, quit_in_5, indicator)
    gtk.main()

Revision: 61020
at November 22, 2012 22:17 by ssoton


Initial Code
#!/usr/bin/env python


import gobject
import pygtk
pygtk.require('2.0')
import gtk
import appindicator
import sys


class AppIndicatorExample:
    def __init__(self):
        self.ind = appindicator.Indicator ("example-simple-client", 
                                           "indicator-messages", 
                                           appindicator.CATEGORY_APPLICATION_STATUS)
        self.ind.set_attention_icon ("indicator-messages-new")
        self.ind.set_icon("distributor-logo")
        self.inicialice()

    def inicialice(self):
        # create a menu
        self.menu = gtk.Menu()

        # create items for the menu - labels, checkboxes, radio buttons and images 
        # are supported:
        item = gtk.MenuItem("Regular Menu Item")
        item.show()
        self.menu.append(item)

        check = gtk.CheckMenuItem("Check Menu Item")
        check.show()
        self.menu.append(check)

        radio = gtk.RadioMenuItem(None, "Radio Menu Item")
        radio.show()
        self.menu.append(radio)

        image = gtk.ImageMenuItem(gtk.STOCK_QUIT)
        image.connect("activate", self.quit)
        image.show()
        self.menu.append(image)
                    
        self.menu.show()

        self.ind.set_menu(self.menu)

    def show(self):
        self.ind.set_status (appindicator.STATUS_ACTIVE)

    def quit(self, widget=None, data=None):
        self.ind.set_status(appindicator.STATUS_PASSIVE)
        self.menu.destroy()
        gtk.main_quit()


def quit_in_5(indicator):
    indicator.quit()
    print "Ejecutado quit de indicator"
    return 0
    

if __name__ == "__main__":
    indicator = AppIndicatorExample()
    indicator.show()

    # this timeout help us to reproduce the problem. It gives you 5 seconds
    # to display the indator menu making clic on the icon
    gobject.timeout_add(5000, quit_in_5, indicator)
    gtk.main()

Initial URL
appindicator_facade

Initial Description
snippet to show appindicator problem

Initial Title
Appindicator facade

Initial Tags
python, ubuntu

Initial Language
Python