[gnome-music/wip/jfelder/gtk4-v3: 62/118] albumwidget: Enable song activation
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/gtk4-v3: 62/118] albumwidget: Enable song activation
- Date: Thu, 3 Feb 2022 01:07:15 +0000 (UTC)
commit 6b7c885c316a68394365cc1a48420d1e1a0cedc2
Author: Marinus Schraal <mschraal gnome org>
Date: Sun Apr 25 17:11:29 2021 +0200
albumwidget: Enable song activation
gnomemusic/widgets/albumwidget.py | 7 ++---
gnomemusic/widgets/discbox.py | 58 +++++++++++++++++++--------------------
2 files changed, 32 insertions(+), 33 deletions(-)
---
diff --git a/gnomemusic/widgets/albumwidget.py b/gnomemusic/widgets/albumwidget.py
index 8df57d5b9..6e870a763 100644
--- a/gnomemusic/widgets/albumwidget.py
+++ b/gnomemusic/widgets/albumwidget.py
@@ -39,7 +39,6 @@ if typing.TYPE_CHECKING:
from gnomemusic.coreartist import CoreArtist
from gnomemusic.coredisc import CoreDisc
from gnomemusic.coresong import CoreSong
- from gnomemusic.widgets.songwidget import SongWidget
@Gtk.Template(resource_path='/org/gnome/Music/ui/AlbumWidget.ui')
@@ -260,12 +259,12 @@ class AlbumWidget(Gtk.Box):
self._coremodel.props.active_core_object = self.props.active_coreobject
def _song_activated(
- self, widget: Gtk.Widget, song_widget: SongWidget) -> None:
+ self, widget: Gtk.Widget, coresong: CoreSong) -> None:
if self.props.selection_mode:
- song_widget.props.selected = not song_widget.props.selected
+ coresong.props.selected = not coresong.props.selected
return
- self._play(song_widget.props.coresong)
+ self._play(coresong)
def select_all(self) -> None:
if self._album_model:
diff --git a/gnomemusic/widgets/discbox.py b/gnomemusic/widgets/discbox.py
index fa9f3f9ef..ff56180a5 100644
--- a/gnomemusic/widgets/discbox.py
+++ b/gnomemusic/widgets/discbox.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
from gnomemusic.widgets.songwidgetmenu import SongWidgetMenu
if typing.TYPE_CHECKING:
@@ -49,7 +50,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)
@@ -85,6 +86,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"""
for coresong in self._model:
@@ -109,31 +112,28 @@ 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]