Ejemplo n.º 1
0
    def __init__(self, db_query):

        # Init.
        gtk.VBox.__init__(self)
        SignalContainer.__init__(self)

        self.__db_query = db_query
        self.update_interval = 3000  # 3000 millisecond.
        self.reload_flag = False
        self.search_flag = False
        self.cache_search_list = []
        self.cache_search_view = []
        self.__selected_tag = {"album": [], "artist": [], "genre": []}
        Dispatcher.connect("reload-browser", self.on_dispatcher_reload_browser)
        gobject.timeout_add(self.update_interval, self.on_interval_loaded_view)

        # The saving song Classification presented to the user.
        self.artists_view, self.artists_sw = self.get_icon_view(14)
        self.albums_view, self.albums_sw = self.get_icon_view(14)
        self.genres_view, self.genres_sw = self.get_icon_view(14)
        self.folders_view, self.folders_sw = self.get_icon_view(20)
        self.folders_view.connect("motion-notify-item",
                                  self.on_folders_view_motion_notify)

        # Song list for temporarily storing
        # self.songs_view, self.songs_view_sw = self.get_song_view()
        self.songs_view = self.get_song_view()

        # Classification navigation bar.
        self.filterbar = OptionBar([
            (app_theme.get_pixbuf("filter/artist_normal.png"),
             app_theme.get_pixbuf("filter/artist_press.png"), _("Artist"),
             lambda: self.switch_filter_view("artist")),
            (app_theme.get_pixbuf("filter/album_normal.png"),
             app_theme.get_pixbuf("filter/album_press.png"), _("Album"),
             lambda: self.switch_filter_view("album")),
            (app_theme.get_pixbuf("filter/genre_normal.png"),
             app_theme.get_pixbuf("filter/genre_press.png"), _("Genre"),
             lambda: self.switch_filter_view("genre")),
            (app_theme.get_pixbuf("filter/local_normal.png"),
             app_theme.get_pixbuf("filter/local_press.png"), _("Folder"),
             lambda: self.switch_filter_view("folder"))
        ])

        # Manage the media library (import, refresh)
        self.importbar = SongImportBar()
        self.importbar.reload_items([
            (_("Quick Scan"),
             lambda: ImportFolderJob([os.path.expanduser("~")])),
            (_("Scan"), lambda: ImportFolderJob()),
            (_("Refresh"), lambda: ReloadDBJob())
        ])

        # Left box
        invailed_box = gtk.VBox()
        invailed_box.set_size_request(-1, 10)
        left_vbox = gtk.VBox(spacing=10)
        left_vbox.set_size_request(121, -1)
        # left_vbox.pack_start(invailed_box, False, True)
        left_vbox.pack_start(self.filterbar, False, False)
        left_vbox.pack_start(create_separator_box(), False, False)
        left_vbox.pack_start(self.importbar, False, False)

        # Used to switch songs category view, in the right side of the layout.
        self.switch_view_box = gtk.VBox()
        self.switch_view_box.add(self.artists_sw)
        # self.switch_view_box.add(TaskView())

        # Control back on a view.
        self.back_hbox = gtk.HBox()
        self.back_hbox.set_size_request(-1, 26)
        self.back_hbox.set_no_show_all(True)
        self.back_button = BackButton()
        self.back_button.connect("clicked", self.on_back_button_clicked)
        self.prompt_button = PromptButton()
        self.back_hbox.pack_start(self.back_button, False, False, 5)
        self.back_hbox.pack_start(self.prompt_button, False, False)

        # searchbar
        self.search_entry, search_align = self.get_search_entry()
        search_hbox = gtk.HBox()
        search_hbox.pack_start(self.back_hbox, False, False)
        search_hbox.pack_start(create_right_align(), True, True)
        # search_hbox.pack_start(search_align, False, False)
        search_hbox_align = gtk.Alignment()
        search_hbox_align.set_padding(5, 0, 0, 0)
        search_hbox_align.set(0, 0, 1, 1)
        search_hbox_align.add(search_hbox)

        # Layout on the right.
        content_box = gtk.VBox(spacing=5)
        content_box.pack_start(search_hbox_align, False, False)
        content_box.pack_start(self.switch_view_box, True, True)

        body_paned = HPaned(handle_color=app_theme.get_color("panedHandler"),
                            enable_drag=True)
        body_paned.add1(left_vbox)
        body_paned.add2(content_box)

        self.pack_start(body_paned, True, True)