[gnome-music/wip/mschraal/gtk4-v2: 53/53] albumwidget: Enable song activation
- From: Marinus Schraal <mschraal src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/mschraal/gtk4-v2: 53/53] albumwidget: Enable song activation
- Date: Sat, 15 May 2021 14:35:24 +0000 (UTC)
commit fb9aa99a95d2db7726158835bb1a120e5d7ac378
Author: Marinus Schraal <mschraal gnome org>
Date: Sun Apr 25 17:11:29 2021 +0200
albumwidget: Enable song activation
gnomemusic/widgets/albumwidget.py | 4 +--
gnomemusic/widgets/disclistboxwidget.py | 58 ++++++++++++++++-----------------
2 files changed, 31 insertions(+), 31 deletions(-)
---
diff --git a/gnomemusic/widgets/albumwidget.py b/gnomemusic/widgets/albumwidget.py
index 81bf52957..6f57b707e 100644
--- a/gnomemusic/widgets/albumwidget.py
+++ b/gnomemusic/widgets/albumwidget.py
@@ -153,7 +153,7 @@ class AlbumWidget(Gtk.Box):
self._running_info_label.props.label = ngettext(
"{} minute", "{} minutes", mins).format(mins)
- def _song_activated(self, widget, song_widget):
+ def _song_activated(self, widget, coresong):
if self.props.selection_mode:
song_widget.props.selected = not song_widget.props.selected
return
@@ -161,7 +161,7 @@ class AlbumWidget(Gtk.Box):
signal_id = None
def _on_playlist_loaded(klass, playlist_type):
- self._player.play(song_widget.props.coresong)
+ self._player.play(coresong)
self._coremodel.disconnect(signal_id)
signal_id = self._coremodel.connect(
diff --git a/gnomemusic/widgets/disclistboxwidget.py b/gnomemusic/widgets/disclistboxwidget.py
index ba002de30..8659a8496 100644
--- a/gnomemusic/widgets/disclistboxwidget.py
+++ b/gnomemusic/widgets/disclistboxwidget.py
@@ -28,6 +28,7 @@ import typing
from gi.repository import Gdk, Gio, GObject, Gtk
+from gnomemusic.coresong import CoreSong
from gnomemusic.widgets.songwidget import SongWidget
if typing.TYPE_CHECKING:
from gnomemusic.coredisc import CoreDisc
@@ -46,7 +47,7 @@ class DiscBox(Gtk.ListBoxRow):
_list_view = Gtk.Template.Child()
__gsignals__ = {
- 'song-activated': (GObject.SignalFlags.RUN_FIRST, None, (Gtk.Widget,))
+ 'song-activated': (GObject.SignalFlags.RUN_FIRST, None, (CoreSong,))
}
selection_mode = GObject.Property(type=bool, default=False)
@@ -75,6 +76,8 @@ class DiscBox(Gtk.ListBoxRow):
resource="/org/gnome/Music/ui/SongListItem.ui")
self._list_view.props.factory = list_item_factory
+ self._list_view.connect("activate", self._song_activated)
+
def select_all(self):
"""Select all songs"""
def child_select_all(child):
@@ -99,34 +102,31 @@ class DiscBox(Gtk.ListBoxRow):
return song_widget
- @Gtk.Template.Callback()
- def _song_activated(
- self, list_box: Gtk.ListBox, song_widget: SongWidget) -> bool:
- if song_widget.props.select_click:
- song_widget.props.select_click = False
- return True
-
- event = Gtk.get_current_event()
- (_, state) = event.get_state()
- mod_mask = Gtk.accelerator_get_default_mod_mask()
- if ((state & mod_mask) == Gdk.ModifierType.CONTROL_MASK
- and not self.props.selection_mode):
- self.props.selection_mode = True
- song_widget.props.select_click = True
- song_widget.props.coresong.props.selected = True
- return True
-
- (_, button) = event.get_button()
- if (button == Gdk.BUTTON_PRIMARY
- and not self.props.selection_mode):
- self.emit("song-activated", song_widget)
-
- if self.props.selection_mode:
- song_widget.props.select_click = True
- selection_state = song_widget.props.coresong.props.selected
- song_widget.props.coresong.props.selected = not selection_state
-
- return True
+ def _song_activated(self, widget, position):
+ self.emit("song-activated", self._model[position])
+ # if widget.props.select_click:
+ # widget.props.select_click = False
+ # return
+
+ # mod_mask = Gtk.accelerator_get_default_mod_mask()
+ # if ((event.get_state() & mod_mask) == Gdk.ModifierType.CONTROL_MASK
+ # and not self.props.selection_mode):
+ # self.props.selection_mode = True
+ # widget.props.select_click = True
+ # widget.props.coresong.props.selected = True
+ # return
+
+ # (_, button) = event.get_button()
+ # if (button == Gdk.BUTTON_PRIMARY
+ # and not self.props.selection_mode):
+ # self.emit('song-activated', widget)
+
+ # if self.props.selection_mode:
+ # widget.props.select_click = True
+ # selection_state = widget.props.coresong.props.selected
+ # widget.props.coresong.props.selected = not selection_state
+
+ # return True
class DiscListBox(Gtk.ListBox):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]