Project

General

Profile

[PATCH] Add mouse wheel support to volume button

Added by Netslovdlyasnov Netslovdlyasnov almost 12 years ago

Hello.
I've made a patch to allow users to change volume by using mouse wheel on volume button, without clicking on it.
Seems useful to me.
Please comment.

Subject: [PATCH] Add mouse wheel support to volume button

---
src/gtkui/ui_gtk.c | 17 +++++++++++++++
1 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/src/gtkui/ui_gtk.c b/src/gtkui/ui_gtk.c
index 8b560af..dffc15e 100644
--- a/src/gtkui/ui_gtk.c
+++ b/src/gtkui/ui_gtk.c
@ -319,6 +319,22 @ static void ui_volume_released_cb(GtkButton *button, gpointer user_data)
volume_slider_is_moving = FALSE;
}

static void ui_volume_scroll(GtkButton *button, GdkEvent *event, gpointer user_data)
{
+ if (event->scroll.direction == GDK_SCROLL_UP)
+ {
+ int vol = 0;
+ aud_drct_get_volume_main (& vol);
+ aud_drct_set_volume_main (vol + 5);
+ }
+ else if (event->scroll.direction == GDK_SCROLL_DOWN)
+ {
+ int vol = 0;
+ aud_drct_get_volume_main (& vol);
+ aud_drct_set_volume_main (vol - 5);
+ }
}

static gboolean ui_volume_slider_update(gpointer data) {
gint volume;
@ -826,6 +842,7 @ static gboolean init (void)
volume_change_handler_id = g_signal_connect(volume, "value-changed", G_CALLBACK(ui_volume_value_changed_cb), NULL);
g_signal_connect(volume, "pressed", G_CALLBACK(ui_volume_pressed_cb), NULL);
g_signal_connect(volume, "released", G_CALLBACK(ui_volume_released_cb), NULL);
+ g_signal_connect(volume, "scroll-event", G_CALLBACK(ui_volume_scroll), NULL);
update_volume_timeout_source = g_timeout_add(250, (GSourceFunc) ui_volume_slider_update, volume);

g_signal_connect (window, "map-event", (GCallback) window_mapped_cb, NULL);
--
1.7.9.1

Replies (7)

RE: [PATCH] Add mouse wheel support to volume button - Added by Lightning Rose almost 12 years ago

I'm running Audacious v2.5.3 (until Ubuntu 12.04 final release) and the mouse wheel already controls the volume slider. Did this fall out of v3.0?

RE: [PATCH] Add mouse wheel support to volume button - Added by Netslovdlyasnov Netslovdlyasnov almost 12 years ago

With this patch mouse wheel works over the volume button itself, not the volume slider.
This way you don't have to click on it.

RE: [PATCH] Add mouse wheel support to volume button - Added by Joop Braak almost 12 years ago

I don't have to click it, it already works like that. also in v3.

RE: [PATCH] Add mouse wheel support to volume button - Added by Lightning Rose almost 12 years ago

Mousing over the volume button also works with v2.5.3 - I didn't think to try it before.

Netslovdlyasnov, in what version did you find it not to work?

RE: [PATCH] Add mouse wheel support to volume button - Added by Netslovdlyasnov Netslovdlyasnov almost 12 years ago

Oh, well.. Seems like it was working. Strange, but I didn't notice that.
Even it was working, it felt like it wasn't.
I tried several times, but never felt it was working.
When the volume level is about 50% you have to make several rotations to make the icon change, so it feels like it does nothing.
Seems like that is the main problem.
I think some indicator should be involved.

RE: [PATCH] Add mouse wheel support to volume button - Added by Lightning Rose almost 12 years ago

Well, again with v2.5.3 mousing over the volume button I get an indicator showing the volume as a percentage.

I haven't looked at the code, but it appears to be a gtk_tooltips object. Are you using a non-English version? If so, could it be a translation problem in one of the po files?

RE: [PATCH] Add mouse wheel support to volume button - Added by Netslovdlyasnov Netslovdlyasnov almost 12 years ago

So, further investigation revealed that this is not an audacious problem, but gtk-3.4 itself.

    (1-7/7)