1 /* Gnome Music Player Client (GMPC)
2 * Copyright (C) 2004-2012 Qball Cow <qball@gmpclient.org>
3 * Project homepage: http://gmpclient.org/
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.
21 * This plugin adds a search field to the sidebar
28 private const bool use_transition_snsong
= Gmpc
.use_transition
;
29 private const string some_unique_name_snsong
= Config
.VERSION
;
31 public class Gmpc
.Plugins
.SidebarNextSong
: Gmpc
.Plugin
.Base
, Gmpc
.Plugin
.SidebarIface
34 private Grid hbox
= null;
35 private Gmpc
.MetaData
.Image AlbumImage
= null;
36 private Label label
= null;
38 private const int[] version
= {0,0,0};
39 private void status_changed(MPD
.Server mi
, MPD
.Status
.Changed what
)
41 if(hbox
== null) return;
42 if((what
&MPD
.Status
.Changed
.NEXTSONG
) == MPD
.Status
.Changed
.NEXTSONG
)
47 public SidebarNextSong()
49 Gmpc
.gmpcconn
.status_changed
.connect(status_changed
);
53 public override unowned
int[] get_version()
58 public override unowned
string get_name()
60 return "Sidebar Next Song";
64 /* We don't want a title */
65 public string sidebar_get_title()
70 public int sidebar_get_position()
74 public void sidebar_set_state(Gmpc
.Plugin
.SidebarState state
)
76 if(hbox
== null) return;
77 if(state
== Plugin
.SidebarState
.COLLAPSED
)
91 int id
= Gmpc
.server
.player_get_next_song_id();
93 // Make sure the image is redrawn.
94 AlbumImage
.set_dirty();
97 MPD
.Song? song
= Gmpc
.server
.playlist_get_song(id
);
98 AlbumImage
.update_from_song(song
);
99 char[] buffer
= new
char[1024];
100 song
.markup(buffer
, "%title%[\n%artist%]");
101 label
.set_text((string )buffer
);
102 hbox
.set_tooltip_text((string)buffer
);
106 AlbumImage
.set_cover_na();
110 public void sidebar_pane_construct(Gtk
.Grid parent
)
113 hbox
.set_halign(Gtk
.Align
.FILL
);
114 hbox
.set_column_spacing(6);
116 AlbumImage
= new Gmpc
.MetaData
.Image(Gmpc
.MetaData
.Type
.ALBUM_ART
, 32);
117 hbox
.add(AlbumImage
);//, false, true, 0);
118 AlbumImage
.has_tooltip
= false;
120 label
= new Gtk
.Label("");
121 label
.set_hexpand(true);
122 label
.set_alignment(0f
, 0.5f
);
123 label
.set_halign(Gtk
.Align
.FILL
);
124 label
.set_max_width_chars(3);
125 label
.set_ellipsize(Pango
.EllipsizeMode
.END
);
126 hbox
.add(label
);//, true, true, 0);
128 parent
.attach(hbox
,0,1,1,1);//, false, false, 0);
131 this
.sidebar_set_state(Gmpc
.Playlist
.get_sidebar_state());
134 public void sidebar_pane_destroy(Gtk
.Grid parent
)
136 foreach(Gtk
.Widget child
in parent
.get_children())
138 parent
.remove(child
);