Ejemplo n.º 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()
Ejemplo n.º 2
0
    def __init__ (self, xmlui, bindings, props, appletMode):
        window = xmlui.get_widget("lookuplet");
        self.about = xmlui.get_widget("about");
        self.bindings = bindings;
        self.props = props;
        self.appletMode = appletMode;

        # wire up our handlers
        xmlui.signal_connect("on_query_key_press_event",
                             self.on_query_key_press_event);
        xmlui.signal_connect("on_prefs_clicked", self.on_prefs_clicked);
        xmlui.signal_connect("exit_lookuplet", self.exit_lookuplet);

        # create our query history
        self.history = history.History();

        # if we're in applet mode, extract the UI and stick it into an
        # applet widget
        if (appletMode):
            applet = gnome.applet.AppletWidget("lookuplet");
            mainbox = xmlui.get_widget("mainbox");
            # lose the border
            mainbox.set_border_width(0);
            # and hide the prefs button
            prefs = xmlui.get_widget("prefs");
            prefs.hide();
            # remove everything from the window
            window.remove(mainbox);
            # and add it to the applet
            applet.add(mainbox);
            # register our menu items
            applet.register_stock_callback(
                "properties", gnome.ui.STOCK_MENU_PROP,
                "Properties...", self.on_props_selected, None);
            applet.register_stock_callback(
                "about", gnome.ui.STOCK_MENU_ABOUT,
                "About...", self.on_about_selected, None);
            applet.show();

        else:
            window.show();

        # obtain the primary selection and stuff that into our entry box
        # clip = gtk.clipboard_get(gtk.GDK_SELECTION_PRIMARY);
        # selection = gtk.clipboard_wait_for_text(clip);
        query = xmlui.get_widget("query");
        # self.display_selection(self, query, selection);
        # query.paste_clipboard();

        # put the focus in the query box
        query.grab_focus();
Ejemplo n.º 3
0
def xatar_applet(applet, iid):
   # Definimos el Applet
   label = gtk.Label("xatar")
   applet.add(label)
   applet.show_all()

   # Creamos el temporizador
   gtk.timeout_add(500, actualizar, label)   # Milisegundos, Funcion, Parametro

   # Entrada About del menu... ¿quién coño documenta esto?
   applet.setup_menu_from_file(None, "/usr/lib/xatar/xatar.xml", None, [("About", about)])

   # Salimos como chicos buenos
   return gtk.TRUE
Ejemplo n.º 4
0
    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()
Ejemplo n.º 5
0
	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")
Ejemplo n.º 6
0
    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])