def setup_source(self): colour = self.viewmgr.get_selection_colour() self.cover_search_pane = CoverSearchPane(self.plugin, colour) self.stack.add_titled(self.cover_search_pane, "notebook_covers", _("Covers")) # define entry-view toolbar self.stars = ReactiveStar() self.stars.set_rating(0) self.stars.connect('changed', self.rating_changed_callback) self.stars.props.valign = Gtk.Align.CENTER self.entry_view_grid.attach(self.stars, 1, 1, 1, 1) stack_switcher = Gtk.StackSwitcher() stack_switcher.set_stack(self.stack) self.entry_view_grid.attach(stack_switcher, 0, 1, 1, 1) viewtoggle = PixbufButton() viewtoggle.set_image(create_button_image(self.plugin, "entryview.png")) self.viewtoggle_id = None setting = self.gs.get_setting(self.gs.Path.PLUGIN) viewtoggle.set_active(not setting[self.gs.PluginKey.ENTRY_VIEW_MODE]) self.entry_view_toggled(viewtoggle, True) viewtoggle.connect('toggled', self.entry_view_toggled) smallwindowbutton = PixbufButton() smallwindowbutton.set_image( create_button_image(self.plugin, "view-restore.png")) smallwindowbutton.connect('toggled', self.smallwindowbutton_callback) self.smallwindowext = ExternalPlugin() self.smallwindowext.appendattribute('plugin_name', 'smallwindow') self.smallwindowext.appendattribute('action_group_name', 'small window actions') self.smallwindowext.appendattribute('action_name', 'SmallWindow') self.smallwindowext.appendattribute('action_type', 'app') whatsplayingtoggle = PixbufButton() whatsplayingtoggle.set_image( create_button_image(self.plugin, "whatsplaying.png")) whatsplayingtoggle.connect('toggled', self.whatsplayingtoggle_callback) rightgrid = Gtk.Grid() rightgrid.props.halign = Gtk.Align.END # rightgrid.attach(whatsplayingtoggle, 0, 0, 1, 1) rightgrid.attach(viewtoggle, 1, 0, 1, 1) rightgrid.attach(smallwindowbutton, 2, 0, 1, 1) self.entry_view_grid.attach_next_to(rightgrid, self.stars, Gtk.PositionType.RIGHT, 1, 1) self.stack.set_visible_child(self.entry_view_results) self.stack.connect('notify::visible-child-name', self.notebook_switch_page_callback) self.entry_view_grid.show_all() smallwindowbutton.set_visible(self.smallwindowext.is_activated())
def _setup_source(self): ''' Setups the differents parts of the source so they are ready to be used by the user. It also creates and configure some custom widgets. ''' print("CoverArtBrowser DEBUG - _setup_source") cl = CoverLocale() cl.switch_locale(cl.Locale.LOCALE_DOMAIN) # setup iconview popup self.viewmgr.current_view.set_popup_menu(self.popup_menu) # setup entry-view objects and widgets setting = self.gs.get_setting(self.gs.Path.PLUGIN) setting.bind(self.gs.PluginKey.PANED_POSITION, self.paned, 'collapsible-y', Gio.SettingsBindFlags.DEFAULT) setting.bind(self.gs.PluginKey.DISPLAY_BOTTOM, self.paned.get_child2(), 'visible', Gio.SettingsBindFlags.DEFAULT) # create entry view. Don't allow to reorder until the load is finished self.entry_view = EV(self.shell, self) self.entry_view.set_columns_clickable(False) self.shell.props.library_source.get_entry_view().set_columns_clickable( False) self.stars = ReactiveStar() self.stars.set_rating(0) a = Gtk.Alignment.new(0.5, 0.5, 0, 0) a.add(self.stars) self.stars.connect('changed', self.rating_changed_callback) vbox = Gtk.Box() vbox.set_orientation(Gtk.Orientation.VERTICAL) vbox.pack_start(self.entry_view, True, True, 0) vbox.pack_start(a, False, False, 1) vbox.show_all() self.notebook.append_page(vbox, Gtk.Label.new_with_mnemonic(_("Tracks"))) # create an album manager self.album_manager = AlbumManager(self.plugin, self.viewmgr.current_view) self.viewmgr.current_view.initialise(self) # setup cover search pane colour = self.viewmgr.get_selection_colour() self.cover_search_pane = CoverSearchPane(self.plugin, colour) self.notebook.append_page(self.cover_search_pane, Gtk.Label.new_with_mnemonic(_("Covers"))) # connect a signal to when the info of albums is ready self.load_fin_id = self.album_manager.loader.connect( 'model-load-finished', self.load_finished_callback) # prompt the loader to load the albums self.album_manager.loader.load_albums(self.props.base_query_model) # initialise the variables of the quick search self.quick_search_controller = AlbumQuickSearchController( self.album_manager) self.quick_search_controller.connect_quick_search(self.quick_search) # set sensitivity of export menu item for iconview self.popup_menu.set_sensitive( 'export_embed_menu_item', CoverArtExport(self.plugin, self.shell, self.album_manager).is_search_plugin_enabled()) # setup the statusbar component self.statusbar = Statusbar(self) # initialise the toolbar manager self.toolbar_manager = ToolbarManager(self.plugin, self.page, self.viewmgr) self.viewmgr.current_view.emit('update-toolbar') cl.switch_locale(cl.Locale.RB) # setup the artist paned artist_pview = None for view in self.shell.props.library_source.get_property_views(): print(view.props.title) print(_("Artist")) if view.props.title == _("Artist"): artist_pview = view break assert artist_pview, "cannot find artist property view" self.artist_treeview.set_model(artist_pview.get_model()) setting.bind(self.gs.PluginKey.ARTIST_PANED_POSITION, self, 'artist-paned-pos', Gio.SettingsBindFlags.DEFAULT) self.artist_paned.connect('button-release-event', self.artist_paned_button_release_callback) # intercept JumpToPlaying Song action so that we can scroll to the playing album appshell = rb3compat.ApplicationShell(self.shell) action = appshell.lookup_action("", "jump-to-playing", "win") action.action.connect("activate", self.jump_to_playing, None) self.echonest_similar_playlist = None print("CoverArtBrowser DEBUG - end _setup_source")