[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: Tue, 15 Jan 2019 02:06:50 +0000 (UTC)
commit 5d7343f042e21a0fc38dc22c10db2631a12c4151
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 9dd7253d..a2129836 100644
--- a/data/ui/AlbumWidget.ui
+++ b/data/ui/AlbumWidget.ui
@@ -218,7 +218,7 @@
</packing>
</child>
<child>
- <object class="GtkScrolledWindow" id="scrolledWindow">
+ <object class="GtkScrolledWindow" id="_scrolledWindow">
<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 ecdc2c93..e91d33bd 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, Gtk
+from gi.repository import Gdk, GdkPixbuf, GObject, 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()
+ _scrolledWindow = Gtk.Template.Child()
_running_info_label = Gtk.Template.Child()
_title_label = Gtk.Template.Child()
@@ -93,6 +94,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."""
@@ -280,3 +284,14 @@ class AlbumWidget(Gtk.EventBox):
:rtype: list
"""
return self._disc_listbox.get_selected_items()
+
+ 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.scrolledWindow.props.vadjustment
+ vadjust.props.value += delta * vadjust.props.step_increment
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]