fix bug: source file needs to be explicitly rewound before reading/writing in callbac...
[flac.git] / src / plugin_xmms / fileinfo.c
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  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
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19  */
20
21 #include <stdlib.h>
22 #include <sys/types.h>
23 #include <sys/stat.h>
24 #include <unistd.h>
25 #include <stdarg.h>
26 #include <gtk/gtk.h>
27
28 #include "FLAC/metadata.h"
29 #include "charset.h"
30 #include "configure.h"
31 #include "plugin_common/vorbiscomment.h"
32 #include "plugin_common/locale_hack.h"
33
34 static GtkWidget *window = NULL;
35 static GList *genre_list = NULL;
36 static GtkWidget *filename_entry, *tag_frame;
37 static GtkWidget *title_entry, *artist_entry, *album_entry, *date_entry, *tracknum_entry, *comment_entry;
38 static GtkWidget *genre_combo;
39 static GtkWidget *flac_samplerate, *flac_channels, *flac_bits_per_sample, *flac_blocksize, *flac_filesize, *flac_samples, *flac_bitrate;
40
41 static gchar *current_filename = NULL;
42 static FLAC_Plugin__CanonicalTag *canonical_tag = NULL;
43
44 static const gchar *vorbis_genres[] =
45 {
46         N_("Blues"), N_("Classic Rock"), N_("Country"), N_("Dance"),
47         N_("Disco"), N_("Funk"), N_("Grunge"), N_("Hip-Hop"),
48         N_("Jazz"), N_("Metal"), N_("New Age"), N_("Oldies"),
49         N_("Other"), N_("Pop"), N_("R&B"), N_("Rap"), N_("Reggae"),
50         N_("Rock"), N_("Techno"), N_("Industrial"), N_("Alternative"),
51         N_("Ska"), N_("Death Metal"), N_("Pranks"), N_("Soundtrack"),
52         N_("Euro-Techno"), N_("Ambient"), N_("Trip-Hop"), N_("Vocal"),
53         N_("Jazz+Funk"), N_("Fusion"), N_("Trance"), N_("Classical"),
54         N_("Instrumental"), N_("Acid"), N_("House"), N_("Game"),
55         N_("Sound Clip"), N_("Gospel"), N_("Noise"), N_("Alt"),
56         N_("Bass"), N_("Soul"), N_("Punk"), N_("Space"),
57         N_("Meditative"), N_("Instrumental Pop"),
58         N_("Instrumental Rock"), N_("Ethnic"), N_("Gothic"),
59         N_("Darkwave"), N_("Techno-Industrial"), N_("Electronic"),
60         N_("Pop-Folk"), N_("Eurodance"), N_("Dream"),
61         N_("Southern Rock"), N_("Comedy"), N_("Cult"),
62         N_("Gangsta Rap"), N_("Top 40"), N_("Christian Rap"),
63         N_("Pop/Funk"), N_("Jungle"), N_("Native American"),
64         N_("Cabaret"), N_("New Wave"), N_("Psychedelic"), N_("Rave"),
65         N_("Showtunes"), N_("Trailer"), N_("Lo-Fi"), N_("Tribal"),
66         N_("Acid Punk"), N_("Acid Jazz"), N_("Polka"), N_("Retro"),
67         N_("Musical"), N_("Rock & Roll"), N_("Hard Rock"), N_("Folk"),
68         N_("Folk/Rock"), N_("National Folk"), N_("Swing"),
69         N_("Fast-Fusion"), N_("Bebob"), N_("Latin"), N_("Revival"),
70         N_("Celtic"), N_("Bluegrass"), N_("Avantgarde"),
71         N_("Gothic Rock"), N_("Progressive Rock"),
72         N_("Psychedelic Rock"), N_("Symphonic Rock"), N_("Slow Rock"),
73         N_("Big Band"), N_("Chorus"), N_("Easy Listening"),
74         N_("Acoustic"), N_("Humour"), N_("Speech"), N_("Chanson"),
75         N_("Opera"), N_("Chamber Music"), N_("Sonata"), N_("Symphony"),
76         N_("Booty Bass"), N_("Primus"), N_("Porn Groove"),
77         N_("Satire"), N_("Slow Jam"), N_("Club"), N_("Tango"),
78         N_("Samba"), N_("Folklore"), N_("Ballad"), N_("Power Ballad"),
79         N_("Rhythmic Soul"), N_("Freestyle"), N_("Duet"),
80         N_("Punk Rock"), N_("Drum Solo"), N_("A Cappella"),
81         N_("Euro-House"), N_("Dance Hall"), N_("Goa"),
82         N_("Drum & Bass"), N_("Club-House"), N_("Hardcore"),
83         N_("Terror"), N_("Indie"), N_("BritPop"), N_("Negerpunk"),
84         N_("Polsk Punk"), N_("Beat"), N_("Christian Gangsta Rap"),
85         N_("Heavy Metal"), N_("Black Metal"), N_("Crossover"),
86         N_("Contemporary Christian"), N_("Christian Rock"),
87         N_("Merengue"), N_("Salsa"), N_("Thrash Metal"),
88         N_("Anime"), N_("JPop"), N_("Synthpop")
89 };
90
91 static void local__safe_free(void *object)
92 {
93         if(0 != object)
94                 free(object);
95 }
96
97 static void label_set_text(GtkWidget * label, char *str, ...)
98 {
99         va_list args;
100         gchar *tempstr;
101
102         va_start(args, str);
103         tempstr = g_strdup_vprintf(str, args);
104         va_end(args);
105
106         gtk_label_set_text(GTK_LABEL(label), tempstr);
107         g_free(tempstr);
108 }
109
110 static void set_entry_tag(GtkEntry * entry, gchar * tag)
111 {
112         char *text;
113
114         if(tag) {
115                 if(flac_cfg.title.convert_char_set) {
116                         text = convert_from_file_to_user(tag);
117                         gtk_entry_set_text(entry, text);
118                         free(text);
119                 }
120                 else
121                         gtk_entry_set_text(entry, tag);
122         }
123         else
124                 gtk_entry_set_text(entry, "");
125 }
126
127 static char *get_entry_tag(GtkEntry * entry)
128 {
129         gchar *text;
130
131         text = gtk_entry_get_text(entry);
132         if (!text || strlen(text) == 0)
133                 return 0;
134         if(flac_cfg.title.convert_char_set)
135                 return convert_from_user_to_file(text);
136         else
137                 return strdup(text);
138 }
139
140 static void show_tag()
141 {
142         set_entry_tag(GTK_ENTRY(title_entry), canonical_tag->title);
143         set_entry_tag(GTK_ENTRY(artist_entry), canonical_tag->composer);
144         set_entry_tag(GTK_ENTRY(album_entry), canonical_tag->album);
145         set_entry_tag(GTK_ENTRY(date_entry), canonical_tag->year_recorded);
146         set_entry_tag(GTK_ENTRY(tracknum_entry), canonical_tag->track_number);
147         set_entry_tag(GTK_ENTRY(comment_entry), canonical_tag->comment);
148         set_entry_tag(GTK_ENTRY(GTK_COMBO(genre_combo)->entry), canonical_tag->genre);
149 }
150
151 static void save_tag(GtkWidget * w, gpointer data)
152 {
153         (void)w;
154         (void)data;
155
156         local__safe_free(canonical_tag->title);
157         local__safe_free(canonical_tag->composer);
158         local__safe_free(canonical_tag->album);
159         local__safe_free(canonical_tag->year_recorded);
160         local__safe_free(canonical_tag->track_number);
161         local__safe_free(canonical_tag->comment);
162         local__safe_free(canonical_tag->genre);
163         canonical_tag->title = get_entry_tag(GTK_ENTRY(title_entry));
164         canonical_tag->composer = get_entry_tag(GTK_ENTRY(artist_entry));
165         canonical_tag->album = get_entry_tag(GTK_ENTRY(album_entry));
166         canonical_tag->year_recorded = get_entry_tag(GTK_ENTRY(date_entry));
167         canonical_tag->track_number = get_entry_tag(GTK_ENTRY(tracknum_entry));
168         canonical_tag->comment = get_entry_tag(GTK_ENTRY(comment_entry));
169         canonical_tag->genre = get_entry_tag(GTK_ENTRY(GTK_COMBO(genre_combo)->entry));
170         
171         FLAC_plugin__vorbiscomment_set(current_filename, canonical_tag);
172         gtk_widget_destroy(window);
173 }
174
175 static void remove_tag(GtkWidget * w, gpointer data)
176 {
177         (void)w;
178         (void)data;
179         
180         local__safe_free(canonical_tag->title);
181         local__safe_free(canonical_tag->composer);
182         local__safe_free(canonical_tag->album);
183         local__safe_free(canonical_tag->year_recorded);
184         local__safe_free(canonical_tag->track_number);
185         local__safe_free(canonical_tag->comment);
186         local__safe_free(canonical_tag->genre);
187
188         canonical_tag->title = canonical_tag->composer = canonical_tag->album = canonical_tag->year_recorded = canonical_tag->track_number = canonical_tag->comment = canonical_tag->genre = 0;
189
190         FLAC_plugin__vorbiscomment_set(current_filename, canonical_tag);
191         gtk_widget_destroy(window);
192 }
193
194 static void show_file_info()
195 {
196         FLAC__StreamMetadata streaminfo;
197         struct stat _stat;
198
199         gtk_label_set_text(GTK_LABEL(flac_samplerate), "");
200         gtk_label_set_text(GTK_LABEL(flac_channels), "");
201         gtk_label_set_text(GTK_LABEL(flac_bits_per_sample), "");
202         gtk_label_set_text(GTK_LABEL(flac_blocksize), "");
203         gtk_label_set_text(GTK_LABEL(flac_filesize), "");
204         gtk_label_set_text(GTK_LABEL(flac_samples), "");
205         gtk_label_set_text(GTK_LABEL(flac_bitrate), "");
206
207         if(!FLAC__metadata_get_streaminfo(current_filename, &streaminfo)) {
208                 return;
209         }
210
211         label_set_text(flac_samplerate, _("Samplerate: %d Hz"), streaminfo.data.stream_info.sample_rate);
212         label_set_text(flac_channels, _("Channels: %d"), streaminfo.data.stream_info.channels);
213         label_set_text(flac_bits_per_sample, _("Bits/Sample: %d"), streaminfo.data.stream_info.bits_per_sample);
214         if(streaminfo.data.stream_info.min_blocksize == streaminfo.data.stream_info.max_blocksize)
215                 label_set_text(flac_blocksize, _("Blocksize: %d"), streaminfo.data.stream_info.min_blocksize);
216         else
217                 label_set_text(flac_blocksize, _("Blocksize: variable\n  min/max: %d/%d"), streaminfo.data.stream_info.min_blocksize, streaminfo.data.stream_info.max_blocksize);
218
219         if (streaminfo.data.stream_info.total_samples)
220                 label_set_text(flac_samples, _("Samples: %llu\nLength: %d:%.2d"),
221                                 streaminfo.data.stream_info.total_samples,
222                                 (int)(streaminfo.data.stream_info.total_samples / streaminfo.data.stream_info.sample_rate / 60),
223                                 (int)(streaminfo.data.stream_info.total_samples / streaminfo.data.stream_info.sample_rate % 60));
224
225         if(!stat(current_filename, &_stat) && S_ISREG(_stat.st_mode)) {
226                 label_set_text(flac_filesize, _("Filesize: %ld B"), _stat.st_size);
227                 if (streaminfo.data.stream_info.total_samples)
228                         label_set_text(flac_bitrate, _("Avg. bitrate: %.1f kb/s\nCompression ratio: %.1f%%"),
229                                         8.0 * (float)(_stat.st_size) / (1000.0 * (float)streaminfo.data.stream_info.total_samples / (float)streaminfo.data.stream_info.sample_rate),
230                                         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));
231         }
232 }
233
234 void FLAC_XMMS__file_info_box(char *filename)
235 {
236         unsigned i;
237         gchar *title;
238
239         if (!window)
240         {
241                 GtkWidget *vbox, *hbox, *left_vbox, *table;
242                 GtkWidget *flac_frame, *flac_box;
243                 GtkWidget *label, *filename_hbox;
244                 GtkWidget *bbox, *save, *remove, *cancel;
245
246                 window = gtk_window_new(GTK_WINDOW_DIALOG);
247                 gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, FALSE);
248                 gtk_signal_connect(GTK_OBJECT(window), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), &window);
249                 gtk_container_set_border_width(GTK_CONTAINER(window), 10);
250
251                 vbox = gtk_vbox_new(FALSE, 10);
252                 gtk_container_add(GTK_CONTAINER(window), vbox);
253
254                 filename_hbox = gtk_hbox_new(FALSE, 5);
255                 gtk_box_pack_start(GTK_BOX(vbox), filename_hbox, FALSE, TRUE, 0);
256
257                 label = gtk_label_new(_("Filename:"));
258                 gtk_box_pack_start(GTK_BOX(filename_hbox), label, FALSE, TRUE, 0);
259                 filename_entry = gtk_entry_new();
260                 gtk_editable_set_editable(GTK_EDITABLE(filename_entry), FALSE);
261                 gtk_box_pack_start(GTK_BOX(filename_hbox), filename_entry, TRUE, TRUE, 0);
262
263                 hbox = gtk_hbox_new(FALSE, 10);
264                 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
265
266                 left_vbox = gtk_vbox_new(FALSE, 10);
267                 gtk_box_pack_start(GTK_BOX(hbox), left_vbox, FALSE, FALSE, 0);
268
269                 tag_frame = gtk_frame_new(_("Tag:"));
270                 gtk_box_pack_start(GTK_BOX(left_vbox), tag_frame, FALSE, FALSE, 0);
271
272                 table = gtk_table_new(5, 5, FALSE);
273                 gtk_container_set_border_width(GTK_CONTAINER(table), 5);
274                 gtk_container_add(GTK_CONTAINER(tag_frame), table);
275
276                 label = gtk_label_new(_("Title:"));
277                 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
278                 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, GTK_FILL, GTK_FILL, 5, 5);
279
280                 title_entry = gtk_entry_new();
281                 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);
282
283                 label = gtk_label_new(_("Artist:"));
284                 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
285                 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, GTK_FILL, GTK_FILL, 5, 5);
286
287                 artist_entry = gtk_entry_new();
288                 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);
289
290                 label = gtk_label_new(_("Album:"));
291                 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
292                 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3, GTK_FILL, GTK_FILL, 5, 5);
293
294                 album_entry = gtk_entry_new();
295                 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);
296
297                 label = gtk_label_new(_("Comment:"));
298                 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
299                 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4, GTK_FILL, GTK_FILL, 5, 5);
300
301                 comment_entry = gtk_entry_new();
302                 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);
303
304                 label = gtk_label_new(_("Date:"));
305                 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
306                 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 4, 5, GTK_FILL, GTK_FILL, 5, 5);
307
308                 date_entry = gtk_entry_new();
309                 gtk_widget_set_usize(date_entry, 40, -1);
310                 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);
311
312                 label = gtk_label_new(_("Track number:"));
313                 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
314                 gtk_table_attach(GTK_TABLE(table), label, 2, 3, 4, 5, GTK_FILL, GTK_FILL, 5, 5);
315
316                 tracknum_entry = gtk_entry_new();
317                 gtk_widget_set_usize(tracknum_entry, 40, -1);
318                 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);
319
320                 label = gtk_label_new(_("Genre:"));
321                 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
322                 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 5, 6, GTK_FILL, GTK_FILL, 5, 5);
323
324                 genre_combo = gtk_combo_new();
325                 gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(genre_combo)->entry), TRUE);
326
327                 if (!genre_list)
328                 {
329                         for (i = 0; i < sizeof(vorbis_genres) / sizeof(*vorbis_genres) ; i++)
330                                 genre_list = g_list_prepend(genre_list, (char *)vorbis_genres[i]);
331                         genre_list = g_list_prepend(genre_list, "");
332                         genre_list = g_list_sort(genre_list, (GCompareFunc)g_strcasecmp);
333                 }
334                 gtk_combo_set_popdown_strings(GTK_COMBO(genre_combo), genre_list);
335
336                 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);
337
338                 bbox = gtk_hbutton_box_new();
339                 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
340                 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5);
341                 gtk_box_pack_start(GTK_BOX(left_vbox), bbox, FALSE, FALSE, 0);
342
343                 save = gtk_button_new_with_label(_("Save"));
344                 gtk_signal_connect(GTK_OBJECT(save), "clicked", GTK_SIGNAL_FUNC(save_tag), NULL);
345                 GTK_WIDGET_SET_FLAGS(save, GTK_CAN_DEFAULT);
346                 gtk_box_pack_start(GTK_BOX(bbox), save, TRUE, TRUE, 0);
347                 gtk_widget_grab_default(save);
348
349                 remove= gtk_button_new_with_label(_("Remove Tag"));
350                 gtk_signal_connect(GTK_OBJECT(remove), "clicked", GTK_SIGNAL_FUNC(remove_tag), NULL);
351                 GTK_WIDGET_SET_FLAGS(remove, GTK_CAN_DEFAULT);
352                 gtk_box_pack_start(GTK_BOX(bbox), remove, TRUE, TRUE, 0);
353
354                 cancel = gtk_button_new_with_label(_("Cancel"));
355                 gtk_signal_connect_object(GTK_OBJECT(cancel), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(window));
356                 GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT);
357                 gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0);
358
359                 flac_frame = gtk_frame_new(_("FLAC Info:"));
360                 gtk_box_pack_start(GTK_BOX(hbox), flac_frame, FALSE, FALSE, 0);
361
362                 flac_box = gtk_vbox_new(FALSE, 5);
363                 gtk_container_add(GTK_CONTAINER(flac_frame), flac_box);
364                 gtk_container_set_border_width(GTK_CONTAINER(flac_box), 10);
365                 gtk_box_set_spacing(GTK_BOX(flac_box), 0);
366
367                 flac_samplerate = gtk_label_new("");
368                 gtk_misc_set_alignment(GTK_MISC(flac_samplerate), 0, 0);
369                 gtk_label_set_justify(GTK_LABEL(flac_samplerate), GTK_JUSTIFY_LEFT);
370                 gtk_box_pack_start(GTK_BOX(flac_box), flac_samplerate, FALSE, FALSE, 0);
371
372                 flac_channels = gtk_label_new("");
373                 gtk_misc_set_alignment(GTK_MISC(flac_channels), 0, 0);
374                 gtk_label_set_justify(GTK_LABEL(flac_channels), GTK_JUSTIFY_LEFT);
375                 gtk_box_pack_start(GTK_BOX(flac_box), flac_channels, FALSE, FALSE, 0);
376
377                 flac_bits_per_sample = gtk_label_new("");
378                 gtk_misc_set_alignment(GTK_MISC(flac_bits_per_sample), 0, 0);
379                 gtk_label_set_justify(GTK_LABEL(flac_bits_per_sample), GTK_JUSTIFY_LEFT);
380                 gtk_box_pack_start(GTK_BOX(flac_box), flac_bits_per_sample, FALSE, FALSE, 0);
381
382                 flac_blocksize = gtk_label_new("");
383                 gtk_misc_set_alignment(GTK_MISC(flac_blocksize), 0, 0);
384                 gtk_label_set_justify(GTK_LABEL(flac_blocksize), GTK_JUSTIFY_LEFT);
385                 gtk_box_pack_start(GTK_BOX(flac_box), flac_blocksize, FALSE, FALSE, 0);
386
387                 flac_filesize = gtk_label_new("");
388                 gtk_misc_set_alignment(GTK_MISC(flac_filesize), 0, 0);
389                 gtk_label_set_justify(GTK_LABEL(flac_filesize), GTK_JUSTIFY_LEFT);
390                 gtk_box_pack_start(GTK_BOX(flac_box), flac_filesize, FALSE, FALSE, 0);
391
392                 flac_samples = gtk_label_new("");
393                 gtk_misc_set_alignment(GTK_MISC(flac_samples), 0, 0);
394                 gtk_label_set_justify(GTK_LABEL(flac_samples), GTK_JUSTIFY_LEFT);
395                 gtk_box_pack_start(GTK_BOX(flac_box), flac_samples, FALSE, FALSE, 0);
396
397                 flac_bitrate = gtk_label_new("");
398                 gtk_misc_set_alignment(GTK_MISC(flac_bitrate), 0, 0);
399                 gtk_label_set_justify(GTK_LABEL(flac_bitrate), GTK_JUSTIFY_LEFT);
400                 gtk_box_pack_start(GTK_BOX(flac_box), flac_bitrate, FALSE, FALSE, 0);
401
402                 gtk_widget_show_all(window);
403         }
404
405         if(current_filename)
406                 g_free(current_filename);
407         if(!(current_filename = g_strdup(filename)))
408                 return;
409
410         title = g_strdup_printf(_("File Info - %s"), g_basename(filename));
411         gtk_window_set_title(GTK_WINDOW(window), title);
412         g_free(title);
413
414         gtk_entry_set_text(GTK_ENTRY(filename_entry), filename);
415         gtk_editable_set_position(GTK_EDITABLE(filename_entry), -1);
416
417         if(canonical_tag)
418                 FLAC_plugin__canonical_tag_clear(canonical_tag);
419         else
420                 canonical_tag = FLAC_plugin__canonical_tag_new();
421
422         FLAC_plugin__vorbiscomment_get(current_filename, canonical_tag);
423
424         show_tag();
425         show_file_info();
426
427         gtk_widget_set_sensitive(tag_frame, TRUE);
428 }