예제 #1
0
 def __init__(self, rent):
     Box.__init__(self, rent)
     self.parent = rent
     
     #This appears on the button in the main swmai window
     self.name = "Skel"
     #The section in the main window the button is added to
     self.section = "The Body"
     #Search terms that this module should appear for
     self.searchData = []
     #Command line argument to open this module directly
     self.launchArg = "--skel"
     #Should be none by default. This value is used internally by swami
     self.button = None
     
     self.icon = Icon(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
     #Use FDO icons -> http://standards.freedesktop.org/icon-naming-spec/latest/ar01s04.html
     self.icon.standard_set('icon-name')
     self.icon.show()
     
     self.mainBox = Box(self, size_hint_weight = EXPAND_BOTH)
     self.mainBox.show()
     
     buttonBox = Box(self, size_hint_weight = EXPAND_HORIZ, size_hint_align = FILL_BOTH)
     buttonBox.horizontal = True
     
     buttonReturn = StandardButton(self, "Back", "go-previous", self.returnPressed)
     buttonReturn.show()
     
     buttonBox.pack_end(buttonReturn)
     buttonBox.show()
     
     self.pack_end(self.mainBox)
     self.pack_end(buttonBox)
예제 #2
0
 def __init__(self, rent):
     Box.__init__(self, rent)
     self.parent = rent
     
     #This appears on the button in the main swmai window
     self.name = "Light DM"
     #The section in the main window the button is added to
     self.section = "System Settings"
     #Search terms that this module should appear for
     self.searchData = ["lightdm", "autologin", "login", "display"]
     #Command line argument to open this module directly
     self.launchArg = "--lightdm"
     #Should be none by default. This value is used internally by swami
     self.button = None
     
     self.icon = Icon(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
     #Use FDO icons -> http://standards.freedesktop.org/icon-naming-spec/latest/ar01s04.html
     self.icon.standard_set('video-display')
     self.icon.show()
     
     self.mainBox = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
     self.mainBox.show()
     
     self.config = {}
     
     with open(LightDMConf) as f:
         for line in f:
             #Sections start with [ - such as [SeatDefaults]
             if line[0] != "[":
                 setting, value = line.replace("\n", "").split("=")
                 
                 e = Entry(self)
                 e.single_line_set(True)
                 e.text = value
                 e.show()
                 
                 f = Frame(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ)
                 f.text = setting
                 f.content = e
                 f.show()
                 
                 self.mainBox.pack_end(f)
                 
                 self.config[setting] = f
     
     buttonBox = Box(self, size_hint_weight = EXPAND_HORIZ, size_hint_align = FILL_BOTH)
     buttonBox.horizontal = True
     
     buttonSave = StandardButton(self, "Save Changes", "ok", self.savePressed)
     buttonSave.show()
     
     buttonReturn = StandardButton(self, "Back", "go-previous", self.returnPressed)
     buttonReturn.show()
     
     buttonBox.pack_end(buttonSave)
     buttonBox.pack_end(buttonReturn)
     buttonBox.show()
     
     self.pack_end(self.mainBox)
     self.pack_end(buttonBox)
예제 #3
0
 def __init__(self, rent):
     Box.__init__(self, rent)
     self.parent = rent
     
     #This appears on the button in the main swmai window
     self.name = "Startup Applications"
     #The section in the main window the button is added to
     self.section = "Applications"
     #Search terms that this module should appear for
     self.searchData = ["startup", "command", "applications", "apps"]
     #Command line argument to open this module directly
     self.launchArg = "--startupapps"
     #Should be none by default. This value is used internally by swami
     self.button = None
     
     self.icon = Icon(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
     #Use FDO icons -> http://standards.freedesktop.org/icon-naming-spec/latest/ar01s04.html
     self.icon.standard_set('system-run')
     self.icon.show()
     
     self.mainBox = Box(self, size_hint_weight = EXPAND_BOTH)
     self.mainBox.show()
     
     buttonBox = Box(self, size_hint_weight = EXPAND_HORIZ, size_hint_align = FILL_BOTH)
     buttonBox.horizontal = True
     
     buttonReturn = StandardButton(self, "Back", "go-previous", self.returnPressed)
     buttonReturn.show()
     
     buttonBox.pack_end(buttonReturn)
     buttonBox.show()
     
     self.pack_end(self.mainBox)
     self.pack_end(buttonBox)
예제 #4
0
    def select_torrent(self):
        sel = Fileselector(self.win)
        sel.expandable = False
        sel.path_set(os.path.expanduser("~"))
        sel.size_hint_weight_set(1.0, 1.0)
        sel.size_hint_align_set(-1.0, -1.0)
        sel.show()

        sf = Frame(self.win)
        sf.size_hint_weight_set(1.0, 1.0)
        sf.size_hint_align_set(-1.0, -1.0)
        sf.text = "Select torrent file"
        sf.content = sel
        sf.show()

        magnet = Entry(self.win)
        magnet.single_line = True
        magnet.scrollable = True
        if hasattr(magnet, "cnp_selection_get"):
            magnet.cnp_selection_get(ELM_SEL_TYPE_CLIPBOARD,
                                     ELM_SEL_FORMAT_TEXT)
        else:
            import pyperclip
            t = pyperclip.paste()
            if t is not None and t.startswith("magnet:"):
                magnet.entry = t
        magnet.show()

        mf = Frame(self.win)
        mf.size_hint_weight_set(1.0, 0.0)
        mf.size_hint_align_set(-1.0, 0.0)
        mf.text = "Or enter magnet URI here"
        mf.content = magnet
        mf.show()

        mbtn = Button(self.win)
        mbtn.text = "Done"
        mbtn.show()
        mbox = Box(self.win)
        mbox.size_hint_weight_set(1.0, 0.0)
        mbox.size_hint_align_set(-1.0, 0.0)
        mbox.horizontal = True
        mbox.pack_end(mf)
        mbox.pack_end(mbtn)
        mbox.show()

        box = Box(self.win)
        box.size_hint_weight = (1.0, 1.0)
        box.size_hint_align = (-1.0, -1.0)
        box.pack_end(sf)
        box.pack_end(mbox)
        box.show()

        inwin = InnerWindow(self.win)
        inwin.content = box
        sel.callback_done_add(self.add_torrent_cb)
        sel.callback_done_add(lambda x, y: inwin.delete())
        mbtn.callback_clicked_add(self.add_magnet_uri_cb, magnet)
        mbtn.callback_clicked_add(lambda x: inwin.delete())
        inwin.activate()
예제 #5
0
    def select_torrent(self):
        sel = Fileselector(self.win)
        sel.expandable = False
        sel.path_set(os.path.expanduser("~"))
        sel.size_hint_weight_set(1.0, 1.0)
        sel.size_hint_align_set(-1.0, -1.0)
        sel.show()

        sf = Frame(self.win)
        sf.size_hint_weight_set(1.0, 1.0)
        sf.size_hint_align_set(-1.0, -1.0)
        sf.text = "Select torrent file"
        sf.content = sel
        sf.show()

        magnet = Entry(self.win)
        magnet.single_line = True
        magnet.scrollable = True
        if hasattr(magnet, "cnp_selection_get"):
            magnet.cnp_selection_get(ELM_SEL_TYPE_CLIPBOARD, ELM_SEL_FORMAT_TEXT)
        else:
            import pyperclip
            t = pyperclip.paste()
            if t is not None and t.startswith("magnet:"):
                    magnet.entry = t
        magnet.show()

        mf = Frame(self.win)
        mf.size_hint_weight_set(1.0, 0.0)
        mf.size_hint_align_set(-1.0, 0.0)
        mf.text = "Or enter magnet URI here"
        mf.content = magnet
        mf.show()

        mbtn = Button(self.win)
        mbtn.text = "Done"
        mbtn.show()
        mbox = Box(self.win)
        mbox.size_hint_weight_set(1.0, 0.0)
        mbox.size_hint_align_set(-1.0, 0.0)
        mbox.horizontal = True
        mbox.pack_end(mf)
        mbox.pack_end(mbtn)
        mbox.show()

        box = Box(self.win)
        box.size_hint_weight = (1.0, 1.0)
        box.size_hint_align = (-1.0, -1.0)
        box.pack_end(sf)
        box.pack_end(mbox)
        box.show()

        inwin = InnerWindow(self.win)
        inwin.content = box
        sel.callback_done_add(self.add_torrent_cb)
        sel.callback_done_add(lambda x, y: inwin.delete())
        mbtn.callback_clicked_add(self.add_magnet_uri_cb, magnet)
        mbtn.callback_clicked_add(lambda x: inwin.delete())
        inwin.activate()
    def __init__(self, parent_widget, titles=None, *args, **kwargs):
        Box.__init__(self, parent_widget, *args, **kwargs)

        self.outPut = Entry(self,
                            size_hint_weight=EXPAND_BOTH,
                            size_hint_align=FILL_BOTH)
        self.outPut.editable_set(False)
        self.outPut.scrollable_set(True)
        self.outPut.callback_changed_add(self.changedCb)
        self.outPut.show()

        frame = Frame(self,
                      size_hint_weight=EXPAND_HORIZ,
                      size_hint_align=FILL_HORIZ)
        frame.text = "Input:"
        frame.autocollapse_set(True)
        frame.collapse_go(True)
        frame.show()

        bx = Box(self,
                 size_hint_weight=EXPAND_HORIZ,
                 size_hint_align=FILL_HORIZ)
        bx.horizontal = True
        bx.show()

        frame.content = bx

        self.inPut = Entry(self,
                           size_hint_weight=EXPAND_BOTH,
                           size_hint_align=FILL_BOTH)
        self.inPut.single_line_set(True)
        self.inPut.callback_activated_add(self.enterPressed)
        self.inPut.show()

        enterButton = Button(self)
        enterButton.text = "Execute"
        enterButton.callback_pressed_add(self.enterPressed)
        enterButton.show()

        bx.pack_end(self.inPut)
        bx.pack_end(enterButton)

        self.pack_end(self.outPut)
        self.pack_end(frame)

        self.cmd_exe = None
        self.done_cb = None
예제 #7
0
    def __init__(self, parent_widget, *args, **kwargs):
        Box.__init__(self, parent_widget, *args, **kwargs)

        self.output = Entry(self,
                            size_hint_weight=EXPAND_BOTH,
                            size_hint_align=FILL_BOTH)
        self.output.editable_set(False)
        self.output.scrollable_set(True)
        self.output.callback_changed_add(self.cb_changed)
        self.output.show()

        frame = Frame(self,
                      size_hint_weight=EXPAND_HORIZ,
                      size_hint_align=FILL_HORIZ)
        frame.text = 'Input:'
        frame.autocollapse_set(True)
        frame.collapse_go(True)
        frame.show()

        hbx = Box(self,
                  size_hint_weight=EXPAND_HORIZ,
                  size_hint_align=FILL_HORIZ)
        hbx.horizontal = True
        hbx.show()

        frame.content = hbx

        self.input = Entry(self,
                           size_hint_weight=EXPAND_BOTH,
                           size_hint_align=FILL_BOTH)
        self.input.single_line_set(True)
        self.input.callback_activated_add(self.cb_enter)
        self.input.show()

        enter_btn = Button(self)
        enter_btn.text = 'Execute'
        enter_btn.callback_pressed_add(self.cb_enter)
        enter_btn.show()

        hbx.pack_end(self.input)
        hbx.pack_end(enter_btn)

        self.pack_end(self.output)
        self.pack_end(frame)

        self.cmd_exe = None
        self.done_cb = None
예제 #8
0
 def __init__(self, rent):
     Box.__init__(self, rent)
     self.parent = rent
     
     self.name = "Keyboard Layout"
     self.section = "System Settings"
     self.searchData = ["keyboard", "layout", "system", "input"]
     self.launchArg = "--keyboard"
     self.button = None
     
     self.icon = Icon(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
     #Use FDO icons -> http://standards.freedesktop.org/icon-naming-spec/latest/ar01s04.html
     self.icon.standard_set('input-keyboard')
     self.icon.show()
     
     #print(list(KeyboardLayouts))
     
     self.keyboardList = keyboardList = SearchableList(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
     keyboardList.callback_item_focused_add(self.enableKBSelect)
     self.keys = list(KeyboardLayouts)
     self.keys.sort()
     for kbl in self.keys:
         keyboardList.item_append(kbl)
     keyboardList.show()
     
     self.mainBox = Box(self, size_hint_weight = EXPAND_BOTH, size_hint_align = FILL_BOTH)
     self.mainBox.pack_end(keyboardList)
     self.mainBox.show()
     
     buttonBox = Box(self, size_hint_weight = EXPAND_HORIZ, size_hint_align = FILL_BOTH)
     buttonBox.horizontal = True
     
     self.buttonKBSelect = buttonKBSelect = StandardButton(self, "Apply Selected", "ok", self.applyPressed)
     buttonKBSelect.disabled = True
     buttonKBSelect.show()
     
     buttonReturn = StandardButton(self, "Back", "go-previous", self.returnPressed)
     buttonReturn.show()
     
     buttonBox.pack_end(buttonKBSelect)
     buttonBox.pack_end(buttonReturn)
     buttonBox.show()
     
     self.pack_end(self.mainBox)
     self.pack_end(buttonBox)
    def __init__(self, parent_widget, titles=None, *args, **kwargs):
        Box.__init__(self, parent_widget, *args, **kwargs)

        self.outPut = Entry(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        self.outPut.editable_set(False)
        self.outPut.scrollable_set(True)
        self.outPut.callback_changed_add(self.changedCb)
        self.outPut.show()

        frame = Frame(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ)
        frame.text = "Input:"
        frame.autocollapse_set(True)
        frame.collapse_go(True)
        frame.show()

        bx = Box(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_HORIZ)
        bx.horizontal = True
        bx.show()

        frame.content = bx

        self.inPut = Entry(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        self.inPut.single_line_set(True)
        self.inPut.callback_activated_add(self.enterPressed)
        self.inPut.show()

        enterButton = Button(self)
        enterButton.text = "Execute"
        enterButton.callback_pressed_add(self.enterPressed)
        enterButton.show()

        bx.pack_end(self.inPut)
        bx.pack_end(enterButton)

        self.pack_end(self.outPut)
        self.pack_end(frame)

        self.cmd_exe = None
        self.done_cb = None
    def __init__(self, parent, h):
        Box.__init__(self, parent)

        filelist = Genlist(self)
        filelist.size_hint_align = -1.0, -1.0
        filelist.size_hint_weight = 1.0, 1.0

        self.populate(filelist, h)

        filelist.callback_activated_add(self.item_activated_cb)
        filelist.show()

        sel_all = Button(self)
        sel_all.text = "Select all"
        sel_all.callback_clicked_add(self.select_all_cb, filelist, h, True)
        sel_all.show()

        sel_none = Button(self)
        sel_none.text = "Select none"
        sel_none.callback_clicked_add(self.select_all_cb, filelist, h, False)
        sel_none.show()

        xbtn = Button(self)
        xbtn.text = "Close"
        xbtn.callback_clicked_add(lambda x: parent.item_pop())
        xbtn.show()

        btn_box = Box(self)
        btn_box.horizontal = True
        btn_box.pack_end(sel_all)
        btn_box.pack_end(sel_none)
        btn_box.pack_end(xbtn)
        btn_box.show()

        self.pack_end(filelist)
        self.pack_end(btn_box)
        self.show()
    def __init__(self, rent):
        Box.__init__(self, rent)
        self.parent = rent
        
        #This appears on the button in the main swmai window
        self.name = "Startup Applications"
        #The section in the main window the button is added to
        self.section = "Applications"
        #Search terms that this module should appear for
        self.searchData = ["startup", "command", "applications", "apps"]
        #Command line argument to open this module directly
        self.launchArg = "--startupapps"
        #Should be none by default. This value is used internally by swami
        self.button = None
        
        self.icon = Icon(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        #Use FDO icons -> http://standards.freedesktop.org/icon-naming-spec/latest/ar01s04.html
        self.icon.standard_set('system-run')
        self.icon.show()
        
        self.mainBox = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        self.mainBox.show()
        
        buttonBox = Box(self, size_hint_weight = EXPAND_HORIZ, size_hint_align = FILL_BOTH)
        buttonBox.horizontal = True
        
        buttonApply = StandardButton(self, "Apply", "ok", self.applyPressed)
        buttonApply.show()
        
        buttonFlip = StandardButton(self, "Startup Commands", "preferences-system", self.flipPressed)
        buttonFlip.show()
        
        buttonReturn = StandardButton(self, "Back", "go-previous", self.returnPressed)
        buttonReturn.show()
        
        buttonBox.pack_end(buttonApply)
        buttonBox.pack_end(buttonFlip)
        buttonBox.pack_end(buttonReturn)
        buttonBox.show()
        
        startupApplications = []
        
        with open(StartupApplicationsFile) as startupFile:
            for line in startupFile:
                startupApplications.append(line.rstrip())
        
        desktopFiles = []
        
        for ourPath in ApplicationPaths:
            desktopFiles += [os.path.join(dp, f) for dp, dn, filenames in os.walk(ourPath) for f in filenames if os.path.splitext(f)[1] == '.desktop']
        
        self.startupList = startupList = List(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        
        self.applicationsList = applicationsList = SearchableList(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)

        startupToAdd = []
        applicationsToAdd = []

        for d in desktopFiles:
            with open(d) as desktopFile:
                fileName = d.split("/")[-1]
                icon = None
                for line in desktopFile:
                    if line[:5] == "Name=":
                        name = line[5:][:-1]
                    
                    if line[:5] == "Icon=":
                        icon = line[5:].strip()
                
                try:
                    iconObj = Icon(self, standard=icon, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
                except:
                    iconObj = Icon(self, standard="preferences-system", size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
                    icon = None
                
                if fileName in startupApplications:
                    startupToAdd.append([name, iconObj, fileName, icon])
                else:
                    applicationsToAdd.append([name, iconObj, fileName, icon])
        
        startupToAdd.sort()
        applicationsToAdd.sort()
        
        for s in startupToAdd:
            ourItem = startupList.item_append(s[0], s[1])
            ourItem.data["file"] = s[2]
            ourItem.data["icon"] = s[3]
            #ourItem.append_to(startupList)
            #startupList.item_append(ourItem)
        
        for a in applicationsToAdd:
            ourItem = applicationsList.item_append(a[0], a[1])
            ourItem.data["file"] = a[2]
            ourItem.data["icon"] = a[3]
            #ourItem.append_to(applicationsList.ourList)
            #applicationsList.item_append(a[0], a[1])
        
        startupList.callback_clicked_double_add(self.startupAppRemove)
        applicationsList.callback_clicked_double_add(self.startupAppAdd)
        
        startupList.go()
        startupList.show()
        applicationsList.show()
        
        startupFrame = Frame(self, size_hint_weight = EXPAND_BOTH, size_hint_align=FILL_BOTH)
        startupFrame.text = "Startup Applications"
        startupFrame.content_set(startupList)
        startupFrame.show()
        
        otherFrame = Frame(self, size_hint_weight = EXPAND_BOTH, size_hint_align=FILL_BOTH)
        otherFrame.text = "Other Applications"
        otherFrame.content_set(applicationsList)
        otherFrame.show()
        
        self.mainBox.pack_end(startupFrame)
        self.mainBox.pack_end(otherFrame)
        
        self.backBox = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        self.backBox.show()
        
        self.commandsList = commandsList = List(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        
        with open(StartupCommandsFile) as scf:
            for line in scf:
                if line.rstrip()[-3:] == "| \\":
                    commandsList.item_append(line.rstrip()[:-3])
                else:
                    commandsList.item_append(line.rstrip())
                
        commandsList.callback_clicked_right_add(self.commandRightClicked)
        
        commandsList.go()
        commandsList.show()
        
        commandBox = Box(self, size_hint_weight=EXPAND_HORIZ, size_hint_align=(1, 0.5))
        commandBox.horizontal = True
        commandBox.show()
        
        self.newCommandEntry = newCommandEntry = Entry(self, size_hint_weight = EXPAND_HORIZ, size_hint_align = FILL_BOTH)
        newCommandEntry.single_line = True
        newCommandEntry.text = "<i>Type command here</i>"
        newCommandEntry.data["default text"] = True
        newCommandEntry.callback_clicked_add(self.entryClicked)
        newCommandEntry.show()
        
        newCommandButton = StandardButton(self, "Add Command", "add", self.newCmdPressed)
        newCommandButton.show()
        
        delCommandButton = StandardButton(self, "Delete Command", "exit", self.delCmdPressed)
        delCommandButton.show()
        
        commandBox.pack_end(newCommandButton)
        commandBox.pack_end(delCommandButton)
        
        newCommandFrame = Frame(self, size_hint_weight = EXPAND_HORIZ, size_hint_align = FILL_BOTH)
        newCommandFrame.text = "Add Startup Command:"
        newCommandFrame.content_set(newCommandEntry)
        newCommandFrame.show()
        
        self.backBox.pack_end(commandsList)
        self.backBox.pack_end(newCommandFrame)
        self.backBox.pack_end(commandBox)
        
        self.flip = Flip(self, size_hint_weight=EXPAND_BOTH,
                         size_hint_align=FILL_BOTH)
        self.flip.part_content_set("front", self.mainBox)
        self.flip.part_content_set("back", self.backBox)
        self.flip.show()
        
        self.pack_end(self.flip)
        self.pack_end(buttonBox)
예제 #12
0
    def __init__(self, rent):
        Box.__init__(self, rent)
        self.parent = rent

        #This appears on the button in the main swmai window
        self.name = "Startup Applications"
        #The section in the main window the button is added to
        self.section = "Applications"
        #Search terms that this module should appear for
        self.searchData = ["startup", "command", "applications", "apps"]
        #Command line argument to open this module directly
        self.launchArg = "--startupapps"
        #Should be none by default. This value is used internally by swami
        self.button = None

        self.icon = Icon(self,
                         size_hint_weight=EXPAND_BOTH,
                         size_hint_align=FILL_BOTH)
        #Use FDO icons -> http://standards.freedesktop.org/icon-naming-spec/latest/ar01s04.html
        self.icon.standard_set('system-run')
        self.icon.show()

        self.mainBox = Box(self,
                           size_hint_weight=EXPAND_BOTH,
                           size_hint_align=FILL_BOTH)
        self.mainBox.show()

        buttonBox = Box(self,
                        size_hint_weight=EXPAND_HORIZ,
                        size_hint_align=FILL_BOTH)
        buttonBox.horizontal = True

        buttonApply = StandardButton(self, "Apply", "ok", self.applyPressed)
        buttonApply.show()

        buttonFlip = StandardButton(self, "Startup Commands",
                                    "preferences-system", self.flipPressed)
        buttonFlip.show()

        buttonReturn = StandardButton(self, "Back", "go-previous",
                                      self.returnPressed)
        buttonReturn.show()

        buttonBox.pack_end(buttonApply)
        buttonBox.pack_end(buttonFlip)
        buttonBox.pack_end(buttonReturn)
        buttonBox.show()

        startupApplications = []

        with open(StartupApplicationsFile, "a+") as startupFile:
            for line in startupFile:
                startupApplications.append(line.rstrip())

        desktopFiles = []

        for ourPath in ApplicationPaths:
            desktopFiles += [
                os.path.join(dp, f) for dp, dn, filenames in os.walk(ourPath)
                for f in filenames if os.path.splitext(f)[1] == '.desktop'
            ]

        self.startupList = startupList = List(self,
                                              size_hint_weight=EXPAND_BOTH,
                                              size_hint_align=FILL_BOTH)

        self.applicationsList = applicationsList = SearchableList(
            self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)

        startupToAdd = []
        applicationsToAdd = []

        for d in desktopFiles:
            if os.access(d, os.R_OK):
                with open(d) as desktopFile:
                    fileName = d.split("/")[-1]
                    icon = None
                    for line in desktopFile:
                        if line[:5] == "Name=":
                            name = line[5:][:-1]

                        if line[:5] == "Icon=":
                            icon = line[5:].strip()

                    try:
                        iconObj = Icon(self,
                                       standard=icon,
                                       size_hint_weight=EXPAND_BOTH,
                                       size_hint_align=FILL_BOTH)
                    except:
                        iconObj = Icon(self,
                                       standard="preferences-system",
                                       size_hint_weight=EXPAND_BOTH,
                                       size_hint_align=FILL_BOTH)
                        icon = None

                    if fileName in startupApplications:
                        startupToAdd.append([name, iconObj, fileName, icon])
                    else:
                        applicationsToAdd.append(
                            [name, iconObj, fileName, icon])
            else:
                # Broken link or file problem, inform user
                print "Swami IOError: [Errno 2] No such file or directory: {0}".format(
                    d)

        startupToAdd.sort()
        applicationsToAdd.sort()

        for s in startupToAdd:
            ourItem = startupList.item_append(s[0], s[1])
            ourItem.data["file"] = s[2]
            ourItem.data["icon"] = s[3]
            #ourItem.append_to(startupList)
            #startupList.item_append(ourItem)

        for a in applicationsToAdd:
            ourItem = applicationsList.item_append(a[0], a[1])
            ourItem.data["file"] = a[2]
            ourItem.data["icon"] = a[3]
            #ourItem.append_to(applicationsList.ourList)
            #applicationsList.item_append(a[0], a[1])

        startupList.callback_clicked_double_add(self.startupAppRemove)
        applicationsList.callback_clicked_double_add(self.startupAppAdd)

        startupList.go()
        startupList.show()
        applicationsList.show()

        startupFrame = Frame(self,
                             size_hint_weight=EXPAND_BOTH,
                             size_hint_align=FILL_BOTH)
        startupFrame.text = "Startup Applications"
        startupFrame.content_set(startupList)
        startupFrame.show()

        otherFrame = Frame(self,
                           size_hint_weight=EXPAND_BOTH,
                           size_hint_align=FILL_BOTH)
        otherFrame.text = "Other Applications"
        otherFrame.content_set(applicationsList)
        otherFrame.show()

        self.mainBox.pack_end(startupFrame)
        self.mainBox.pack_end(otherFrame)

        self.backBox = Box(self,
                           size_hint_weight=EXPAND_BOTH,
                           size_hint_align=FILL_BOTH)
        self.backBox.show()

        self.commandsList = commandsList = List(self,
                                                size_hint_weight=EXPAND_BOTH,
                                                size_hint_align=FILL_BOTH)

        with open(StartupCommandsFile, "a+") as scf:
            for line in scf:
                if line.rstrip()[-3:] == "| \\":
                    commandsList.item_append(line.rstrip()[:-3])
                else:
                    commandsList.item_append(line.rstrip())

        commandsList.callback_clicked_right_add(self.commandRightClicked)

        commandsList.go()
        commandsList.show()

        commandBox = Box(self,
                         size_hint_weight=EXPAND_HORIZ,
                         size_hint_align=(1, 0.5))
        commandBox.horizontal = True
        commandBox.show()

        self.newCommandEntry = newCommandEntry = Entry(
            self, size_hint_weight=EXPAND_HORIZ, size_hint_align=FILL_BOTH)
        newCommandEntry.single_line = True
        newCommandEntry.text = "<i>Type command here</i>"
        newCommandEntry.data["default text"] = True
        newCommandEntry.callback_clicked_add(self.entryClicked)
        newCommandEntry.show()

        newCommandButton = StandardButton(self, "Add Command", "add",
                                          self.newCmdPressed)
        newCommandButton.show()

        delCommandButton = StandardButton(self, "Delete Command", "exit",
                                          self.delCmdPressed)
        delCommandButton.show()

        commandBox.pack_end(newCommandButton)
        commandBox.pack_end(delCommandButton)

        newCommandFrame = Frame(self,
                                size_hint_weight=EXPAND_HORIZ,
                                size_hint_align=FILL_BOTH)
        newCommandFrame.text = "Add Startup Command:"
        newCommandFrame.content_set(newCommandEntry)
        newCommandFrame.show()

        self.backBox.pack_end(commandsList)
        self.backBox.pack_end(newCommandFrame)
        self.backBox.pack_end(commandBox)

        self.flip = Flip(self,
                         size_hint_weight=EXPAND_BOTH,
                         size_hint_align=FILL_BOTH)
        self.flip.part_content_set("front", self.mainBox)
        self.flip.part_content_set("back", self.backBox)
        self.flip.show()

        self.pack_end(self.flip)
        self.pack_end(buttonBox)
예제 #13
0
파일: esudo.py 프로젝트: JeffHoogland/esudo
    def __init__(self,
                 command=None, win=None,
                 start_callback=None, end_callback=None,
                 *args, **kwargs):
        if not win:
            nowindow = True
            win = self.win = Window("esudo", ELM_WIN_DIALOG_BASIC)
            win.title = "eSudo"
            win.borderless = True
            win.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND
            win.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
            win.resize(300, 200)
            win.callback_delete_request_add(lambda o: elementary.exit())
            win.layer_set(11)
            #~ win.fullscreen = True
            win.show()
            win.activate()

            bg = Background(win)
            bg.size_hint_weight = 1.0, 1.0
            win.resize_object_add(bg)
            bg.show()

            self.embedded = False
        else:
            nowindow = False
            self.embedded = True

        self.cmd = command
        self.start_cb = start_callback if callable(start_callback) else None
        self.end_cb = end_callback if callable(end_callback) else None
        self.args = args
        self.kwargs = kwargs

#--------eSudo Window
        bz = Box(win)
        if nowindow:
            bz.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0
        else:
            bz.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND
        bz.size_hint_align = evas.EVAS_HINT_FILL, 0.0
        bz.show()

        if nowindow:
            lbl = Label(win)
            lbl.style = "marker"
            lbl.color = 170, 170, 170, 255
            lbl.size_hint_align = 0.5, 0.0
            lbl.scale = 2.0
            lbl.text = "<b>eSudo</b>"
            bz.pack_end(lbl)
            lbl.show()

            sep = Separator(win)
            sep.horizontal = True
            bz.pack_end(sep)
            sep.show()

        fr = Frame(win)
        fr.text = "Command:"
        fr.size_hint_align = evas.EVAS_HINT_FILL, 0.0
        bz.pack_end(fr)
        fr.show()

        if nowindow:
            sep = Separator(win)
            sep.horizontal = True
            bz.pack_end(sep)
            sep.show()

        self.cmdline = cmdline = Entry(win)
        cmdline.elm_event_callback_add(self.entry_event)
        cmdline.single_line = True
        if self.cmd:
            cmdline.text = self.cmd
            cmdline.editable = False
        fr.content = cmdline
        cmdline.scrollable_set(True)
        cmdline.show()

        if nowindow:
            fr = Frame(win)
            fr.text = "Password:"******"<b>Password:</b>"
            lb.size_hint_align = 0.0, 0.5
            bz1.pack_end(lb)
            lb.show()

        en = self.en = Entry(win)
        en.name = "password"
        en.elm_event_callback_add(self.entry_event)
        en.single_line = True
        en.password = True
        en.show()

        if nowindow:
            fr.content = en
        else:
            bz1.pack_end(en)

        sep = Separator(win)
        sep.horizontal = True
        bz.pack_end(sep)
        sep.show()

        btnb = Box(win)
        btnb.horizontal = True
        btnb.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0
        btnb.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
        bz.pack_end(btnb)
        btnb.show()

        bt = Button(win)
        bt.text = "Cancel"
        bt.callback_clicked_add(self.esudo_cancel, en)
        bt.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
        bt.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0
        btnb.pack_end(bt)
        bt.show()

        bt = Button(win)
        bt.text = "OK"
        bt.callback_clicked_add(self.password_check, en)
        bt.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
        bt.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0
        btnb.pack_end(bt)
        bt.show()

        self.iw = iw = InnerWindow(win)
        iw.content = bz
        iw.show()
        iw.activate()
        if self.cmd:
            en.focus = True
예제 #14
0
    def __init__(self, rent):
        Box.__init__(self, rent)
        self.parent = rent

        self.name = "Wallpaper"
        self.section = "Appearance"
        self.searchData = ["wallpaper", "appearance", "look"]
        self.launchArg = "--wallpaper"
        self.button = None

        self.icon = Icon(self,
                         size_hint_weight=EXPAND_BOTH,
                         size_hint_align=FILL_BOTH)
        #Use FDO icons -> http://standards.freedesktop.org/icon-naming-spec/latest/ar01s04.html
        self.icon.standard_set('wallpaper')
        self.icon.show()

        self.foundWalls = []

        self.currentPreview = None
        self.selectedWall = None

        self.flip = Flip(self,
                         size_hint_weight=EXPAND_BOTH,
                         size_hint_align=FILL_BOTH)

        wallBox = Box(self.flip,
                      size_hint_weight=EXPAND_BOTH,
                      size_hint_align=FILL_BOTH)
        wallBox.horizontal_set(True)

        self.previewBox = previewBox = Scroller(wallBox,
                                                size_hint_weight=EXPAND_BOTH,
                                                size_hint_align=FILL_BOTH)
        previewBox.show()

        self.wallList = List(self,
                             size_hint_weight=(0.35, 1.0),
                             size_hint_align=FILL_BOTH,
                             mode=ELM_LIST_COMPRESS)
        #Adds walls in the WallPaths to the list for selection
        self.populateWalls()
        self.wallList.go()
        self.wallList.show()

        wallBox.pack_end(self.wallList)
        wallBox.pack_end(self.previewBox)
        wallBox.show()

        self.fs = fs = FileSelector(self,
                                    size_hint_weight=EXPAND_BOTH,
                                    size_hint_align=FILL_BOTH)
        fs.setMode("Open")
        fs.show()

        #need to do this to shutdown threading for the file selector
        self.parent.callback_delete_request_add(self.shutDownFS)

        fs.callback_activated_add(self.fileSelected)

        # Flip object has the file selector on one side
        #   and the GUI on the other
        self.flip.part_content_set("front", wallBox)
        self.flip.part_content_set("back", self.fs)
        self.flip.show()

        fs.callback_cancel_add(
            lambda o: self.flip.go(ELM_FLIP_ROTATE_YZ_CENTER_AXIS))

        #self.flip.go(ELM_FLIP_ROTATE_YZ_CENTER_AXIS)

        self.mainBox = Box(self,
                           size_hint_weight=EXPAND_BOTH,
                           size_hint_align=FILL_BOTH)
        self.mainBox.pack_end(self.flip)
        self.mainBox.show()

        buttonBox = Box(self,
                        size_hint_weight=EXPAND_HORIZ,
                        size_hint_align=FILL_BOTH)
        buttonBox.horizontal = True

        buttonApply = StandardButton(self, "Apply Selected", "ok",
                                     self.applyPressed)
        buttonApply.show()

        buttonImport = StandardButton(self, "Import Wallpaper", "wallpaper",
                                      self.importPressed)
        buttonImport.show()

        buttonReturn = StandardButton(self, "Back", "go-previous",
                                      self.returnPressed)
        buttonReturn.show()

        buttonBox.pack_end(buttonApply)
        #buttonBox.pack_end(buttonWeb)
        buttonBox.pack_end(buttonImport)
        buttonBox.pack_end(buttonReturn)
        buttonBox.show()

        self.pack_end(self.mainBox)
        self.pack_end(buttonBox)
예제 #15
0
    def __init__(self, rent):
        Box.__init__(self, rent)
        self.parent = rent
        
        self.name = "Theme Selector"
        self.section = "Appearance"
        self.searchData = ["theme", "gtk", "elementary", "elm", "gnome",
                    "appearance", "look"]
        self.launchArg = "--theme"
        self.button = None
        
        self.icon = Icon(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        self.icon.standard_set('preferences-desktop-theme')
        self.icon.show()
        
        self.foundThemes = []
        
        self.currentPreview = None
        self.selectedTheme = None
        
        self.previewBox = previewBox = Scroller(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        previewBox.show()
        
        self.themeList = List(self, size_hint_weight=(0.35, 1.0), 
                    size_hint_align=FILL_BOTH, mode=ELM_LIST_COMPRESS)
        #Adds themes in the ThemePaths to the list for selection
        self.populateThemes()
        self.themeList.go()
        self.themeList.show()
        
        themeBox = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        themeBox.horizontal_set(True)
        themeBox.pack_end(self.themeList)
        themeBox.pack_end(self.previewBox)
        themeBox.show()
        
        self.fs = fs = FileSelector(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        fs.setMode("Open")
        fs.show()

        #need to do this to shutdown threading for the file selector
        self.parent.callback_delete_request_add(self.shutDownFS)
        
        fs.callback_activated_add(self.fileSelected)
        
        # Flip object has the file selector on one side
        #   and the GUI on the other
        self.flip = Flip(self, size_hint_weight=EXPAND_BOTH,
                         size_hint_align=FILL_BOTH)
        self.flip.part_content_set("front", themeBox)
        self.flip.part_content_set("back", self.fs)
        self.flip.show()
        
        fs.callback_cancel_add(lambda o: self.flip.go(ELM_FLIP_ROTATE_YZ_CENTER_AXIS))
        
        #self.flip.go(ELM_FLIP_ROTATE_YZ_CENTER_AXIS)
        
        self.mainBox = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        self.mainBox.pack_end(self.flip)
        self.mainBox.show()
        
        buttonBox = Box(self, size_hint_weight = EXPAND_HORIZ, size_hint_align = FILL_BOTH)
        buttonBox.horizontal = True
        
        buttonApply = StandardButton(self, "Apply Selected", "ok", self.applyPressed)
        buttonApply.show()
        
        buttonWeb = StandardButton(self, "Get Themes", "applications-internet", self.webPressed)
        buttonWeb.show()
        
        #buttonGTK = StandardButton(self, "GTK Theme", "preferences-desktop-gnome", self.gtkPressed)
        #buttonGTK.show()
        
        #buttonElm = StandardButton(self, "Elementary Theme", "", self.elmPressed)
        #buttonElm.show()
        
        buttonImport = StandardButton(self, "Import Theme", "preferences-desktop-theme", self.importPressed)
        buttonImport.show()
        
        buttonReturn = StandardButton(self, "Back", "go-previous", self.returnPressed)
        buttonReturn.show()
        
        buttonBox.pack_end(buttonApply)
        buttonBox.pack_end(buttonWeb)
        #buttonBox.pack_end(buttonGTK)
        #buttonBox.pack_end(buttonElm)
        buttonBox.pack_end(buttonImport)
        buttonBox.pack_end(buttonReturn)
        buttonBox.show()
        
        self.pack_end(self.mainBox)
        self.pack_end(buttonBox)
예제 #16
0
    def __init__(self, parent, session):
        self.parent = parent
        self.session = session

        elm_conf = Configuration()
        scale = elm_conf.scale

        self.log = logging.getLogger("epour.gui")

        self.torrentitems = {}

        win = self.win = StandardWindow("epour", "Epour")
        win.callback_delete_request_add(lambda x: elm.exit())
        win.screen_constrain = True
        win.size = 480 * scale, 400 * scale

        mbox = Box(win)
        mbox.size_hint_weight = 1.0, 1.0
        win.resize_object_add(mbox)
        mbox.show()

        tb = Toolbar(win)
        tb.homogeneous = False
        tb.shrink_mode = ELM_TOOLBAR_SHRINK_NONE
        tb.select_mode = ELM_OBJECT_SELECT_MODE_NONE
        tb.size_hint_align = -1.0, 0.0
        tb.menu_parent = win

        item = tb.item_append("document-new", "Add torrent",
                              lambda t, i: self.select_torrent())

        def pause_session(it):
            self.session.pause()
            it.state_set(it.state_next())

        def resume_session(it):
            session.resume()
            del it.state

        item = tb.item_append("media-playback-pause", "Pause Session",
                              lambda tb, it: pause_session(it))
        item.state_add("media-playback-start", "Resume Session",
                       lambda tb, it: resume_session(it))

        item = tb.item_append("preferences-system", "Preferences")
        item.menu = True
        item.menu.item_add(None, "General", "preferences-system",
                           lambda o, i: PreferencesGeneral(self, self.session))
        item.menu.item_add(None, "Proxy", "preferences-system",
                           lambda o, i: PreferencesProxy(self, self.session))
        item.menu.item_add(None, "Session", "preferences-system",
                           lambda o, i: PreferencesSession(self, self.session))

        item = tb.item_append("application-exit", "Exit",
                              lambda tb, it: elm.exit())

        mbox.pack_start(tb)
        tb.show()

        self.tlist = tlist = Genlist(win)
        tlist.select_mode = ELM_OBJECT_SELECT_MODE_NONE
        tlist.mode = ELM_LIST_COMPRESS
        tlist.callback_activated_add(self.item_activated_cb)
        tlist.homogeneous = True
        tlist.size_hint_weight = 1.0, 1.0
        tlist.size_hint_align = -1.0, -1.0
        tlist.show()

        mbox.pack_end(tlist)

        pad = Rectangle(win.evas)
        pad.size_hint_weight = 1.0, 1.0

        p = Panel(win)
        p.color = 200, 200, 200, 200
        p.size_hint_weight = 1.0, 1.0
        p.size_hint_align = -1.0, -1.0
        p.orient = ELM_PANEL_ORIENT_BOTTOM
        p.content = SessionStatus(win, session)
        p.hidden = True
        p.show()

        topbox = Box(win)
        topbox.horizontal = True
        topbox.size_hint_weight = 1.0, 1.0
        win.resize_object_add(topbox)

        topbox.pack_end(pad)
        topbox.pack_end(p)
        topbox.stack_above(mbox)
        topbox.show()

        session.alert_manager.callback_add("torrent_added_alert",
                                           self.torrent_added_cb)
        session.alert_manager.callback_add("torrent_removed_alert",
                                           self.torrent_removed_cb)

        for a_name in "torrent_paused_alert", "torrent_resumed_alert":
            session.alert_manager.callback_add(a_name, self.update_icon)

        session.alert_manager.callback_add("state_changed_alert",
                                           self.state_changed_cb)

        Timer(
            15.0, lambda: session.alert_manager.callback_add(
                "torrent_finished_alert", self.torrent_finished_cb))
예제 #17
0
    def __init__(self, rent):
        Box.__init__(self, rent)
        self.parent = rent
        
        self.name = "Wallpaper"
        self.section = "Appearance"
        self.searchData = ["wallpaper", "appearance", "look"]
        self.launchArg = "--wallpaper"
        self.button = None
        
        self.icon = Icon(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        #Use FDO icons -> http://standards.freedesktop.org/icon-naming-spec/latest/ar01s04.html
        self.icon.standard_set('wallpaper')
        self.icon.show()
        
        self.foundWalls = []
        
        self.currentPreview = None
        self.selectedWall = None
        
        self.flip = Flip(self, size_hint_weight=EXPAND_BOTH,
                         size_hint_align=FILL_BOTH)
        
        wallBox = Box(self.flip, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        wallBox.horizontal_set(True)
        
        self.previewBox = previewBox = Scroller(wallBox, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        previewBox.show()
        
        self.wallList = List(self, size_hint_weight=(0.35, 1.0), 
                    size_hint_align=FILL_BOTH, mode=ELM_LIST_COMPRESS)
        #Adds walls in the WallPaths to the list for selection
        self.populateWalls()
        self.wallList.go()
        self.wallList.show()
        
        wallBox.pack_end(self.wallList)
        wallBox.pack_end(self.previewBox)
        wallBox.show()
        
        self.fs = fs = FileSelector(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        fs.setMode("Open")
        fs.show()

        #need to do this to shutdown threading for the file selector
        self.parent.callback_delete_request_add(self.shutDownFS)
        
        fs.callback_activated_add(self.fileSelected)
        
        # Flip object has the file selector on one side
        #   and the GUI on the other
        self.flip.part_content_set("front", wallBox)
        self.flip.part_content_set("back", self.fs)
        self.flip.show()
        
        fs.callback_cancel_add(lambda o: self.flip.go(ELM_FLIP_ROTATE_YZ_CENTER_AXIS))
        
        #self.flip.go(ELM_FLIP_ROTATE_YZ_CENTER_AXIS)
        
        self.mainBox = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        self.mainBox.pack_end(self.flip)
        self.mainBox.show()
        
        buttonBox = Box(self, size_hint_weight = EXPAND_HORIZ, size_hint_align = FILL_BOTH)
        buttonBox.horizontal = True
        
        buttonApply = StandardButton(self, "Apply Selected", "ok", self.applyPressed)
        buttonApply.show()
        
        buttonImport = StandardButton(self, "Import Wallpaper", "wallpaper", self.importPressed)
        buttonImport.show()
        
        buttonReturn = StandardButton(self, "Back", "go-previous", self.returnPressed)
        buttonReturn.show()
        
        buttonBox.pack_end(buttonApply)
        #buttonBox.pack_end(buttonWeb)
        buttonBox.pack_end(buttonImport)
        buttonBox.pack_end(buttonReturn)
        buttonBox.show()
        
        self.pack_end(self.mainBox)
        self.pack_end(buttonBox)
예제 #18
0
    def __init__(self, rent):
        Box.__init__(self, rent)
        self.parent = rent

        #This appears on the button in the main swmai window
        self.name = "Light DM"
        #The section in the main window the button is added to
        self.section = "System Settings"
        #Search terms that this module should appear for
        self.searchData = ["lightdm", "autologin", "login", "display"]
        #Command line argument to open this module directly
        self.launchArg = "--lightdm"
        #Should be none by default. This value is used internally by swami
        self.button = None

        self.icon = Icon(self,
                         size_hint_weight=EXPAND_BOTH,
                         size_hint_align=FILL_BOTH)
        #Use FDO icons -> http://standards.freedesktop.org/icon-naming-spec/latest/ar01s04.html
        self.icon.standard_set('video-display')
        self.icon.show()

        self.mainBox = Box(self,
                           size_hint_weight=EXPAND_BOTH,
                           size_hint_align=FILL_BOTH)
        self.mainBox.show()

        self.config = {"sections": []}

        with open(LightDMConf) as f:
            currentSection = None
            for line in f:
                #Sections start with [ - such as [SeatDefaults]
                if line[0] == "[":
                    self.config["sections"].append(line)
                    currentSection = line.rstrip()
                    s = Frame(self,
                              size_hint_weight=EXPAND_HORIZ,
                              size_hint_align=FILL_HORIZ)
                    s.text = currentSection[1:-1]
                    s.show()

                    sectionBox = Box(self,
                                     size_hint_weight=EXPAND_BOTH,
                                     size_hint_align=FILL_BOTH)
                    sectionBox.show()

                    s.content = sectionBox

                    self.mainBox.pack_end(s)
                elif line[0] not in ["[", "\n"]:
                    setting, value = line.replace("\n", "").split("=")

                    e = Entry(self)
                    e.single_line_set(True)
                    e.text = value
                    e.show()

                    f = Frame(self,
                              size_hint_weight=EXPAND_HORIZ,
                              size_hint_align=FILL_HORIZ)
                    f.text = setting
                    f.content = e
                    f.show()

                    sectionBox.pack_end(f)

                    self.config[setting] = [f, currentSection]

        buttonBox = Box(self,
                        size_hint_weight=EXPAND_HORIZ,
                        size_hint_align=FILL_BOTH)
        buttonBox.horizontal = True

        buttonSave = StandardButton(self, "Save Changes", "ok",
                                    self.savePressed)
        buttonSave.show()

        buttonReturn = StandardButton(self, "Back", "go-previous",
                                      self.returnPressed)
        buttonReturn.show()

        buttonBox.pack_end(buttonSave)
        buttonBox.pack_end(buttonReturn)
        buttonBox.show()

        self.pack_end(self.mainBox)
        self.pack_end(buttonBox)
예제 #19
0
    def __init__(self, rent):
        Box.__init__(self, rent)
        self.parent = rent

        self.name = "Theme Selector"
        self.section = "Appearance"
        self.searchData = [
            "theme", "gtk", "elementary", "elm", "gnome", "appearance", "look"
        ]
        self.launchArg = "--theme"
        self.button = None

        self.icon = Icon(self,
                         size_hint_weight=EXPAND_BOTH,
                         size_hint_align=FILL_BOTH)
        self.icon.standard_set('preferences-desktop-theme')
        self.icon.show()

        self.foundThemes = []

        self.currentPreview = None
        self.selectedTheme = None

        self.previewBox = previewBox = Scroller(self,
                                                size_hint_weight=EXPAND_BOTH,
                                                size_hint_align=FILL_BOTH)
        previewBox.show()

        self.themeList = List(self,
                              size_hint_weight=(0.35, 1.0),
                              size_hint_align=FILL_BOTH,
                              mode=ELM_LIST_COMPRESS)
        #Adds themes in the ThemePaths to the list for selection
        self.populateThemes()
        self.themeList.go()
        self.themeList.show()

        themeBox = Box(self,
                       size_hint_weight=EXPAND_BOTH,
                       size_hint_align=FILL_BOTH)
        themeBox.horizontal_set(True)
        themeBox.pack_end(self.themeList)
        themeBox.pack_end(self.previewBox)
        themeBox.show()

        self.fs = fs = FileSelector(self,
                                    size_hint_weight=EXPAND_BOTH,
                                    size_hint_align=FILL_BOTH)
        fs.setMode("Open")
        fs.show()

        #need to do this to shutdown threading for the file selector
        self.parent.callback_delete_request_add(self.shutDownFS)

        fs.callback_activated_add(self.fileSelected)

        # Flip object has the file selector on one side
        #   and the GUI on the other
        self.flip = Flip(self,
                         size_hint_weight=EXPAND_BOTH,
                         size_hint_align=FILL_BOTH)
        self.flip.part_content_set("front", themeBox)
        self.flip.part_content_set("back", self.fs)
        self.flip.show()

        fs.callback_cancel_add(
            lambda o: self.flip.go(ELM_FLIP_ROTATE_YZ_CENTER_AXIS))

        #self.flip.go(ELM_FLIP_ROTATE_YZ_CENTER_AXIS)

        self.mainBox = Box(self,
                           size_hint_weight=EXPAND_BOTH,
                           size_hint_align=FILL_BOTH)
        self.mainBox.pack_end(self.flip)
        self.mainBox.show()

        buttonBox = Box(self,
                        size_hint_weight=EXPAND_HORIZ,
                        size_hint_align=FILL_BOTH)
        buttonBox.horizontal = True

        buttonApply = StandardButton(self, "Apply Selected", "ok",
                                     self.applyPressed)
        buttonApply.show()

        buttonWeb = StandardButton(self, "Get Themes", "applications-internet",
                                   self.webPressed)
        buttonWeb.show()

        #buttonGTK = StandardButton(self, "GTK Theme", "preferences-desktop-gnome", self.gtkPressed)
        #buttonGTK.show()

        #buttonElm = StandardButton(self, "Elementary Theme", "", self.elmPressed)
        #buttonElm.show()

        buttonImport = StandardButton(self, "Import Theme",
                                      "preferences-desktop-theme",
                                      self.importPressed)
        buttonImport.show()

        buttonReturn = StandardButton(self, "Back", "go-previous",
                                      self.returnPressed)
        buttonReturn.show()

        buttonBox.pack_end(buttonApply)
        buttonBox.pack_end(buttonWeb)
        #buttonBox.pack_end(buttonGTK)
        #buttonBox.pack_end(buttonElm)
        buttonBox.pack_end(buttonImport)
        buttonBox.pack_end(buttonReturn)
        buttonBox.show()

        self.pack_end(self.mainBox)
        self.pack_end(buttonBox)
    def __init__(self, parent, h):
        if not h.is_valid():
            Information(parent.win, "Invalid torrent handle.")
            return

        if not h.has_metadata():
            Information(parent.win, "Torrent contains no metadata.")
            return

        i = h.get_torrent_info()

        InnerWindow.__init__(self, parent.win)

        box = Box(self)
        box.size_hint_align = -1.0, -1.0
        box.size_hint_weight = 1.0, 1.0

        tname = Label(self)
        tname.size_hint_align = -1.0, 0.5
        tname.line_wrap = ELM_WRAP_CHAR
        tname.ellipsis = True
        tname.text = "{}".format(cgi.escape(i.name()))
        tname.show()
        box.pack_end(tname)

        for func in i.comment, i.creation_date, i.creator:
            try:
                w = func()
            except Exception as e:
                log.debug(e)
            else:
                if w:
                    f = Frame(self)
                    f.size_hint_align = -1.0, 0.0
                    f.text = func.__name__.replace("_", " ").capitalize()
                    l = Label(self)
                    l.ellipsis = True
                    l.text = cgi.escape(str(w))
                    l.show()
                    f.content = l
                    f.show()
                    box.pack_end(f)

        tpriv = Check(self)
        tpriv.size_hint_align = 0.0, 0.0
        tpriv.text = "Private"
        tpriv.tooltip_text_set("Whether this torrent is private.<br> \
            i.e., it should not be distributed on the trackerless network<br> \
            (the kademlia DHT).")
        tpriv.disabled = True
        tpriv.state = i.priv()

        magnet_uri = lt.make_magnet_uri(h)

        f = Frame(self)
        f.size_hint_align = -1.0, 0.0
        f.text = "Magnet URI"
        me_box = Box(self)
        me_box.horizontal = True
        me = Entry(self)
        me.size_hint_align = -1.0, 0.0
        me.size_hint_weight = 1.0, 0.0
        #me.editable = False
        me.entry = magnet_uri
        me_box.pack_end(me)
        me.show()
        me_btn = Button(self)
        me_btn.text = "Copy"
        if hasattr(me, "cnp_selection_set"):
            me_btn.callback_clicked_add(
                lambda x: me.top_widget.cnp_selection_set(
                    ELM_SEL_TYPE_CLIPBOARD, ELM_SEL_FORMAT_TEXT, me.text))
        else:
            import pyperclip
            me_btn.callback_clicked_add(lambda x: pyperclip.copy(magnet_uri))
        me_btn.show()
        me_box.pack_end(me_btn)
        me_box.show()
        f.content = me_box
        f.show()
        box.pack_end(f)

        fl_btn = Button(self)
        fl_btn.text = "Files ->"
        fl_btn.callback_clicked_add(self.file_list_cb, h)

        xbtn = Button(self)
        xbtn.text_set("Close")
        xbtn.callback_clicked_add(lambda x: self.delete())

        for w in tpriv, fl_btn, xbtn:
            w.show()
            box.pack_end(w)

        box.show()

        nf = self.nf = Naviframe(self)
        nf.item_simple_push(box)

        self.content_set(nf)
        self.activate()
예제 #21
0
    def __init__(self, parent, session):
        self.parent = parent
        self.session = session

        elm_conf = Configuration()
        scale = elm_conf.scale

        self.log = logging.getLogger("epour.gui")

        self.torrentitems = {}

        win = self.win = StandardWindow("epour", "Epour")
        win.callback_delete_request_add(lambda x: elm.exit())
        win.screen_constrain = True
        win.size = 480 * scale, 400 * scale

        mbox = Box(win)
        mbox.size_hint_weight = 1.0, 1.0
        win.resize_object_add(mbox)
        mbox.show()

        tb = Toolbar(win)
        tb.homogeneous = False
        tb.shrink_mode = ELM_TOOLBAR_SHRINK_NONE
        tb.select_mode = ELM_OBJECT_SELECT_MODE_NONE
        tb.size_hint_align = -1.0, 0.0
        tb.menu_parent = win

        item = tb.item_append("document-new", "Add torrent",
                              lambda t,i: self.select_torrent())

        def pause_session(it):
            self.session.pause()
            it.state_set(it.state_next())
        def resume_session(it):
            session.resume()
            del it.state
        item = tb.item_append("media-playback-pause", "Pause Session",
                              lambda tb, it: pause_session(it))
        item.state_add("media-playback-start", "Resume Session",
                              lambda tb, it: resume_session(it))

        item = tb.item_append("preferences-system", "Preferences")
        item.menu = True
        item.menu.item_add(None, "General", "preferences-system",
                           lambda o,i: PreferencesGeneral(self, self.session))
        item.menu.item_add(None, "Proxy", "preferences-system",
                           lambda o,i: PreferencesProxy(self, self.session))
        item.menu.item_add(None, "Session", "preferences-system",
                           lambda o,i: PreferencesSession(self, self.session))

        item = tb.item_append("application-exit", "Exit",
                              lambda tb, it: elm.exit())

        mbox.pack_start(tb)
        tb.show()

        self.tlist = tlist = Genlist(win)
        tlist.select_mode = ELM_OBJECT_SELECT_MODE_NONE
        tlist.mode = ELM_LIST_COMPRESS
        tlist.callback_activated_add(self.item_activated_cb)
        tlist.homogeneous = True
        tlist.size_hint_weight = 1.0, 1.0
        tlist.size_hint_align = -1.0, -1.0
        tlist.show()

        mbox.pack_end(tlist)

        pad = Rectangle(win.evas)
        pad.size_hint_weight = 1.0, 1.0

        p = Panel(win)
        p.color = 200,200,200,200
        p.size_hint_weight = 1.0, 1.0
        p.size_hint_align = -1.0, -1.0
        p.orient = ELM_PANEL_ORIENT_BOTTOM
        p.content = SessionStatus(win, session)
        p.hidden = True
        p.show()

        topbox = Box(win)
        topbox.horizontal = True
        topbox.size_hint_weight = 1.0, 1.0
        win.resize_object_add(topbox)

        topbox.pack_end(pad)
        topbox.pack_end(p)
        topbox.stack_above(mbox)
        topbox.show()

        session.alert_manager.callback_add(
            "torrent_added_alert", self.torrent_added_cb)
        session.alert_manager.callback_add(
            "torrent_removed_alert", self.torrent_removed_cb)

        for a_name in "torrent_paused_alert", "torrent_resumed_alert":
            session.alert_manager.callback_add(a_name, self.update_icon)

        session.alert_manager.callback_add(
            "state_changed_alert", self.state_changed_cb)

        Timer(15.0, lambda: session.alert_manager.callback_add(
            "torrent_finished_alert", self.torrent_finished_cb))
예제 #22
0
    def __init__(self,
                 command=None,
                 win=None,
                 start_callback=None,
                 end_callback=None,
                 *args,
                 **kwargs):
        if not win:
            nowindow = True
            win = self.win = Window("esudo", ELM_WIN_DIALOG_BASIC)
            win.title = "eSudo"
            win.borderless = True
            win.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND
            win.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
            win.resize(300, 200)
            win.callback_delete_request_add(lambda o: elementary.exit())
            win.layer_set(11)
            #~ win.fullscreen = True
            win.show()
            win.activate()

            bg = Background(win)
            bg.size_hint_weight = 1.0, 1.0
            win.resize_object_add(bg)
            bg.show()

            self.embedded = False
        else:
            nowindow = False
            self.embedded = True

        self.cmd = command
        self.start_cb = start_callback if callable(start_callback) else None
        self.end_cb = end_callback if callable(end_callback) else None
        self.args = args
        self.kwargs = kwargs

        #--------eSudo Window
        bz = Box(win)
        if nowindow:
            bz.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0
        else:
            bz.size_hint_weight = evas.EVAS_HINT_EXPAND, evas.EVAS_HINT_EXPAND
        bz.size_hint_align = evas.EVAS_HINT_FILL, 0.0
        bz.show()

        if nowindow:
            lbl = Label(win)
            lbl.style = "marker"
            lbl.color = 170, 170, 170, 255
            lbl.size_hint_align = 0.5, 0.0
            lbl.scale = 2.0
            lbl.text = "<b>eSudo</b>"
            bz.pack_end(lbl)
            lbl.show()

            sep = Separator(win)
            sep.horizontal = True
            bz.pack_end(sep)
            sep.show()

        fr = Frame(win)
        fr.text = "Command:"
        fr.size_hint_align = evas.EVAS_HINT_FILL, 0.0
        bz.pack_end(fr)
        fr.show()

        if nowindow:
            sep = Separator(win)
            sep.horizontal = True
            bz.pack_end(sep)
            sep.show()

        self.cmdline = cmdline = Entry(win)
        cmdline.elm_event_callback_add(self.entry_event)
        cmdline.single_line = True
        if self.cmd:
            cmdline.text = self.cmd
            cmdline.editable = False
        fr.content = cmdline
        cmdline.scrollable_set(True)
        cmdline.show()

        if nowindow:
            fr = Frame(win)
            fr.text = "Password:"******"<b>Password:</b>"
            lb.size_hint_align = 0.0, 0.5
            bz1.pack_end(lb)
            lb.show()

        en = self.en = Entry(win)
        en.name = "password"
        en.elm_event_callback_add(self.entry_event)
        en.single_line = True
        en.password = True
        en.show()

        if nowindow:
            fr.content = en
        else:
            bz1.pack_end(en)

        sep = Separator(win)
        sep.horizontal = True
        bz.pack_end(sep)
        sep.show()

        btnb = Box(win)
        btnb.horizontal = True
        btnb.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0
        btnb.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
        bz.pack_end(btnb)
        btnb.show()

        bt = Button(win)
        bt.text = "Cancel"
        bt.callback_clicked_add(self.esudo_cancel, en)
        bt.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
        bt.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0
        btnb.pack_end(bt)
        bt.show()

        bt = Button(win)
        bt.text = "OK"
        bt.callback_clicked_add(self.password_check, en)
        bt.size_hint_align = evas.EVAS_HINT_FILL, evas.EVAS_HINT_FILL
        bt.size_hint_weight = evas.EVAS_HINT_EXPAND, 0.0
        btnb.pack_end(bt)
        bt.show()

        self.iw = iw = InnerWindow(win)
        iw.content = bz
        iw.show()
        iw.activate()
        if self.cmd:
            en.focus = True
예제 #23
0
    def __init__(self, rent):
        Box.__init__(self, rent)
        self.parent = rent
        
        self.name = "Date and Time"
        self.section = "System Settings"
        self.searchData = ["clock", "timezone", "date", "system"]
        self.launchArg = "--time"
        self.button = None
        
        self.timezones = getTimeZones()
        
        self.icon = Icon(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        #Use FDO icons -> http://standards.freedesktop.org/icon-naming-spec/latest/ar01s04.html
        self.icon.standard_set('clock')
        self.icon.show()
        
        cframe = Frame(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        cframe.text = "Current Time"
        cframe.show()

        self.clock = clock = Clock(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        clock.show_seconds_set(True)
        clock.show_am_pm_set(True)
        clock.show()
        
        cframe.content = clock
        
        dframe = Frame(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        dframe.text = "Current Day"
        dframe.show()

        self.cal = cal = Calendar(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        cal.select_mode = ELM_CALENDAR_SELECT_MODE_NONE
        cal.show()
        
        dframe.content = cal
        
        tzframe = Frame(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        tzframe.text = "Current Timezone"
        tzframe.show()

        self.tz = tz = Label(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        tz.text = "<b>%s</b>"%time.tzname[0]
        tz.show()
        
        tzframe.content = tz
        
        self.mainBox = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        self.mainBox.pack_end(cframe)
        self.mainBox.pack_end(dframe)
        self.mainBox.pack_end(tzframe)
        self.mainBox.show()
        
        self.zoneList = zoneList = SearchableList(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        zoneList.callback_item_focused_add(self.enableTZSelect)
        self.zones = []
        for tz in self.timezones:
            for each in self.timezones[tz]:
                if each not in self.zones:
                    self.zones.append(each)
        self.zones.sort(reverse=True)
        for zone in self.zones:
            zoneList.item_append(zone)
        zoneList.show()
        
        self.buttonTZSelect = buttonTZSelect = StandardButton(self, "Select", "ok", self.tzselectPressed)
        buttonTZSelect.disabled = True
        buttonTZSelect.show()
        
        buttonTZCancel = StandardButton(self, "Cancel", "close", self.tzcancelPressed)
        buttonTZCancel.show()
        
        tzBBox = Box(self, size_hint_weight = EXPAND_HORIZ, size_hint_align = FILL_BOTH)
        tzBBox.horizontal = True
        tzBBox.pack_end(buttonTZSelect)
        tzBBox.pack_end(buttonTZCancel)
        tzBBox.show()

        tzChangeBox = Box(self, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        tzChangeBox.pack_end(zoneList)
        tzChangeBox.pack_end(tzBBox)
        tzChangeBox.show()
        
        self.flip = Flip(self, size_hint_weight=EXPAND_BOTH,
                         size_hint_align=FILL_BOTH)
        self.flip.part_content_set("front", self.mainBox)
        self.flip.part_content_set("back", tzChangeBox)
        self.flip.show()
        
        buttonBox = Box(self, size_hint_weight = EXPAND_HORIZ, size_hint_align = FILL_BOTH)
        buttonBox.horizontal = True
        
        self.buttonApply = buttonApply = StandardButton(self, "Apply Changes", "ok", self.applyPressed)
        buttonApply.disabled = True
        buttonApply.show()
        
        self.buttonSync = buttonSync = StandardButton(self, "Sync from Internet", "refresh", self.syncPressed)
        buttonSync.show()
        
        self.buttonDT = buttonDT = StandardButton(self, "Edit Date and Time", "x-office-calendar", self.editDTPressed)
        buttonDT.show()
        
        self.buttonTZ = buttonTZ = StandardButton(self, "Change Timezone", "clock", self.editTZPressed)
        buttonTZ.show()
        
        buttonReturn = StandardButton(self, "Back", "go-previous", self.returnPressed)
        buttonReturn.show()
        
        buttonBox.pack_end(buttonApply)
        buttonBox.pack_end(buttonSync)
        buttonBox.pack_end(buttonDT)
        buttonBox.pack_end(buttonTZ)
        buttonBox.pack_end(buttonReturn)
        buttonBox.show()
        
        self.pack_end(self.flip)
        self.pack_end(buttonBox)