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.
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
28 private Gtk
.TreeView par_widget
= null;
29 private Gtk
.Image image
= null;
30 public Gmpc
.MetaData
.Type mtype
= Gmpc
.MetaData
.Type
.ARTIST_ART
;
31 public string? request_artist
= null;
32 private string checksum
= null;
34 query_tooltip_callback(int x
, int y
, bool keyboard_tip
, Gtk
.Tooltip tooltip
)
38 Gtk
.TreePath path
= null;
40 var model
= this
.par_widget
.get_model();
41 if(config
.get_int_with_default("GmpcTreeView", "show-tooltip", 1) != 1) return false;
42 if(this
.mtype
!= Gmpc
.MetaData
.Type
.ARTIST_ART
&& this
.mtype
!= Gmpc
.MetaData
.Type
.ALBUM_ART
)
48 if(!this
.par_widget
.get_tooltip_context(ref x
, ref y
,keyboard_tip
, out model
, out path
, out iter
))
50 if(!this
.par_widget
.get_tooltip_context(out x
, out y
,keyboard_tip
, out model
, out path
, out iter
))
57 MPD
.Song song
= new MPD
.Song();
58 /* Get the row type */
59 model
.get(iter
, 26, out row_type
);
60 if(row_type
== MPD
.Data
.Type
.SONG
)
63 model
.get(iter
, 5, out tag
, 6 , out album
);
67 else if (row_type
== MPD
.Data
.Type
.TAG
)
69 if(this
.mtype
== Gmpc
.MetaData
.Type
.ARTIST_ART
)
71 model
.get(iter
, 7, out tag
);
74 else if (this
.mtype
== Gmpc
.MetaData
.Type
.ALBUM_ART
)
76 model
.get(iter
, 7, out tag
);
77 song
.artist
= this
.request_artist
;
82 string new_check
= Gmpc
.Misc
.song_checksum(song
);
83 if(new_check
!= this
.checksum
&& this
.checksum
!= null)
88 if(new_check
!= this
.checksum
)
91 this
.checksum
= new_check
;
92 Gmpc
.MetaData
.Item met
= null;
93 var result
= MetaData
.get_path(song
, this
.mtype
, out met
);
94 metadata_changed(metawatcher
, song
, this
.mtype
,result
, met
);
96 if(this
.image
.get_storage_type() == Gtk
.ImageType
.EMPTY
) return false;
100 private void metadata_changed(Meta
.Watcher gmw2
, MPD
.Song song
, Gmpc
.MetaData
.Type type
, Gmpc
.MetaData
.Result result
, Gmpc
.MetaData
.Item? met
)
102 if(type
!= this
.mtype
) return;
104 if(this
.checksum
!= Gmpc
.Misc
.song_checksum(song
)) return;
105 if(result
== Gmpc
.MetaData
.Result
.UNAVAILABLE
)
109 else if (result
== Gmpc
.MetaData
.Result
.FETCHING
)
113 else if (result
== Gmpc
.MetaData
.Result
.AVAILABLE
)
115 if(met
.content_type
== Gmpc
.MetaData
.ContentType
.URI
)
119 var pb
= new Gdk
.Pixbuf
.from_file_at_scale(met
.get_uri(), 150, 150, true);
120 image
.set_from_pixbuf(pb
);
136 this
.type
= Gtk
.WindowType
.POPUP
;
139 Tooltip(Gtk
.TreeView pw
, Gmpc
.MetaData
.Type type
)
141 this
.resizable
= false;
142 this
.par_widget
= pw
;
143 /*Set up all needed for tooltip */
144 pw
.query_tooltip
.connect(query_tooltip_callback
);
145 this
.par_widget
.set_tooltip_window(this
);
147 this
.image
= new Gtk
.Image();
151 this
.set_border_width(2);
152 this
.modify_bg(Gtk
.StateType
.NORMAL
, pw
.style
.black
);
154 metawatcher
.data_changed
.connect(metadata_changed
);