Commit 658ef438 authored by Arnel Borja's avatar Arnel Borja Committed by Vadim Rutkovsky

widgets: Add selection mode to ArtistAlbums

This is for selection mode in Search view when selecting an artist.
parent 647d1efb
...@@ -35,6 +35,18 @@ ...@@ -35,6 +35,18 @@
<child> <child>
<placeholder/> <placeholder/>
</child> </child>
<child>
<object class="GtkCheckButton" id="select">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="no_show_all">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child> <child>
<object class="GtkLabel" id="num"> <object class="GtkLabel" id="num">
<property name="visible">True</property> <property name="visible">True</property>
......
...@@ -680,9 +680,14 @@ class Artists (ViewContainer): ...@@ -680,9 +680,14 @@ class Artists (ViewContainer):
artistAlbums = None artistAlbums = None
if (self._model.get_string_from_iter(_iter) == if (self._model.get_string_from_iter(_iter) ==
self._model.get_string_from_iter(self._allIter)): self._model.get_string_from_iter(self._allIter)):
artistAlbums = Widgets.AllArtistsAlbums(self.player) artistAlbums = Widgets.AllArtistsAlbums(
self.player, self.header_bar, self.selection_toolbar
)
else: else:
artistAlbums = Widgets.ArtistAlbums(artist, albums, self.player) artistAlbums = Widgets.ArtistAlbums(
artist, albums, self.player,
self.header_bar, self.selection_toolbar
)
self._artists[artist.casefold()]['widget'] = artistAlbums self._artists[artist.casefold()]['widget'] = artistAlbums
new_artistAlbumsWidget.add(artistAlbums) new_artistAlbumsWidget.add(artistAlbums)
new_artistAlbumsWidget.show() new_artistAlbumsWidget.show()
...@@ -1210,7 +1215,10 @@ class Search(ViewContainer): ...@@ -1210,7 +1215,10 @@ class Search(ViewContainer):
artist = self._model.get_value(_iter, 2) artist = self._model.get_value(_iter, 2)
albums = self._artists[artist.casefold()]['albums'] albums = self._artists[artist.casefold()]['albums']
self._artistAlbumsWidget = Widgets.ArtistAlbums(artist, albums, self.player) self._artistAlbumsWidget = Widgets.ArtistAlbums(
artist, albums, self.player,
self.header_bar, self.selection_toolbar
)
self.add(self._artistAlbumsWidget) self.add(self._artistAlbumsWidget)
self.header_bar.set_state(ToolbarState.SEARCH_VIEW) self.header_bar.set_state(ToolbarState.SEARCH_VIEW)
......
...@@ -320,11 +320,14 @@ class AlbumWidget(Gtk.EventBox): ...@@ -320,11 +320,14 @@ class AlbumWidget(Gtk.EventBox):
class ArtistAlbums(Gtk.VBox): class ArtistAlbums(Gtk.VBox):
@log @log
def __init__(self, artist, albums, player): def __init__(self, artist, albums, player, header_bar, selection_toolbar):
Gtk.VBox.__init__(self) Gtk.VBox.__init__(self)
self.player = player self.player = player
self.artist = artist self.artist = artist
self.albums = albums self.albums = albums
self.selectionMode = False
self.selection_toolbar = selection_toolbar
self.header_bar = header_bar
self.ui = Gtk.Builder() self.ui = Gtk.Builder()
self.ui.add_from_resource('/org/gnome/Music/ArtistAlbumsWidget.ui') self.ui.add_from_resource('/org/gnome/Music/ArtistAlbumsWidget.ui')
self.set_border_width(0) self.set_border_width(0)
...@@ -415,12 +418,19 @@ class ArtistAlbums(Gtk.VBox): ...@@ -415,12 +418,19 @@ class ArtistAlbums(Gtk.VBox):
itr = self.model.iter_next(itr) itr = self.model.iter_next(itr)
return False return False
@log
def set_selection_mode(self, selectionMode):
self.selectionMode = selectionMode
for widget in self.widgets:
widget.set_selection_mode(selectionMode)
class AllArtistsAlbums(ArtistAlbums): class AllArtistsAlbums(ArtistAlbums):
@log @log
def __init__(self, player): def __init__(self, player, header_bar, selection_toolbar):
ArtistAlbums.__init__(self, _("All Artists"), [], player) ArtistAlbums.__init__(self, _("All Artists"), [], player,
header_bar, selection_toolbar)
self._offset = 0 self._offset = 0
self._populate() self._populate()
...@@ -446,6 +456,8 @@ class ArtistAlbumWidget(Gtk.HBox): ...@@ -446,6 +456,8 @@ class ArtistAlbumWidget(Gtk.HBox):
self.album = album self.album = album
self.artist = artist self.artist = artist
self.model = model self.model = model
self.model.connect('row-changed', self._model_row_changed)
self.selectionMode = False
self.songs = [] self.songs = []
self.monitors = [] self.monitors = []
self.ui = Gtk.Builder() self.ui = Gtk.Builder()
...@@ -503,6 +515,11 @@ class ArtistAlbumWidget(Gtk.HBox): ...@@ -503,6 +515,11 @@ class ArtistAlbumWidget(Gtk.HBox):
song_widget._iter = itr song_widget._iter = itr
song_widget.model = self.model song_widget.model = self.model
song_widget.title = ui.get_object('title') song_widget.title = ui.get_object('title')
song_widget.checkButton = ui.get_object('select')
song_widget.checkButton.set_visible(self.selectionMode)
song_widget.checkButton.connect(
'toggled', self._check_button_toggled, song_widget
)
self.player.discover_item(track, self._on_discovered, song_widget) self.player.discover_item(track, self._on_discovered, song_widget)
g_file = Gio.file_new_for_uri(track.get_url()) g_file = Gio.file_new_for_uri(track.get_url())
self.monitors.append(g_file.monitor_file(Gio.FileMonitorFlags.NONE, self.monitors.append(g_file.monitor_file(Gio.FileMonitorFlags.NONE,
...@@ -548,11 +565,37 @@ class ArtistAlbumWidget(Gtk.HBox): ...@@ -548,11 +565,37 @@ class ArtistAlbumWidget(Gtk.HBox):
if not widget.can_be_played: if not widget.can_be_played:
return return
if self.selectionMode:
self.model[widget._iter][6] = not self.model[widget._iter][6]
return
self.player.stop() self.player.stop()
self.player.set_playlist('Artist', self.artist, self.player.set_playlist('Artist', self.artist,
widget.model, widget._iter, 5) widget.model, widget._iter, 5)
self.player.set_playing(True) self.player.set_playing(True)
@log
def set_selection_mode(self, selectionMode):
self.selectionMode = selectionMode
for songWidget in self.songs:
songWidget.checkButton.set_visible(selectionMode)
if not selectionMode:
songWidget.model[songWidget._iter][6] = False
@log
def _check_button_toggled(self, button, songWidget):
if songWidget.model[songWidget._iter][6] != button.get_active():
songWidget.model[songWidget._iter][6] = button.get_active()
@log
def _model_row_changed(self, model, path, _iter):
if not model[_iter][5]:
return
songWidget = model[_iter][5].song_widget
selected = model[_iter][6]
if selected != songWidget.checkButton.get_active():
songWidget.checkButton.set_active(selected)
class PlaylistDialog(): class PlaylistDialog():
@log @log
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment