def __init__(self, control, size): self.__dict__["_ControlWrapper__length"] = size if size <= 0: size = 1 # We need to deepcopy in order to get individually changeable # Control instances try: self.__dict__["_ControlWrapper__control"] = \ Vault( [ deepcopy(control) for i in range(size) ] ) except: self.__dict__["_ControlWrapper__control"] = \ Vault( [ control ] ) if self.__length > 0: log(_("Error: Control %s can't be replicated! This is a BUG in the Desklet!" "\nThings probably won't work right for you.") % control) self.__dict__["_ControlWrapper__length"] = 0 size = 1 else: # Initialize all initial copies for ctl in self.__dict__["_ControlWrapper__control"](open): ctl.__init__() # Keep an original copy around for extending the array self.__dict__["_ControlWrapper__original_control"] = Vault(control) # deactivate the original control ctl = self.__dict__["_ControlWrapper__original_control"](open) ctl.stop() # Create a property handler for each deep copy of control self.__dict__["_ControlWrapper__properties"] = \ [ PropertyInterface(self.__control(open)[i]) for i in range(size) ] ids = [ Interface.get_id(i) for i in Interface.get_interfaces( control.__class__ ) ] taz_ids = [ Interface.get_taz_style_id(i) for i in Interface.get_interfaces( control.__class__ ) ] self.__dict__["_ControlWrapper__ifaces_id"] = \ Vault( tuple(ids + taz_ids) )
def __get_interfaces(self, collection): icon = os.path.join(self._get_path(), "interface.png") values = [] matches = collection.query("(MATCH 'interface' '*')") for m in matches: values += [ (icon, Interface.get_id(iface), "(MATCH 'interface' '%s')" % (Interface.get_id(iface))) for iface in Interface.get_interfaces(m) ] return values
def __item_renderer(self, item): icon = os.path.join(self._get_path(), "control.png") pixbuf = gtk.gdk.pixbuf_new_from_file(icon) name = item.__name__ interfaces = Interface.get_interfaces(item) ifaces = [] for i in interfaces: ifaces.append(Interface.get_id(i)) return (pixbuf, name, "\n".join(ifaces))
def __register_plugin(self, module): clss = module.get_class() path = os.path.abspath(os.path.dirname(module.__file__)) clss._path = path interfaces = Interface.get_interfaces(clss) name = clss.__name__ mtime = os.path.getmtime(module.__file__) self.__trie.insert([self.NAME] + list(name), clss) self.__trie.insert([self.MTIME] + list(`mtime`), clss) for iface in interfaces: ident = Interface.get_id(iface) taz_ident = Interface.get_taz_style_id(iface) self.__trie.insert([self.INTERFACE] + list(ident), clss) self.__trie.insert([self.TAZINTERFACE] + list(taz_ident), clss)