def __init__(self):
        win = StandardWindow("Testing", "Elementary SearchableList")
        win.callback_delete_request_add(lambda o: elm.exit())
        win.show()

        ourList = SearchableList(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        self.keys = ["Jeff", "Kristi", "Jacob", "Declan", "Joris", "Timmy", "Tristam"]
        for kbl in self.keys:
            ourList.item_append(kbl)
        ourList.show()

        win.resize_object_add(ourList)

        win.resize(600, 400)
        win.show()
Exemplo n.º 2
0
    def __init__(self):
        StandardWindow.__init__(self, "ex10", "Searchable List", size=(300, 200))
        self.callback_delete_request_add(lambda o: elm.exit())

        searchList = SearchableList(self)
        searchList.size_hint_weight = EXPAND_BOTH
        searchList.ourList.callback_activated_add(self.listItemSelected)
        
        ListItems.sort()
        
        for it in ListItems:
            searchList.item_append(it)
        
        searchList.show()
        
        self.resize_object_add(searchList)
Exemplo n.º 3
0
    def __init__( self ):
        win = StandardWindow("Testing", "Elementary SearchableList")
        win.callback_delete_request_add(lambda o: elm.exit())
        
        ourList = SearchableList(win, size_hint_weight=EXPAND_BOTH, size_hint_align=FILL_BOTH)
        self.keys = ["Jeff", "Kristi", "Jacob", "Declan", "Joris", 
                "Timmy", "Tristam"]
        for kbl in self.keys:
            ourList.item_append(kbl)
        ourList.show()
        
        win.resize_object_add(ourList)

        win.resize(600, 400)
        win.show()
Exemplo n.º 4
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)
Exemplo n.º 5
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)