def restore(self): text = config.get("browsers", "query_text").decode("utf-8") entry = self.__search entry.set_text(text) # update_filter expects a parsable query if Query.is_parsable(text): self.__update_filter(entry, text, scroll_up=False, restore=True) keys = config.get("browsers", "albums").split("\n") # FIXME: If albums is "" then it could be either all albums or # no albums. If it's "" and some other stuff, assume no albums, # otherwise all albums. self.__inhibit() if keys == [""]: self.view.set_cursor((0,)) else: def select_fun(row): album = row[0] if not album: # all return False return album.str_key in keys self.view.select_by_func(select_fun) self.__uninhibit()
def __filter_changed(self, *args): self.__remove_timeout() text = self.__entry.get_text().decode('utf-8') if Query.is_parsable(text): self.__refill_id = gobject.idle_add( self.emit, 'query-changed', text)
def filter_text(self, text): self.__search.set_text(text) if Query.is_parsable(text): self.__update_filter(self.__search, text) self.__inhibit() self.view.set_cursor((0,)) self.__uninhibit() self.activate()
def filter_text(self, text): self.__search.set_text(text) if Query.is_parsable(text): self.__update_filter(self.__search, text) self.__inhibit() self.view.set_cursor((0,)) self.__uninhibit() self.activate()
def activate(self): if self._text is not None and Query.is_parsable(self._text): star = dict.fromkeys(SongList.star) star.update(self.__star) self._filter = Query(self._text, star.keys()).search songs = filter(self._filter, self._library) bg = background_filter() if bg: songs = filter(bg, songs) self.__panes[0].fill(songs)
def activate(self): text = self._get_text() if Query.is_parsable(text): star = dict.fromkeys(SongList.star) star.update(self.__star) self._filter = Query(text, star.keys()).search songs = filter(self._filter, self._library) bg = background_filter() if bg: songs = filter(bg, songs) self._panes[0].fill(songs)
def __save_search(self, entry, *args): # only save the query on focus-out if eager_search is turned on if args and not config.getboolean('settings', 'eager_search'): return text = entry.get_text().decode('utf-8').strip() if text and Query.is_parsable(text): # Adding the active text to the model triggers a changed signal # (get_active is no longer -1), so inhibit self.__inhibit() self.__combo.prepend_text(text) self.__combo.write() self.__uninhibit()
def __save_search(self, entry, *args): # only save the query on focus-out if eager_search is turned on if args and not config.getboolean('settings', 'eager_search'): return text = entry.get_text().decode('utf-8').strip() if text and Query.is_parsable(text): # Adding the active text to the model triggers a changed signal # (get_active is no longer -1), so inhibit self.__inhibit() self.__combo.prepend_text(text) self.__combo.write() self.__uninhibit()
def restore(self): text = config.get("browsers", "query_text").decode("utf-8") self.__searchbar.set_text(text) if Query.is_parsable(text): self.__filter_changed(self.__searchbar, text, restore=True) keys = config.get("browsers", "radio").splitlines() def select_func(row): return row[self.TYPE] != self.TYPE_SEP and row[self.KEY] in keys self.__inhibit() view = self.view if not view.select_by_func(select_func): for row in view.get_model(): if row[self.TYPE] == self.TYPE_FAV: view.set_cursor(row.path) break self.__uninhibit()
def __text_changed(self, *args): # the combobox has an active entry selected -> no timeout # todo: we need a timeout when the selection changed because # of keyboard input (up/down arrows) if self.__combo.get_active() != -1: self.__filter_changed() return if not config.getboolean('settings', 'eager_search'): return # remove the timeout self.__remove_timeout() # parse and new timeout text = self.__entry.get_text().decode('utf-8') if Query.is_parsable(text): self.__refill_id = GLib.timeout_add(self.timeout, self.__filter_changed)
def __text_changed(self, *args): # the combobox has an active entry selected -> no timeout # todo: we need a timeout when the selection changed because # of keyboard input (up/down arrows) if self.__combo.get_active() != -1: self.__filter_changed() return if not config.getboolean('settings', 'eager_search'): return # remove the timeout self.__remove_timeout() # parse and new timeout text = self.__entry.get_text().decode('utf-8') if Query.is_parsable(text): self.__refill_id = gobject.timeout_add( self.timeout, self.__filter_changed)
def restore(self): text = config.get("browsers", "query_text").decode("utf-8") self.__searchbar.set_text(text) if Query.is_parsable(text): self.__filter_changed(self.__searchbar, text, restore=True) keys = config.get("browsers", "radio").splitlines() def select_func(row): return row[self.TYPE] != self.TYPE_SEP and row[self.KEY] in keys self.__inhibit() view = self.view if not view.select_by_func(select_func): for row in view.get_model(): if row[self.TYPE] == self.TYPE_FAV: view.set_cursor(row.path) break self.__uninhibit()
def restore(self): text = config.get("browsers", "query_text").decode("utf-8") entry = self.__search entry.set_text(text) # update_filter expects a parsable query if Query.is_parsable(text): self.__update_filter(entry, text, scroll_up=False, restore=True) albums = config.get("browsers", "albums").split("\n") # FIXME: If albums is "" then it could be either all albums or # no albums. If it's "" and some other stuff, assume no albums, # otherwise all albums. self.__inhibit() if albums == [""]: self.view.set_cursor((0,)) else: select = lambda r: r[0] and r[0].title in albums self.view.select_by_func(select) self.__uninhibit()
def test_empty(self): self.failUnless(Query.is_valid('')) self.failUnless(Query.is_parsable('')) self.failUnless(Query(''))
def __filter_changed(self, *args): self.__deferred_changed.abort() text = self.get_text() if Query.is_parsable(text): GLib.idle_add(self.emit, 'query-changed', text)
def __filter_changed(self, *args): self.__remove_timeout() text = self.__entry.get_text().decode('utf-8') if Query.is_parsable(text): self.__refill_id = GLib.idle_add(self.emit, 'query-changed', text)
def test_empty(self): self.failUnless(Query.is_valid('')) self.failUnless(Query.is_parsable('')) self.failUnless(Query(''))