[gnome-music/wip/jfelder/albumwidget-scroll-event] albumWidget: Add scroll-event signal
- From: Jean Felder <jfelder src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music/wip/jfelder/albumwidget-scroll-event] albumWidget: Add scroll-event signal
- Date: Wed, 24 Apr 2019 22:49:50 +0000 (UTC)
commit 5141f8d8a7dd64270527e1fe5675da5f3a370f39
Author: Jean Felder <jfelder src gnome org>
Date: Tue Jan 15 03:06:01 2019 +0100
albumWidget: Add scroll-event signal
data/ui/AlbumWidget.ui | 2 +-
gnomemusic/widgets/albumwidget.py | 17 ++++++++++++++++-
2 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/data/ui/AlbumWidget.ui b/data/ui/AlbumWidget.ui
index 04f70b03..7be54065 100644
--- a/data/ui/AlbumWidget.ui
+++ b/data/ui/AlbumWidget.ui
@@ -205,7 +205,7 @@
</packing>
</child>
<child>
- <object class="GtkScrolledWindow" id="scrolledWindow">
+ <object class="GtkScrolledWindow" id="_scrolled_window">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
diff --git a/gnomemusic/widgets/albumwidget.py b/gnomemusic/widgets/albumwidget.py
index f380ad2e..8134080c 100644
--- a/gnomemusic/widgets/albumwidget.py
+++ b/gnomemusic/widgets/albumwidget.py
@@ -23,7 +23,7 @@
# delete this exception statement from your version.
from gettext import ngettext
-from gi.repository import GdkPixbuf, GObject, Grl, Gtk
+from gi.repository import Gdk, GdkPixbuf, GObject, Grl, Gtk
from gnomemusic import log
from gnomemusic.albumartcache import Art
@@ -51,6 +51,7 @@ class AlbumWidget(Gtk.EventBox):
_cover_stack = Gtk.Template.Child()
_disc_listbox = Gtk.Template.Child()
_released_info_label = Gtk.Template.Child()
+ _scrolled_window = Gtk.Template.Child()
_running_info_label = Gtk.Template.Child()
_title_label = Gtk.Template.Child()
@@ -94,6 +95,9 @@ class AlbumWidget(Gtk.EventBox):
self.bind_property(
'selected-items-count', self._parent_view, 'selected-items-count')
+ self.add_events(Gdk.EventMask.SCROLL_MASK)
+ self.connect("scroll-event", self._album_widget_scrolled)
+
@log
def _create_model(self):
"""Create the ListStore model for this widget."""
@@ -293,3 +297,14 @@ class AlbumWidget(Gtk.EventBox):
:rtype: Grl.Media
"""
return self._album
+
+ def _album_widget_scrolled(self, klass, event):
+ direction = event.direction
+ if direction not in [Gdk.ScrollDirection.DOWN, Gdk.ScrollDirection.UP]:
+ return
+
+ delta = -1.0
+ if direction == Gdk.ScrollDirection.DOWN:
+ delta = 1.0
+ vadjust = self._scrolled_window.props.vadjustment
+ vadjust.props.value += delta * vadjust.props.step_increment
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]