• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*  XMMS - Cross-platform multimedia player
2  *  Copyright (C) 1998-2000  Peter Alm, Mikael Alm, Olle Hallnas, Thomas Nilsson and 4Front Technologies
3  *  Copyright (C) 1999,2000  H�vard Kv�len
4  *  Copyright (C) 2002,2003,2004,2005,2006,2007,2008,2009  Daisuke Shimamura
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License along
17  *  with this program; if not, write to the Free Software Foundation, Inc.,
18  *  with this program; if not, write to the Free Software Foundation, Inc.,
19  */
20 
21 #ifdef HAVE_CONFIG_H
22 #include "config.h"
23 #endif
24 
25 #include "plugin.h"
26 
27 #include <stdlib.h>
28 #include <string.h> /* for strlen() */
29 #include <sys/types.h>
30 #include <sys/stat.h>
31 #include <unistd.h>
32 #include <stdarg.h>
33 #include <inttypes.h>
34 #include <gtk/gtk.h>
35 
36 #include "FLAC/metadata.h"
37 #include "charset.h"
38 #include "configure.h"
39 #include "plugin_common/replaygain.h"
40 #include "plugin_common/tags.h"
41 #include "locale_hack.h"
42 
43 static GtkWidget *window = NULL;
44 static GList *genre_list = NULL;
45 static GtkWidget *filename_entry, *tag_frame;
46 static GtkWidget *title_entry, *artist_entry, *album_entry, *date_entry, *tracknum_entry, *comment_entry;
47 static GtkWidget *replaygain_reference, *replaygain_track_gain, *replaygain_album_gain, *replaygain_track_peak, *replaygain_album_peak;
48 static GtkWidget *genre_combo;
49 static GtkWidget *flac_samplerate, *flac_channels, *flac_bits_per_sample, *flac_blocksize, *flac_filesize, *flac_samples, *flac_bitrate;
50 
51 static gchar *current_filename = NULL;
52 static FLAC__StreamMetadata *tags_ = NULL;
53 
54 static const gchar *vorbis_genres[] =
55 {
56 	N_("Blues"), N_("Classic Rock"), N_("Country"), N_("Dance"),
57 	N_("Disco"), N_("Funk"), N_("Grunge"), N_("Hip-Hop"),
58 	N_("Jazz"), N_("Metal"), N_("New Age"), N_("Oldies"),
59 	N_("Other"), N_("Pop"), N_("R&B"), N_("Rap"), N_("Reggae"),
60 	N_("Rock"), N_("Techno"), N_("Industrial"), N_("Alternative"),
61 	N_("Ska"), N_("Death Metal"), N_("Pranks"), N_("Soundtrack"),
62 	N_("Euro-Techno"), N_("Ambient"), N_("Trip-Hop"), N_("Vocal"),
63 	N_("Jazz+Funk"), N_("Fusion"), N_("Trance"), N_("Classical"),
64 	N_("Instrumental"), N_("Acid"), N_("House"), N_("Game"),
65 	N_("Sound Clip"), N_("Gospel"), N_("Noise"), N_("Alt"),
66 	N_("Bass"), N_("Soul"), N_("Punk"), N_("Space"),
67 	N_("Meditative"), N_("Instrumental Pop"),
68 	N_("Instrumental Rock"), N_("Ethnic"), N_("Gothic"),
69 	N_("Darkwave"), N_("Techno-Industrial"), N_("Electronic"),
70 	N_("Pop-Folk"), N_("Eurodance"), N_("Dream"),
71 	N_("Southern Rock"), N_("Comedy"), N_("Cult"),
72 	N_("Gangsta Rap"), N_("Top 40"), N_("Christian Rap"),
73 	N_("Pop/Funk"), N_("Jungle"), N_("Native American"),
74 	N_("Cabaret"), N_("New Wave"), N_("Psychedelic"), N_("Rave"),
75 	N_("Showtunes"), N_("Trailer"), N_("Lo-Fi"), N_("Tribal"),
76 	N_("Acid Punk"), N_("Acid Jazz"), N_("Polka"), N_("Retro"),
77 	N_("Musical"), N_("Rock & Roll"), N_("Hard Rock"), N_("Folk"),
78 	N_("Folk/Rock"), N_("National Folk"), N_("Swing"),
79 	N_("Fast-Fusion"), N_("Bebob"), N_("Latin"), N_("Revival"),
80 	N_("Celtic"), N_("Bluegrass"), N_("Avantgarde"),
81 	N_("Gothic Rock"), N_("Progressive Rock"),
82 	N_("Psychedelic Rock"), N_("Symphonic Rock"), N_("Slow Rock"),
83 	N_("Big Band"), N_("Chorus"), N_("Easy Listening"),
84 	N_("Acoustic"), N_("Humour"), N_("Speech"), N_("Chanson"),
85 	N_("Opera"), N_("Chamber Music"), N_("Sonata"), N_("Symphony"),
86 	N_("Booty Bass"), N_("Primus"), N_("Porn Groove"),
87 	N_("Satire"), N_("Slow Jam"), N_("Club"), N_("Tango"),
88 	N_("Samba"), N_("Folklore"), N_("Ballad"), N_("Power Ballad"),
89 	N_("Rhythmic Soul"), N_("Freestyle"), N_("Duet"),
90 	N_("Punk Rock"), N_("Drum Solo"), N_("A Cappella"),
91 	N_("Euro-House"), N_("Dance Hall"), N_("Goa"),
92 	N_("Drum & Bass"), N_("Club-House"), N_("Hardcore"),
93 	N_("Terror"), N_("Indie"), N_("BritPop"), N_("Negerpunk"),
94 	N_("Polsk Punk"), N_("Beat"), N_("Christian Gangsta Rap"),
95 	N_("Heavy Metal"), N_("Black Metal"), N_("Crossover"),
96 	N_("Contemporary Christian"), N_("Christian Rock"),
97 	N_("Merengue"), N_("Salsa"), N_("Thrash Metal"),
98 	N_("Anime"), N_("JPop"), N_("Synthpop")
99 };
100 
label_set_text(GtkWidget * label,char * str,...)101 static void label_set_text(GtkWidget * label, char *str, ...)
102 {
103 	va_list args;
104 	gchar *tempstr;
105 
106 	va_start(args, str);
107 	tempstr = g_strdup_vprintf(str, args);
108 	va_end(args);
109 
110 	gtk_label_set_text(GTK_LABEL(label), tempstr);
111 	g_free(tempstr);
112 }
113 
set_entry_tag(GtkEntry * entry,const char * utf8)114 static void set_entry_tag(GtkEntry * entry, const char * utf8)
115 {
116 	if(utf8) {
117 		if(flac_cfg.title.convert_char_set) {
118 			char *text = convert_from_utf8_to_user(utf8);
119 			gtk_entry_set_text(entry, text);
120 			free(text);
121 		}
122 		else
123 			gtk_entry_set_text(entry, utf8);
124 	}
125 	else
126 		gtk_entry_set_text(entry, "");
127 }
128 
get_entry_tag(GtkEntry * entry,const char * name)129 static void get_entry_tag(GtkEntry * entry, const char *name)
130 {
131 	gchar *text;
132 	char *utf8;
133 
134 	text = gtk_entry_get_text(entry);
135 	if (!text || strlen(text) == 0)
136 		return;
137 	if(flac_cfg.title.convert_char_set)
138 		utf8 = convert_from_user_to_utf8(text);
139 	else
140 		utf8 = text;
141 
142 	FLAC_plugin__tags_add_tag_utf8(tags_, name, utf8, /*separator=*/0);
143 
144 	if(flac_cfg.title.convert_char_set)
145 		free(utf8);
146 }
147 
show_tag(void)148 static void show_tag(void)
149 {
150 	set_entry_tag(GTK_ENTRY(title_entry)                  , FLAC_plugin__tags_get_tag_utf8(tags_, "TITLE"));
151 	set_entry_tag(GTK_ENTRY(artist_entry)                 , FLAC_plugin__tags_get_tag_utf8(tags_, "ARTIST"));
152 	set_entry_tag(GTK_ENTRY(album_entry)                  , FLAC_plugin__tags_get_tag_utf8(tags_, "ALBUM"));
153 	set_entry_tag(GTK_ENTRY(date_entry)                   , FLAC_plugin__tags_get_tag_utf8(tags_, "DATE"));
154 	set_entry_tag(GTK_ENTRY(tracknum_entry)               , FLAC_plugin__tags_get_tag_utf8(tags_, "TRACKNUMBER"));
155 	set_entry_tag(GTK_ENTRY(comment_entry)                , FLAC_plugin__tags_get_tag_utf8(tags_, "DESCRIPTION"));
156 	set_entry_tag(GTK_ENTRY(GTK_COMBO(genre_combo)->entry), FLAC_plugin__tags_get_tag_utf8(tags_, "GENRE"));
157 }
158 
save_tag(GtkWidget * w,gpointer data)159 static void save_tag(GtkWidget * w, gpointer data)
160 {
161 	(void)w;
162 	(void)data;
163 
164 	FLAC_plugin__tags_delete_tag(tags_, "TITLE");
165 	FLAC_plugin__tags_delete_tag(tags_, "ARTIST");
166 	FLAC_plugin__tags_delete_tag(tags_, "ALBUM");
167 	FLAC_plugin__tags_delete_tag(tags_, "DATE");
168 	FLAC_plugin__tags_delete_tag(tags_, "TRACKNUMBER");
169 	FLAC_plugin__tags_delete_tag(tags_, "DESCRIPTION");
170 	FLAC_plugin__tags_delete_tag(tags_, "GENRE");
171 
172 	get_entry_tag(GTK_ENTRY(title_entry)                  , "TITLE");
173 	get_entry_tag(GTK_ENTRY(artist_entry)                 , "ARTIST");
174 	get_entry_tag(GTK_ENTRY(album_entry)                  , "ALBUM");
175 	get_entry_tag(GTK_ENTRY(date_entry)                   , "DATE");
176 	get_entry_tag(GTK_ENTRY(tracknum_entry)               , "TRACKNUMBER");
177 	get_entry_tag(GTK_ENTRY(comment_entry)                , "DESCRIPTION");
178 	get_entry_tag(GTK_ENTRY(GTK_COMBO(genre_combo)->entry), "GENRE");
179 
180 	FLAC_plugin__tags_set(current_filename, tags_);
181 	gtk_widget_destroy(window);
182 }
183 
remove_tag(GtkWidget * w,gpointer data)184 static void remove_tag(GtkWidget * w, gpointer data)
185 {
186 	(void)w;
187 	(void)data;
188 
189 	FLAC_plugin__tags_delete_tag(tags_, "TITLE");
190 	FLAC_plugin__tags_delete_tag(tags_, "ARTIST");
191 	FLAC_plugin__tags_delete_tag(tags_, "ALBUM");
192 	FLAC_plugin__tags_delete_tag(tags_, "DATE");
193 	FLAC_plugin__tags_delete_tag(tags_, "TRACKNUMBER");
194 	FLAC_plugin__tags_delete_tag(tags_, "DESCRIPTION");
195 	FLAC_plugin__tags_delete_tag(tags_, "GENRE");
196 
197 	FLAC_plugin__tags_set(current_filename, tags_);
198 	gtk_widget_destroy(window);
199 }
200 
show_file_info(void)201 static void show_file_info(void)
202 {
203 	FLAC__StreamMetadata streaminfo;
204 	struct stat _stat;
205 
206 	gtk_label_set_text(GTK_LABEL(flac_samplerate), "");
207 	gtk_label_set_text(GTK_LABEL(flac_channels), "");
208 	gtk_label_set_text(GTK_LABEL(flac_bits_per_sample), "");
209 	gtk_label_set_text(GTK_LABEL(flac_blocksize), "");
210 	gtk_label_set_text(GTK_LABEL(flac_filesize), "");
211 	gtk_label_set_text(GTK_LABEL(flac_samples), "");
212 	gtk_label_set_text(GTK_LABEL(flac_bitrate), "");
213 
214 	if(!FLAC__metadata_get_streaminfo(current_filename, &streaminfo)) {
215 		return;
216 	}
217 
218 	label_set_text(flac_samplerate, _("Samplerate: %d Hz"), streaminfo.data.stream_info.sample_rate);
219 	label_set_text(flac_channels, _("Channels: %d"), streaminfo.data.stream_info.channels);
220 	label_set_text(flac_bits_per_sample, _("Bits/Sample: %d"), streaminfo.data.stream_info.bits_per_sample);
221 	if(streaminfo.data.stream_info.min_blocksize == streaminfo.data.stream_info.max_blocksize)
222 		label_set_text(flac_blocksize, _("Blocksize: %d"), streaminfo.data.stream_info.min_blocksize);
223 	else
224 		label_set_text(flac_blocksize, _("Blocksize: variable\n  min/max: %d/%d"), streaminfo.data.stream_info.min_blocksize, streaminfo.data.stream_info.max_blocksize);
225 
226 	if (streaminfo.data.stream_info.total_samples)
227 		label_set_text(flac_samples, _("Samples: %" PRIu64 "\nLength: %d:%.2d"),
228 				streaminfo.data.stream_info.total_samples,
229 				(int)(streaminfo.data.stream_info.total_samples / streaminfo.data.stream_info.sample_rate / 60),
230 				(int)(streaminfo.data.stream_info.total_samples / streaminfo.data.stream_info.sample_rate % 60));
231 
232 	if(!stat(current_filename, &_stat) && S_ISREG(_stat.st_mode)) {
233 		label_set_text(flac_filesize, _("Filesize: %zd B"), _stat.st_size);
234 		if (streaminfo.data.stream_info.total_samples)
235 			label_set_text(flac_bitrate, _("Avg. bitrate: %.1f kb/s\nCompression ratio: %.1f%%"),
236 					8.0 * (float)(_stat.st_size) / (1000.0 * (float)streaminfo.data.stream_info.total_samples / (float)streaminfo.data.stream_info.sample_rate),
237 					100.0 * (float)_stat.st_size / (float)(streaminfo.data.stream_info.bits_per_sample / 8 * streaminfo.data.stream_info.channels * streaminfo.data.stream_info.total_samples));
238 	}
239 }
240 
show_replaygain(void)241 static void show_replaygain(void)
242 {
243 	/* known limitation: If only one of gain and peak is set, neither will be shown. This is true for
244 	 * both track and album replaygain tags. Written so it will be easy to fix, with some trouble.  */
245 
246 	gtk_label_set_text(GTK_LABEL(replaygain_reference), "");
247 	gtk_label_set_text(GTK_LABEL(replaygain_track_gain), "");
248 	gtk_label_set_text(GTK_LABEL(replaygain_album_gain), "");
249 	gtk_label_set_text(GTK_LABEL(replaygain_track_peak), "");
250 	gtk_label_set_text(GTK_LABEL(replaygain_album_peak), "");
251 
252 	double reference, track_gain, track_peak, album_gain, album_peak;
253 	FLAC__bool reference_set, track_gain_set, track_peak_set, album_gain_set, album_peak_set;
254 
255 	if(!FLAC_plugin__replaygain_get_from_file(
256 		current_filename,
257 		&reference, &reference_set,
258 		&track_gain, &track_gain_set,
259 		&album_gain, &album_gain_set,
260 		&track_peak, &track_peak_set,
261 		&album_peak, &album_peak_set
262 	))
263 		return;
264 
265 	if(reference_set)
266 		  label_set_text(replaygain_reference, _("ReplayGain Reference Loudness: %2.1f dB"), reference);
267 	if(track_gain_set)
268 		  label_set_text(replaygain_track_gain, _("ReplayGain Track Gain: %+2.2f dB"), track_gain);
269 	if(album_gain_set)
270 		  label_set_text(replaygain_album_gain, _("ReplayGain Album Gain: %+2.2f dB"), album_gain);
271 	if(track_peak_set)
272 		  label_set_text(replaygain_track_peak, _("ReplayGain Track Peak: %1.8f"), track_peak);
273 	if(album_peak_set)
274 		  label_set_text(replaygain_album_peak, _("ReplayGain Album Peak: %1.8f"), album_peak);
275 }
276 
FLAC_XMMS__file_info_box(char * filename)277 void FLAC_XMMS__file_info_box(char *filename)
278 {
279 	uint32_t i;
280 	gchar *title;
281 
282 	if (!window)
283 	{
284 		GtkWidget *vbox, *hbox, *left_vbox, *table;
285 		GtkWidget *flac_frame, *flac_box;
286 		GtkWidget *label, *filename_hbox;
287 		GtkWidget *bbox, *save, *remove, *cancel;
288 
289 		window = gtk_window_new(GTK_WINDOW_DIALOG);
290 		gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, FALSE);
291 		gtk_signal_connect(GTK_OBJECT(window), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), &window);
292 		gtk_container_set_border_width(GTK_CONTAINER(window), 10);
293 
294 		vbox = gtk_vbox_new(FALSE, 10);
295 		gtk_container_add(GTK_CONTAINER(window), vbox);
296 
297 		filename_hbox = gtk_hbox_new(FALSE, 5);
298 		gtk_box_pack_start(GTK_BOX(vbox), filename_hbox, FALSE, TRUE, 0);
299 
300 		label = gtk_label_new(_("Filename:"));
301 		gtk_box_pack_start(GTK_BOX(filename_hbox), label, FALSE, TRUE, 0);
302 		filename_entry = gtk_entry_new();
303 		gtk_editable_set_editable(GTK_EDITABLE(filename_entry), FALSE);
304 		gtk_box_pack_start(GTK_BOX(filename_hbox), filename_entry, TRUE, TRUE, 0);
305 
306 		hbox = gtk_hbox_new(FALSE, 10);
307 		gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
308 
309 		left_vbox = gtk_vbox_new(FALSE, 10);
310 		gtk_box_pack_start(GTK_BOX(hbox), left_vbox, FALSE, FALSE, 0);
311 
312 		tag_frame = gtk_frame_new(_("Tag:"));
313 		gtk_box_pack_start(GTK_BOX(left_vbox), tag_frame, FALSE, FALSE, 0);
314 
315 		table = gtk_table_new(5, 5, FALSE);
316 		gtk_container_set_border_width(GTK_CONTAINER(table), 5);
317 		gtk_container_add(GTK_CONTAINER(tag_frame), table);
318 
319 		label = gtk_label_new(_("Title:"));
320 		gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
321 		gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 5, 5);
322 
323 		title_entry = gtk_entry_new();
324 		gtk_table_attach(GTK_TABLE(table), title_entry, 1, 4, 0, 1, GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
325 
326 		label = gtk_label_new(_("Artist:"));
327 		gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
328 		gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, GTK_FILL, GTK_FILL, 5, 5);
329 
330 		artist_entry = gtk_entry_new();
331 		gtk_table_attach(GTK_TABLE(table), artist_entry, 1, 4, 1, 2, GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
332 
333 		label = gtk_label_new(_("Album:"));
334 		gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
335 		gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3, GTK_FILL, GTK_FILL, 5, 5);
336 
337 		album_entry = gtk_entry_new();
338 		gtk_table_attach(GTK_TABLE(table), album_entry, 1, 4, 2, 3, GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
339 
340 		label = gtk_label_new(_("Comment:"));
341 		gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
342 		gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4, GTK_FILL, GTK_FILL, 5, 5);
343 
344 		comment_entry = gtk_entry_new();
345 		gtk_table_attach(GTK_TABLE(table), comment_entry, 1, 4, 3, 4, GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
346 
347 		label = gtk_label_new(_("Date:"));
348 		gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
349 		gtk_table_attach(GTK_TABLE(table), label, 0, 1, 4, 5, GTK_FILL, GTK_FILL, 5, 5);
350 
351 		date_entry = gtk_entry_new();
352 		gtk_widget_set_usize(date_entry, 40, -1);
353 		gtk_table_attach(GTK_TABLE(table), date_entry, 1, 2, 4, 5, GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
354 
355 		label = gtk_label_new(_("Track number:"));
356 		gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
357 		gtk_table_attach(GTK_TABLE(table), label, 2, 3, 4, 5, GTK_FILL, GTK_FILL, 5, 5);
358 
359 		tracknum_entry = gtk_entry_new();
360 		gtk_widget_set_usize(tracknum_entry, 40, -1);
361 		gtk_table_attach(GTK_TABLE(table), tracknum_entry, 3, 4, 4, 5, GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
362 
363 		label = gtk_label_new(_("Genre:"));
364 		gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
365 		gtk_table_attach(GTK_TABLE(table), label, 0, 1, 5, 6, GTK_FILL, GTK_FILL, 5, 5);
366 
367 		genre_combo = gtk_combo_new();
368 		gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(genre_combo)->entry), TRUE);
369 
370 		if (!genre_list)
371 		{
372 			for (i = 0; i < sizeof(vorbis_genres) / sizeof(*vorbis_genres) ; i++)
373 				genre_list = g_list_prepend(genre_list, (char *)vorbis_genres[i]);
374 			genre_list = g_list_prepend(genre_list, "");
375 			genre_list = g_list_sort(genre_list, (GCompareFunc)g_strcasecmp);
376 		}
377 		gtk_combo_set_popdown_strings(GTK_COMBO(genre_combo), genre_list);
378 
379 		gtk_table_attach(GTK_TABLE(table), genre_combo, 1, 4, 5, 6, GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
380 
381 		bbox = gtk_hbutton_box_new();
382 		gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
383 		gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5);
384 		gtk_box_pack_start(GTK_BOX(left_vbox), bbox, FALSE, FALSE, 0);
385 
386 		save = gtk_button_new_with_label(_("Save"));
387 		gtk_signal_connect(GTK_OBJECT(save), "clicked", GTK_SIGNAL_FUNC(save_tag), NULL);
388 		GTK_WIDGET_SET_FLAGS(save, GTK_CAN_DEFAULT);
389 		gtk_box_pack_start(GTK_BOX(bbox), save, TRUE, TRUE, 0);
390 		gtk_widget_grab_default(save);
391 
392 		remove= gtk_button_new_with_label(_("Remove Tag"));
393 		gtk_signal_connect(GTK_OBJECT(remove), "clicked", GTK_SIGNAL_FUNC(remove_tag), NULL);
394 		GTK_WIDGET_SET_FLAGS(remove, GTK_CAN_DEFAULT);
395 		gtk_box_pack_start(GTK_BOX(bbox), remove, TRUE, TRUE, 0);
396 
397 		cancel = gtk_button_new_with_label(_("Cancel"));
398 		gtk_signal_connect_object(GTK_OBJECT(cancel), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(window));
399 		GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT);
400 		gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0);
401 
402 		flac_frame = gtk_frame_new(_("FLAC Info:"));
403 		gtk_box_pack_start(GTK_BOX(hbox), flac_frame, FALSE, FALSE, 0);
404 
405 		flac_box = gtk_vbox_new(FALSE, 5);
406 		gtk_container_add(GTK_CONTAINER(flac_frame), flac_box);
407 		gtk_container_set_border_width(GTK_CONTAINER(flac_box), 10);
408 		gtk_box_set_spacing(GTK_BOX(flac_box), 0);
409 
410 		flac_samplerate = gtk_label_new("");
411 		gtk_misc_set_alignment(GTK_MISC(flac_samplerate), 0, 0);
412 		gtk_label_set_justify(GTK_LABEL(flac_samplerate), GTK_JUSTIFY_LEFT);
413 		gtk_box_pack_start(GTK_BOX(flac_box), flac_samplerate, FALSE, FALSE, 0);
414 
415 		flac_channels = gtk_label_new("");
416 		gtk_misc_set_alignment(GTK_MISC(flac_channels), 0, 0);
417 		gtk_label_set_justify(GTK_LABEL(flac_channels), GTK_JUSTIFY_LEFT);
418 		gtk_box_pack_start(GTK_BOX(flac_box), flac_channels, FALSE, FALSE, 0);
419 
420 		flac_bits_per_sample = gtk_label_new("");
421 		gtk_misc_set_alignment(GTK_MISC(flac_bits_per_sample), 0, 0);
422 		gtk_label_set_justify(GTK_LABEL(flac_bits_per_sample), GTK_JUSTIFY_LEFT);
423 		gtk_box_pack_start(GTK_BOX(flac_box), flac_bits_per_sample, FALSE, FALSE, 0);
424 
425 		flac_blocksize = gtk_label_new("");
426 		gtk_misc_set_alignment(GTK_MISC(flac_blocksize), 0, 0);
427 		gtk_label_set_justify(GTK_LABEL(flac_blocksize), GTK_JUSTIFY_LEFT);
428 		gtk_box_pack_start(GTK_BOX(flac_box), flac_blocksize, FALSE, FALSE, 0);
429 
430 		flac_filesize = gtk_label_new("");
431 		gtk_misc_set_alignment(GTK_MISC(flac_filesize), 0, 0);
432 		gtk_label_set_justify(GTK_LABEL(flac_filesize), GTK_JUSTIFY_LEFT);
433 		gtk_box_pack_start(GTK_BOX(flac_box), flac_filesize, FALSE, FALSE, 0);
434 
435 		flac_samples = gtk_label_new("");
436 		gtk_misc_set_alignment(GTK_MISC(flac_samples), 0, 0);
437 		gtk_label_set_justify(GTK_LABEL(flac_samples), GTK_JUSTIFY_LEFT);
438 		gtk_box_pack_start(GTK_BOX(flac_box), flac_samples, FALSE, FALSE, 0);
439 
440 		flac_bitrate = gtk_label_new("");
441 		gtk_misc_set_alignment(GTK_MISC(flac_bitrate), 0, 0);
442 		gtk_label_set_justify(GTK_LABEL(flac_bitrate), GTK_JUSTIFY_LEFT);
443 		gtk_box_pack_start(GTK_BOX(flac_box), flac_bitrate, FALSE, FALSE, 0);
444 
445 		replaygain_reference = gtk_label_new("");
446 		gtk_misc_set_alignment(GTK_MISC(replaygain_reference), 0, 0);
447 		gtk_label_set_justify(GTK_LABEL(replaygain_reference), GTK_JUSTIFY_LEFT);
448 		gtk_box_pack_start(GTK_BOX(flac_box), replaygain_reference, FALSE, FALSE, 0);
449 
450 		replaygain_track_gain = gtk_label_new("");
451 		gtk_misc_set_alignment(GTK_MISC(replaygain_track_gain), 0, 0);
452 		gtk_label_set_justify(GTK_LABEL(replaygain_track_gain), GTK_JUSTIFY_LEFT);
453 		gtk_box_pack_start(GTK_BOX(flac_box), replaygain_track_gain, FALSE, FALSE, 0);
454 
455 		replaygain_album_gain = gtk_label_new("");
456 		gtk_misc_set_alignment(GTK_MISC(replaygain_album_gain), 0, 0);
457 		gtk_label_set_justify(GTK_LABEL(replaygain_album_gain), GTK_JUSTIFY_LEFT);
458 		gtk_box_pack_start(GTK_BOX(flac_box), replaygain_album_gain, FALSE, FALSE, 0);
459 
460 		replaygain_track_peak = gtk_label_new("");
461 		gtk_misc_set_alignment(GTK_MISC(replaygain_track_peak), 0, 0);
462 		gtk_label_set_justify(GTK_LABEL(replaygain_track_peak), GTK_JUSTIFY_LEFT);
463 		gtk_box_pack_start(GTK_BOX(flac_box), replaygain_track_peak, FALSE, FALSE, 0);
464 
465 		replaygain_album_peak = gtk_label_new("");
466 		gtk_misc_set_alignment(GTK_MISC(replaygain_album_peak), 0, 0);
467 		gtk_label_set_justify(GTK_LABEL(replaygain_album_peak), GTK_JUSTIFY_LEFT);
468 		gtk_box_pack_start(GTK_BOX(flac_box), replaygain_album_peak, FALSE, FALSE, 0);
469 
470 		gtk_widget_show_all(window);
471 	}
472 
473 	if(current_filename)
474 		g_free(current_filename);
475 	if(!(current_filename = g_strdup(filename)))
476 		return;
477 
478 	title = g_strdup_printf(_("File Info - %s"), g_basename(filename));
479 	gtk_window_set_title(GTK_WINDOW(window), title);
480 	g_free(title);
481 
482 	gtk_entry_set_text(GTK_ENTRY(filename_entry), filename);
483 	gtk_editable_set_position(GTK_EDITABLE(filename_entry), -1);
484 
485 	if(tags_)
486 		FLAC_plugin__tags_destroy(&tags_);
487 
488 	FLAC_plugin__tags_get(current_filename, &tags_);
489 
490 	show_tag();
491 	show_file_info();
492 	show_replaygain();
493 
494 	gtk_widget_set_sensitive(tag_frame, TRUE);
495 }
496