コード例 #1
0
	def __init__(self,applet,iid):
		self.timeout = 15000
		self.applet = applet
		self.data = self.get_data()
		self.label = gtk.Label()
		self.label.set_markup(self.get_label_markup(self.data))
		applet.add(self.label)

		gtk.timeout_add(self.timeout,self.timeout_callback, self)
		applet.connect("destroy", self.cleanup, None)
		applet.show_all()
コード例 #2
0
ファイル: focus.py プロジェクト: pranjalv123/TimeTracker
    def __init__(self, applet, iid):
        self.timeout_interval = 1000
        self.timeout_callback = self.write_focused_window
        gnome.init("focus", "1.0")
        self.applet = applet
        self.tooltips = gtk.Tooltips()
        self.hbox = gtk.HBox()
        applet.add(self.hbox)

        self.ev_box = gtk.EventBox()
        self.ev_box.connect("button-press-event", self.button_press)
        self.ev_box.connect("enter-notify-event", self.update_info)
        self.hbox.add(self.ev_box)
        self.prog = gtk.ProgressBar()
        self.ev_box.add(self.prog)
        gtk.timeout_add(self.timeout_interval, self.timeout_callback, self)
        applet.connect("destroy", self.cleanup)
        applet.show_all()
コード例 #3
0
ファイル: internode.py プロジェクト: AntiSol/nodeutil
	def __init__(self, applet, iid):
		"""
		Initialises the usage meter
		"""
		log("---------------------------------------------------")
		log("Internode GNOME Applet (%s) - Init" % INTERNODE_GNOMEAPPLET)
		log("%s" % applet)

		# Initialize GConf
		self.gconf_client = gconf.client_get_default()

		self.applet = applet

		# Initialize GTK widgets
		self.image = gtk.Image()
		self.image.expand = True

		self.label = gtk.Label("??%")
		self.eventbox = gtk.EventBox()
		self.hbox = gtk.HBox()
		self.hbox.expand = False
		self.hbox.padding = 2
		self.tooltips = gtk.Tooltips()
	
		# Add widgets to applet
		self.hbox.add(self.image)
		self.hbox.add(self.label)
		self.eventbox.add(self.hbox)

		applet.add(self.eventbox)

		icon = NodeIcons.icons["x"]
		#s = self.applet.get_size() - 2
		s = self.applet.get_size()
		#log("Reported size: %s" % s)
		s2 = s - (s % 8) - 8
		if s2 <= (s - 3):
			s = s2
		if s < 25: s= 25
		#log("s2: %s" % s)
		self.image.set_from_pixbuf(icon.scale_simple(s,s,gtk.gdk.INTERP_HYPER))
		
		#hardcoded menu XML:
		menu = """
			<popup name="button3">
			<menuitem name="Item 1" verb="Preferences" label="_Preferences..."
				pixtype="stock" pixname="gtk-properties"/>
			<menuitem name="Item 2" verb="About" label="_About..."
				pixtype="stock" pixname="gnome-stock-about"/>
			<menuitem name="Item 3" verb="Graph" label="_Graph..."/>
			<menuitem name="Item 4" verb="Update" label="_Update"/>
			</popup>
		"""
		
		applet.setup_menu(menu,
						 [("Preferences", self.show_prefs),
						  ("About", self.show_about),
						  ("Graph", self.show_graph),
						  ("Update", self.update)],
						  None)
		
		applet.show_all()

		# Initialize Internode Usage Checker
		self.nodeutil = NodeUtil()
		self.nodeutil.user_agent_text = "GNOME Applet"
		if not self.nodeutil.load_prefs():
			self.show_prefs()
		self.set_timeout(True)
		self.dialog = None
		applet.connect("button-press-event",self.on_clicked)
		applet.connect("change-size",self.on_resize)

		# Connect background callback
		applet.connect("change_background", self.change_background)

		#check for a new version
		latest = self.nodeutil.check_version()
		if float(VERSION) < latest:
			log("A New Version of Nodeutils is available!")
			markup = "<b>A New version of the Internode Usage Meter is available!</b>\nversion %02.1f is out, get it now!" % latest
			NodeDialog_Alert(self.nodeutil,None,"Internode Usage Meter",markup)
			#self.alert.show("A New Version (v%02.1f) of Nodeutils is available!" % latest,False)

		#update nodeutil...
		self.nodeutil.update(True)
		log("Init Complete")
コード例 #4
0
ファイル: hstray.py プロジェクト: pglen/hsenc
    def __init__(self, applet, iid):

        #syslog.syslog("Init Applet")

        self.applet = applet
        self.apselect = None
        self.prefsdialog = None

        self.dict = {}
        self.ttext = "High Security Encrypting\n"\
                     "       File System"

        # Start from a known place
        os.chdir(os.environ['HOME'])

        #<menuitem name="Item 2" verb="Props" label="_Preferences" pixtype="stock" pixname="gtk-properties"/>

        self.propxml = """
        <popup name="button3">
        <menuitem name="Item 1" verb="Mounts" label="_Mounts" pixtype="stock" pixname="gtk-properties"/>
        <menuitem name="Item 3" verb="About" label="_About ..." pixtype="stock" pixname="gnome-stock-about"/>
        </popup>
        """

        #( "Props",  self.props ),
        self.verbs = [("Mounts", self.Mounts), ("About", self.about_info)]

        warnings.simplefilter("ignore", Warning)
        gnome.init("HSTray", "1.03")
        warnings.simplefilter("default", Warning)

        try:
            self.logo_pixbuf = gtk.gdk.pixbuf_new_from_file(\
                        os.path.basename(imgname))
        except:
            try:
                self.logo_pixbuf = gtk.gdk.pixbuf_new_from_file(imgname)
            except:
                try:
                    self.logo_pixbuf = gtk.gdk.pixbuf_new_from_file(imgname2)
                except:
                    pass

        self.ev_box = gtk.EventBox()
        #self.applet.set_size_request(-1, -1)

        self.ev_box.connect("event", self.button_press)
        self.applet.connect("change-background", self.panel_bg)

        self.main_icon = gtk.Image()
        main_pixbuf = None

        try:
            main_pixbuf = gtk.gdk.pixbuf_new_from_file(
                os.path.basename(imgname))
        except:
            try:
                #global imgname
                main_pixbuf = gtk.gdk.pixbuf_new_from_file(imgname)
            except:
                try:
                    main_pixbuf = gtk.gdk.pixbuf_new_from_file(imgname2)
                except:
                    pass
                    #print "img", sys.exc_info()

        if main_pixbuf:
            main_pixbuf2 = main_pixbuf.scale_simple(25, 25,
                                                    gtk.gdk.INTERP_BILINEAR)
            self.main_icon.set_from_pixbuf(main_pixbuf2)
        else:
            # This will let a broken image go through
            self.main_icon.set_from_file("")

        #self.label = gtk.Label("")
        self.main_hbox = gtk.HBox()

        self.main_hbox.pack_start(self.main_icon, False, False, 5)
        self.ev_box.add(self.main_hbox)

        self.main_hbox.show()

        applet.add(self.ev_box)
        applet.connect("destroy", self.cleanup, None)
        applet.show_all()

        # Set the tooltip
        self.main_hbox.set_has_tooltip(True)
        self.main_hbox.set_tooltip_text(self.ttext)

        # Mount automount entries. use ondemand for no prompt
        traydb2 = traySQL(traydbname)
        alldata = traydb2.getall()
        for aa in alldata:
            if aa[3] == "True":
                if not is_mounted(aa[2]):
                    ret = mountitem("-o", aa[1], aa[2], aa[4])