From d63e34369b925cd75b477e6f4ee2676f1701c409 Mon Sep 17 00:00:00 2001 From: Qball Cow Date: Sun, 10 May 2009 17:34:08 +0200 Subject: [PATCH] Add scroll up/down support. --- src/plugin.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/plugin.c b/src/plugin.c index 5a2b444..da63adb 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -166,6 +166,23 @@ void album_size_changed(GtkRange *spin, gpointer user_data) cfg_set_single_value_as_int(config, "albumview", "zoom-level", (int)gtk_range_get_value(spin)); } +static gboolean albumview_scroll_event(GtkWidget *event_box, GdkEventScroll *event, gpointer data) +{ + AlbumViewPlugin *self = ALBUM_VIEW_PLUGIN(data); + if(self->priv->current_item == NULL) return FALSE; + if(event->direction == GDK_SCROLL_UP) + { + int value = gtk_range_get_value(GTK_RANGE(self->priv->slider_scale))-self->priv->supported_columns; + gtk_range_set_value(GTK_RANGE(self->priv->slider_scale), value); + }else if(event->direction == GDK_SCROLL_DOWN) { + int value = gtk_range_get_value(GTK_RANGE(self->priv->slider_scale))+self->priv->supported_columns; + gtk_range_set_value(GTK_RANGE(self->priv->slider_scale), value); + } + + + return FALSE; +} + static void albumview_init(AlbumViewPlugin *self) { /** Get an allready exposed widgets to grab theme colors from. */ @@ -211,6 +228,8 @@ static void albumview_init(AlbumViewPlugin *self) gtk_event_box_set_visible_window(GTK_EVENT_BOX(bg_event), TRUE); gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(event), bg_event); gtk_container_add(GTK_CONTAINER(bg_event), iv); + gtk_widget_add_events(bg_event, GDK_SCROLL_MASK|GDK_BUTTON_PRESS_MASK); + g_signal_connect(G_OBJECT(bg_event), "scroll-event", G_CALLBACK(albumview_scroll_event), self); gtk_widget_show_all(self->priv->albumview_main_box); /* maintain my own reference to the widget, so it won't get destroyed removing -- 2.11.4.GIT