From 8a150e35136e1f1bdfd09c0cd0a648b8947c83c9 Mon Sep 17 00:00:00 2001 From: QC Date: Mon, 29 Dec 2014 15:24:21 +0100 Subject: [PATCH] Improve rating widget. --- src/Widgets/gmpc-rating.vala | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Widgets/gmpc-rating.vala b/src/Widgets/gmpc-rating.vala index e280b2d3..e1b13abd 100644 --- a/src/Widgets/gmpc-rating.vala +++ b/src/Widgets/gmpc-rating.vala @@ -49,16 +49,17 @@ public class Gmpc.Rating : Gtk.Frame } public bool button_press_event_callback(Gtk.Widget wid, Gdk.EventButton event) { - if(event.type == Gdk.EventType.BUTTON_PRESS) + if(event.type == Gdk.EventType.BUTTON_RELEASE) { if(event.button == 1) { Gtk.Allocation ns; this.event_box.get_allocation(out ns); int width = ns.width; - int button = (int)((((event.x)/(double)width)+0.15)*10); - MPD.Sticker.Song.set(this.server, this.song.file, "rating", button.to_string()); - this.set_rating(button/2); + int button = (int)((((event.x)/(double)width)+0.15)*5); + if(button == rating) { button = 0; } + MPD.Sticker.Song.set(this.server, this.song.file, "rating", (button*2).to_string()); + this.set_rating(button); } } @@ -99,7 +100,7 @@ public class Gmpc.Rating : Gtk.Frame } this.event_box.add(this.box); - this.event_box.button_press_event.connect(button_press_event_callback); + this.event_box.button_release_event.connect(button_press_event_callback); this.add(this.event_box); this.show_all(); } -- 2.11.4.GIT