61
|
1 /* BMP - Cross-platform multimedia player
|
|
2 * Copyright (C) 2003-2004 BMP development team.
|
|
3 *
|
|
4 * Based on XMMS:
|
|
5 * Copyright (C) 1998-2003 XMMS development team.
|
|
6 *
|
|
7 * This program is free software; you can redistribute it and/or modify
|
|
8 * it under the terms of the GNU General Public License as published by
|
|
9 * the Free Software Foundation; either version 2 of the License, or
|
|
10 * (at your option) any later version.
|
|
11 *
|
|
12 * This program is distributed in the hope that it will be useful,
|
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15 * GNU General Public License for more details.
|
|
16 *
|
|
17 * You should have received a copy of the GNU General Public License
|
|
18 * along with this program; if not, write to the Free Software
|
|
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
20 */
|
|
21
|
|
22 #include "mpg123.h"
|
|
23
|
|
24 #ifdef HAVE_ID3LIB
|
|
25 # include <id3.h>
|
|
26 #endif
|
|
27
|
|
28 #include <glib.h>
|
|
29 #include <glib/gi18n.h>
|
|
30 #include <gtk/gtk.h>
|
|
31 #include <gdk/gdkkeysyms.h>
|
|
32 #include <stdio.h>
|
|
33 #include <stdlib.h>
|
|
34 #include <string.h>
|
|
35 #include <stdarg.h>
|
|
36
|
|
37 #include <unistd.h>
|
|
38 #include <fcntl.h>
|
|
39 #include <errno.h>
|
|
40
|
|
41 #include "audacious/util.h"
|
|
42 #include <libaudacious/util.h>
|
|
43 #include <libaudacious/vfs.h>
|
|
44 #include <libaudacious/xentry.h>
|
|
45
|
|
46 #include "mp3.xpm"
|
|
47
|
|
48 static GtkWidget *window = NULL;
|
|
49 static GtkWidget *filename_entry, *id3_frame;
|
|
50 static GtkWidget *title_entry, *artist_entry, *album_entry, *year_entry,
|
|
51 *tracknum_entry, *comment_entry;
|
|
52 static GtkWidget *genre_combo;
|
|
53 #ifdef HAVE_ID3LIB
|
|
54 static GtkWidget * totaltracks_entry;
|
|
55 #endif
|
|
56 static GtkWidget *mpeg_level, *mpeg_bitrate, *mpeg_samplerate, *mpeg_flags,
|
|
57 *mpeg_error, *mpeg_copy, *mpeg_orig, *mpeg_emph, *mpeg_frames,
|
|
58 *mpeg_filesize;
|
|
59 static GtkWidget *mpeg_level_val, *mpeg_bitrate_val, *mpeg_samplerate_val,
|
|
60 *mpeg_error_val, *mpeg_copy_val, *mpeg_orig_val, *mpeg_emph_val,
|
|
61 *mpeg_frames_val, *mpeg_filesize_val;
|
|
62
|
|
63 GtkWidget *vbox, *hbox, *left_vbox, *table;
|
|
64 GtkWidget *mpeg_frame, *mpeg_box;
|
|
65 GtkWidget *label, *filename_vbox;
|
|
66 GtkWidget *bbox;
|
|
67 GtkWidget *remove_id3, *cancel, *save;
|
|
68 GtkWidget *boxx;
|
|
69 #if 0
|
|
70 GtkWidget *revert;
|
|
71 #endif
|
|
72
|
|
73 VFSFile *fh;
|
|
74 struct id3v1tag_t tag;
|
|
75 const gchar *emphasis[4];
|
|
76 const gchar *bool_label[2];
|
|
77
|
|
78
|
|
79 static GList *genre_list = NULL;
|
|
80 static gchar *current_filename = NULL;
|
|
81
|
|
82 extern gchar *mpg123_filename;
|
|
83 extern gint mpg123_bitrate, mpg123_frequency, mpg123_layer, mpg123_lsf,
|
|
84 mpg123_mode;
|
|
85 extern gboolean mpg123_stereo, mpg123_mpeg25;
|
|
86
|
|
87 glong info_rate;
|
|
88
|
|
89 void fill_entries(GtkWidget * w, gpointer data);
|
|
90
|
|
91 #define MAX_STR_LEN 100
|
|
92
|
|
93 #ifndef HAVE_ID3LIB
|
|
94
|
|
95 static void
|
|
96 set_entry_tag(GtkEntry * entry, gchar * tag, gint length)
|
|
97 {
|
|
98 gint stripped_len;
|
|
99 gchar *text, *text_utf8;
|
|
100
|
|
101 stripped_len = mpg123_strip_spaces(tag, length);
|
|
102 text = g_strdup_printf("%-*.*s", stripped_len, stripped_len, tag);
|
|
103
|
|
104 if ((text_utf8 = str_to_utf8(text))) {
|
|
105 gtk_entry_set_text(entry, text_utf8);
|
|
106 g_free(text_utf8);
|
|
107 }
|
|
108 else {
|
|
109 gtk_entry_set_text(entry, "");
|
|
110 }
|
|
111
|
|
112 g_free(text);
|
|
113 }
|
|
114
|
|
115 static void
|
|
116 get_entry_tag(GtkEntry * entry, gchar * tag, gint length)
|
|
117 {
|
|
118 gchar *text = str_to_utf8(gtk_entry_get_text(entry));
|
|
119 memset(tag, ' ', length);
|
|
120 memcpy(tag, text, strlen(text) > length ? length : strlen(text));
|
|
121 }
|
|
122
|
|
123 static gint
|
|
124 find_genre_id(const gchar * text)
|
|
125 {
|
|
126 gint i;
|
|
127
|
|
128 for (i = 0; i < GENRE_MAX; i++) {
|
|
129 if (!strcmp(mpg123_id3_genres[i], text))
|
|
130 return i;
|
|
131 }
|
|
132 if (text[0] == '\0')
|
|
133 return 0xff;
|
|
134 return 0;
|
|
135 }
|
|
136
|
|
137 static void
|
|
138 press_save(GtkWidget * w, gpointer data)
|
|
139 {
|
|
140 gtk_button_clicked(GTK_BUTTON(save));
|
|
141 }
|
|
142
|
|
143 #else
|
|
144
|
|
145 GtkWidget * copy_album_tags_but, * paste_album_tags_but;
|
|
146
|
|
147 struct album_tags_t {
|
|
148 char * performer;
|
|
149 char * album;
|
|
150 char * year;
|
|
151 char * total_tracks;
|
|
152 };
|
|
153
|
|
154 struct album_tags_t album_tags = { NULL, NULL, NULL, NULL };
|
|
155
|
|
156 #define FREE_AND_ZERO(x) do { g_free(x); x = NULL; } while (0)
|
|
157
|
|
158 static void free_album_tags()
|
|
159 {
|
|
160 FREE_AND_ZERO(album_tags.performer);
|
|
161 FREE_AND_ZERO(album_tags.album);
|
|
162 FREE_AND_ZERO(album_tags.year);
|
|
163 FREE_AND_ZERO(album_tags.total_tracks);
|
|
164 }
|
|
165
|
|
166 static inline char * entry_text_dup_or_null(GtkWidget * e)
|
|
167 {
|
|
168 const char * text = gtk_entry_get_text(GTK_ENTRY(e));
|
|
169 if (strlen(text) > 0)
|
|
170 return g_strdup(text);
|
|
171 else
|
|
172 return NULL;
|
|
173 }
|
|
174
|
|
175 static inline void
|
|
176 update_paste_sensitive()
|
|
177 {
|
|
178 gtk_widget_set_sensitive(GTK_WIDGET(paste_album_tags_but),
|
|
179 album_tags.performer ||
|
|
180 album_tags.album ||
|
|
181 album_tags.year ||
|
|
182 album_tags.total_tracks);
|
|
183
|
|
184 }
|
|
185
|
|
186 static void validate_zeropad_tracknums()
|
|
187 {
|
|
188 const char * tn_str, * tt_str, * end;
|
|
189 char buf[5];
|
|
190 int tn, tt;
|
|
191
|
|
192 tn_str = gtk_entry_get_text(GTK_ENTRY(tracknum_entry));
|
|
193 tt_str = gtk_entry_get_text(GTK_ENTRY(totaltracks_entry));
|
|
194
|
|
195 end = tt_str;
|
|
196 tt = strtol(tt_str,(char**)&end,10);
|
|
197 if (end != tt_str) {
|
|
198 sprintf(buf,"%02d",tt);
|
|
199 gtk_entry_set_text(GTK_ENTRY(totaltracks_entry),buf);
|
|
200 } else {
|
|
201 gtk_entry_set_text(GTK_ENTRY(totaltracks_entry),"");
|
|
202 tt = 1000; /* any tracknum is valid */
|
|
203 }
|
|
204
|
|
205 end = tn_str;
|
|
206 tn = strtol(tn_str,(char**)&end,10);
|
|
207 if (end != tn_str && tn <= tt) {
|
|
208 sprintf(buf,"%02d",tn);
|
|
209 gtk_entry_set_text(GTK_ENTRY(tracknum_entry),buf);
|
|
210 } else
|
|
211 gtk_entry_set_text(GTK_ENTRY(tracknum_entry),"");
|
|
212
|
|
213 }
|
|
214
|
|
215 static void
|
|
216 copy_album_tags()
|
|
217 {
|
|
218 validate_zeropad_tracknums();
|
|
219 free_album_tags();
|
|
220 album_tags.performer = entry_text_dup_or_null(artist_entry);
|
|
221 album_tags.album = entry_text_dup_or_null(album_entry);
|
|
222 album_tags.year = entry_text_dup_or_null(year_entry);
|
|
223 album_tags.total_tracks = entry_text_dup_or_null(totaltracks_entry);
|
|
224 update_paste_sensitive();
|
|
225 }
|
|
226
|
|
227 static void
|
|
228 paste_album_tags()
|
|
229 {
|
|
230 if (album_tags.performer)
|
|
231 gtk_entry_set_text(GTK_ENTRY(artist_entry),album_tags.performer);
|
|
232 if (album_tags.album)
|
|
233 gtk_entry_set_text(GTK_ENTRY(album_entry),album_tags.album);
|
|
234 if (album_tags.year)
|
|
235 gtk_entry_set_text(GTK_ENTRY(year_entry),album_tags.year);
|
|
236 if (album_tags.total_tracks)
|
|
237 gtk_entry_set_text(GTK_ENTRY(totaltracks_entry),album_tags.total_tracks);
|
|
238 }
|
|
239
|
|
240 #endif
|
|
241
|
|
242 static gint
|
|
243 genre_comp_func(gconstpointer a, gconstpointer b)
|
|
244 {
|
|
245 return strcasecmp(a, b);
|
|
246 }
|
|
247
|
|
248 static gboolean
|
|
249 fileinfo_keypress_cb(GtkWidget * widget,
|
|
250 GdkEventKey * event,
|
|
251 gpointer data)
|
|
252 {
|
|
253 if (!event)
|
|
254 return FALSE;
|
|
255
|
|
256 switch (event->keyval) {
|
|
257 case GDK_Escape:
|
|
258 gtk_widget_destroy(window);
|
|
259 break;
|
|
260 default:
|
|
261 return FALSE;
|
|
262 }
|
|
263
|
|
264 return TRUE;
|
|
265 }
|
|
266
|
|
267 #ifdef HAVE_ID3LIB
|
|
268 /* some helper id3(v2) functions */
|
|
269
|
|
270 static void str_to_id3v2_frame(const char * str, ID3Tag * tag, ID3_FrameID frame_id)
|
|
271 {
|
|
272 ID3Frame * frame = ID3Tag_FindFrameWithID(tag,frame_id);
|
|
273 ID3Field * text_field;
|
|
274 gboolean new_frame = frame?FALSE:TRUE;
|
|
275
|
|
276 if (new_frame) {
|
|
277 frame = ID3Frame_NewID(frame_id);
|
|
278 }
|
|
279
|
|
280 text_field = ID3Frame_GetField(frame,ID3FN_TEXT);
|
|
281 ID3Field_SetASCII(text_field, str);
|
|
282
|
|
283 if (new_frame)
|
|
284 ID3Tag_AddFrame(tag,frame);
|
|
285 }
|
|
286
|
|
287 static void genre_combo_to_tag(GtkWidget * combo, ID3Tag * tag)
|
|
288 {
|
|
289 int idx = -1, i;
|
|
290 const char * genre = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(combo)->entry));
|
|
291 for(i=0;i<ID3_NR_OF_V1_GENRES;i++)
|
|
292 if (!strcmp(genre,ID3_v1_genre_description[i])) {
|
|
293 idx = i; break;
|
|
294 }
|
|
295 if (idx>-1) {
|
|
296 char code[7];
|
|
297 snprintf(code,7,"(%d)",idx);
|
|
298 str_to_id3v2_frame(code,tag,ID3FID_CONTENTTYPE);
|
|
299 }
|
|
300 }
|
|
301
|
|
302 static void id3v2_frame_to_entry(GtkWidget * entry,ID3Tag * tag, ID3_FrameID frame_id)
|
|
303 {
|
|
304 ID3Frame * frame = ID3Tag_FindFrameWithID(tag,frame_id);
|
|
305 ID3Field * text_field;
|
|
306 if (frame) {
|
|
307 char buf[4096];
|
|
308 text_field = ID3Frame_GetField(frame,ID3FN_TEXT);
|
|
309 ID3Field_GetASCII(text_field,buf,4096);
|
|
310 gtk_entry_set_text(GTK_ENTRY(entry),buf);
|
|
311 } else
|
|
312 gtk_entry_set_text(GTK_ENTRY(entry),"");
|
|
313 }
|
|
314
|
|
315 static void id3v2_frame_to_text_view(GtkWidget * entry,ID3Tag * tag, ID3_FrameID frame_id)
|
|
316 {
|
|
317 ID3Frame * frame = ID3Tag_FindFrameWithID(tag,frame_id);
|
|
318 ID3Field * text_field;
|
|
319 if (frame) {
|
|
320 char buf[4096];
|
|
321 text_field = ID3Frame_GetField(frame,ID3FN_TEXT);
|
|
322 ID3Field_GetASCII(text_field,buf,4096);
|
|
323 gtk_text_buffer_set_text(gtk_text_view_get_buffer(GTK_TEXT_VIEW(entry)),buf,-1);
|
|
324 } else
|
|
325 gtk_text_buffer_set_text(gtk_text_view_get_buffer(GTK_TEXT_VIEW(entry)),"",-1);
|
|
326 }
|
|
327
|
|
328 static void id3v2_tracknum_to_entries(GtkWidget * tracknum_entry,
|
|
329 GtkWidget * totaltracks_entry,
|
|
330 ID3Tag * tag)
|
|
331 {
|
|
332 ID3Frame * frame = ID3Tag_FindFrameWithID(tag,ID3FID_TRACKNUM);
|
|
333 ID3Field * text_field;
|
|
334 if (frame) {
|
|
335 char buf[4096];
|
|
336 char * slash;
|
|
337 text_field = ID3Frame_GetField(frame,ID3FN_TEXT);
|
|
338 ID3Field_GetASCII(text_field,buf,4096);
|
|
339 slash = strchr(buf,'/');
|
|
340 if (slash) {
|
|
341 slash[0] = 0;
|
|
342 gtk_entry_set_text(GTK_ENTRY(tracknum_entry),buf);
|
|
343 gtk_entry_set_text(GTK_ENTRY(totaltracks_entry),slash+1);
|
|
344 } else {
|
|
345 gtk_entry_set_text(GTK_ENTRY(tracknum_entry),buf);
|
|
346 gtk_entry_set_text(GTK_ENTRY(totaltracks_entry),"");
|
|
347 }
|
|
348 } else {
|
|
349 gtk_entry_set_text(GTK_ENTRY(tracknum_entry),"");
|
|
350 gtk_entry_set_text(GTK_ENTRY(totaltracks_entry),"");
|
|
351 }
|
|
352 }
|
|
353
|
|
354 /*
|
|
355 if has v2 - link with v2, if not - attempt to link with v1
|
|
356 use this only for reading - always save v2
|
|
357 */
|
|
358 size_t ID3Tag_LinkPreferV2(ID3Tag *tag, const char *fileName)
|
|
359 {
|
|
360 size_t r;
|
|
361
|
|
362 r = ID3Tag_Link(tag,fileName);
|
|
363 if (ID3Tag_HasTagType(tag,ID3TT_ID3V2)) {
|
|
364 ID3Tag_Clear(tag);
|
|
365 r = ID3Tag_LinkWithFlags(tag,fileName,ID3TT_ID3V2);
|
|
366 }
|
|
367 return r;
|
|
368 }
|
|
369
|
|
370 #endif /* HAVE_ID3LIB */
|
|
371
|
|
372 #ifdef HAVE_ID3LIB
|
|
373
|
|
374 static void
|
|
375 save_cb(GtkWidget * w, gpointer data)
|
|
376 {
|
|
377 ID3Tag * id3tag;
|
|
378 const char * tracks_str, * trackno_str, * endptr;
|
|
379 int trackno, tracks;
|
|
380
|
|
381 if (str_has_prefix_nocase(current_filename, "http://"))
|
|
382 return;
|
|
383
|
|
384 validate_zeropad_tracknums();
|
|
385
|
|
386 id3tag = ID3Tag_New();
|
|
387 ID3Tag_LinkWithFlags(id3tag, current_filename, ID3TT_ID3);
|
|
388
|
|
389 str_to_id3v2_frame(gtk_entry_get_text(GTK_ENTRY(title_entry)),id3tag,ID3FID_TITLE);
|
|
390 str_to_id3v2_frame(gtk_entry_get_text(GTK_ENTRY(artist_entry)),id3tag,ID3FID_LEADARTIST);
|
|
391 str_to_id3v2_frame(gtk_entry_get_text(GTK_ENTRY(album_entry)),id3tag,ID3FID_ALBUM);
|
|
392 {
|
|
393 GtkTextIter start, end;
|
|
394 GtkTextBuffer * buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(comment_entry));
|
|
395 gtk_text_buffer_get_start_iter(buffer,&start);
|
|
396 gtk_text_buffer_get_end_iter(buffer,&end);
|
|
397 str_to_id3v2_frame(gtk_text_buffer_get_text(buffer,&start,&end,FALSE),id3tag,ID3FID_COMMENT);
|
|
398 }
|
|
399 str_to_id3v2_frame(gtk_entry_get_text(GTK_ENTRY(year_entry)),id3tag,ID3FID_YEAR);
|
|
400
|
|
401 /* saving trackno -> may be with album tracks number */
|
|
402 trackno_str = gtk_entry_get_text(GTK_ENTRY(tracknum_entry));
|
|
403 endptr = trackno_str;
|
|
404 trackno = strtol(trackno_str,(char**)&endptr,10);
|
|
405 if (endptr != trackno_str) {
|
|
406 char buf[10];
|
|
407 tracks_str = gtk_entry_get_text(GTK_ENTRY(totaltracks_entry));
|
|
408 endptr = tracks_str;
|
|
409 tracks = strtol(tracks_str,(char**)&endptr,10);
|
|
410 if (endptr != tracks_str)
|
|
411 snprintf(buf,10,"%02d/%02d",trackno,tracks);
|
|
412 else
|
|
413 snprintf(buf,10,"%02d",trackno);
|
|
414 str_to_id3v2_frame(buf,id3tag,ID3FID_TRACKNUM);
|
|
415 } else
|
|
416 str_to_id3v2_frame("",id3tag,ID3FID_TRACKNUM);
|
|
417
|
|
418
|
|
419 genre_combo_to_tag(genre_combo,id3tag);
|
|
420 gtk_widget_set_sensitive(GTK_WIDGET(w), FALSE);
|
|
421
|
|
422 ID3Tag_Update(id3tag);
|
|
423
|
|
424 ID3Tag_Delete(id3tag);
|
|
425 }
|
|
426
|
|
427 #else /* ! HAVE_ID3LIB */
|
|
428
|
|
429 static void
|
|
430 save_cb(GtkWidget * widget,
|
|
431 gpointer data)
|
|
432 {
|
|
433 VFSFile *file;
|
|
434 gchar *msg = NULL;
|
|
435
|
|
436 if (str_has_prefix_nocase(current_filename, "http://"))
|
|
437 return;
|
|
438
|
|
439 if ((file = vfs_fopen(current_filename, "r+b")) != NULL) {
|
|
440 gint tracknum;
|
|
441
|
|
442 vfs_fseek(file, -128, SEEK_END);
|
|
443 vfs_fread(&tag, 1, sizeof(struct id3v1tag_t), file);
|
|
444
|
|
445 if (g_str_has_prefix(tag.tag, "TAG"))
|
|
446 vfs_fseek(file, -128L, SEEK_END);
|
|
447 else
|
|
448 vfs_fseek(file, 0L, SEEK_END);
|
|
449
|
|
450 tag.tag[0] = 'T';
|
|
451 tag.tag[1] = 'A';
|
|
452 tag.tag[2] = 'G';
|
|
453
|
|
454 get_entry_tag(GTK_ENTRY(title_entry), tag.title, 30);
|
|
455 get_entry_tag(GTK_ENTRY(artist_entry), tag.artist, 30);
|
|
456 get_entry_tag(GTK_ENTRY(album_entry), tag.album, 30);
|
|
457 get_entry_tag(GTK_ENTRY(year_entry), tag.year, 4);
|
|
458
|
|
459 tracknum = atoi(gtk_entry_get_text(GTK_ENTRY(tracknum_entry)));
|
|
460 if (tracknum > 0) {
|
|
461 get_entry_tag(GTK_ENTRY(comment_entry), tag.u.v1_1.comment, 28);
|
|
462 tag.u.v1_1.__zero = 0;
|
|
463 tag.u.v1_1.track_number = MIN(tracknum, 255);
|
|
464 }
|
|
465 else
|
|
466 get_entry_tag(GTK_ENTRY(comment_entry), tag.u.v1_0.comment, 30);
|
|
467
|
|
468 tag.genre = find_genre_id(gtk_entry_get_text(GTK_ENTRY(GTK_COMBO
|
|
469 (genre_combo)->entry)));
|
|
470 if (vfs_fwrite(&tag, 1, sizeof(tag), file) != sizeof(tag))
|
|
471 msg = g_strdup_printf(_("%s\nUnable to write to file: %s"),
|
|
472 _("Couldn't write tag!"), strerror(errno));
|
|
473 vfs_fclose(file);
|
|
474 }
|
|
475 else
|
|
476 msg = g_strdup_printf(_("%s\nUnable to open file: %s"),
|
|
477 _("Couldn't write tag!"), strerror(errno));
|
|
478 if (msg) {
|
|
479 GtkWidget *mwin = xmms_show_message(_("File Info"), msg, _("Ok"),
|
|
480 FALSE, NULL, NULL);
|
|
481 gtk_window_set_transient_for(GTK_WINDOW(mwin), GTK_WINDOW(window));
|
|
482 g_free(msg);
|
|
483 }
|
|
484 else {
|
|
485 gtk_widget_set_sensitive(GTK_WIDGET(data), TRUE);
|
|
486 gtk_widget_set_sensitive(GTK_WIDGET(widget), FALSE);
|
|
487 }
|
|
488 }
|
|
489
|
|
490 #endif /* HAVE_ID3LIB */
|
|
491
|
|
492 static void
|
|
493 label_set_text(GtkWidget * label, gchar * str, ...)
|
|
494 {
|
|
495 va_list args;
|
|
496 gchar tempstr[MAX_STR_LEN];
|
|
497
|
|
498 va_start(args, str);
|
|
499 g_vsnprintf(tempstr, MAX_STR_LEN, str, args);
|
|
500 va_end(args);
|
|
501
|
|
502 gtk_label_set_text(GTK_LABEL(label), tempstr);
|
|
503 }
|
|
504
|
|
505 #ifdef HAVE_ID3LIB
|
|
506
|
|
507 static void
|
|
508 remove_id3_cb(GtkWidget * w, gpointer data)
|
|
509 {
|
|
510 ID3Tag * id3tag;
|
|
511
|
|
512 if (str_has_prefix_nocase(current_filename, "http://"))
|
|
513 return;
|
|
514
|
|
515 id3tag = ID3Tag_New();
|
|
516 ID3Tag_LinkWithFlags(id3tag, current_filename, ID3TT_ID3);
|
|
517
|
|
518 ID3Tag_Strip(id3tag,ID3TT_ALL);
|
|
519 ID3Tag_Update(id3tag);
|
|
520
|
|
521 ID3Tag_Delete(id3tag);
|
|
522 gtk_entry_set_text(GTK_ENTRY(title_entry), "");
|
|
523 gtk_entry_set_text(GTK_ENTRY(artist_entry), "");
|
|
524 gtk_entry_set_text(GTK_ENTRY(album_entry), "");
|
|
525 gtk_text_buffer_set_text(gtk_text_view_get_buffer(GTK_TEXT_VIEW(comment_entry)), "",-1);
|
|
526 gtk_entry_set_text(GTK_ENTRY(year_entry), "");
|
|
527 gtk_entry_set_text(GTK_ENTRY(album_entry), "");
|
|
528 gtk_entry_set_text(GTK_ENTRY(tracknum_entry), "");
|
|
529 gtk_entry_set_text(GTK_ENTRY(totaltracks_entry), "");
|
|
530 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(genre_combo)->entry), "");
|
|
531 gtk_widget_set_sensitive(GTK_WIDGET(w), FALSE);
|
|
532 gtk_widget_set_sensitive(GTK_WIDGET(data), FALSE);
|
|
533 }
|
|
534
|
|
535 #else
|
|
536
|
|
537 static void
|
|
538 remove_id3_cb(GtkWidget * w, gpointer data)
|
|
539 {
|
|
540 VFSFile *file;
|
|
541 gint len;
|
|
542 struct id3v1tag_t tag;
|
|
543 gchar *msg = NULL;
|
|
544
|
|
545 if (str_has_prefix_nocase(current_filename, "http://"))
|
|
546 return;
|
|
547
|
|
548 if ((file = vfs_fopen(current_filename, "rb+")) != NULL) {
|
|
549 vfs_fseek(file, -128, SEEK_END);
|
|
550 len = vfs_ftell(file);
|
|
551
|
|
552 vfs_fread(&tag, 1, sizeof(struct id3v1tag_t), file);
|
|
553
|
|
554 if (g_str_has_prefix(tag.tag, "TAG")) {
|
|
555 if (vfs_truncate(file, len))
|
|
556 msg = g_strdup_printf(_("%s\n"
|
|
557 "Unable to truncate file: %s"),
|
|
558 _("Couldn't remove tag!"),
|
|
559 strerror(errno));
|
|
560 }
|
|
561 else
|
|
562 msg = strdup(_("No tag to remove!"));
|
|
563
|
|
564 vfs_fclose(file);
|
|
565 }
|
|
566 else
|
|
567 msg = g_strdup_printf(_("%s\nUnable to open file: %s"),
|
|
568 _("Couldn't remove tag!"), strerror(errno));
|
|
569 if (msg) {
|
|
570 GtkWidget *mwin = xmms_show_message(_("File Info"), msg, _("Ok"),
|
|
571 FALSE, NULL, NULL);
|
|
572 gtk_window_set_transient_for(GTK_WINDOW(mwin), GTK_WINDOW(window));
|
|
573 g_free(msg);
|
|
574 }
|
|
575 else {
|
|
576 gtk_entry_set_text(GTK_ENTRY(title_entry), "");
|
|
577 gtk_entry_set_text(GTK_ENTRY(artist_entry), "");
|
|
578 gtk_entry_set_text(GTK_ENTRY(album_entry), "");
|
|
579 gtk_entry_set_text(GTK_ENTRY(comment_entry), "");
|
|
580 gtk_entry_set_text(GTK_ENTRY(year_entry), "");
|
|
581 gtk_entry_set_text(GTK_ENTRY(album_entry), "");
|
|
582 gtk_entry_set_text(GTK_ENTRY(tracknum_entry), "");
|
|
583 gtk_widget_set_sensitive(GTK_WIDGET(w), FALSE);
|
|
584 gtk_widget_set_sensitive(GTK_WIDGET(data), FALSE);
|
|
585 }
|
|
586 }
|
|
587
|
|
588 #endif
|
|
589
|
|
590 static void
|
|
591 set_mpeg_level_label(gboolean mpeg25, gint lsf, gint layer)
|
|
592 {
|
|
593 if (mpeg25)
|
|
594 label_set_text(mpeg_level_val, "MPEG-2.5 Layer %d", layer);
|
|
595 else
|
|
596 label_set_text(mpeg_level_val, "MPEG-%d Layer %d", lsf + 1, layer);
|
|
597 }
|
|
598
|
|
599 static const gchar *
|
|
600 channel_mode_name(gint mode)
|
|
601 {
|
|
602 static const gchar *channel_mode[] = { N_("Stereo"), N_("Joint stereo"),
|
|
603 N_("Dual channel"), N_("Single channel")
|
|
604 };
|
|
605 if (mode < 0 || mode > 3)
|
|
606 return "";
|
|
607
|
|
608 return gettext(channel_mode[mode]);
|
|
609 }
|
|
610
|
|
611 static void
|
|
612 file_info_http(gchar * filename)
|
|
613 {
|
|
614 gtk_widget_set_sensitive(id3_frame, FALSE);
|
|
615 if (mpg123_filename && !strcmp(filename, mpg123_filename) &&
|
|
616 mpg123_bitrate != 0) {
|
|
617 set_mpeg_level_label(mpg123_mpeg25, mpg123_lsf, mpg123_layer);
|
|
618 label_set_text(mpeg_bitrate_val, _("%d KBit/s"), mpg123_bitrate);
|
|
619 label_set_text(mpeg_samplerate_val, _("%ld Hz"), mpg123_frequency);
|
|
620 label_set_text(mpeg_flags, "%s", channel_mode_name(mpg123_mode));
|
|
621 }
|
|
622 }
|
|
623
|
|
624 static void
|
|
625 change_buttons(GtkObject * object)
|
|
626 {
|
|
627 gtk_widget_set_sensitive(GTK_WIDGET(object), TRUE);
|
|
628 #if 0
|
|
629 gtk_widget_set_sensitive(GTK_WIDGET(revert),TRUE);
|
|
630 #endif
|
|
631 }
|
|
632
|
|
633 void
|
|
634 mpg123_file_info_box(gchar * filename)
|
|
635 {
|
|
636 gint i;
|
|
637 gchar *title, *filename_utf8;
|
|
638
|
|
639 emphasis[0] = _("None");
|
|
640 emphasis[1] = _("50/15 ms");
|
|
641 emphasis[2] = "";
|
|
642 emphasis[3] = _("CCIT J.17");
|
|
643 bool_label[0] = _("No");
|
|
644 bool_label[1] = _("Yes");
|
|
645
|
|
646 if (!window) {
|
|
647 GtkWidget *pixmapwid;
|
|
648 GdkPixbuf *pixbuf;
|
|
649 PangoAttrList *attrs;
|
|
650 PangoAttribute *attr;
|
|
651 GtkWidget *test_table = gtk_table_new(2, 10, FALSE);
|
|
652 GtkWidget *urk, *blark;
|
|
653 #ifdef HAVE_ID3LIB
|
|
654 GtkWidget * tracknum_box, * comment_frame;
|
|
655 #endif
|
|
656
|
|
657 window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
|
658 gtk_window_set_type_hint(GTK_WINDOW(window),
|
|
659 GDK_WINDOW_TYPE_HINT_DIALOG);
|
|
660 gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
|
|
661 gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
|
|
662 g_signal_connect(G_OBJECT(window), "destroy",
|
|
663 G_CALLBACK(gtk_widget_destroyed), &window);
|
|
664 gtk_container_set_border_width(GTK_CONTAINER(window), 10);
|
|
665
|
|
666 vbox = gtk_vbox_new(FALSE, 10);
|
|
667 gtk_container_add(GTK_CONTAINER(window), vbox);
|
|
668
|
|
669
|
|
670 filename_vbox = gtk_hbox_new(FALSE, 5);
|
|
671 gtk_box_pack_start(GTK_BOX(vbox), filename_vbox, FALSE, TRUE, 0);
|
|
672
|
|
673 pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **)
|
|
674 gnome_mime_audio_xpm);
|
|
675 pixmapwid = gtk_image_new_from_pixbuf(pixbuf);
|
|
676 g_object_unref(pixbuf);
|
|
677 gtk_misc_set_alignment(GTK_MISC(pixmapwid), 0, 0);
|
|
678 gtk_box_pack_start(GTK_BOX(filename_vbox), pixmapwid, FALSE, FALSE,
|
|
679 0);
|
|
680
|
|
681 label = gtk_label_new(NULL);
|
|
682
|
|
683 attrs = pango_attr_list_new();
|
|
684
|
|
685 attr = pango_attr_weight_new(PANGO_WEIGHT_BOLD);
|
|
686 attr->start_index = 0;
|
|
687 attr->end_index = -1;
|
|
688 pango_attr_list_insert(attrs, attr);
|
|
689
|
|
690 gtk_label_set_attributes(GTK_LABEL(label), attrs);
|
|
691 gtk_label_set_text(GTK_LABEL(label), _("Name:"));
|
|
692 gtk_box_pack_start(GTK_BOX(filename_vbox), label, FALSE, FALSE, 0);
|
|
693
|
|
694 filename_entry = gtk_entry_new();
|
|
695 gtk_editable_set_editable(GTK_EDITABLE(filename_entry), FALSE);
|
|
696 gtk_box_pack_start(GTK_BOX(filename_vbox), filename_entry, TRUE,
|
|
697 TRUE, 0);
|
|
698
|
|
699 hbox = gtk_hbox_new(FALSE, 10);
|
|
700 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0);
|
|
701
|
|
702 left_vbox = gtk_table_new(2, 4, FALSE);
|
|
703 gtk_box_pack_start(GTK_BOX(hbox), left_vbox, FALSE, FALSE, 0);
|
|
704
|
|
705 /* MPEG-Info window */
|
|
706
|
|
707 mpeg_frame = gtk_frame_new(_(" MPEG Info "));
|
|
708 gtk_table_attach(GTK_TABLE(left_vbox), mpeg_frame, 0, 2, 0, 1,
|
|
709 GTK_FILL, GTK_FILL, 0, 4);
|
|
710
|
|
711 mpeg_box = gtk_vbox_new(FALSE, 5);
|
|
712 gtk_container_add(GTK_CONTAINER(mpeg_frame), mpeg_box);
|
|
713 gtk_container_set_border_width(GTK_CONTAINER(mpeg_box), 10);
|
|
714 gtk_box_set_spacing(GTK_BOX(mpeg_box), 0);
|
|
715
|
|
716 /* MPEG Layer Info */
|
|
717
|
|
718 /* FIXME: Obvious... */
|
|
719 gtk_container_set_border_width(GTK_CONTAINER(test_table), 0);
|
|
720 gtk_container_add(GTK_CONTAINER(mpeg_box), test_table);
|
|
721
|
|
722 mpeg_level = gtk_label_new(_("MPEG Level:"));
|
|
723 gtk_misc_set_alignment(GTK_MISC(mpeg_level), 1, 0.5);
|
|
724 gtk_label_set_justify(GTK_LABEL(mpeg_level), GTK_JUSTIFY_RIGHT);
|
|
725 gtk_label_set_attributes(GTK_LABEL(mpeg_level), attrs);
|
|
726 gtk_table_attach(GTK_TABLE(test_table), mpeg_level, 0, 1, 0, 1,
|
|
727 GTK_FILL, GTK_FILL, 5, 2);
|
|
728
|
|
729 mpeg_level_val = gtk_label_new("");
|
|
730 gtk_misc_set_alignment(GTK_MISC(mpeg_level_val), 0, 0);
|
|
731 gtk_label_set_justify(GTK_LABEL(mpeg_level_val), GTK_JUSTIFY_LEFT);
|
|
732 gtk_table_attach(GTK_TABLE(test_table), mpeg_level_val, 1, 2, 0, 1,
|
|
733 GTK_FILL, GTK_FILL, 10, 2);
|
|
734
|
|
735 mpeg_bitrate = gtk_label_new(_("Bit rate:"));
|
|
736 gtk_misc_set_alignment(GTK_MISC(mpeg_bitrate), 1, 0.5);
|
|
737 gtk_label_set_justify(GTK_LABEL(mpeg_bitrate), GTK_JUSTIFY_RIGHT);
|
|
738 gtk_label_set_attributes(GTK_LABEL(mpeg_bitrate), attrs);
|
|
739 gtk_table_attach(GTK_TABLE(test_table), mpeg_bitrate, 0, 1, 1, 2,
|
|
740 GTK_FILL, GTK_FILL, 5, 2);
|
|
741
|
|
742 mpeg_bitrate_val = gtk_label_new("");
|
|
743 gtk_misc_set_alignment(GTK_MISC(mpeg_bitrate_val), 0, 0);
|
|
744 gtk_label_set_justify(GTK_LABEL(mpeg_bitrate_val), GTK_JUSTIFY_LEFT);
|
|
745 gtk_table_attach(GTK_TABLE(test_table), mpeg_bitrate_val, 1, 2, 1,
|
|
746 2, GTK_FILL, GTK_FILL, 10, 2);
|
|
747
|
|
748 mpeg_samplerate = gtk_label_new(_("Sample rate:"));
|
|
749 gtk_misc_set_alignment(GTK_MISC(mpeg_samplerate), 1, 0.5);
|
|
750 gtk_label_set_justify(GTK_LABEL(mpeg_samplerate), GTK_JUSTIFY_RIGHT);
|
|
751 gtk_label_set_attributes(GTK_LABEL(mpeg_samplerate), attrs);
|
|
752 gtk_table_attach(GTK_TABLE(test_table), mpeg_samplerate, 0, 1, 2,
|
|
753 3, GTK_FILL, GTK_FILL, 5, 2);
|
|
754
|
|
755 mpeg_samplerate_val = gtk_label_new("");
|
|
756 gtk_misc_set_alignment(GTK_MISC(mpeg_samplerate_val), 0, 0);
|
|
757 gtk_label_set_justify(GTK_LABEL(mpeg_samplerate_val),
|
|
758 GTK_JUSTIFY_LEFT);
|
|
759 gtk_table_attach(GTK_TABLE(test_table), mpeg_samplerate_val, 1, 2,
|
|
760 2, 3, GTK_FILL, GTK_FILL, 10, 2);
|
|
761
|
|
762 mpeg_frames = gtk_label_new(_("Frames:"));
|
|
763 gtk_misc_set_alignment(GTK_MISC(mpeg_frames), 1, 0.5);
|
|
764 gtk_label_set_justify(GTK_LABEL(mpeg_frames), GTK_JUSTIFY_RIGHT);
|
|
765 gtk_label_set_attributes(GTK_LABEL(mpeg_frames), attrs);
|
|
766 gtk_table_attach(GTK_TABLE(test_table), mpeg_frames, 0, 1, 3, 4,
|
|
767 GTK_FILL, GTK_FILL, 5, 2);
|
|
768
|
|
769 mpeg_frames_val = gtk_label_new("");
|
|
770 gtk_misc_set_alignment(GTK_MISC(mpeg_frames_val), 0, 0);
|
|
771 gtk_label_set_justify(GTK_LABEL(mpeg_frames_val), GTK_JUSTIFY_LEFT);
|
|
772 gtk_table_attach(GTK_TABLE(test_table), mpeg_frames_val, 1, 2, 3,
|
|
773 4, GTK_FILL, GTK_FILL, 10, 2);
|
|
774
|
|
775 mpeg_filesize = gtk_label_new(_("File size:"));
|
|
776 gtk_misc_set_alignment(GTK_MISC(mpeg_filesize), 1, 0.5);
|
|
777 gtk_label_set_justify(GTK_LABEL(mpeg_filesize), GTK_JUSTIFY_RIGHT);
|
|
778 gtk_label_set_attributes(GTK_LABEL(mpeg_filesize), attrs);
|
|
779 gtk_table_attach(GTK_TABLE(test_table), mpeg_filesize, 0, 1, 4, 5,
|
|
780 GTK_FILL, GTK_FILL, 5, 2);
|
|
781
|
|
782 mpeg_filesize_val = gtk_label_new("");
|
|
783 gtk_misc_set_alignment(GTK_MISC(mpeg_filesize_val), 0, 0);
|
|
784 gtk_label_set_justify(GTK_LABEL(mpeg_filesize_val), GTK_JUSTIFY_LEFT);
|
|
785 gtk_table_attach(GTK_TABLE(test_table), mpeg_filesize_val, 1, 2, 4,
|
|
786 5, GTK_FILL, GTK_FILL, 10, 2);
|
|
787
|
|
788 urk = gtk_label_new("");
|
|
789 blark = gtk_label_new("");
|
|
790 gtk_misc_set_alignment(GTK_MISC(urk), 1, 0.5);
|
|
791 gtk_misc_set_alignment(GTK_MISC(blark), 0, 0);
|
|
792
|
|
793 gtk_table_attach(GTK_TABLE(test_table), urk, 0, 1, 5, 6, GTK_FILL,
|
|
794 GTK_FILL, 5, 5);
|
|
795 gtk_table_attach(GTK_TABLE(test_table), blark, 1, 2, 5, 6,
|
|
796 GTK_FILL, GTK_FILL, 10, 5);
|
|
797
|
|
798 mpeg_error = gtk_label_new(_("Error Protection:"));
|
|
799 gtk_misc_set_alignment(GTK_MISC(mpeg_error), 1, 0.5);
|
|
800 gtk_label_set_justify(GTK_LABEL(mpeg_error), GTK_JUSTIFY_RIGHT);
|
|
801 gtk_label_set_attributes(GTK_LABEL(mpeg_error), attrs);
|
|
802 gtk_table_attach(GTK_TABLE(test_table), mpeg_error, 0, 1, 6, 7,
|
|
803 GTK_FILL, GTK_FILL, 5, 0);
|
|
804
|
|
805 mpeg_error_val = gtk_label_new("");
|
|
806 gtk_misc_set_alignment(GTK_MISC(mpeg_error_val), 0, 0);
|
|
807 gtk_label_set_justify(GTK_LABEL(mpeg_error_val), GTK_JUSTIFY_LEFT);
|
|
808 gtk_table_attach(GTK_TABLE(test_table), mpeg_error_val, 1, 2, 6, 7,
|
|
809 GTK_FILL, GTK_FILL, 10, 2);
|
|
810
|
|
811 mpeg_copy = gtk_label_new(_("Copyright:"));
|
|
812 gtk_misc_set_alignment(GTK_MISC(mpeg_copy), 1, 0.5);
|
|
813 gtk_label_set_justify(GTK_LABEL(mpeg_copy), GTK_JUSTIFY_RIGHT);
|
|
814 gtk_label_set_attributes(GTK_LABEL(mpeg_copy), attrs);
|
|
815 gtk_table_attach(GTK_TABLE(test_table), mpeg_copy, 0, 1, 7, 8,
|
|
816 GTK_FILL, GTK_FILL, 5, 2);
|
|
817
|
|
818 mpeg_copy_val = gtk_label_new("");
|
|
819 gtk_misc_set_alignment(GTK_MISC(mpeg_copy_val), 0, 0);
|
|
820 gtk_label_set_justify(GTK_LABEL(mpeg_copy_val), GTK_JUSTIFY_LEFT);
|
|
821 gtk_table_attach(GTK_TABLE(test_table), mpeg_copy_val, 1, 2, 7, 8,
|
|
822 GTK_FILL, GTK_FILL, 10, 2);
|
|
823
|
|
824 mpeg_orig = gtk_label_new(_("Original:"));
|
|
825 gtk_misc_set_alignment(GTK_MISC(mpeg_orig), 1, 0.5);
|
|
826 gtk_label_set_justify(GTK_LABEL(mpeg_orig), GTK_JUSTIFY_RIGHT);
|
|
827 gtk_label_set_attributes(GTK_LABEL(mpeg_orig), attrs);
|
|
828 gtk_table_attach(GTK_TABLE(test_table), mpeg_orig, 0, 1, 8, 9,
|
|
829 GTK_FILL, GTK_FILL, 5, 2);
|
|
830
|
|
831 mpeg_orig_val = gtk_label_new("");
|
|
832 gtk_misc_set_alignment(GTK_MISC(mpeg_orig_val), 0, 0);
|
|
833 gtk_label_set_justify(GTK_LABEL(mpeg_orig_val), GTK_JUSTIFY_LEFT);
|
|
834 gtk_table_attach(GTK_TABLE(test_table), mpeg_orig_val, 1, 2, 8, 9,
|
|
835 GTK_FILL, GTK_FILL, 10, 2);
|
|
836
|
|
837 mpeg_emph = gtk_label_new(_("Emphasis:"));
|
|
838 gtk_misc_set_alignment(GTK_MISC(mpeg_emph), 1, 0.5);
|
|
839 gtk_label_set_justify(GTK_LABEL(mpeg_emph), GTK_JUSTIFY_RIGHT);
|
|
840 gtk_label_set_attributes(GTK_LABEL(mpeg_emph), attrs);
|
|
841 gtk_table_attach(GTK_TABLE(test_table), mpeg_emph, 0, 1, 9, 10,
|
|
842 GTK_FILL, GTK_FILL, 5, 2);
|
|
843
|
|
844 mpeg_emph_val = gtk_label_new("");
|
|
845 gtk_misc_set_alignment(GTK_MISC(mpeg_emph_val), 0, 0);
|
|
846 gtk_label_set_justify(GTK_LABEL(mpeg_emph_val), GTK_JUSTIFY_LEFT);
|
|
847 gtk_table_attach(GTK_TABLE(test_table), mpeg_emph_val, 1, 2, 9, 10,
|
|
848 GTK_FILL, GTK_FILL, 10, 2);
|
|
849
|
|
850
|
|
851 id3_frame = gtk_frame_new(_(" ID3 Tag "));
|
|
852 gtk_table_attach(GTK_TABLE(left_vbox), id3_frame, 2, 4, 0, 1,
|
|
853 GTK_FILL, GTK_FILL, 0, 4);
|
|
854
|
|
855 table = gtk_table_new(7, 5, FALSE);
|
|
856 gtk_container_set_border_width(GTK_CONTAINER(table), 5);
|
|
857 gtk_container_add(GTK_CONTAINER(id3_frame), table);
|
|
858
|
|
859 label = gtk_label_new(_("Title:"));
|
|
860 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
|
|
861 gtk_label_set_attributes(GTK_LABEL(label), attrs);
|
|
862 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, GTK_FILL,
|
|
863 GTK_FILL, 5, 5);
|
|
864
|
|
865 #ifdef HAVE_ID3LIB
|
|
866 title_entry = gtk_entry_new();
|
|
867 #else
|
|
868 title_entry = gtk_entry_new_with_max_length(30);
|
|
869 #endif
|
|
870 gtk_table_attach(GTK_TABLE(table), title_entry, 1, 6, 0, 1,
|
|
871 GTK_FILL | GTK_EXPAND | GTK_SHRINK,
|
|
872 GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
|
|
873
|
|
874 label = gtk_label_new(_("Artist:"));
|
|
875 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
|
|
876 gtk_label_set_attributes(GTK_LABEL(label), attrs);
|
|
877 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, GTK_FILL,
|
|
878 GTK_FILL, 5, 5);
|
|
879
|
|
880 #ifdef HAVE_ID3LIB
|
|
881 artist_entry = gtk_entry_new();
|
|
882 #else
|
|
883 artist_entry = gtk_entry_new_with_max_length(30);
|
|
884 #endif
|
|
885 gtk_table_attach(GTK_TABLE(table), artist_entry, 1, 6, 1, 2,
|
|
886 GTK_FILL | GTK_EXPAND | GTK_SHRINK,
|
|
887 GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
|
|
888
|
|
889 label = gtk_label_new(_("Album:"));
|
|
890 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
|
|
891 gtk_label_set_attributes(GTK_LABEL(label), attrs);
|
|
892 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3, GTK_FILL,
|
|
893 GTK_FILL, 5, 5);
|
|
894
|
|
895 #ifdef HAVE_ID3LIB
|
|
896 album_entry = gtk_entry_new();
|
|
897 #else
|
|
898 album_entry = gtk_entry_new_with_max_length(30);
|
|
899 #endif
|
|
900 gtk_table_attach(GTK_TABLE(table), album_entry, 1, 6, 2, 3,
|
|
901 GTK_FILL | GTK_EXPAND | GTK_SHRINK,
|
|
902 GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
|
|
903
|
|
904 label = gtk_label_new(_("Comment:"));
|
|
905 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
|
|
906 gtk_label_set_attributes(GTK_LABEL(label), attrs);
|
|
907 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4, GTK_FILL,
|
|
908 GTK_FILL, 5, 5);
|
|
909
|
|
910 #ifdef HAVE_ID3LIB
|
|
911 comment_frame = gtk_frame_new(NULL);
|
|
912 gtk_frame_set_shadow_type(GTK_FRAME(comment_frame),GTK_SHADOW_IN);
|
|
913 comment_entry = gtk_text_view_new();
|
|
914 gtk_text_view_set_accepts_tab(GTK_TEXT_VIEW(comment_entry),FALSE);
|
|
915 gtk_container_add(GTK_CONTAINER(comment_frame),comment_entry);
|
|
916 gtk_table_attach(GTK_TABLE(table), comment_frame, 1, 6, 3, 4,
|
|
917 GTK_FILL | GTK_EXPAND | GTK_SHRINK,
|
|
918 GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
|
|
919 #else
|
|
920 comment_entry = gtk_entry_new_with_max_length(30);
|
|
921 gtk_table_attach(GTK_TABLE(table), comment_entry, 1, 6, 3, 4,
|
|
922 GTK_FILL | GTK_EXPAND | GTK_SHRINK,
|
|
923 GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
|
|
924 #endif
|
|
925
|
|
926 label = gtk_label_new(_("Year:"));
|
|
927 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
|
|
928 gtk_label_set_attributes(GTK_LABEL(label), attrs);
|
|
929 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 4, 5, GTK_FILL,
|
|
930 GTK_FILL, 5, 5);
|
|
931
|
|
932 year_entry = gtk_entry_new_with_max_length(4);
|
|
933 gtk_entry_set_width_chars(GTK_ENTRY(year_entry),4);
|
|
934 gtk_table_attach(GTK_TABLE(table), year_entry, 1, 2, 4, 5,
|
|
935 GTK_FILL | GTK_EXPAND | GTK_SHRINK,
|
|
936 GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
|
|
937
|
|
938 label = gtk_label_new(_("Track number:"));
|
|
939 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
|
|
940 gtk_label_set_attributes(GTK_LABEL(label), attrs);
|
|
941 gtk_table_attach(GTK_TABLE(table), label, 2, 3, 4, 5, GTK_FILL,
|
|
942 GTK_FILL, 5, 5);
|
|
943
|
|
944 #ifdef HAVE_ID3LIB
|
|
945 tracknum_box = gtk_hbox_new(FALSE,0);
|
|
946 tracknum_entry = gtk_entry_new_with_max_length(2);
|
|
947 gtk_entry_set_width_chars(GTK_ENTRY(tracknum_entry),2);
|
|
948 totaltracks_entry = gtk_entry_new_with_max_length(2);
|
|
949 gtk_entry_set_width_chars(GTK_ENTRY(totaltracks_entry),2);
|
|
950 gtk_box_pack_start(GTK_BOX(tracknum_box),
|
|
951 tracknum_entry, TRUE, TRUE, 1);
|
|
952 gtk_box_pack_start(GTK_BOX(tracknum_box),
|
|
953 gtk_label_new(" / "), FALSE, FALSE, 1);
|
|
954 gtk_box_pack_start(GTK_BOX(tracknum_box),
|
|
955 totaltracks_entry, TRUE, TRUE, 1);
|
|
956 gtk_table_attach(GTK_TABLE(table),
|
|
957 tracknum_box,
|
|
958 3, 4, 4, 5,
|
|
959 GTK_FILL | GTK_EXPAND | GTK_SHRINK,
|
|
960 GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
|
|
961
|
|
962 #else
|
|
963 tracknum_entry = gtk_entry_new_with_max_length(3);
|
|
964 gtk_widget_set_usize(tracknum_entry, 40, -1);
|
|
965 gtk_table_attach(GTK_TABLE(table), tracknum_entry, 3, 4, 4, 5,
|
|
966 GTK_FILL | GTK_EXPAND | GTK_SHRINK,
|
|
967 GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
|
|
968 #endif
|
|
969
|
|
970 label = gtk_label_new(_("Genre:"));
|
|
971 gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5);
|
|
972 gtk_label_set_attributes(GTK_LABEL(label), attrs);
|
|
973 gtk_table_attach(GTK_TABLE(table), label, 0, 1, 5, 6, GTK_FILL,
|
|
974 GTK_FILL, 5, 5);
|
|
975
|
|
976 pango_attr_list_unref(attrs);
|
|
977
|
|
978 genre_combo = gtk_combo_new();
|
|
979 gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(genre_combo)->entry),
|
|
980 FALSE);
|
|
981 if (!genre_list) {
|
|
982 for (i = 0; i < GENRE_MAX; i++)
|
|
983 genre_list =
|
|
984 g_list_prepend(genre_list,
|
|
985 (gchar *) mpg123_id3_genres[i]);
|
|
986 genre_list = g_list_prepend(genre_list, "");
|
|
987 genre_list = g_list_sort(genre_list, genre_comp_func);
|
|
988 }
|
|
989 gtk_combo_set_popdown_strings(GTK_COMBO(genre_combo), genre_list);
|
|
990
|
|
991 gtk_table_attach(GTK_TABLE(table), genre_combo, 1, 6, 5, 6,
|
|
992 GTK_FILL | GTK_EXPAND | GTK_SHRINK,
|
|
993 GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
|
|
994
|
|
995 boxx = gtk_hbutton_box_new();
|
|
996 gtk_hbutton_box_set_layout_default(GTK_BUTTONBOX_SPREAD);
|
|
997
|
|
998 remove_id3 = gtk_button_new_from_stock(GTK_STOCK_DELETE);
|
|
999 gtk_container_add(GTK_CONTAINER(boxx), remove_id3);
|
|
1000
|
|
1001 #if 0
|
|
1002 revert = gtk_button_new_from_stock(GTK_STOCK_REVERT_TO_SAVED);
|
|
1003 gtk_container_add(GTK_CONTAINER(boxx), revert);
|
|
1004 #endif
|
|
1005
|
|
1006 #ifdef HAVE_ID3LIB
|
|
1007 copy_album_tags_but = gtk_button_new_with_label(_("Copy album tags"));
|
|
1008 paste_album_tags_but = gtk_button_new_with_label(_("Paste album tags"));
|
|
1009
|
|
1010 gtk_container_add(GTK_CONTAINER(boxx), copy_album_tags_but);
|
|
1011 gtk_container_add(GTK_CONTAINER(boxx), paste_album_tags_but);
|
|
1012
|
|
1013 g_signal_connect(G_OBJECT(copy_album_tags_but), "clicked",
|
|
1014 G_CALLBACK(copy_album_tags), NULL);
|
|
1015 g_signal_connect(G_OBJECT(paste_album_tags_but), "clicked",
|
|
1016 G_CALLBACK(paste_album_tags), NULL);
|
|
1017
|
|
1018 gtk_widget_set_sensitive(GTK_WIDGET(paste_album_tags_but), FALSE);
|
|
1019 #endif
|
|
1020 save = gtk_button_new_from_stock(GTK_STOCK_SAVE);
|
|
1021 gtk_container_add(GTK_CONTAINER(boxx), save);
|
|
1022
|
|
1023 g_signal_connect(G_OBJECT(remove_id3), "clicked",
|
|
1024 G_CALLBACK(remove_id3_cb), save);
|
|
1025 g_signal_connect(G_OBJECT(save), "clicked", G_CALLBACK(save_cb),
|
|
1026 remove_id3);
|
|
1027 #if 0
|
|
1028 g_signal_connect(G_OBJECT(revert), "clicked", G_CALLBACK(fill_entries),
|
|
1029 NULL);
|
|
1030 #endif
|
|
1031
|
|
1032
|
|
1033 gtk_table_attach(GTK_TABLE(table), boxx, 0, 5, 6, 7, GTK_FILL, 0,
|
|
1034 0, 8);
|
|
1035
|
|
1036 bbox = gtk_hbutton_box_new();
|
|
1037 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
|
|
1038 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5);
|
|
1039 gtk_table_attach(GTK_TABLE(left_vbox), bbox, 0, 4, 1, 2, GTK_FILL,
|
|
1040 0, 0, 8);
|
|
1041
|
|
1042 cancel = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
|
|
1043 g_signal_connect_swapped(G_OBJECT(cancel), "clicked",
|
|
1044 G_CALLBACK(gtk_widget_destroy),
|
|
1045 G_OBJECT(window));
|
|
1046 GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT);
|
|
1047 gtk_box_pack_start(GTK_BOX(bbox), cancel, FALSE, FALSE, 0);
|
|
1048 gtk_widget_grab_default(cancel);
|
|
1049
|
|
1050
|
|
1051 gtk_table_set_col_spacing(GTK_TABLE(left_vbox), 1, 10);
|
|
1052
|
|
1053
|
|
1054 g_signal_connect_swapped(G_OBJECT(title_entry), "changed",
|
|
1055 G_CALLBACK(change_buttons), save);
|
|
1056 g_signal_connect_swapped(G_OBJECT(artist_entry), "changed",
|
|
1057 G_CALLBACK(change_buttons), save);
|
|
1058 g_signal_connect_swapped(G_OBJECT(album_entry), "changed",
|
|
1059 G_CALLBACK(change_buttons), save);
|
|
1060 g_signal_connect_swapped(G_OBJECT(year_entry), "changed",
|
|
1061 G_CALLBACK(change_buttons), save);
|
|
1062 #ifdef HAVE_ID3LIB
|
|
1063 g_signal_connect_swapped(G_OBJECT(gtk_text_view_get_buffer(GTK_TEXT_VIEW(comment_entry))), "changed",
|
|
1064 G_CALLBACK(change_buttons), save);
|
|
1065 g_signal_connect_swapped(G_OBJECT(totaltracks_entry), "changed",
|
|
1066 G_CALLBACK(change_buttons), save);
|
|
1067 #else
|
|
1068 g_signal_connect_swapped(G_OBJECT(comment_entry), "changed",
|
|
1069 G_CALLBACK(change_buttons), save);
|
|
1070 #endif
|
|
1071 g_signal_connect_swapped(G_OBJECT(tracknum_entry), "changed",
|
|
1072 G_CALLBACK(change_buttons), save);
|
|
1073 g_signal_connect_swapped(G_OBJECT(GTK_COMBO(genre_combo)->entry), "changed",
|
|
1074 G_CALLBACK(change_buttons), save);
|
|
1075
|
|
1076 /* Nonsence, should i remove this altogether?
|
|
1077 causes changes to be saved as you type -
|
|
1078 makes save /revert buttons pointless
|
|
1079 g_signal_connect(G_OBJECT(title_entry), "activate",
|
|
1080 G_CALLBACK(press_save), NULL);
|
|
1081 g_signal_connect(G_OBJECT(artist_entry), "activate",
|
|
1082 G_CALLBACK(press_save), NULL);
|
|
1083 g_signal_connect(G_OBJECT(album_entry), "activate",
|
|
1084 G_CALLBACK(press_save), NULL);
|
|
1085 g_signal_connect(G_OBJECT(year_entry), "activate",
|
|
1086 G_CALLBACK(press_save), NULL);
|
|
1087 g_signal_connect(G_OBJECT(comment_entry), "activate",
|
|
1088 G_CALLBACK(press_save), NULL);
|
|
1089 g_signal_connect(G_OBJECT(tracknum_entry), "activate",
|
|
1090 G_CALLBACK(press_save), NULL);
|
|
1091 */
|
|
1092 g_signal_connect(G_OBJECT(window), "key_press_event",
|
|
1093 G_CALLBACK(fileinfo_keypress_cb), NULL);
|
|
1094 }
|
|
1095
|
|
1096 g_free(current_filename);
|
|
1097 current_filename = g_strdup(filename);
|
|
1098
|
|
1099 filename_utf8 = filename_to_utf8(filename);
|
|
1100
|
|
1101 title = g_strdup_printf(_("%s - BMP"), g_basename(filename_utf8));
|
|
1102 gtk_window_set_title(GTK_WINDOW(window), title);
|
|
1103 g_free(title);
|
|
1104
|
|
1105 gtk_entry_set_text(GTK_ENTRY(filename_entry), filename_utf8);
|
|
1106 g_free(filename_utf8);
|
|
1107
|
|
1108 gtk_editable_set_position(GTK_EDITABLE(filename_entry), -1);
|
|
1109
|
|
1110 gtk_entry_set_text(GTK_ENTRY(artist_entry), "");
|
|
1111 gtk_entry_set_text(GTK_ENTRY(album_entry), "");
|
|
1112 gtk_entry_set_text(GTK_ENTRY(year_entry), "");
|
|
1113 gtk_entry_set_text(GTK_ENTRY(tracknum_entry), "");
|
|
1114 #ifdef HAVE_ID3LIB
|
|
1115 gtk_text_buffer_set_text(gtk_text_view_get_buffer(GTK_TEXT_VIEW(comment_entry)),"",-1);
|
|
1116 #else
|
|
1117 gtk_entry_set_text(GTK_ENTRY(comment_entry), "");
|
|
1118 #endif
|
|
1119 gtk_list_select_item(GTK_LIST(GTK_COMBO(genre_combo)->list),
|
|
1120 g_list_index(genre_list, ""));
|
|
1121
|
|
1122 gtk_label_set_text(GTK_LABEL(mpeg_level), _("MPEG Level:"));
|
|
1123 gtk_label_set_text(GTK_LABEL(mpeg_level_val), _("N/A"));
|
|
1124
|
|
1125 gtk_label_set_text(GTK_LABEL(mpeg_bitrate), _("Bit rate:"));
|
|
1126 gtk_label_set_text(GTK_LABEL(mpeg_bitrate_val), _("N/A"));
|
|
1127
|
|
1128 gtk_label_set_text(GTK_LABEL(mpeg_samplerate), _("Sample rate:"));
|
|
1129 gtk_label_set_text(GTK_LABEL(mpeg_samplerate_val), _("N/A"));
|
|
1130
|
|
1131 gtk_label_set_text(GTK_LABEL(mpeg_error), _("Error Protection:"));
|
|
1132 gtk_label_set_text(GTK_LABEL(mpeg_error_val), _("N/A"));
|
|
1133
|
|
1134 gtk_label_set_text(GTK_LABEL(mpeg_copy), _("Copyright:"));
|
|
1135 gtk_label_set_text(GTK_LABEL(mpeg_copy_val), _("N/A"));
|
|
1136
|
|
1137 gtk_label_set_text(GTK_LABEL(mpeg_orig), _("Original:"));
|
|
1138 gtk_label_set_text(GTK_LABEL(mpeg_orig_val), _("N/A"));
|
|
1139
|
|
1140 gtk_label_set_text(GTK_LABEL(mpeg_emph), _("Emphasis:"));
|
|
1141 gtk_label_set_text(GTK_LABEL(mpeg_emph_val), _("N/A"));
|
|
1142
|
|
1143 gtk_label_set_text(GTK_LABEL(mpeg_frames), _("Frames:"));
|
|
1144 gtk_label_set_text(GTK_LABEL(mpeg_frames_val), _("N/A"));
|
|
1145
|
|
1146 gtk_label_set_text(GTK_LABEL(mpeg_filesize), _("File size:"));
|
|
1147 gtk_label_set_text(GTK_LABEL(mpeg_filesize_val), _("N/A"));
|
|
1148
|
|
1149 if (str_has_prefix_nocase(filename, "http://")) {
|
|
1150 file_info_http(filename);
|
|
1151 return;
|
|
1152 }
|
|
1153
|
|
1154 gtk_widget_set_sensitive(id3_frame,
|
|
1155 vfs_is_writeable(filename));
|
|
1156
|
|
1157 fill_entries(NULL, NULL);
|
|
1158
|
|
1159 gtk_widget_set_sensitive(GTK_WIDGET(save), FALSE);
|
|
1160 #if 0
|
|
1161 gtk_widget_set_sensitive(GTK_WIDGET(revert), FALSE);
|
|
1162 #endif
|
|
1163 gtk_widget_show_all(window);
|
|
1164 }
|
|
1165
|
|
1166 #ifdef HAVE_ID3LIB
|
|
1167
|
|
1168 void
|
|
1169 fill_entries(GtkWidget * w, gpointer data)
|
|
1170 {
|
|
1171 VFSFile *fh;
|
|
1172 ID3Tag * id3tag;
|
|
1173
|
|
1174 if (str_has_prefix_nocase(current_filename, "http://"))
|
|
1175 return;
|
|
1176
|
|
1177 id3tag = ID3Tag_New();
|
|
1178 ID3Tag_LinkPreferV2(id3tag, current_filename);
|
|
1179
|
|
1180 id3v2_frame_to_entry(title_entry, id3tag, ID3FID_TITLE);
|
|
1181 id3v2_frame_to_entry(artist_entry, id3tag, ID3FID_LEADARTIST);
|
|
1182 id3v2_frame_to_entry(album_entry, id3tag, ID3FID_ALBUM);
|
|
1183 id3v2_frame_to_text_view(comment_entry, id3tag, ID3FID_COMMENT);
|
|
1184 id3v2_frame_to_entry(year_entry, id3tag, ID3FID_YEAR);
|
|
1185 id3v2_tracknum_to_entries(tracknum_entry, totaltracks_entry, id3tag);
|
|
1186 {
|
|
1187 ID3Frame * frame = ID3Tag_FindFrameWithID(id3tag, ID3FID_CONTENTTYPE);
|
|
1188
|
|
1189 if (frame) {
|
|
1190 int genre_idx = -1;
|
|
1191 char genre[64];
|
|
1192 const char * genre2;
|
|
1193 ID3Field * text_field = ID3Frame_GetField(frame,ID3FN_TEXT);
|
|
1194 ID3Field_GetASCII(text_field,genre,64);
|
|
1195
|
|
1196 /* attempt to find corresponding genre */
|
|
1197 g_strstrip(genre);
|
|
1198 sscanf(genre,"(%d)",&genre_idx);
|
|
1199 if ((genre2 = ID3_V1GENRE2DESCRIPTION(genre_idx)))
|
|
1200 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(genre_combo)->entry),
|
|
1201 genre2);
|
|
1202 }
|
|
1203 }
|
|
1204
|
|
1205 gtk_widget_set_sensitive(GTK_WIDGET(remove_id3), TRUE);
|
|
1206 gtk_widget_set_sensitive(GTK_WIDGET(save), FALSE);
|
|
1207
|
|
1208 update_paste_sensitive();
|
|
1209
|
|
1210 ID3Tag_Delete(id3tag);
|
|
1211
|
|
1212 if ((fh = vfs_fopen(current_filename, "rb")) != NULL) {
|
|
1213 guint32 head;
|
|
1214 guchar tmp[4];
|
|
1215 struct frame frm;
|
|
1216 gboolean id3_found = FALSE;
|
|
1217
|
|
1218 if (vfs_fread(tmp, 1, 4, fh) != 4) {
|
|
1219 vfs_fclose(fh);
|
|
1220 return;
|
|
1221 }
|
|
1222 head =
|
|
1223 ((guint32) tmp[0] << 24) | ((guint32) tmp[1] << 16) |
|
|
1224 ((guint32) tmp[2] << 8) | (guint32) tmp[3];
|
|
1225 while (!mpg123_head_check(head)) {
|
|
1226 head <<= 8;
|
|
1227 if (vfs_fread(tmp, 1, 1, fh) != 1) {
|
|
1228 vfs_fclose(fh);
|
|
1229 return;
|
|
1230 }
|
|
1231 head |= tmp[0];
|
|
1232 }
|
|
1233 if (mpg123_decode_header(&frm, head)) {
|
|
1234 guchar *buf;
|
|
1235 gdouble tpf;
|
|
1236 gint pos;
|
|
1237 xing_header_t xing_header;
|
|
1238 guint32 num_frames;
|
|
1239
|
|
1240 buf = g_malloc(frm.framesize + 4);
|
|
1241 vfs_fseek(fh, -4, SEEK_CUR);
|
|
1242 vfs_fread(buf, 1, frm.framesize + 4, fh);
|
|
1243 tpf = mpg123_compute_tpf(&frm);
|
|
1244 set_mpeg_level_label(frm.mpeg25, frm.lsf, frm.lay);
|
|
1245 pos = vfs_ftell(fh);
|
|
1246 vfs_fseek(fh, 0, SEEK_END);
|
|
1247 if (mpg123_get_xing_header(&xing_header, buf)) {
|
|
1248 num_frames = xing_header.frames;
|
|
1249 label_set_text(mpeg_bitrate_val,
|
|
1250 _("Variable,\navg. bitrate: %d KBit/s"),
|
|
1251 (gint) ((xing_header.bytes * 8) /
|
|
1252 (tpf * xing_header.frames * 1000)));
|
|
1253 }
|
|
1254 else {
|
|
1255 num_frames =
|
|
1256 ((vfs_ftell(fh) - pos -
|
|
1257 (id3_found ? 128 : 0)) / mpg123_compute_bpf(&frm)) + 1;
|
|
1258 label_set_text(mpeg_bitrate_val, _("%d KBit/s"),
|
|
1259 tabsel_123[frm.lsf][frm.lay -
|
|
1260 1][frm.bitrate_index]);
|
|
1261 }
|
|
1262 label_set_text(mpeg_samplerate_val, _("%ld Hz"),
|
|
1263 mpg123_freqs[frm.sampling_frequency]);
|
|
1264 label_set_text(mpeg_error_val, _("%s"),
|
|
1265 bool_label[frm.error_protection]);
|
|
1266 label_set_text(mpeg_copy_val, _("%s"), bool_label[frm.copyright]);
|
|
1267 label_set_text(mpeg_orig_val, _("%s"), bool_label[frm.original]);
|
|
1268 label_set_text(mpeg_emph_val, _("%s"), emphasis[frm.emphasis]);
|
|
1269 label_set_text(mpeg_frames_val, _("%d"), num_frames);
|
|
1270 label_set_text(mpeg_filesize_val, _("%lu Bytes"), vfs_ftell(fh));
|
|
1271 g_free(buf);
|
|
1272 }
|
|
1273 vfs_fclose(fh);
|
|
1274 }
|
|
1275
|
|
1276 }
|
|
1277
|
|
1278 #else /* ! HAVE_ID3LIB */
|
|
1279
|
|
1280 void
|
|
1281 fill_entries(GtkWidget * w, gpointer data)
|
|
1282 {
|
|
1283 if ((fh = vfs_fopen(current_filename, "rb")) != NULL) {
|
|
1284 guint32 head;
|
|
1285 guchar tmp[4];
|
|
1286 struct frame frm;
|
|
1287 gboolean id3_found = FALSE;
|
|
1288
|
|
1289 vfs_fseek(fh, -sizeof(tag), SEEK_END);
|
|
1290 if (vfs_fread(&tag, 1, sizeof(tag), fh) == sizeof(tag)) {
|
|
1291 if (!strncmp(tag.tag, "TAG", 3)) {
|
|
1292 id3_found = TRUE;
|
|
1293 set_entry_tag(GTK_ENTRY(title_entry), tag.title, 30);
|
|
1294 set_entry_tag(GTK_ENTRY(artist_entry), tag.artist, 30);
|
|
1295 set_entry_tag(GTK_ENTRY(album_entry), tag.album, 30);
|
|
1296 set_entry_tag(GTK_ENTRY(year_entry), tag.year, 4);
|
|
1297 /* Check for v1.1 tags */
|
|
1298 if (tag.u.v1_1.__zero == 0) {
|
|
1299 gchar *temp =
|
|
1300 g_strdup_printf("%d", tag.u.v1_1.track_number);
|
|
1301 set_entry_tag(GTK_ENTRY(comment_entry),
|
|
1302 tag.u.v1_1.comment, 28);
|
|
1303 gtk_entry_set_text(GTK_ENTRY(tracknum_entry), temp);
|
|
1304 g_free(temp);
|
|
1305 }
|
|
1306 else {
|
|
1307 set_entry_tag(GTK_ENTRY(comment_entry),
|
|
1308 tag.u.v1_0.comment, 30);
|
|
1309 gtk_entry_set_text(GTK_ENTRY(tracknum_entry), "");
|
|
1310 }
|
|
1311
|
|
1312 gtk_list_select_item(GTK_LIST
|
|
1313 (GTK_COMBO(genre_combo)->list),
|
|
1314 g_list_index(genre_list, (gchar *)
|
|
1315 mpg123_id3_genres[tag.
|
|
1316 genre]));
|
|
1317 gtk_widget_set_sensitive(GTK_WIDGET(remove_id3), TRUE);
|
|
1318 gtk_widget_set_sensitive(GTK_WIDGET(save), FALSE);
|
|
1319 #if 0
|
|
1320 gtk_widget_set_sensitive(GTK_WIDGET(revert), FALSE);
|
|
1321 #endif
|
|
1322 }
|
|
1323 else {
|
|
1324 gtk_entry_set_text(GTK_ENTRY(title_entry), "");
|
|
1325 gtk_entry_set_text(GTK_ENTRY(artist_entry), "");
|
|
1326 gtk_entry_set_text(GTK_ENTRY(album_entry), "");
|
|
1327 gtk_entry_set_text(GTK_ENTRY(comment_entry), "");
|
|
1328 gtk_entry_set_text(GTK_ENTRY(year_entry), "");
|
|
1329 gtk_entry_set_text(GTK_ENTRY(album_entry), "");
|
|
1330 gtk_entry_set_text(GTK_ENTRY(tracknum_entry), "");
|
|
1331 gtk_widget_set_sensitive(GTK_WIDGET(remove_id3), FALSE);
|
|
1332 gtk_widget_set_sensitive(GTK_WIDGET(save), FALSE);
|
|
1333 #if 0
|
|
1334 gtk_widget_set_sensitive(GTK_WIDGET(revert), FALSE);
|
|
1335 #endif
|
|
1336 }
|
|
1337 }
|
|
1338 vfs_rewind(fh);
|
|
1339 if (vfs_fread(tmp, 1, 4, fh) != 4) {
|
|
1340 vfs_fclose(fh);
|
|
1341 return;
|
|
1342 }
|
|
1343 head =
|
|
1344 ((guint32) tmp[0] << 24) | ((guint32) tmp[1] << 16) |
|
|
1345 ((guint32) tmp[2] << 8) | (guint32) tmp[3];
|
|
1346 while (!mpg123_head_check(head)) {
|
|
1347 head <<= 8;
|
|
1348 if (vfs_fread(tmp, 1, 1, fh) != 1) {
|
|
1349 vfs_fclose(fh);
|
|
1350 return;
|
|
1351 }
|
|
1352 head |= tmp[0];
|
|
1353 }
|
|
1354 if (mpg123_decode_header(&frm, head)) {
|
|
1355 guchar *buf;
|
|
1356 gdouble tpf;
|
|
1357 gint pos;
|
|
1358 xing_header_t xing_header;
|
|
1359 guint32 num_frames;
|
|
1360
|
|
1361 buf = g_malloc(frm.framesize + 4);
|
|
1362 vfs_fseek(fh, -4, SEEK_CUR);
|
|
1363 vfs_fread(buf, 1, frm.framesize + 4, fh);
|
|
1364 tpf = mpg123_compute_tpf(&frm);
|
|
1365 set_mpeg_level_label(frm.mpeg25, frm.lsf, frm.lay);
|
|
1366 pos = vfs_ftell(fh);
|
|
1367 vfs_fseek(fh, 0, SEEK_END);
|
|
1368 if (mpg123_get_xing_header(&xing_header, buf)) {
|
|
1369 num_frames = xing_header.frames;
|
|
1370 label_set_text(mpeg_bitrate_val,
|
|
1371 _("Variable,\navg. bitrate: %d KBit/s"),
|
|
1372 (gint) ((xing_header.bytes * 8) /
|
|
1373 (tpf * xing_header.frames * 1000)));
|
|
1374 }
|
|
1375 else {
|
|
1376 num_frames =
|
|
1377 ((vfs_ftell(fh) - pos -
|
|
1378 (id3_found ? 128 : 0)) / mpg123_compute_bpf(&frm)) + 1;
|
|
1379 label_set_text(mpeg_bitrate_val, _("%d KBit/s"),
|
|
1380 tabsel_123[frm.lsf][frm.lay -
|
|
1381 1][frm.bitrate_index]);
|
|
1382 }
|
|
1383 label_set_text(mpeg_samplerate_val, _("%ld Hz"),
|
|
1384 mpg123_freqs[frm.sampling_frequency]);
|
|
1385 label_set_text(mpeg_error_val, _("%s"),
|
|
1386 bool_label[frm.error_protection]);
|
|
1387 label_set_text(mpeg_copy_val, _("%s"), bool_label[frm.copyright]);
|
|
1388 label_set_text(mpeg_orig_val, _("%s"), bool_label[frm.original]);
|
|
1389 label_set_text(mpeg_emph_val, _("%s"), emphasis[frm.emphasis]);
|
|
1390 label_set_text(mpeg_frames_val, _("%d"), num_frames);
|
|
1391 label_set_text(mpeg_filesize_val, _("%lu Bytes"), vfs_ftell(fh));
|
|
1392 g_free(buf);
|
|
1393 }
|
|
1394 vfs_fclose(fh);
|
|
1395 }
|
|
1396 }
|
|
1397
|
|
1398 #endif
|