Fix rating menu.
[gmpc.git] / src / Widgets / gmpc-menu-item-rating.vala
blob4add201fc11dc855695b86daacc2da0c754be22a
1 /* Gnome Music Player Client (GMPC)
2 * Copyright (C) 2004-2014 Qball Cow <qball@sarine.nl>
3 * Project homepage: http://gmpc.wikia.com/
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 using GLib;
21 using Config;
22 using Gtk;
23 using Gdk;
24 using Cairo;
25 using MPD;
26 using Gmpc;
29 private const bool use_transition_mir = Gmpc.use_transition;
31 public class Gmpc.MenuItem.Rating : Gtk.MenuItem
33 private const string some_unique_name = Config.VERSION;
34 public Gtk.VBox hbox = null;
35 public Gmpc.Rating rating = null;
36 private int value = 0;
37 private MPD.Song song = null;
38 private unowned MPD.Server server = null;
40 public int get_rating ()
42 return 0;
44 bool button_press_event_callback(Gdk.EventButton event, void *userdata)
46 return true;
49 public Rating (MPD.Server server, MPD.Song song, int value)
51 this.server = server;
52 this.song = song.copy();
53 this.value = value;
54 /* this fixes vala bitching */
55 this.activate.connect(() => {
56 MPD.Sticker.Song.set(this.server, this.song.file, "rating", (value).to_string());
57 });
60 var hbox = new Gtk.Box(Gtk.Orientation.HORIZONTAL,6);
61 for (int i =0; i < 5; i++ ){
62 var image = new Gtk.Image.from_icon_name("rating", Gtk.IconSize.MENU);
63 hbox.pack_start(image, false, false, 0);
64 if(i > (value/2.0 -0.01)) {
65 image.set_sensitive(false);
69 this.add(hbox);
70 this.show_all();