def __init__(self): Query() self.MostPlayed.QUERY = Query.get_most_played_songs() self.NeverPlayed.QUERY = Query.get_never_played_songs() self.RecentlyPlayed.QUERY = Query.get_recently_played_songs() self.RecentlyAdded.QUERY = Query.get_recently_added_songs() self.Favorites.QUERY = Query.get_favorite_songs()
def _setup_view(self): self._box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.player = Player(self) self.selection_toolbar = SelectionToolbar() self.toolbar = Toolbar() self.views = [] self._stack = Gtk.Stack( transition_type=Gtk.StackTransitionType.CROSSFADE, transition_duration=100, visible=True, can_focus=False) # Add the 'background' styleclass so it properly hides the # bottom line of the searchbar self._stack.get_style_context().add_class('background') self._overlay = Gtk.Overlay(child=self._stack) self._overlay.add_overlay(self.toolbar.dropdown) self.set_titlebar(self.toolbar.header_bar) self._box.pack_start(self.toolbar.searchbar, False, False, 0) self._box.pack_start(self._overlay, True, True, 0) self._box.pack_start(self.player.actionbar, False, False, 0) self._box.pack_start(self.selection_toolbar.actionbar, False, False, 0) self.add(self._box) count = 0 cursor = None Query() if Query.music_folder: try: cursor = tracker.query(Query.all_songs_count(), None) if cursor is not None and cursor.next(None): count = cursor.get_integer(0) except Exception as e: logger.error("Tracker query crashed: %s", e) count = 0 if count > 0: self._switch_to_player_view() # To revert to the No Music View when no songs are found else: if self.toolbar._selectionMode is False: self._switch_to_empty_view() else: # Revert to No Music view if XDG dirs are not set self._switch_to_empty_view() self.toolbar._search_button.connect('toggled', self._on_search_toggled) self.toolbar.connect('selection-mode-changed', self._on_selection_mode_changed) self.selection_toolbar._add_to_playlist_button.connect( 'clicked', self._on_add_to_playlist_button_clicked) self.selection_toolbar._remove_from_playlist_button.connect( 'clicked', self._on_remove_from_playlist_button_clicked) self.toolbar.set_state(ToolbarState.MAIN) self.toolbar.header_bar.show() self._overlay.show() self.player.actionbar.show_all() self._box.show() self.show()
def _setup_view(self): self._box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self.player = Player(self) self.selection_toolbar = SelectionToolbar() self.toolbar = Toolbar() self.views = [] self._stack = Gtk.Stack( transition_type=Gtk.StackTransitionType.CROSSFADE, transition_duration=100, visible=True, can_focus=False) # Add the 'background' styleclass so it properly hides the # bottom line of the searchbar self._stack.get_style_context().add_class('background') self._overlay = Gtk.Overlay(child=self._stack) self._overlay.add_overlay(self.toolbar.dropdown) self.set_titlebar(self.toolbar.header_bar) self._box.pack_start(self.toolbar.searchbar, False, False, 0) self._box.pack_start(self._overlay, True, True, 0) self._box.pack_start(self.player.actionbar, False, False, 0) self._box.pack_start(self.selection_toolbar.actionbar, False, False, 0) self.add(self._box) def songs_available_cb(available): if available: self._switch_to_player_view() else: self._switch_to_empty_view() Query() if Query.music_folder: grilo.songs_available(songs_available_cb) else: self._switch_to_empty_view() self.toolbar._search_button.connect('toggled', self._on_search_toggled) self.toolbar.connect('selection-mode-changed', self._on_selection_mode_changed) self.selection_toolbar._add_to_playlist_button.connect( 'clicked', self._on_add_to_playlist_button_clicked) self.selection_toolbar._remove_from_playlist_button.connect( 'clicked', self._on_remove_from_playlist_button_clicked) self.toolbar.set_state(ToolbarState.MAIN) self.toolbar.header_bar.show() self._overlay.show() self.player.actionbar.show_all() self._box.show() self.show()
def _setup_view(self): self._box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL) self._headerbar = HeaderBar() self._searchbar = Searchbar() self._player = Player(self) self._player_toolbar = PlayerToolbar(self._player, self) selection_toolbar = SelectionToolbar() self.views = [None] * len(View) self._stack = Gtk.Stack( transition_type=Gtk.StackTransitionType.CROSSFADE, transition_duration=100, homogeneous=False, visible=True, can_focus=False) self._headerbar.bind_property( "search-mode-enabled", self._searchbar, "search-mode-enabled", GObject.BindingFlags.BIDIRECTIONAL | GObject.BindingFlags.SYNC_CREATE) self._searchbar.props.stack = self._stack self._headerbar.connect( 'back-button-clicked', self._switch_back_from_childview) self.connect('notify::selection-mode', self._on_selection_mode_changed) self.bind_property( 'selected-items-count', self._headerbar, 'selected-items-count') self.bind_property( 'selected-items-count', selection_toolbar, 'selected-items-count') self.bind_property( 'selection-mode', self._headerbar, 'selection-mode', GObject.BindingFlags.BIDIRECTIONAL | GObject.BindingFlags.SYNC_CREATE) self.bind_property( 'selection-mode', selection_toolbar, 'visible', GObject.BindingFlags.SYNC_CREATE) # Create only the empty view at startup # if no music, switch to empty view and hide stack # if some music is available, populate stack with mainviews, # show stack and set empty_view to empty_search_view self.views[View.EMPTY] = EmptyView() self._stack.add_named(self.views[View.EMPTY], "emptyview") # Add the 'background' styleclass so it properly hides the # bottom line of the searchbar self._stack.get_style_context().add_class('background') self._overlay = Gtk.Overlay() self._overlay.add(self._stack) # FIXME: Need to find a proper way to do this. self._overlay.add_overlay(self._searchbar._dropdown) self._overlay.add_overlay(self.notifications_popup) self.set_titlebar(self._headerbar) self._box.pack_start(self._searchbar, False, False, 0) self._box.pack_start(self._overlay, True, True, 0) self._box.pack_start(self._player_toolbar, False, False, 0) self._box.pack_start(selection_toolbar, False, False, 0) self.add(self._box) self._headerbar._search_button.connect( 'toggled', self._on_search_toggled) selection_toolbar.connect( 'add-to-playlist', self._on_add_to_playlist) self._headerbar.props.state = HeaderBar.State.MAIN self._headerbar.show() self._overlay.show() self._player_toolbar.show_all() self._box.show() self.show() def songs_available_cb(available): if available: self._switch_to_player_view() else: self._switch_to_empty_view() if Query().music_folder: grilo.songs_available(songs_available_cb) else: self._switch_to_empty_view()
def _setup_view(self): self._search = Search() self._searchbar = SearchBar() self._searchbar.props.stack = self._stack self._headerbar = HeaderBar() self._search.bind_property( "search-mode-active", self._headerbar, "search-mode-active", GObject.BindingFlags.BIDIRECTIONAL | GObject.BindingFlags.SYNC_CREATE) self._search.bind_property("search-mode-active", self._searchbar, "search-mode-enabled", GObject.BindingFlags.SYNC_CREATE) self._search.bind_property("state", self._searchbar, "search-state", GObject.BindingFlags.SYNC_CREATE) self._player_toolbar = PlayerToolbar() self._player_toolbar.props.player = self._player self._headerbar.connect('back-button-clicked', self._switch_back_from_childview) self.bind_property('selected-items-count', self._headerbar, 'selected-items-count') self.bind_property("selected-items-count", self._selection_toolbar, "selected-items-count") self.bind_property( 'selection-mode', self._headerbar, 'selection-mode', GObject.BindingFlags.BIDIRECTIONAL | GObject.BindingFlags.SYNC_CREATE) self.bind_property("selection-mode", self._player_toolbar, "visible", GObject.BindingFlags.INVERT_BOOLEAN) self.bind_property("selection-mode", self._selection_toolbar, "visible") self.connect("notify::selection-mode", self._on_selection_mode_changed) self.views = [Gtk.Box()] * len(View) # Create only the empty view at startup # if no music, switch to empty view and hide stack # if some music is available, populate stack with mainviews, # show stack and set empty_view to empty_search_view self.views[View.EMPTY] = EmptyView() self._stack.add_named(self.views[View.EMPTY], "emptyview") # Add the 'background' styleclass so it properly hides the # bottom line of the searchbar self._stack.get_style_context().add_class('background') # FIXME: Need to find a proper way to do this. self._overlay.add_overlay(self._searchbar._dropdown) self._box.pack_start(self._searchbar, False, False, 0) self._box.reorder_child(self._searchbar, 0) self._box.pack_end(self._player_toolbar, False, False, 0) self.set_titlebar(self._headerbar) self._selection_toolbar.connect('add-to-playlist', self._on_add_to_playlist) self._search.connect("notify::state", self._on_search_state_changed) self._headerbar.props.state = HeaderBar.State.MAIN self._headerbar.show() def songs_available_cb(available): if available: self._switch_to_player_view() else: self._switch_to_empty_view() if Query().music_folder: grilo.songs_available(songs_available_cb) else: self._switch_to_empty_view()