1
/* Gnome Music Player Client (GMPC)
2
* Copyright (C) 2004-2011 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.
24
private const bool use_transition_tp = Gmpc.use_transition;
26
public class Gmpc.MetaData.EditWindow : Gtk.Window {
27
private const string some_unique_name = Config.VERSION;
28
private MPD.Song? song = null;
29
private Gmpc.MetaData.Type query_type = Gmpc.MetaData.Type.ALBUM_ART;
31
private GLib.List<unowned Gmpc.AsyncDownload.Handle> downloads = null;
32
/** fetching handles */
33
private void *handle = null;
34
private void *handle2 = null;
36
private Gtk.HBox pbox = null;
37
private Gtk.Label warning_label = null;
38
private Gtk.Entry artist_entry;
39
private Gtk.Entry album_entry;
40
private Gtk.Entry title_entry;
41
private Gtk.Button cancel = null;
42
private Gtk.Button refresh = null;
43
private Gtk.ComboBox combo = null;
44
private Gtk.ProgressBar bar = null;
46
private Gtk.ScrolledWindow sw = null;
47
private Gtk.EventBox ilevent = null;
49
private Gtk.VBox itemslist = new Gtk.VBox(false, 6);
52
this.type = Gtk.WindowType.TOPLEVEL;
53
int height = config.get_int_with_default(
54
"Metadata Selector" , "window_height", 600);
55
int width = config.get_int_with_default(
56
"Metadata Selector" , "window_width", 480);
58
this.resize(width,height);
59
this.set_border_width(8);
60
/* Connect to allocation changes so I can store new size */
61
this.size_allocate.connect((source, alloc) => {
63
"Metadata Selector" , "window_width", alloc.width);
66
"Metadata Selector" , "window_height", alloc.height);
70
private void add_entry_image(string? provider, string uri,Gdk.PixbufFormat? format, Gdk.Pixbuf pb, bool is_raw = false, bool is_thumbnail = false)
73
a = "";// Markup.printf_escaped("<b>%s</b>: %s",_("Uri"),uri);
74
if(provider != null) {
75
a+= Markup.printf_escaped("\n<b>%s</b>: %s",_("Provider"), provider);
79
a+= Markup.printf_escaped("\n<b>%s</b>: %s",_("Filetype"), format.get_name());
84
a+="\n<b>%s</b>: %ix%i (%s) (%s)".printf(_("Size"), pb.width, pb.height,_("width x height"),
85
_("high-res image will be downloaded"));
87
a+="\n<b>%s</b>: %ix%i (%s)".printf(_("Size"), pb.width, pb.height,_("width x height"));
92
if(pb.width < pb.height) {
94
new_w = (int)((150.0/(double)pb.height)*pb.width);
99
new_h = (int)((150.0/(double)pb.width)*pb.height);
103
var hbox = new Gtk.HBox(false, 6);
104
var label = new Gtk.Label("");
105
label.set_ellipsize(Pango.EllipsizeMode.MIDDLE);
107
label.set_line_wrap(true);
108
label.set_alignment(0.0f, 0.5f);
110
var image = new Gtk.Image.from_pixbuf(pb.scale_simple(new_w,new_h,Gdk.InterpType.BILINEAR));
111
image.set_size_request(180,-1);
112
hbox.pack_start(image, false, true, 0);
113
hbox.pack_start(label, true, true, 0);
116
var ali = new Gtk.Alignment(0f,0f,0f,0f);
117
var button = new Gtk.Button.with_label(_("Set"));
119
button.set_data_full("path",(void *)uri.dup(),(GLib.DestroyNotify)g_free);
121
button.set_data_full("data",(void *)uri.dup(),(GLib.DestroyNotify)g_free);
124
hbox.pack_start(ali, false, true, 0);
125
button.clicked.connect(set_metadata);
128
this.itemslist.pack_start(hbox,false, true, 0);
129
var sep = new Gtk.HSeparator();
130
sep.set_size_request(-1, 4);
132
this.itemslist.pack_start(sep, false, true, 0);
136
private void add_entry_text(string? provider, string uri,string text)
139
a = "";// "<b>%s</b>: %s".printf(_("Uri"),uri);
140
if(provider != null) {
141
a+="\n<b>%s</b>: %s".printf(_("Provider"), provider);
143
var hbox = new Gtk.HBox(false, 6);
144
var label = new Gtk.Label("");
146
label.set_ellipsize(Pango.EllipsizeMode.MIDDLE);
147
label.set_line_wrap(true);
148
label.set_alignment(0.0f, 0.0f);
149
label.set_size_request(280,-1);
150
hbox.pack_start(label, false, true, 0);
152
var text_label = new Gtk.Label(text);
153
text_label.set_ellipsize(Pango.EllipsizeMode.END);
154
text_label.set_alignment(0.0f, 0.0f);
155
text_label.set_size_request(180,-1);
156
hbox.pack_start(text_label, true, true, 0);
158
var ali = new Gtk.Alignment(0f,0f,0f,0f);
159
var button = new Gtk.Button.with_label(_("Set"));
160
button.set_data_full("lyrics",(void *)text.dup(),(GLib.DestroyNotify)g_free);
162
hbox.pack_start(ali, false, true, 0);
163
button.clicked.connect(set_metadata);
166
this.itemslist.pack_start(hbox,false, true, 0);
167
var sep = new Gtk.HSeparator();
168
sep.set_size_request(-1, 4);
170
this.itemslist.pack_start(sep, false, true, 0);
173
public void image_downloaded(Gmpc.AsyncDownload.Handle handle, Gmpc.AsyncDownload.Status status, void *p)
175
MetaData.Item *item = (MetaData.Item *)p;
176
GLib.assert(item != null);
177
if(status == Gmpc.AsyncDownload.Status.PROGRESS) return;
178
this.downloads.remove(handle);
180
if(status == Gmpc.AsyncDownload.Status.DONE)
182
unowned uchar[] data = handle.get_data<uchar[]>();
183
if(this.query_type == Gmpc.MetaData.Type.ALBUM_ART || this.query_type == Gmpc.MetaData.Type.ARTIST_ART)
186
var load = new Gdk.PixbufLoader();
190
GLib.debug("Failed to load file: %s::%s\n",e.message,handle.get_uri());
194
Gdk.Pixbuf pb = load.get_pixbuf();
196
this.add_entry_image((string)handle.get_user_data(),
201
(item->get_thumbnail_uri() != null));
203
GLib.debug("Failed to load file: %s::%s\n",e.message,handle.get_uri());
208
this.add_entry_text((string)handle.get_user_data(),handle.get_uri(),(string)data);
212
if(this.handle == null && this.handle2 == null && this.downloads == null)
215
this.refresh.sensitive = true;
216
this.ilevent.sensitive = true;
217
this.combo.sensitive = true;
221
public void callback(void *handle,string? plugin_name,GLib.List<MetaData.Item>? list)
225
if(this.handle == handle)
228
if(this.handle == null && this.downloads == null)
231
this.refresh.sensitive = true;
232
this.ilevent.sensitive = true;
233
this.combo.sensitive = true;
236
if(this.handle2 == handle)
241
if(this.handle == null && this.downloads == null)
244
this.combo.sensitive = true;
245
this.ilevent.sensitive = true;
246
this.refresh.sensitive = true;
250
foreach(unowned MetaData.Item md in list)
253
if(this.query_type == Gmpc.MetaData.Type.ALBUM_ART || this.query_type == Gmpc.MetaData.Type.ARTIST_ART)
255
if(md.content_type == Gmpc.MetaData.ContentType.URI)
257
if(md.content_type == Gmpc.MetaData.ContentType.URI)
259
unowned string uri = null;
260
if(md.get_thumbnail_uri() != null) {
261
uri = md.get_thumbnail_uri();
267
Gdk.Pixbuf pb = new Gdk.Pixbuf.from_file(uri);
271
add_entry_image(plugin_name, uri,Gdk.Pixbuf.get_file_info(uri,out w, out h), pb);
278
MetaData.Item *item = MetaData.Item.copy(md);
279
var h = Gmpc.AsyncDownload.download_vala(uri,(void *)item,image_downloaded);
282
h.set_user_data(md.plugin_name);
283
this.downloads.append(h);
287
}else if (md.content_type == Gmpc.MetaData.ContentType.RAW){
288
var data = md.get_raw();
289
var load = new Gdk.PixbufLoader();
293
GLib.debug("Failed to load raw data: %s\n",e.message);
298
GLib.debug("Failed to close loader: %s\n",e.message);
301
Gdk.Pixbuf pb = load.get_pixbuf();
303
var base16 = GLib.Base64.encode(data);
304
this.add_entry_image(plugin_name,base16,load.get_format(),pb,true);
309
if(md.content_type == Gmpc.MetaData.ContentType.TEXT)
311
unowned string uri = md.get_text();
312
add_entry_text(plugin_name, "n/a", uri);
315
if(md.content_type == Gmpc.MetaData.ContentType.HTML)
317
string uri = md.get_text_from_html();
318
add_entry_text(plugin_name, "n/a", uri);
321
if(md.content_type == Gmpc.MetaData.ContentType.URI)
323
unowned string uri = md.get_uri();
327
if(GLib.FileUtils.get_contents(uri,out content))
329
add_entry_text(plugin_name,uri, content);
342
public void store_image(Gmpc.AsyncDownload.Handle handle, Gmpc.AsyncDownload.Status status)
344
if(status == Gmpc.AsyncDownload.Status.PROGRESS){
345
unowned uchar[] data =handle.get_data<uchar[]>();
346
this.sensitive = false;
348
int64 total_size = handle.get_content_size();
349
if(data.length > 0 && total_size > 0){
350
double progress = data.length/(double)total_size;
351
this.bar.set_fraction(progress);
353
else this.bar.pulse();
356
this.downloads.remove(handle);
357
if(status == Gmpc.AsyncDownload.Status.DONE)
359
unowned uchar[] data = handle.get_data<uchar[]>();
360
var file = Gmpc.MetaData.get_metadata_filename(this.query_type, this.song,null);
362
GLib.FileUtils.set_contents(file, (string)data, (long)data.length);
363
var met = new MetaData.Item();
364
met.type = this.query_type;
365
met.plugin_name = "User set";
366
met.content_type = MetaData.ContentType.URI;
368
Gmpc.MetaData.set_metadata(this.song, Gmpc.MetaData.Result.AVAILABLE, met);
370
var met_false = new MetaData.Item();
371
met_false.type = this.query_type;
372
met_false.plugin_name = "User set";
373
met_false.content_type = MetaData.ContentType.EMPTY;
374
metawatcher.data_changed(this.song, this.query_type, Gmpc.MetaData.Result.UNAVAILABLE, met_false);
375
metawatcher.data_changed(this.song, this.query_type, Gmpc.MetaData.Result.AVAILABLE, met);
381
this.sensitive = true;
385
set_metadata(Gtk.Button button)
388
if(this.query_type == Gmpc.MetaData.Type.ALBUM_ART || this.query_type == Gmpc.MetaData.Type.ARTIST_ART)
390
path = (string)button.get_data<string>("path");
395
var met = new MetaData.Item();
396
met.type = this.query_type;
397
met.plugin_name = "User set";
398
met.content_type = MetaData.ContentType.URI;
400
Gmpc.MetaData.set_metadata(this.song, Gmpc.MetaData.Result.AVAILABLE, met);
402
var met_false = new MetaData.Item();
403
met_false.type = this.query_type;
404
met_false.plugin_name = "User set";
405
met_false.content_type = MetaData.ContentType.EMPTY;
406
metawatcher.data_changed(this.song, this.query_type, Gmpc.MetaData.Result.UNAVAILABLE, met_false);
407
metawatcher.data_changed(this.song, this.query_type, Gmpc.MetaData.Result.AVAILABLE, met);
409
var h = Gmpc.AsyncDownload.download(path, store_image);
411
this.downloads.append(h);
414
string base64 =(string)button.get_data<string>("data");
416
string filename = Gmpc.MetaData.get_metadata_filename(this.query_type,this.song, null);
417
uchar[] data = GLib.Base64.decode(base64 );
419
GLib.FileUtils.set_contents(filename, (string)data, (ssize_t)data.length);
421
var met = new MetaData.Item();
422
met.type = this.query_type;
423
met.plugin_name = "User set";
424
met.content_type = MetaData.ContentType.URI;
425
met.set_uri(filename);
426
Gmpc.MetaData.set_metadata(this.song, Gmpc.MetaData.Result.AVAILABLE, met);
428
var met_false = new MetaData.Item();
429
met_false.type = this.query_type;
430
met_false.plugin_name = "User set";
431
met_false.content_type = MetaData.ContentType.EMPTY;
432
metawatcher.data_changed(this.song, this.query_type, Gmpc.MetaData.Result.UNAVAILABLE, met_false);
433
metawatcher.data_changed(this.song, this.query_type, Gmpc.MetaData.Result.AVAILABLE, met);
442
lyric = (string)button.get_data<string>("lyrics");
443
var file = Gmpc.MetaData.get_metadata_filename(this.query_type, this.song,null);
445
GLib.FileUtils.set_contents(file,lyric, -1);
446
var met = new MetaData.Item();
447
met.type = this.query_type;
448
met.plugin_name = "User set";
449
met.content_type = MetaData.ContentType.URI;
451
Gmpc.MetaData.set_metadata(this.song, Gmpc.MetaData.Result.AVAILABLE, met);
453
var met_false = new MetaData.Item();
454
met_false.type = this.query_type;
455
met_false.plugin_name = "User set";
456
met_false.content_type = MetaData.ContentType.EMPTY;
457
metawatcher.data_changed(this.song, this.query_type, Gmpc.MetaData.Result.UNAVAILABLE, met_false);
458
metawatcher.data_changed(this.song, this.query_type, Gmpc.MetaData.Result.AVAILABLE, met);
468
destroy_popup(Gtk.Button button)
472
private void clear_itemslist()
474
foreach(Gtk.Widget client in this.itemslist.get_children())
480
public void refresh_query(Gtk.Button button)
483
GLib.log("MetadataSelector", GLib.LogLevelFlags.LEVEL_DEBUG, "Query metadata");
484
MPD.Song ss = this.song.copy();
485
ss.artist = this.artist_entry.get_text();
486
ss.album = this.album_entry.get_text();
487
ss.title = this.title_entry.get_text();
489
if(this.handle == null && this.handle2 == null) {
491
this.refresh.sensitive = false;
492
this.combo.sensitive = false;
493
this.ilevent.sensitive = false;
494
GLib.log("MetadataSelector", GLib.LogLevelFlags.LEVEL_DEBUG,"Start metdata get_list query");
495
this.handle = Gmpc.MetaData.get_list(ss, this.query_type, callback);
496
GLib.log("MetadataSelector", GLib.LogLevelFlags.LEVEL_DEBUG,"Wait");
500
private void combo_box_changed(Gtk.ComboBox comb)
503
int active = comb.active;
504
this.title_entry.sensitive = false;
505
this.album_entry.sensitive = false;
506
this.artist_entry.sensitive = false;
507
this.refresh.sensitive = false;
508
this.warning_label.hide();
511
this.query_type = Gmpc.MetaData.Type.ARTIST_ART;
512
if(this.song.artist != null)
514
this.artist_entry.sensitive = true;
515
this.refresh.sensitive = true;
517
else this.warning_label.show();
518
}else if (active == 1) {
519
this.query_type = Gmpc.MetaData.Type.ALBUM_ART;
521
if(this.song.artist != null && this.song.album != null)
523
this.artist_entry.sensitive = true;
524
this.album_entry.sensitive = true;
525
this.refresh.sensitive = true;
527
else this.warning_label.show();
528
} else if (active == 2) {
529
this.query_type = Gmpc.MetaData.Type.SONG_TXT;
531
if(this.song.artist != null && this.song.title != null)
533
this.artist_entry.sensitive = true;
534
this.title_entry.sensitive = true;
535
this.refresh.sensitive = true;
537
else this.warning_label.show();
538
}else if (active == 3) {
539
this.query_type = Gmpc.MetaData.Type.ALBUM_TXT;
541
if(this.song.artist != null && this.song.album != null)
543
this.artist_entry.sensitive = true;
544
this.album_entry.sensitive = true;
545
this.refresh.sensitive = true;
547
else this.warning_label.show();
548
}else if (active == 4) {
549
this.query_type = Gmpc.MetaData.Type.ARTIST_TXT;
551
if(this.song.artist != null)
553
this.artist_entry.sensitive = true;
554
this.refresh.sensitive = true;
556
else this.warning_label.show();
557
}else if (active == 5) {
558
this.query_type = Gmpc.MetaData.Type.SONG_GUITAR_TAB;
560
if(this.song.artist != null && this.song.title != null)
562
this.artist_entry.sensitive = true;
563
this.title_entry.sensitive = true;
564
this.refresh.sensitive = true;
566
else this.warning_label.show();
571
EditWindow (MPD.Song song, Gmpc.MetaData.Type type) {
572
var vbox = new Gtk.VBox(false, 6);
573
this.song = song.copy();
574
this.query_type = type;
575
this.pbox = new Gtk.HBox(false, 6);
576
this.bar = new Gtk.ProgressBar();
577
vbox.pack_start(this.pbox, false, false, 0);
578
this.cancel = new Gtk.Button.from_stock("gtk-cancel");
579
this.cancel.clicked.connect(this.b_cancel);
580
this.pbox.pack_start(this.bar, true, true, 0);
581
this.pbox.pack_start(this.cancel, false, false, 0);
584
this.pbox.no_show_all = true;
587
sw = new Gtk.ScrolledWindow(null, null);
589
sw.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC);
590
sw.set_shadow_type(Gtk.ShadowType.ETCHED_IN);
594
var hbox = new Gtk.HBox(false, 6);
596
var button = new Gtk.Button.from_stock("gtk-quit");
597
button.clicked.connect(destroy_popup);
598
hbox.pack_end(button, false, false, 0);
599
vbox.pack_end(hbox, false, false,0);
602
this.warning_label = new Gtk.Label("");
603
this.warning_label.set_markup("<span size='x-large'>%s</span>".printf(_("Insufficient information to store/fetch this metadata")));
604
this.warning_label.set_alignment(0.0f, 0.5f);
605
vbox.pack_start(this.warning_label, false, false, 0);
606
this.warning_label.hide();
608
var group = new Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL);
609
var qhbox = new Gtk.HBox(false, 6);
610
Gtk.Label label = null;
612
var list = new Gtk.ListStore(2,typeof(string), typeof(string),-1);
613
list.insert_with_values(null, -1, 0, "media-artist", 1, _("Artist art"));
614
list.insert_with_values(null, -1, 0, "media-album", 1, _("Album art"));
615
list.insert_with_values(null, -1, 0, "gtk-dnd", 1, _("Song lyrics"));
616
list.insert_with_values(null, -1, 0, "media-album", 1, _("Album Info"));
617
list.insert_with_values(null, -1, 0, "media-artist", 1, _("Artist Biography"));
618
list.insert_with_values(null, -1, 0, "media-album", 1, _("Guitar Tab"));
620
this.combo = new Gtk.ComboBox.with_model(list);
622
Gtk.CellRenderer renderer = new Gtk.CellRendererPixbuf();
623
this.combo.pack_start(renderer,false);
624
this.combo.add_attribute(renderer, "icon-name", 0);
625
renderer = new Gtk.CellRendererText();
626
this.combo.pack_start(renderer,true);
627
this.combo.add_attribute(renderer, "text", 1);
629
qhbox.pack_start(this.combo, true,true,0);
630
this.combo.changed.connect(combo_box_changed);
632
vbox.pack_start(qhbox, false, false, 0);
635
qhbox = new Gtk.HBox(false, 6);
637
label = new Gtk.Label(_("Artist"));
638
label.set_alignment(0.0f, 0.5f);
639
group.add_widget(label);
640
qhbox.pack_start(label, false, false, 0);
641
var image = new Gtk.Image.from_icon_name("media-artist", Gtk.IconSize.BUTTON);
642
qhbox.pack_start(image, false, false, 0);
644
this.artist_entry = new Gtk.Entry();
645
this.artist_entry.set_text(song.artist);
646
qhbox.pack_start(this.artist_entry, true, true, 0);
647
vbox.pack_start(qhbox, false, false, 0);
649
qhbox = new Gtk.HBox(false, 6);
650
label = new Gtk.Label(_("Album"));
651
label.set_alignment(0.0f, 0.5f);
652
group.add_widget(label);
653
qhbox.pack_start(label, false, false, 0);
654
image = new Gtk.Image.from_icon_name("media-album", Gtk.IconSize.BUTTON);
655
qhbox.pack_start(image, false, false, 0);
656
this.album_entry = new Gtk.Entry();
657
if(song.album != null)
658
this.album_entry.set_text(song.album);
659
qhbox.pack_start(this.album_entry, true, true, 0);
660
vbox.pack_start(qhbox, false, false, 0);
662
qhbox = new Gtk.HBox(false, 6);
663
label = new Gtk.Label(_("Title"));
664
label.set_alignment(0.0f, 0.5f);
665
group.add_widget(label);
666
qhbox.pack_start(label, false, false, 0);
667
image = new Gtk.Image.from_icon_name("media-audiofile", Gtk.IconSize.BUTTON);
668
qhbox.pack_start(image, false, false, 0);
669
this.title_entry = new Gtk.Entry();
670
if(song.title != null)
671
this.title_entry.set_text(song.title);
672
qhbox.pack_start(this.title_entry, true, true, 0);
674
vbox.pack_start(qhbox, false, false, 0);
676
if(type != Gmpc.MetaData.Type.ALBUM_ART)
677
this.album_entry.sensitive = false;
680
this.refresh = button = new Gtk.Button.with_label(_("Query"));
681
var ali = new Gtk.Alignment(1.0f, 0.5f, 0.0f, 0.0f);
683
vbox.pack_start(ali, false, false, 0);
684
button.clicked.connect(refresh_query);
688
vbox.pack_start(sw, true, true,0);
690
this.hide_on_delete();
692
ilevent = new Gtk.EventBox();
693
this.itemslist.border_width = 8;
694
ilevent.visible_window = true;
695
ilevent.modify_bg(Gtk.StateType.NORMAL,this.style.base[Gtk.StateType.NORMAL]);
696
this.style_set.connect((source, old) => {
697
this.itemslist.get_parent().modify_bg(Gtk.StateType.NORMAL,this.style.base[Gtk.StateType.NORMAL]);
699
// ilevent.modify_bg(Gtk.StateType.NORMAL,this.style.base[Gtk.StateType.NORMAL]);
701
ilevent.add(itemslist);
702
sw.add_with_viewport(ilevent);
705
if(type == Gmpc.MetaData.Type.ARTIST_ART) this.combo.set_active(0);
706
else if(type == Gmpc.MetaData.Type.ALBUM_ART) this.combo.set_active(1);
707
else if(type == Gmpc.MetaData.Type.SONG_TXT) this.combo.set_active(2);
708
else if(type == Gmpc.MetaData.Type.ALBUM_TXT) this.combo.set_active(3);
709
else if(type == Gmpc.MetaData.Type.ARTIST_TXT)this.combo.set_active(4);
710
else if(type == Gmpc.MetaData.Type.SONG_GUITAR_TAB)this.combo.set_active(5);
711
refresh_query(button);
713
public void b_cancel(){
714
if(this.handle != null){
715
Gmpc.MetaData.get_list_cancel(this.handle);
718
if(this.handle2 != null){
719
Gmpc.MetaData.get_list_cancel(this.handle2);
722
this.downloads.first();
723
while(this.downloads != null){
724
Gmpc.AsyncDownload.Handle handle = this.downloads.data;
727
this.downloads.first();
731
this.refresh.sensitive = true;
732
this.combo.sensitive = true;
741
public class Gmpc.TestPlugin : Gmpc.Plugin.Base,Gmpc.Plugin.ToolMenuIface, Gmpc.Plugin.SongListIface {
742
private const int[] version = {0,0,2};
743
/*********************************************************************************
744
* Plugin base functions
745
* These functions are required.
746
********************************************************************************/
748
/* Mark the plugin as an internal dummy */
749
this.plugin_type = 8+4;
751
public override unowned int[] get_version() {
755
* The name of the plugin
757
public override unowned string get_name() {
758
return "Vala test plugin";
762
* Tells the plugin to save itself
764
public override void save_yourself()
766
/* nothing to save */
772
public override bool get_enabled() {
773
return (bool)config.get_int_with_default(this.get_name(), "enabled", 1);
775
public override void set_enabled(bool state) {
776
config.set_int(this.get_name(), "enabled", (int)state);
781
/*********************************************************************************
783
********************************************************************************/
784
private void menu_activate_tree(Gtk.MenuItem item)
787
Gtk.TreeView tv = (Gtk.TreeView)item.get_data<string>("treeview");
788
Gtk.TreeModel model = tv.get_model();
789
var selection = tv.get_selection();
790
foreach(unowned Gtk.TreePath path in selection.get_selected_rows(out model))
792
if(model.get_iter(out iter, path))
794
unowned MPD.Song? song = null;
795
model.get(iter,0, out song);
798
new Gmpc.MetaData.EditWindow(song,Gmpc.MetaData.Type.ALBUM_ART);
805
public int song_list(Gtk.Widget tree, Gtk.Menu menu)
807
Gtk.TreeView tv = (Gtk.TreeView)tree;
808
var selection = tv.get_selection();
809
if(selection.count_selected_rows() > 0)
811
Gtk.ImageMenuItem item = new Gtk.ImageMenuItem.with_label(_("Metadata selector"));
812
item.set_image( new Gtk.Image.from_stock("gtk-edit", Gtk.IconSize.MENU));
813
item.set_data("treeview", tv);
816
item.activate.connect(menu_activate_tree);
822
public void menu_activated_album(Gtk.MenuItem item)
824
unowned MPD.Song song = server.playlist_get_current_song();
825
new Gmpc.MetaData.EditWindow(song,Gmpc.MetaData.Type.ALBUM_ART);
827
public int tool_menu_integration(Gtk.Menu menu)
829
Gtk.MenuItem item = new Gtk.MenuItem.with_label(_("Edit metadata current song"));
831
item.activate.connect(menu_activated_album);