Ejemplo n.º 1
0
    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()
Ejemplo n.º 2
0
    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()
Ejemplo n.º 3
0
 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()
Ejemplo n.º 4
0
 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()
Ejemplo n.º 5
0
    def activate(self, widget=None, resort=True):
        songs = self._get_playlist_songs()

        text = self._get_text()
        # TODO: remove static dependency on Query
        if Query.is_parsable(text):
            self._query = Query(text, SongList.star)
            songs = self._query.filter(songs)
        GLib.idle_add(self.songs_selected, songs, resort)
Ejemplo n.º 6
0
    def activate(self, widget=None, resort=True):
        songs = self._get_playlist_songs()

        text = self.get_filter_text()
        # TODO: remove static dependency on Query
        if Query.is_parsable(text):
            self._query = Query(text, SongList.star)
            songs = self._query.filter(songs)
        GLib.idle_add(self.songs_selected, songs, resort)
Ejemplo n.º 7
0
 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)
Ejemplo n.º 8
0
 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)
Ejemplo n.º 9
0
    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 = self.get_text().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()
Ejemplo n.º 10
0
    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()
Ejemplo n.º 11
0
    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()
Ejemplo n.º 12
0
 def filter_text(self, text):
     self.__searchbar.set_text(text)
     if Query.is_parsable(text):
         self.__filter_changed(self.__searchbar, text)
         self.activate()
Ejemplo n.º 13
0
 def test_empty(self):
     self.failUnless(Query.is_valid(''))
     self.failUnless(Query.is_parsable(''))
     self.failUnless(Query(''))
Ejemplo n.º 14
0
 def filter_text(self, text):
     self.__searchbar.set_text(text)
     if Query.is_parsable(text):
         self.__filter_changed(self.__searchbar, text)
         self.activate()
Ejemplo n.º 15
0
 def test_empty(self):
     self.failUnless(Query.is_valid(''))
     self.failUnless(Query.is_parsable(''))
     self.failUnless(Query(''))
Ejemplo n.º 16
0
 def filter_text(self, text):
     self.__search.set_text(text)
     if Query.is_parsable(text):
         self.__update_filter(self.__search, text)
         self.activate()
Ejemplo n.º 17
0
 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)