예제 #1
0
    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
예제 #2
0
    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))
예제 #3
0
    def __interface(self):

        """
        Returns a description of the interface of this control.
        """

        return Interface.text_describe(self.__class__)
예제 #4
0
    def __init__(self, ctrlclass):

        HIGDialog.__init__(self, buttons=(gtk.STOCK_CLOSE, gtk.RESPONSE_CLOSE))
        name = ctrlclass.__name__
        self.set_property("title", _("%s Control") % name)

        align = gtk.Alignment(0.0, 0.0, 0.0, 0.0)
        align.set_property("border-width", 6)
        frame = gtk.Frame()
        self.__scrollw = gtk.ScrolledWindow()
        frame.add(self.__scrollw)
        align.add(frame)

        self.__label = gtk.Label()
        self.__label.set_property("selectable", True)

        self.vbox.pack_start(align, False, False, 0)
        self.vbox.pack_start(self.__label, False, False, 0)

        # list the interfaces and their descriptions
        texts = Interface.gui_describe(ctrlclass)

        # create the listview now, with the content
        self.__create_listview(texts)

        def f(*args): self.destroy()
        self.connect("response", f)

        self.vbox.show_all()
예제 #5
0
    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)
예제 #6
0
    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) )
예제 #7
0
    def __init__(self, ctrl):

        self.__dict__["_PropertyInterface__property"] = Vault( dict(Interface.get_properties(ctrl.__class__)) )
        self.__dict__["_PropertyInterface__control"] = Vault(ctrl)
예제 #8
0
else:
    DBusGMainLoop(set_as_default=True)

if "." not in sys.path: sys.path.append(".")
if HOME not in sys.path: sys.path.append(HOME)

try:
    path = os.path.abspath(sys.argv[1])
    folder, base = os.path.split(path)
except:
    sys.exit("Usage: test-control.py <control-directory>")
    

cwd = os.getcwd()
os.chdir(folder)
try:
    module = __import__(base)
    os.chdir(base)
    clss = module.get_class()
    ctrl = clss()
    
except IOError:
    sys.exit("Could not load control %s." % (path))

print
print Interface.text_describe(clss)

__builtin__.ctrl = ctrl
code.InteractiveConsole().interact("Use 'ctrl' to access the control. "
                                   "Press Ctrl+D to quit.")