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.
23 private const bool use_transition_mtt
= Gmpc
.use_transition
;
24 private const string some_unique_name_mtt
= Config
.VERSION
;
26 public class Gmpc
.MpdData
.Treeview
.Tooltip
: Gtk
.Window
{
27 private Gtk
.TreeView par_widget
= null;
28 private Gtk
.Image image
= null;
29 public Gmpc
.MetaData
.Type mtype
= Gmpc
.MetaData
.Type
.ARTIST_ART
;
30 public string? request_artist
= null;
31 private string checksum
= null;
33 query_tooltip_callback(int x
, int y
, bool keyboard_tip
, Gtk
.Tooltip tooltip
)
37 Gtk
.TreePath path
= null;
39 var model
= this
.par_widget
.get_model();
40 if(config
.get_int_with_default("GmpcTreeView", "show-tooltip", 1) != 1) return false;
41 if(this
.mtype
!= Gmpc
.MetaData
.Type
.ARTIST_ART
&& this
.mtype
!= Gmpc
.MetaData
.Type
.ALBUM_ART
) {
46 if(!this
.par_widget
.get_tooltip_context(out x
, out y
,keyboard_tip
, out model
, out path
, out iter
)){
51 MPD
.Song song
= new MPD
.Song();
52 /* Get the row type */
53 model
.get(iter
, 26, out row_type
);
54 if(row_type
== MPD
.Data
.Type
.SONG
)
57 model
.get(iter
, 5, out tag
, 6 , out album
);
61 else if (row_type
== MPD
.Data
.Type
.TAG
)
63 if(this
.mtype
== Gmpc
.MetaData
.Type
.ARTIST_ART
)
65 model
.get(iter
, 7, out tag
);
67 }else if (this
.mtype
== Gmpc
.MetaData
.Type
.ALBUM_ART
)
69 model
.get(iter
, 7, out tag
);
70 song
.artist
= this
.request_artist
;
75 string new_check
= Gmpc
.Misc
.song_checksum(song
);
76 if(new_check
!= this
.checksum
&& this
.checksum
!= null)
81 if(new_check
!= this
.checksum
)
84 this
.checksum
= new_check
;
85 Gmpc
.MetaData
.Item met
= null;
86 var result
= metawatcher
.query(song
, this
.mtype
, out met
);
87 metadata_changed(metawatcher
, song
, this
.mtype
,result
, met
);
89 if(this
.image
.get_storage_type() == Gtk
.ImageType
.EMPTY
) return false;
93 private void metadata_changed(MetaWatcher gmw2
, MPD
.Song song
, Gmpc
.MetaData
.Type type
, Gmpc
.MetaData
.Result result
, Gmpc
.MetaData
.Item? met
)
95 if(type
!= this
.mtype
) return;
97 if(this
.checksum
!= Gmpc
.Misc
.song_checksum(song
)) return;
98 if(result
== Gmpc
.MetaData
.Result
.UNAVAILABLE
) {
101 else if (result
== Gmpc
.MetaData
.Result
.FETCHING
) {
103 }else if (result
== Gmpc
.MetaData
.Result
.AVAILABLE
) {
104 if(met
.content_type
== Gmpc
.MetaData
.ContentType
.URI
) {
106 var pb
= new Gdk
.Pixbuf
.from_file_at_scale(met
.get_uri(), 150, 150, true);
107 image
.set_from_pixbuf(pb
);
118 this
.type
= Gtk
.WindowType
.POPUP
;
121 Tooltip(Gtk
.TreeView pw
, Gmpc
.MetaData
.Type type
){
122 this
.resizable
= false;
123 this
.par_widget
= pw
;
124 /*Set up all needed for tooltip */
125 pw
.query_tooltip
.connect(query_tooltip_callback
);
126 this
.par_widget
.set_tooltip_window(this
);
128 this
.image
= new Gtk
.Image();
132 this
.set_border_width(2);
133 this
.modify_bg(Gtk
.StateType
.NORMAL
, pw
.style
.black
);
135 metawatcher
.data_changed
.connect(metadata_changed
);