def __init__(self, playlist_id, playlist_name, parent): """ Init PlaylistView @parma playlist id as int @param playlist name as str """ View.__init__(self) self._playlist_name = playlist_name self._signal_id = None builder = Gtk.Builder() builder.add_from_resource('/org/gnome/Lollypop/PlaylistView.ui') builder.get_object('title').set_label(playlist_name) builder.connect_signals(self) self._edit_btn = builder.get_object('edit_btn') if playlist_id < 0 and playlist_id != Type.LOVED: self._edit_btn.hide() self._back_btn = builder.get_object('back_btn') self._title = builder.get_object('title') self._playlist_widget = PlaylistWidget(playlist_id, playlist_name) self._playlist_widget.show() self.add(builder.get_object('widget')) self._viewport.add(self._playlist_widget) self._scrolledWindow.set_property('expand', True) self.add(self._scrolledWindow)
def __init__(self, playlist_id): """ Init PlaylistView @parma playlist id as int """ View.__init__(self) self._playlist_id = playlist_id self._signal_id = Lp().playlists.connect('playlist-changed', self._update) builder = Gtk.Builder() builder.add_from_resource('/org/gnome/Lollypop/PlaylistView.ui') builder.get_object('title').set_label( Lp().playlists.get_name(playlist_id)) builder.connect_signals(self) self._edit_btn = builder.get_object('edit_btn') if playlist_id < 0 and playlist_id != Type.LOVED: self._edit_btn.hide() self._back_btn = builder.get_object('back_btn') self._title = builder.get_object('title') self._playlist_widget = PlaylistWidget(playlist_id) self._playlist_widget.show() self.add(builder.get_object('widget')) self._viewport.add(self._playlist_widget) self._scrolledWindow.set_property('expand', True) self.add(self._scrolledWindow)
def __init__(self, playlist_name, parent): View.__init__(self) self._playlist_name = playlist_name self._signal_id = None builder = Gtk.Builder() builder.add_from_resource('/org/gnome/Lollypop/PlaylistView.ui') builder.get_object('title').set_label(playlist_name) builder.connect_signals(self) self._edit_btn = builder.get_object('edit_btn') self._back_btn = builder.get_object('back_btn') self._title = builder.get_object('title') self._playlist_widget = PlaylistWidget(playlist_name) self._playlist_widget.show() self.add(builder.get_object('PlaylistView')) self._viewport.add(self._playlist_widget) self._scrolledWindow.set_property('expand', True) self.add(self._scrolledWindow)
def __init__(self, playlist_name, parent): View.__init__(self) self._playlist_name = playlist_name self._signal_id = None builder = Gtk.Builder() builder.add_from_resource('/org/gnome/Lollypop/PlaylistsView.ui') builder.get_object('title').set_label(playlist_name) builder.connect_signals(self) self._edit_btn = builder.get_object('edit_btn') self._back_btn = builder.get_object('back_btn') self._title = builder.get_object('title') self._playlist_widget = PlaylistWidget(playlist_name) self._playlist_widget.show() self.add(builder.get_object('widget')) self._viewport.add(self._playlist_widget) self._scrolledWindow.set_property('expand', True) self.add(self._scrolledWindow)
class PlaylistView(View): """ Show playlist tracks """ def __init__(self, playlist_id): """ Init PlaylistView @parma playlist id as int """ View.__init__(self) self._playlist_id = playlist_id self._signal_id = Lp().playlists.connect('playlist-changed', self._update) builder = Gtk.Builder() builder.add_from_resource('/org/gnome/Lollypop/PlaylistView.ui') builder.get_object('title').set_label( Lp().playlists.get_name(playlist_id)) builder.connect_signals(self) self._edit_btn = builder.get_object('edit_btn') if playlist_id < 0 and playlist_id != Type.LOVED: self._edit_btn.hide() self._back_btn = builder.get_object('back_btn') self._title = builder.get_object('title') self._playlist_widget = PlaylistWidget(playlist_id) self._playlist_widget.show() self.add(builder.get_object('widget')) self._viewport.add(self._playlist_widget) self._scrolledWindow.set_property('expand', True) self.add(self._scrolledWindow) def populate(self, tracks): """ Populate view with tracks from playlist Thread safe """ mid_tracks = int(0.5+len(tracks)/2) self._playlist_widget.populate_list_left(tracks[:mid_tracks], 1) self._playlist_widget.populate_list_right(tracks[mid_tracks:], mid_tracks + 1) def get_id(self): """ Return playlist id @return id as int """ return self._playlist_id def stop(self): """ Stop populating """ self._playlist_widget.stop() ####################### # PRIVATE # ####################### def _update(self, manager, playlist_id): """ Update tracks widgets @param manager as PlaylistsManager @param playlist id as int """ if playlist_id == self._playlist_id: self._playlist_widget.clear() t = Thread(target=self._update_view) t.daemon = True t.start() def _update_view(self): """ Update tracks widgets """ tracks = Lp().playlists.get_tracks_ids(self._playlist_id) self.populate(tracks) def _on_destroy(self, widget): """ Disconnect signals @param widget as Gtk.Widget """ if self._signal_id: Lp().playlists.disconnect(self._signal_id) self._signal_id = None def _on_edit_btn_clicked(self, button): """ Edit playlist @param button as Gtk.Button @param playlist name as str """ Lp().window.show_playlist_editor(self._playlist_id) def _on_current_changed(self, player): """ Current song changed @param player as Player """ self._playlist_widget.update_playing_indicator()
class PlaylistView(View): """ Init PlaylistView ui with a scrolled grid of PlaylistWidgets @param playlist name as str """ def __init__(self, playlist_name, parent): View.__init__(self) self._playlist_name = playlist_name self._signal_id = None builder = Gtk.Builder() builder.add_from_resource('/org/gnome/Lollypop/PlaylistView.ui') builder.get_object('title').set_label(playlist_name) builder.connect_signals(self) self._edit_btn = builder.get_object('edit_btn') self._back_btn = builder.get_object('back_btn') self._title = builder.get_object('title') self._playlist_widget = PlaylistWidget(playlist_name) self._playlist_widget.show() self.add(builder.get_object('PlaylistView')) self._viewport.add(self._playlist_widget) self._scrolledWindow.set_property('expand', True) self.add(self._scrolledWindow) """ Populate view with tracks from playlist Thread safe """ def populate(self): sql = Objects.db.get_cursor() tracks = Objects.playlists.get_tracks_id(self._playlist_name, sql) mid_tracks = int(0.5 + len(tracks) / 2) self._playlist_widget.populate_list_one(tracks[:mid_tracks], 1) self._playlist_widget.populate_list_two(tracks[mid_tracks:], mid_tracks + 1) """ Return playlist name @return name as str """ def get_name(self): return self._playlist_name """ Do show, connect signals """ def do_show(self): self._signal_id = Objects.playlists.connect("playlist-changed", self._update_view) View.do_show(self) """ Do hide, disconnect signals """ def do_hide(self): if self._signal_id: Objects.playlists.disconnect(self._signal_id) self._signal_id = None View.do_hide(self) ####################### # PRIVATE # ####################### """ Update tracks widgets @param manager as PlaylistsManager @param playlist name as str """ def _update_view(self, manager, playlist_name): if playlist_name == self._playlist_name: self._playlist_widget.clear() start_new_thread(self.populate, ()) """ Edit playlist @param button as Gtk.Button @param playlist name as str """ def _on_edit_btn_clicked(self, button): Objects.window.show_playlist_editor(self._playlist_name) """ Current song changed @param player as Player """ def _on_current_changed(self, player): self._playlist_widget.update_playing_indicator()
class PlaylistView(View): """ Show playlist tracks """ def __init__(self, playlist_id, playlist_name, parent): """ Init PlaylistView @parma playlist id as int @param playlist name as str """ View.__init__(self) self._playlist_name = playlist_name self._signal_id = None builder = Gtk.Builder() builder.add_from_resource('/org/gnome/Lollypop/PlaylistView.ui') builder.get_object('title').set_label(playlist_name) builder.connect_signals(self) self._edit_btn = builder.get_object('edit_btn') if playlist_id < 0 and playlist_id != Type.LOVED: self._edit_btn.hide() self._back_btn = builder.get_object('back_btn') self._title = builder.get_object('title') self._playlist_widget = PlaylistWidget(playlist_id, playlist_name) self._playlist_widget.show() self.add(builder.get_object('widget')) self._viewport.add(self._playlist_widget) self._scrolledWindow.set_property('expand', True) self.add(self._scrolledWindow) def populate(self): """ Populate view with tracks from playlist Thread safe """ sql = Lp.db.get_cursor() tracks = Lp.playlists.get_tracks_id(self._playlist_name, sql) mid_tracks = int(0.5+len(tracks)/2) self._playlist_widget.populate_list_left(tracks[:mid_tracks], 1) self._playlist_widget.populate_list_right(tracks[mid_tracks:], mid_tracks + 1) sql.close() def populate_tracks(self, tracks): """ Populate view with tracks @param tracks as [int] """ mid_tracks = int(0.5+len(tracks)/2) self._playlist_widget.populate_list_left(tracks[:mid_tracks], 1) self._playlist_widget.populate_list_right(tracks[mid_tracks:], mid_tracks + 1) def get_name(self): """ Return playlist name @return name as str """ return self._playlist_name def do_show(self): """ Do show, connect signals """ self._signal_id = Lp.playlists.connect('playlist-changed', self._update_view) View.do_show(self) def do_hide(self): """ Do hide, disconnect signals """ if self._signal_id: Lp.playlists.disconnect(self._signal_id) self._signal_id = None View.do_hide(self) def stop(self): """ Stop populating """ self._playlist_widget.stop() ####################### # PRIVATE # ####################### def _update_view(self, manager, playlist_name): """ Update tracks widgets @param manager as PlaylistsManager @param playlist name as str """ if playlist_name == self._playlist_name: self._playlist_widget.clear() start_new_thread(self.populate, ()) def _on_edit_btn_clicked(self, button): """ Edit playlist @param button as Gtk.Button @param playlist name as str """ Lp.window.show_playlist_editor(self._playlist_name) def _on_current_changed(self, player): """ Current song changed @param player as Player """ self._playlist_widget.update_playing_indicator()
class PlaylistView(View): """ Show playlist tracks """ def __init__(self, playlist_id, playlist_name, parent): """ Init PlaylistView @parma playlist id as int @param playlist name as str """ View.__init__(self) self._playlist_name = playlist_name self._signal_id = None builder = Gtk.Builder() builder.add_from_resource('/org/gnome/Lollypop/PlaylistView.ui') builder.get_object('title').set_label(playlist_name) builder.connect_signals(self) self._edit_btn = builder.get_object('edit_btn') if playlist_id < 0 and playlist_id != Type.LOVED: self._edit_btn.hide() self._back_btn = builder.get_object('back_btn') self._title = builder.get_object('title') self._playlist_widget = PlaylistWidget(playlist_id, playlist_name) self._playlist_widget.show() self.add(builder.get_object('widget')) self._viewport.add(self._playlist_widget) self._scrolledWindow.set_property('expand', True) self.add(self._scrolledWindow) def populate(self, tracks=None): """ Populate view with tracks from playlist Thread safe """ if tracks: self.populate_tracks(tracks) else: tracks = Lp.playlists.get_tracks_id(self._playlist_name) mid_tracks = int(0.5 + len(tracks) / 2) self._playlist_widget.populate_list_left(tracks[:mid_tracks], 1) self._playlist_widget.populate_list_right(tracks[mid_tracks:], mid_tracks + 1) def populate_tracks(self, tracks): """ Populate view with tracks @param tracks as [int] """ mid_tracks = int(0.5 + len(tracks) / 2) self._playlist_widget.populate_list_left(tracks[:mid_tracks], 1) self._playlist_widget.populate_list_right(tracks[mid_tracks:], mid_tracks + 1) def get_name(self): """ Return playlist name @return name as str """ return self._playlist_name def do_show(self): """ Do show, connect signals """ self._signal_id = Lp.playlists.connect('playlist-changed', self._update_view) View.do_show(self) def do_hide(self): """ Do hide, disconnect signals """ if self._signal_id: Lp.playlists.disconnect(self._signal_id) self._signal_id = None View.do_hide(self) def stop(self): """ Stop populating """ self._playlist_widget.stop() ####################### # PRIVATE # ####################### def _update_view(self, manager, playlist_name): """ Update tracks widgets @param manager as PlaylistsManager @param playlist name as str """ if playlist_name == self._playlist_name: self._playlist_widget.clear() self.populate() def _on_edit_btn_clicked(self, button): """ Edit playlist @param button as Gtk.Button @param playlist name as str """ Lp.window.show_playlist_editor(self._playlist_name) def _on_current_changed(self, player): """ Current song changed @param player as Player """ self._playlist_widget.update_playing_indicator()