예제 #1
0
			""" This works in all threads except the main thread. It will quit the whole app.
			For more information about why we do it this way, read the comment in main.py.
			"""
			import sys, os, signal
			os.kill(0, signal.SIGINT)
			sys.stdin.close() # so that the terminal closes, if it is used
		import thread
		thread.start_new_thread(doQuit, ())

# Only init new state if it is new, not at module reload.
try:
	state
except NameError:
	state = State()

gui.registerRootObj(obj=state, name="Main", title=appinfo.progname, priority=0, keyShortcut='1')


class About(object):
	@UserAttrib(type=Traits.OneLineText)
	@property
	def appname(self):
		import appinfo
		return appinfo.progname

	@UserAttrib(type=Traits.OneLineText)
	@property
	def developer(self):
		return "by Albert Zeyer"

	@UserAttrib(type=Traits.Action, name="Homepage")
예제 #2
0
                if self._searchText == txt:
                    self._searchResults = res
                    self.__class__.searchResults.updateEvent(self).push()

        with self._lock:
            self._searchText = txt
            TaskSystem.daemonThreadCall(search, name="Song DB search")

    @UserAttrib(type=Traits.EditableText, searchLook=True)
    def searchText(self, updateText=None):
        with self._lock:
            if updateText is not None and self._searchText != updateText:
                self._startSearch(updateText)
        return self._searchText

    @UserAttrib(type=Traits.Table(
        keys=Keys,
        format_duration=lambda d: formatTime(d) if d > 0 else "",
        format_rating=lambda r: "★" * int(round(r * 5))),
                variableHeight=True,
                addUpdateEvent=True)
    @property
    def searchResults(self):
        with self._lock:
            return list(self._searchResults)


search = Search()

gui.registerRootObj(obj=search, name="Search", priority=-1, keyShortcut='2')
예제 #3
0
	def lastFm_update(self, attrib):
		from appinfo import config
		if config.lastFm:
			attrib.name = "Last.fm is enabled. Disable it."
		else:
			attrib.name = "Last.fm is disabled. Enable it."

	@UserAttrib(type=Traits.Action, updateHandler=lastFm_update, variableWidth=False, addUpdateEvent=True)
	def lastFm(self):
		self.__class__.lastFm.updateEvent(self).push()

		from appinfo import config
		config.lastFm = not config.lastFm
		config.save()

		from State import getModule
		getModule("tracker_lastfm").reload()

	@UserAttrib(type=Traits.Action, alignRight=True, name="reset Last.fm login", variableWidth=False)
	def resetLastFm(self):
		import lastfm, os, sys
		try:
			os.remove(lastfm.StoredSession.TOKEN_FILE)
		except Exception:
			sys.excepthook(*sys.exc_info())

prefs = Preferences()

import gui
gui.registerRootObj(obj=prefs, name="Preferences", priority=-5)
예제 #4
0
                updateHandler=lastFm_update,
                variableWidth=False,
                addUpdateEvent=True)
    def lastFm(self):
        self.__class__.lastFm.updateEvent(self).push()

        from appinfo import config
        config.lastFm = not config.lastFm
        config.save()

        from State import getModule
        getModule("tracker_lastfm").reload()

    @UserAttrib(type=Traits.Action,
                alignRight=True,
                name="reset Last.fm login",
                variableWidth=False)
    def resetLastFm(self):
        import lastfm, os, sys
        try:
            os.remove(lastfm.StoredSession.TOKEN_FILE)
        except Exception:
            sys.excepthook(*sys.exc_info())


prefs = Preferences()

import gui

gui.registerRootObj(obj=prefs, name="Preferences", priority=-5)
예제 #5
0
				if self._searchText != txt: return
			res = songdb.search(txt)
			with self._lock:
				if self._searchText == txt:
					self._searchResults = res
					self.__class__.searchResults.updateEvent(self).push()
		with self._lock:
			self._searchText = txt
			utils.daemonThreadCall(search, name="Song DB search")

	@UserAttrib(type=Traits.EditableText, searchLook=True)
	def searchText(self, updateText=None):
		with self._lock:
			if updateText is not None and self._searchText != updateText:
				self._startSearch(updateText)
		return self._searchText
	
	@UserAttrib(type=Traits.Table(keys=Keys,
		format_duration=lambda d: formatTime(d) if d > 0 else "",
		format_rating=lambda r: "★" * int(round(r * 5))),
		variableHeight=True,
		addUpdateEvent=True)
	@property
	def searchResults(self):
		with self._lock:
			return list(self._searchResults)

search = Search()

gui.registerRootObj(obj=search, name="Search", priority=-1, keyShortcut='2')