예제 #1
0
파일: main_view.py 프로젝트: zippunov/cozy
    def check_for_tracks(self):
        """
        Check if there are any imported files.
        If there aren't display a welcome screen.
        """
        if books().count() < 1:
            path = ""
            if Storage.select().count() > 0:
                path = Storage.select().where(
                    Storage.default == True).get().path

            if not path:
                path = os.path.join(os.path.expanduser("~"), _("Audiobooks"))

                if not os.path.exists(path):
                    os.mkdir(path)

                Storage.create(path=path, default=True)

            self.no_media_file_chooser.set_current_folder(path)
            self.main_stack.props.visible_child_name = "no_media"
            self.block_ui_buttons(True)
            self.titlebar.stop()
            self.category_toolbar.set_visible(False)
        else:
            self.main_stack.props.visible_child_name = "main"
            # This displays the placeholder if there is not a recent book yet
            self.__on_sort_stack_changed(None, None)
예제 #2
0
파일: main_view.py 프로젝트: zippunov/cozy
    def filter_author_reader(self, hide_offline):
        """
        This method filters unavailable (offline) author and readers from
        the list boxes.
        """
        offline_authors = []
        offline_readers = []
        online_authors = []
        online_readers = []

        if hide_offline:
            for b in books():
                if not self.fs_monitor.is_book_online(b) and not b.downloaded:
                    offline_authors.append(b.author)
                    offline_readers.append(b.reader)
                else:
                    online_authors.append(b.author)
                    online_readers.append(b.reader)

            offline_authors = sorted(list(set(offline_authors)))
            offline_readers = sorted(list(set(offline_readers)))
            online_authors = sorted(list(set(online_authors)))
            online_readers = sorted(list(set(online_readers)))

            authors = [i for i in offline_authors if i not in online_authors]
            readers = [i for i in offline_readers if i not in online_readers]

            for row in self.author_box.get_children():
                if not isinstance(row, ListBoxRowWithData):
                    continue

                if any(row.data == x for x in authors):
                    row.set_visible(False)
                else:
                    row.set_visible(True)

            for row in self.reader_box.get_children():
                if not isinstance(row, ListBoxRowWithData):
                    continue

                if any(row.data == x for x in readers):
                    row.set_visible(False)
                else:
                    row.set_visible(True)
        else:
            for row in self.author_box:
                row.set_visible(True)

            for row in self.reader_box:
                row.set_visible(True)
예제 #3
0
    def check_for_tracks(self):
        """
        Check if there are any imported files.
        If there aren't display a welcome screen.
        """
        if books().count() < 1:
            path = ""
            if len(self._settings.storage_locations) > 0:
                path = self._settings.default_location.path

            self.no_media_file_chooser.set_current_folder(path)
            self.main_stack.props.visible_child_name = "no_media"
            self.block_ui_buttons(True)
            self.category_toolbar.set_visible(False)
예제 #4
0
    def refresh_content(self):
        """
        Refresh all content.
        """
        # First clear the boxes
        childs = self.book_box.get_children()
        for element in childs:
            self.book_box.remove(element)

        self.populate_author_reader()
        self.filter_author_reader(tools.get_glib_settings().get_boolean("hide-offline"))

        for b in db.books():
            self.book_box.add(BookElement(b))

        self.book_box.show_all()

        return False