Mercurial > audlegacy-plugins
changeset 2201:df520f828dcf
Say goodbye to custom fileinfo dialog in madplug
author | Eugene Zagidullin <e.asphyx@gmail.com> |
---|---|
date | Sat, 01 Dec 2007 05:15:43 +0300 |
parents | d10f13536b94 |
children | f76e846d53d9 |
files | src/madplug/Makefile src/madplug/fileinfo.c src/madplug/mp3.xpm src/madplug/plugin.c src/madplug/tuples.c |
diffstat | 5 files changed, 379 insertions(+), 1727 deletions(-) [+] |
line wrap: on
line diff
--- a/src/madplug/Makefile Fri Nov 30 04:55:41 2007 +0300 +++ b/src/madplug/Makefile Sat Dec 01 05:15:43 2007 +0300 @@ -5,7 +5,7 @@ input.c \ replaygain.c \ decoder.c \ - fileinfo.c \ + tuples.c \ plugin.c \ xing.c
--- a/src/madplug/fileinfo.c Fri Nov 30 04:55:41 2007 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,760 +0,0 @@ -/* - * mad plugin for audacious - * Copyright (C) 2005-2007 William Pitcock, Yoshiki Yazawa - * - * Portions derived from xmms-mad: - * Copyright (C) 2001-2002 Sam Clegg - See COPYING - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; under version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "config.h" - -#include "plugin.h" -#include "input.h" - -#include "mp3.xpm" - -#include <math.h> -#include <audacious/util.h> -#include <gtk/gtk.h> -#include <gdk/gdkkeysyms.h> - -/* yaz */ -#include <langinfo.h> - -#ifndef NOGUI -static GtkWidget *window = 0; -static GtkWidget *filename_entry, *id3_frame; -static GtkWidget *title_entry, *artist_entry, *album_entry; -static GtkWidget *year_entry, *tracknum_entry, *comment_entry; -static GtkWidget *genre_combo; -static GtkWidget *mpeg_level, *mpeg_bitrate, *mpeg_samplerate, - *mpeg_frames, *mpeg_duration, *mpeg_flags; -static GtkWidget *mpeg_fileinfo, *mpeg_replaygain, *mpeg_replaygain2, - *mpeg_replaygain3, *mpeg_replaygain4, *mp3gain1, *mp3gain2; -#endif /* !NOGUI */ - -static GList *genre_list = 0; -static struct mad_info_t info; -struct id3_frame *id3_frame_new(const char *str); -id3_ucs4_t *mad_parse_genre(const id3_ucs4_t *string); - -#ifndef NOGUI -static void -update_id3_frame(struct id3_tag *tag, const char *frame_name, - const char *data) -{ - int res; - struct id3_frame *frame; - union id3_field *field; - id3_ucs4_t *ucs4; - - if (data == NULL) - return; - - /* printf ("updating id3: %s: %s\n", frame_name, data); */ - - /* - * An empty string removes the frame altogether. - */ - if (strlen(data) == 0) { - while ((frame = id3_tag_findframe(tag, frame_name, 0))) { -#ifdef DEBUG - printf("detachframe\n"); -#endif - id3_tag_detachframe(tag, frame); - } - return; - } - - frame = id3_tag_findframe(tag, frame_name, 0); - if (!frame) { -#ifdef DEBUG - printf("frame_new\n"); -#endif - frame = id3_frame_new(frame_name); - id3_tag_attachframe(tag, frame); - } - - // setup ucs4 string - if(audmad_config.sjis) { - ucs4 = id3_latin1_ucs4duplicate((id3_latin1_t *) data); - } - else { - ucs4 = id3_utf8_ucs4duplicate((id3_utf8_t *) data); - } - - // set encoding - field = id3_frame_field(frame, 0); - id3_field_settextencoding(field, audmad_config.sjis ? ID3_FIELD_TEXTENCODING_ISO_8859_1 : - ID3_FIELD_TEXTENCODING_UTF_8); - - // setup genre code - if (!strcmp(frame_name, ID3_FRAME_GENRE)) { - char *tmp; - int index = id3_genre_number(ucs4); - g_free(ucs4); - - if(index == -1) { // unknown genre. remove TCON frame. -#ifdef DEBUG - printf("remove genre frame\n"); -#endif - id3_tag_detachframe(tag, frame); - } - else { // meaningful genre - tmp = g_strdup_printf("%d", index); - ucs4 = id3_latin1_ucs4duplicate((unsigned char *) tmp); - } - - } - - // write string - if (!strcmp(frame_name, ID3_FRAME_COMMENT)) { - field = id3_frame_field(frame, 3); - field->type = ID3_FIELD_TYPE_STRINGFULL; - res = id3_field_setfullstring(field, ucs4); - } - else { - field = id3_frame_field(frame, 1); - field->type = ID3_FIELD_TYPE_STRINGLIST; - res = id3_field_setstrings(field, 1, &ucs4); - } - - if (res != 0) - g_print("error setting id3 field: %s\n", frame_name); -} - -static void close_window(GtkWidget * w, gpointer data) -{ - input_term(&info); - gtk_widget_destroy(window); -} - -static void save_cb(GtkWidget * w, gpointer data) -{ - gchar *text, *text2; - struct id3_file *id3file; - struct id3_tag *id3tag; - char *encoding; - - if (info.remote) - return; - - /* read tag from file */ - id3file = id3_file_open(info.filename, ID3_FILE_MODE_READWRITE); - if (!id3file) { - audacious_info_dialog(_("File Info"), _("Couldn't open file!"), _("Ok"), - FALSE, NULL, NULL); - return; - } - - id3tag = id3_file_tag(id3file); - if (!id3tag) { -#ifdef DEBUG - printf("no id3tag\n. append new tag.\n"); -#endif - id3tag = id3_tag_new(); - id3_tag_clearframes(id3tag); - id3tag->options |= ID3_TAG_OPTION_APPENDEDTAG | ID3_TAG_OPTION_ID3V1; - } - - id3_tag_options(id3tag, ID3_TAG_OPTION_ID3V1, ~0); /* enables id3v1 */ -// id3_tag_options(id3tag, ID3_TAG_OPTION_ID3V1, 0); /* diable id3v1 */ - - encoding = audmad_config.sjis ? "SJIS" : "UTF-8"; - - text = gtk_editable_get_chars(GTK_EDITABLE(title_entry), 0, -1); - text2 = g_convert(text, strlen(text), encoding, "UTF-8", NULL, NULL, NULL); - - update_id3_frame(id3tag, ID3_FRAME_TITLE, text2); - free(text); - free(text2); - - text = gtk_editable_get_chars(GTK_EDITABLE(artist_entry), 0, -1); - text2 = g_convert(text, strlen(text), encoding, "UTF-8", NULL, NULL, NULL); - update_id3_frame(id3tag, ID3_FRAME_ARTIST, text2); - free(text); - free(text2); - - text = gtk_editable_get_chars(GTK_EDITABLE(album_entry), 0, -1); - text2 = - g_convert(text, strlen(text), encoding, "UTF-8", NULL, NULL, NULL); - update_id3_frame(id3tag, ID3_FRAME_ALBUM, text2); - free(text); - free(text2); - - text = gtk_editable_get_chars(GTK_EDITABLE(year_entry), 0, -1); - text2 = - g_convert(text, strlen(text), encoding, "UTF-8", NULL, NULL, NULL); - update_id3_frame(id3tag, ID3_FRAME_YEAR, text2); - free(text); - free(text2); - - // update TLEN frame - text = g_strdup_printf("%ld", mad_timer_count(info.duration, MAD_UNITS_MILLISECONDS)); - update_id3_frame(id3tag, "TLEN", text); - free(text); - - text = gtk_editable_get_chars(GTK_EDITABLE(comment_entry), 0, -1); - text2 = - g_convert(text, strlen(text), encoding, "UTF-8", NULL, NULL, NULL); - update_id3_frame(id3tag, ID3_FRAME_COMMENT, text2); - free(text); - free(text2); - - text = gtk_editable_get_chars(GTK_EDITABLE(tracknum_entry), 0, -1); - text2 = - g_convert(text, strlen(text), encoding, "UTF-8", NULL, NULL, NULL); - update_id3_frame(id3tag, ID3_FRAME_TRACK, text2); - free(text); - free(text2); - - text = gtk_editable_get_chars(GTK_EDITABLE(GTK_COMBO(genre_combo)->entry), - 0, -1); -#ifdef DEBUG - g_print("genre entry = %s\n", text); -#endif - update_id3_frame(id3tag, ID3_FRAME_GENRE, text); - free(text); - -#ifdef DEBUG - printf("about to write id3tag\n"); -#endif - if (id3_file_update(id3file) != 0) { - audacious_info_dialog(_("File Info"), _("Couldn't write tag!"), _("Ok"), FALSE, - NULL, NULL); - } - id3_file_close(id3file); -} - -static void remove_id3_cb(GtkWidget * w, gpointer data) -{ - struct id3_file *id3file; - struct id3_tag *id3tag; - - id3file = id3_file_open(info.filename, ID3_FILE_MODE_READWRITE); - - if (id3file == NULL) - return; - - id3tag = id3_file_tag(id3file); - - if (id3tag == NULL) - { - id3_file_close(id3file); - return; - } - - id3_tag_clearframes(id3tag); - id3_file_update(id3file); - id3_file_close(id3file); - - gtk_entry_set_text(GTK_ENTRY(title_entry), ""); - gtk_entry_set_text(GTK_ENTRY(artist_entry), ""); - gtk_entry_set_text(GTK_ENTRY(album_entry), ""); - gtk_entry_set_text(GTK_ENTRY(comment_entry), ""); - gtk_entry_set_text(GTK_ENTRY(year_entry), ""); - gtk_entry_set_text(GTK_ENTRY(tracknum_entry), ""); - gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(genre_combo)->entry), ""); - gtk_widget_set_sensitive(GTK_WIDGET(w), FALSE); - gtk_widget_set_sensitive(GTK_WIDGET(data), FALSE); -} - -static void -change_buttons(GtkWidget * object) -{ - gtk_widget_set_sensitive(GTK_WIDGET(object), TRUE); -} - -#ifndef NOGUI -static gboolean -on_fileinfo_window_key_press (GtkWidget *widget, GdkEventKey *event, gpointer data) -{ - g_return_val_if_fail(GTK_IS_WIDGET (widget), FALSE); - - if (event->keyval == GDK_Escape) - { - gtk_widget_hide(widget); - } - - return FALSE; -} -#endif - -void create_window() -{ - GtkWidget *vbox, *hbox, *left_vbox, *table; - GtkWidget *mpeg_frame, *mpeg_box; - GtkWidget *label, *filename_hbox; - GtkWidget *bbox, *save, *remove_id3, *cancel; - GtkWidget *pixmapwid; - GdkPixbuf *pixbuf; - - window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - gtk_window_set_type_hint(GTK_WINDOW(window), - GDK_WINDOW_TYPE_HINT_DIALOG); - gtk_window_set_resizable(GTK_WINDOW(window), FALSE); - gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); - g_signal_connect(G_OBJECT(window), "destroy", - G_CALLBACK(close_window), &window); - g_signal_connect(G_OBJECT(window), "key-press-event", - G_CALLBACK(on_fileinfo_window_key_press), &window); - gtk_container_set_border_width(GTK_CONTAINER(window), 10); - - vbox = gtk_vbox_new(FALSE, 10); - gtk_container_add(GTK_CONTAINER(window), vbox); - - filename_hbox = gtk_hbox_new(FALSE, 5); - gtk_box_pack_start(GTK_BOX(vbox), filename_hbox, FALSE, TRUE, 0); - - pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **) - gnome_mime_audio_xpm); - pixmapwid = gtk_image_new_from_pixbuf(pixbuf); - g_object_unref(pixbuf); - gtk_misc_set_alignment(GTK_MISC(pixmapwid), 0, 0); - gtk_box_pack_start(GTK_BOX(filename_hbox), pixmapwid, FALSE, FALSE, - 0); - - label = gtk_label_new(_("<b>Name:</b>")); - gtk_label_set_use_markup(GTK_LABEL(label), TRUE); - gtk_box_pack_start(GTK_BOX(filename_hbox), label, FALSE, TRUE, 0); - filename_entry = gtk_entry_new(); - gtk_editable_set_editable(GTK_EDITABLE(filename_entry), FALSE); - gtk_box_pack_start(GTK_BOX(filename_hbox), filename_entry, TRUE, TRUE, - 0); - - hbox = gtk_hbox_new(FALSE, 10); - gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, TRUE, 0); - - left_vbox = gtk_table_new(2, 4, FALSE); - gtk_box_pack_start(GTK_BOX(hbox), left_vbox, FALSE, FALSE, 0); - - mpeg_frame = gtk_frame_new(_(" MPEG Info ")); - gtk_table_attach(GTK_TABLE(left_vbox), mpeg_frame, 0, 2, 0, 1, - GTK_FILL, GTK_FILL, 5, 5); - - mpeg_box = gtk_vbox_new(FALSE, 5); - gtk_container_add(GTK_CONTAINER(mpeg_frame), mpeg_box); - gtk_container_set_border_width(GTK_CONTAINER(mpeg_box), 10); - gtk_box_set_spacing(GTK_BOX(mpeg_box), 0); - - mpeg_level = gtk_label_new(""); - gtk_widget_set_usize(mpeg_level, 120, -2); - gtk_misc_set_alignment(GTK_MISC(mpeg_level), 0, 0); - gtk_box_pack_start(GTK_BOX(mpeg_box), mpeg_level, FALSE, FALSE, 0); - - mpeg_bitrate = gtk_label_new(""); - gtk_misc_set_alignment(GTK_MISC(mpeg_bitrate), 0, 0); - gtk_label_set_justify(GTK_LABEL(mpeg_bitrate), GTK_JUSTIFY_LEFT); - gtk_box_pack_start(GTK_BOX(mpeg_box), mpeg_bitrate, FALSE, FALSE, 0); - - mpeg_samplerate = gtk_label_new(""); - gtk_misc_set_alignment(GTK_MISC(mpeg_samplerate), 0, 0); - gtk_box_pack_start(GTK_BOX(mpeg_box), mpeg_samplerate, FALSE, FALSE, - 0); - - mpeg_flags = gtk_label_new(""); - gtk_misc_set_alignment(GTK_MISC(mpeg_flags), 0, 0); - gtk_label_set_justify(GTK_LABEL(mpeg_flags), GTK_JUSTIFY_LEFT); - gtk_box_pack_start(GTK_BOX(mpeg_box), mpeg_flags, FALSE, FALSE, 0); - - mpeg_frames = gtk_label_new(""); - gtk_misc_set_alignment(GTK_MISC(mpeg_frames), 0, 0); - gtk_label_set_justify(GTK_LABEL(mpeg_frames), GTK_JUSTIFY_LEFT); - gtk_box_pack_start(GTK_BOX(mpeg_box), mpeg_frames, FALSE, FALSE, 0); - - mpeg_duration = gtk_label_new(""); - gtk_misc_set_alignment(GTK_MISC(mpeg_duration), 0, 0); - gtk_label_set_justify(GTK_LABEL(mpeg_duration), GTK_JUSTIFY_LEFT); - gtk_box_pack_start(GTK_BOX(mpeg_box), mpeg_duration, FALSE, FALSE, 0); - - mpeg_replaygain = gtk_label_new(""); - gtk_misc_set_alignment(GTK_MISC(mpeg_replaygain), 0, 0); - gtk_label_set_justify(GTK_LABEL(mpeg_replaygain), GTK_JUSTIFY_LEFT); - gtk_box_pack_start(GTK_BOX(mpeg_box), mpeg_replaygain, FALSE, FALSE, - 0); - mpeg_replaygain2 = gtk_label_new(""); - gtk_misc_set_alignment(GTK_MISC(mpeg_replaygain2), 0, 0); - gtk_label_set_justify(GTK_LABEL(mpeg_replaygain2), GTK_JUSTIFY_LEFT); - gtk_box_pack_start(GTK_BOX(mpeg_box), mpeg_replaygain2, FALSE, FALSE, - 0); - mpeg_replaygain3 = gtk_label_new(""); - gtk_misc_set_alignment(GTK_MISC(mpeg_replaygain3), 0, 0); - gtk_label_set_justify(GTK_LABEL(mpeg_replaygain3), GTK_JUSTIFY_LEFT); - gtk_box_pack_start(GTK_BOX(mpeg_box), mpeg_replaygain3, FALSE, FALSE, - 0); - mpeg_replaygain4 = gtk_label_new(""); - gtk_misc_set_alignment(GTK_MISC(mpeg_replaygain4), 0, 0); - gtk_label_set_justify(GTK_LABEL(mpeg_replaygain4), GTK_JUSTIFY_LEFT); - gtk_box_pack_start(GTK_BOX(mpeg_box), mpeg_replaygain4, FALSE, FALSE, - 0); - mp3gain1 = gtk_label_new(""); - gtk_misc_set_alignment(GTK_MISC(mp3gain1), 0, 0); - gtk_label_set_justify(GTK_LABEL(mp3gain1), GTK_JUSTIFY_LEFT); - gtk_box_pack_start(GTK_BOX(mpeg_box), mp3gain1, FALSE, FALSE, 0); - mp3gain2 = gtk_label_new(""); - gtk_misc_set_alignment(GTK_MISC(mp3gain2), 0, 0); - gtk_label_set_justify(GTK_LABEL(mp3gain2), GTK_JUSTIFY_LEFT); - gtk_box_pack_start(GTK_BOX(mpeg_box), mp3gain2, FALSE, FALSE, 0); - - mpeg_fileinfo = gtk_label_new(""); - gtk_misc_set_alignment(GTK_MISC(mpeg_fileinfo), 0, 0); - gtk_label_set_justify(GTK_LABEL(mpeg_fileinfo), GTK_JUSTIFY_LEFT); - gtk_box_pack_start(GTK_BOX(mpeg_box), mpeg_fileinfo, FALSE, FALSE, 0); - - id3_frame = gtk_frame_new(_(" ID3 Tag ")); - gtk_table_attach(GTK_TABLE(left_vbox), id3_frame, 2, 4, 0, 1, - GTK_FILL, GTK_FILL, 0, 5); - - table = gtk_table_new(5, 5, FALSE); - gtk_container_set_border_width(GTK_CONTAINER(table), 5); - gtk_container_add(GTK_CONTAINER(id3_frame), table); - - label = gtk_label_new(_("Title:")); - gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); - gtk_table_attach(GTK_TABLE(table), label, 0, 1, 0, 1, GTK_FILL, - GTK_FILL, 5, 5); - - title_entry = gtk_entry_new(); - 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); - - label = gtk_label_new(_("Artist:")); - gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); - gtk_table_attach(GTK_TABLE(table), label, 0, 1, 1, 2, GTK_FILL, - GTK_FILL, 5, 5); - - artist_entry = gtk_entry_new(); - 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); - - label = gtk_label_new(_("Album:")); - gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); - gtk_table_attach(GTK_TABLE(table), label, 0, 1, 2, 3, GTK_FILL, - GTK_FILL, 5, 5); - - album_entry = gtk_entry_new(); - 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); - - label = gtk_label_new(_("Comment:")); - gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); - gtk_table_attach(GTK_TABLE(table), label, 0, 1, 3, 4, GTK_FILL, - GTK_FILL, 5, 5); - - comment_entry = gtk_entry_new(); - 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); - - label = gtk_label_new(_("Year:")); - gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); - gtk_table_attach(GTK_TABLE(table), label, 0, 1, 4, 5, GTK_FILL, - GTK_FILL, 5, 5); - - year_entry = gtk_entry_new(); - gtk_widget_set_usize(year_entry, 40, -1); - gtk_table_attach(GTK_TABLE(table), year_entry, 1, 2, 4, 5, - GTK_FILL | GTK_EXPAND | GTK_SHRINK, - GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5); - - label = gtk_label_new(_("Track number:")); - gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); - gtk_table_attach(GTK_TABLE(table), label, 2, 3, 4, 5, GTK_FILL, - GTK_FILL, 5, 5); - - tracknum_entry = gtk_entry_new(); - gtk_widget_set_usize(tracknum_entry, 40, -1); - 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); - - label = gtk_label_new(_("Genre:")); - gtk_misc_set_alignment(GTK_MISC(label), 1, 0.5); - gtk_table_attach(GTK_TABLE(table), label, 0, 1, 5, 6, GTK_FILL, - GTK_FILL, 5, 5); - - genre_combo = gtk_combo_new(); - gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(genre_combo)->entry), - FALSE); - if (!genre_list) { - int i = 0; - const id3_ucs4_t *ucs4 = id3_genre_index(i); - - //add "Unknown" to the first. we must shift index. - genre_list = g_list_append(genre_list, _("Unknown")); - - while (ucs4) { - genre_list = - g_list_append(genre_list, id3_ucs4_utf8duplicate(ucs4)); - i++; - ucs4 = id3_genre_index(i); - } - } - gtk_combo_set_popdown_strings(GTK_COMBO(genre_combo), genre_list); - - 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); - - bbox = gtk_hbutton_box_new(); - gtk_hbutton_box_set_layout_default(GTK_BUTTONBOX_SPREAD); - - save = gtk_button_new_from_stock(GTK_STOCK_SAVE); - g_signal_connect(G_OBJECT(save), "clicked", - G_CALLBACK(save_cb), NULL); - gtk_box_pack_start(GTK_BOX(bbox), save, TRUE, TRUE, 0); - - remove_id3 = gtk_button_new_from_stock(GTK_STOCK_DELETE); - g_signal_connect(G_OBJECT(remove_id3), "clicked", - G_CALLBACK(remove_id3_cb), save); - gtk_box_pack_start(GTK_BOX(bbox), remove_id3, TRUE, TRUE, 0); - - g_signal_connect_swapped(G_OBJECT(title_entry), "changed", - G_CALLBACK(change_buttons), save); - g_signal_connect_swapped(G_OBJECT(artist_entry), "changed", - G_CALLBACK(change_buttons), save); - g_signal_connect_swapped(G_OBJECT(album_entry), "changed", - G_CALLBACK(change_buttons), save); - g_signal_connect_swapped(G_OBJECT(year_entry), "changed", - G_CALLBACK(change_buttons), save); - g_signal_connect_swapped(G_OBJECT(comment_entry), "changed", - G_CALLBACK(change_buttons), save); - g_signal_connect_swapped(G_OBJECT(tracknum_entry), "changed", - G_CALLBACK(change_buttons), save); - - g_signal_connect_swapped(G_OBJECT(GTK_COMBO(genre_combo)->entry), "changed", - G_CALLBACK(change_buttons), save); - - - gtk_table_attach(GTK_TABLE(table), bbox, 0, 5, 6, 7, GTK_FILL, 0, - 0, 8); - - bbox = gtk_hbutton_box_new(); - gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); - gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5); - gtk_table_attach(GTK_TABLE(left_vbox), bbox, 0, 4, 1, 2, GTK_FILL, - 0, 0, 8); - - cancel = gtk_button_new_from_stock(GTK_STOCK_CLOSE); - g_signal_connect_swapped(G_OBJECT(cancel), "clicked", - G_CALLBACK(gtk_widget_destroy), - G_OBJECT(window)); - GTK_WIDGET_SET_FLAGS(cancel, GTK_CAN_DEFAULT); - gtk_box_pack_start(GTK_BOX(bbox), cancel, TRUE, TRUE, 0); - gtk_window_set_focus(GTK_WINDOW(window), cancel); - - gtk_widget_show_all(window); -} - -static void id3_frame_to_entry(char *framename, GtkEntry * entry) -{ - gtk_entry_set_text(entry, ""); - - if (info.tag) { - gchar *text = input_id3_get_string(info.tag, framename); - if (text) { - gtk_entry_set_text(entry, text); - g_free(text); - } - } -} -#endif /* !NOGUI */ - -void audmad_get_file_info(char *fileurl) -{ -#ifndef NOGUI - gchar *title; - gchar message[128]; - static char const *const layer_str[3] = { "I", "II", "III" }; - static char const *const mode_str[4] = { - ("single channel"), ("dual channel"), "joint stereo", "stereo" - }; - gchar *tmp, *utf_filename; - gchar *realfn = NULL; -#ifdef DEBUG - { - tmp = aud_str_to_utf8(fileurl); - g_message("f: audmad_get_file_info: %s", tmp); - g_free(tmp); - tmp = NULL; - } -#endif - - if(!aud_vfs_is_remote(fileurl) && !aud_vfs_file_test(fileurl, G_FILE_TEST_EXISTS)) { - return; - } - - input_init(&info, fileurl, NULL); - - if(audmad_is_remote(fileurl)) { - info.remote = TRUE; - if(aud_vfs_is_streaming(info.infile)) - return; //file info dialog for remote streaming doesn't make sense. - } - - realfn = g_filename_from_uri(fileurl, NULL, NULL); - utf_filename = aud_str_to_utf8(realfn ? realfn : fileurl); - g_free(realfn); realfn = NULL; - create_window(); - - info.fileinfo_request = TRUE; - input_get_info(&info, info.remote ? TRUE : FALSE); - - tmp = g_path_get_basename(utf_filename); - title = g_strdup_printf(_("File Info - %s"), tmp); - g_free(tmp); tmp = NULL; - gtk_window_set_title(GTK_WINDOW(window), title); - g_free(title); - - gtk_entry_set_text(GTK_ENTRY(filename_entry), utf_filename); - gtk_editable_set_position(GTK_EDITABLE(filename_entry), -1); - - free(utf_filename); - - id3_frame_to_entry(ID3_FRAME_ARTIST, GTK_ENTRY(artist_entry)); - id3_frame_to_entry(ID3_FRAME_TITLE, GTK_ENTRY(title_entry)); - id3_frame_to_entry(ID3_FRAME_ALBUM, GTK_ENTRY(album_entry)); - -// year -// id3_frame_to_entry (ID3_FRAME_YEAR, GTK_ENTRY (year_entry)); -// to set year entry, we have to do manually because TYER is still used equally to TDRC. - gtk_entry_set_text(GTK_ENTRY(year_entry), ""); - if (info.tag) { - gchar *text = NULL; - text = input_id3_get_string(info.tag, "TDRC"); - if (!text) - text = input_id3_get_string(info.tag, "TYER"); - if (text) { - gtk_entry_set_text(GTK_ENTRY(year_entry), text); - g_free(text); - } - } - - id3_frame_to_entry(ID3_FRAME_TRACK, GTK_ENTRY(tracknum_entry)); - id3_frame_to_entry(ID3_FRAME_COMMENT, GTK_ENTRY(comment_entry)); - snprintf(message, 127, _("Layer %s"), layer_str[info.mpeg_layer - 1]); - gtk_label_set_text(GTK_LABEL(mpeg_level), message); - if (info.vbr) { - snprintf(message, 127, _("VBR (avg. %d kbps)"), info.bitrate / 1000); - } - else { - snprintf(message, 127, "%d kbps", info.bitrate / 1000); - } - gtk_label_set_text(GTK_LABEL(mpeg_bitrate), message); - snprintf(message, 127, _("%d Hz"), info.freq); - gtk_label_set_text(GTK_LABEL(mpeg_samplerate), message); - if (info.frames != -1) { - snprintf(message, 127, _("%d frames"), info.frames); - gtk_label_set_text(GTK_LABEL(mpeg_frames), message); - } - else { - gtk_label_set_text(GTK_LABEL(mpeg_frames), ""); - } - gtk_label_set_text(GTK_LABEL(mpeg_flags), mode_str[info.mode]); - { - guint sec = mad_timer_count(info.duration, MAD_UNITS_SECONDS); - snprintf(message, 127, _("%d:%02d (%d seconds)"), sec /60 ,sec % 60, sec); - } - gtk_label_set_text(GTK_LABEL(mpeg_duration), message); - - if (info.replaygain_album_str != NULL) { - snprintf(message, 127, _("RG_album=%4s (x%4.2f)"), - info.replaygain_album_str, info.replaygain_album_scale); - gtk_label_set_text(GTK_LABEL(mpeg_replaygain), message); - } - else - gtk_label_set_text(GTK_LABEL(mpeg_replaygain), ""); - - if (info.replaygain_track_str != NULL) { - snprintf(message, 127, _("RG_track=%4s (x%4.2f)"), - info.replaygain_track_str, info.replaygain_track_scale); - gtk_label_set_text(GTK_LABEL(mpeg_replaygain2), message); - } - else - gtk_label_set_text(GTK_LABEL(mpeg_replaygain2), ""); - - if (info.replaygain_album_peak_str != NULL) { - snprintf(message, 127, _("Peak album=%4s (%+5.3fdBFS)"), - info.replaygain_album_peak_str, - 20 * log10(info.replaygain_album_peak)); - gtk_label_set_text(GTK_LABEL(mpeg_replaygain3), message); - } - else - gtk_label_set_text(GTK_LABEL(mpeg_replaygain3), ""); - - if (info.replaygain_track_peak_str != NULL) { - snprintf(message, 127, _("Peak track=%4s (%+5.3fdBFS)"), - info.replaygain_track_peak_str, - 20 * log10(info.replaygain_track_peak)); - gtk_label_set_text(GTK_LABEL(mpeg_replaygain4), message); - } - else - gtk_label_set_text(GTK_LABEL(mpeg_replaygain3), ""); - - if (info.mp3gain_undo_str != NULL) { - snprintf(message, 127, _("mp3gain undo=%4s (%+5.3fdB)"), - info.mp3gain_undo_str, info.mp3gain_undo); - gtk_label_set_text(GTK_LABEL(mp3gain1), message); - } - else - gtk_label_set_text(GTK_LABEL(mp3gain1), ""); - - if (info.mp3gain_minmax_str != NULL) { - snprintf(message, 127, _("mp3gain minmax=%4s (max-min=%+6.3fdB)"), - info.mp3gain_minmax_str, info.mp3gain_minmax); - gtk_label_set_text(GTK_LABEL(mp3gain2), message); - } - else - gtk_label_set_text(GTK_LABEL(mp3gain2), ""); - - gtk_label_set_text(GTK_LABEL(mpeg_fileinfo), ""); - - - /* work out the index of the genre in the list */ - { - const id3_ucs4_t *string; - id3_ucs4_t *genre; - struct id3_frame *frame; - union id3_field *field; - frame = id3_tag_findframe(info.tag, ID3_FRAME_GENRE, 0); - if (frame) { - field = id3_frame_field(frame, 1); - string = id3_field_getstrings(field, 0); - genre = mad_parse_genre(string); -#ifdef DEBUG - if (genre) { - gchar *utf = (gchar *)id3_ucs4_utf8duplicate(genre); - g_print("genre = %s\n", utf); - g_print("genre num = %d\n", id3_genre_number(genre)); - g_free(utf); - } -#endif - if (genre) { - gtk_list_select_item(GTK_LIST - (GTK_COMBO(genre_combo)->list), - id3_genre_number(genre)+1); //shift one for "Unknown". - g_free((void *)genre); - } - } - } - - gtk_widget_set_sensitive(id3_frame, TRUE); - -#endif /* !NOGUI */ -}
--- a/src/madplug/mp3.xpm Fri Nov 30 04:55:41 2007 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,963 +0,0 @@ -/* XPM */ -static char * gnome_mime_audio_xpm[] = { -"48 52 908 2", -" c None", -". c #000000", -"+ c #010100", -"@ c #020201", -"# c #030201", -"$ c #232323", -"% c #1F1F1F", -"& c #DADADA", -"* c #FFFFFF", -"= c #F6F6F6", -"- c #CFCFCF", -"; c #707070", -"> c #FFFFFE", -", c #FEFEFE", -"' c #FBFBFB", -") c #EDEDED", -"! c #C0C0C0", -"~ c #FFFEFE", -"{ c #F8F5F2", -"] c #EBE7E1", -"^ c #ECEDE8", -"/ c #ECEFEA", -"( c #E6E9E4", -"_ c #CED0CE", -": c #BCBFBC", -"< c #F0F0EF", -"[ c #FEFEFD", -"} c #F7F7F7", -"| c #D7D7D7", -"1 c #F1F1F1", -"2 c #B7B7B7", -"3 c #EAEDEA", -"4 c #8EA299", -"5 c #697D70", -"6 c #546459", -"7 c #404D44", -"8 c #2C352F", -"9 c #4E5649", -"0 c #D6D8D3", -"a c #D2D2D2", -"b c #AEAEAE", -"c c #070707", -"d c #FCFCFB", -"e c #6D7C75", -"f c #5A5D4C", -"g c #6B735F", -"h c #6E7B63", -"i c #5B6052", -"j c #4A5042", -"k c #CED0CB", -"l c #FEFDFD", -"m c #FDFDFD", -"n c #B8B8B8", -"o c #DCDCDC", -"p c #A4A4A3", -"q c #0E0E0E", -"r c #8A928F", -"s c #6A7F68", -"t c #4D564E", -"u c #4E5950", -"v c #585E57", -"w c #333530", -"x c #9D9C9B", -"y c #FCFDFE", -"z c #FDFEFE", -"A c #FDFDFE", -"B c #F5F5F4", -"C c #B5B5B5", -"D c #F9F9F9", -"E c #FCFCFC", -"F c #CBCBCB", -"G c #A5A5A5", -"H c #CECDCB", -"I c #788976", -"J c #C6BDBB", -"K c #E2E2E2", -"L c #E2E0DF", -"M c #656A65", -"N c #4A4B49", -"O c #EAEDF1", -"P c #CED5DD", -"Q c #DBE0E9", -"R c #DDE1E9", -"S c #D3D7DD", -"T c #D9DCE1", -"U c #F4F4F4", -"V c #ACACAC", -"W c #ECECEC", -"X c #C3C3C3", -"Y c #C2C2C2", -"Z c #C9C9C8", -"` c #A8A8A8", -" . c #F6F8F6", -".. c #A7ADA5", -"+. c #6D7F71", -"@. c #ECECE9", -"#. c #FDFDFC", -"$. c #939C9A", -"%. c #1B2321", -"&. c #FCFBFA", -"*. c #F2F6F9", -"=. c #B4BFCC", -"-. c #7E8A9B", -";. c #515B6F", -">. c #50596A", -",. c #737D8D", -"'. c #BEC6CE", -"). c #C4CBD5", -"!. c #BFC5D1", -"~. c #F1F2F4", -"{. c #F4F4F3", -"]. c #ABABAB", -"^. c #515151", -"/. c #474747", -"(. c #464645", -"_. c #464646", -":. c #5D5D5C", -"<. c #A9A9A9", -"[. c #FAFAF9", -"}. c #EDEFF0", -"|. c #F1F5F5", -"1. c #636E62", -"2. c #636E5F", -"3. c #D4D5D3", -"4. c #FBF7F4", -"5. c #9BA595", -"6. c #657366", -"7. c #001514", -"8. c #FCFAF8", -"9. c #FDFCFC", -"0. c #FBF9F7", -"a. c #E3E6EA", -"b. c #9DACBF", -"c. c #515A6D", -"d. c #111828", -"e. c #131B29", -"f. c #0F1A2B", -"g. c #081125", -"h. c #0D1328", -"i. c #C2C9D1", -"j. c #C5CBD4", -"k. c #A6AEBB", -"l. c #F6F6F7", -"m. c #FAFAFA", -"n. c #F2F2F2", -"o. c #F3F3F3", -"p. c #AAAAAA", -"q. c #A0A09F", -"r. c #8A8A8A", -"s. c #7A7A7A", -"t. c #6C6C6C", -"u. c #454545", -"v. c #ABB3AF", -"w. c #A8B6A3", -"x. c #D0DBD0", -"y. c #F2F3F0", -"z. c #DEE1E0", -"A. c #66736A", -"B. c #354336", -"C. c #556254", -"D. c #C5C7C6", -"E. c #F2EDEA", -"F. c #CADAD9", -"G. c #9BA893", -"H. c #1B3128", -"I. c #FCF4EF", -"J. c #FDFBF9", -"K. c #DDDFE4", -"L. c #97A3B4", -"M. c #374152", -"N. c #0D131C", -"O. c #1C2026", -"P. c #262C3A", -"Q. c #242E43", -"R. c #202D41", -"S. c #172538", -"T. c #121523", -"U. c #BABCC3", -"V. c #9DA6B5", -"W. c #BABEC4", -"X. c #F8F8F7", -"Y. c #E7E7E7", -"Z. c #C6C6C5", -"`. c #BABAB9", -" + c #E7E9E9", -".+ c #63736C", -"++ c #464945", -"@+ c #5F7361", -"#+ c #CED4C3", -"$+ c #DBDEDA", -"%+ c #979999", -"&+ c #404342", -"*+ c #606E6B", -"=+ c #E5E5E3", -"-+ c #4B5F52", -";+ c #455845", -">+ c #2D362F", -",+ c #FCFAF9", -"'+ c #E4E4E7", -")+ c #97A8B9", -"!+ c #343C4A", -"~+ c #13181E", -"{+ c #1B2027", -"]+ c #1D232B", -"^+ c #1F2632", -"/+ c #212A3C", -"(+ c #242F45", -"_+ c #2A374D", -":+ c #121C2F", -"<+ c #525A67", -"[+ c #D9DDE5", -"}+ c #737C8C", -"|+ c #EAEBEB", -"1+ c #F7F7F6", -"2+ c #F6F6F5", -"3+ c #F5F5F5", -"4+ c #EDEDEB", -"5+ c #FBFBFA", -"6+ c #6C8175", -"7+ c #778673", -"8+ c #121613", -"9+ c #4C504A", -"0+ c #8FA695", -"a+ c #E2DCD8", -"b+ c #E5E6E7", -"c+ c #FBFAF9", -"d+ c #CAC6C1", -"e+ c #847F79", -"f+ c #FCFAFA", -"g+ c #ECE9E9", -"h+ c #A6B1C4", -"i+ c #232B37", -"j+ c #12171E", -"k+ c #191F27", -"l+ c #1D222B", -"m+ c #1E242B", -"n+ c #1E252F", -"o+ c #202937", -"p+ c #232F44", -"q+ c #283853", -"r+ c #253046", -"s+ c #0A1526", -"t+ c #D5D7DB", -"u+ c #727D90", -"v+ c #CFD0D2", -"w+ c #B1B1B1", -"x+ c #99A597", -"y+ c #7B9173", -"z+ c #65705D", -"A+ c #1F201B", -"B+ c #58655E", -"C+ c #F3F2F1", -"D+ c #AAB3C1", -"E+ c #525C6D", -"F+ c #0A0F17", -"G+ c #1C2129", -"H+ c #1E242A", -"I+ c #1E242C", -"J+ c #1F232D", -"K+ c #232E41", -"L+ c #2B3855", -"M+ c #2C3B57", -"N+ c #070D1F", -"O+ c #A3ABB6", -"P+ c #828EA0", -"Q+ c #B9BCC2", -"R+ c #F3F3F2", -"S+ c #F1EFEC", -"T+ c #72886D", -"U+ c #4E5849", -"V+ c #748268", -"W+ c #808080", -"X+ c #D6D9DE", -"Y+ c #5E6A7A", -"Z+ c #121621", -"`+ c #161D26", -" @ c #1D242C", -".@ c #1F242B", -"+@ c #1E2427", -"@@ c #212C3F", -"#@ c #283552", -"$@ c #2F405D", -"%@ c #0E162B", -"&@ c #59657B", -"*@ c #8A98AA", -"=@ c #AFB4BC", -"-@ c #F2F2F1", -";@ c #7D9074", -">@ c #494949", -",@ c #676D65", -"'@ c #C8CBC7", -")@ c #818B9B", -"!@ c #1B232F", -"~@ c #0F151F", -"{@ c #1B212B", -"]@ c #1E232D", -"^@ c #20252C", -"/@ c #24272C", -"(@ c #1F2429", -"_@ c #1C2228", -":@ c #1F2A3C", -"<@ c #1F2A40", -"[@ c #25344E", -"}@ c #314464", -"|@ c #15223A", -"1@ c #34445E", -"2@ c #939FB3", -"3@ c #ACB2BC", -"4@ c #F1F1F0", -"5@ c #ECEEEB", -"6@ c #B8BCB7", -"7@ c #647C65", -"8@ c #797E78", -"9@ c #C4C3C2", -"0@ c #919191", -"a@ c #DCE3EA", -"b@ c #242C3D", -"c@ c #0B101C", -"d@ c #1A212A", -"e@ c #1F242C", -"f@ c #21252C", -"g@ c #222629", -"h@ c #1C232A", -"i@ c #212B3D", -"j@ c #33415B", -"k@ c #27344B", -"l@ c #212F47", -"m@ c #374A68", -"n@ c #1A2840", -"o@ c #34445F", -"p@ c #96A3B5", -"q@ c #B3B7C0", -"r@ c #F2F2F0", -"s@ c #F0F0F0", -"t@ c #E2E7E2", -"u@ c #939E92", -"v@ c #50644E", -"w@ c #3D443E", -"x@ c #D4D2CF", -"y@ c #7F8898", -"z@ c #020A14", -"A@ c #171E28", -"B@ c #1C222A", -"C@ c #1E232B", -"D@ c #1F242D", -"E@ c #1F2228", -"F@ c #1D2328", -"G@ c #283449", -"H@ c #4A5C7B", -"I@ c #697D98", -"J@ c #4D5D79", -"K@ c #1F2D45", -"L@ c #394A6B", -"M@ c #1B2943", -"N@ c #425371", -"O@ c #95A3B5", -"P@ c #B8BDC2", -"Q@ c #EFEFEE", -"R@ c #EFEFED", -"S@ c #EDEEED", -"T@ c #EFF0F0", -"U@ c #F7FCF3", -"V@ c #313F30", -"W@ c #1C2120", -"X@ c #C9CBC9", -"Y@ c #F9F9F8", -"Z@ c #E9EEF2", -"`@ c #3C4352", -" # c #0C111D", -".# c #1E232E", -"+# c #1D212A", -"@# c #20242C", -"## c #1B1D20", -"$# c #263043", -"%# c #576886", -"&# c #8396B1", -"*# c #7A8FAD", -"=# c #677B99", -"-# c #28374F", -";# c #384A69", -"># c #182642", -",# c #5D708F", -"'# c #828FA3", -")# c #C5C7CB", -"!# c #F1F1EF", -"~# c #EEEEED", -"{# c #EEEEEC", -"]# c #9DA7A4", -"^# c #2A3B34", -"/# c #222725", -"(# c #80807E", -"_# c #EFEEEC", -":# c #F1F0EF", -"<# c #F4F3F2", -"[# c #F8F8F8", -"}# c #A8AFBB", -"|# c #0D1522", -"1# c #1A212E", -"2# c #1D232C", -"3# c #21252D", -"4# c #1E2327", -"5# c #171B20", -"6# c #637593", -"7# c #95A6BE", -"8# c #6D7F9C", -"9# c #617395", -"0# c #5A6E8B", -"a# c #2A354A", -"b# c #3D4E6D", -"c# c #1C2A46", -"d# c #748DAB", -"e# c #6D798A", -"f# c #DEDFE0", -"g# c #EEEEEE", -"h# c #EDEDEC", -"i# c #ECEAE7", -"j# c #ADB1B0", -"k# c #B5B9BA", -"l# c #F1F0F0", -"m# c #F9F8F8", -"n# c #F7F5F4", -"o# c #A7AAA4", -"p# c #B7BAB4", -"q# c #F7F6F6", -"r# c #ECEFF1", -"s# c #747F8E", -"t# c #0A121E", -"u# c #232C3A", -"v# c #1D232E", -"w# c #222932", -"x# c #1B1D21", -"y# c #1C273E", -"z# c #C1CFE1", -"A# c #8FA1B7", -"B# c #6D81A0", -"C# c #596D93", -"D# c #455674", -"E# c #293343", -"F# c #4A5C7D", -"G# c #304060", -"H# c #7690B8", -"I# c #5D6878", -"J# c #BBC0CC", -"K# c #ECECEB", -"L# c #F6F4F3", -"M# c #F4F1EF", -"N# c #F7F5F3", -"O# c #F9F8F7", -"P# c #BBBDB9", -"Q# c #4D5852", -"R# c #71746D", -"S# c #F0EAE7", -"T# c #DBDEE3", -"U# c #3E495B", -"V# c #1C2435", -"W# c #273041", -"X# c #283040", -"Y# c #293141", -"Z# c #262B38", -"`# c #1D212D", -" $ c #4A5B77", -".$ c #CFDBEB", -"+$ c #7A8FAC", -"@$ c #6C83A5", -"#$ c #4D6389", -"$$ c #35445E", -"%$ c #404D60", -"&$ c #506586", -"*$ c #4F6687", -"=$ c #6983AB", -"-$ c #343E50", -";$ c #4D5F7A", -">$ c #B8C0CC", -",$ c #F7F6F5", -"'$ c #D2D6D3", -")$ c #6C866F", -"!$ c #5A715E", -"~$ c #566758", -"{$ c #B5C1B4", -"]$ c #B2BAC8", -"^$ c #273245", -"/$ c #29354A", -"($ c #323D53", -"_$ c #364258", -":$ c #333F52", -"<$ c #343F52", -"[$ c #28354A", -"}$ c #6D7B92", -"|$ c #ACBDD2", -"1$ c #5B7297", -"2$ c #495F87", -"3$ c #3A4D6B", -"4$ c #252F44", -"5$ c #8292AC", -"6$ c #586E94", -"7$ c #6782A9", -"8$ c #37404D", -"9$ c #394860", -"0$ c #475977", -"a$ c #6E7E99", -"b$ c #EBEBEA", -"c$ c #BEC3BE", -"d$ c #CFD1CE", -"e$ c #F4F2F0", -"f$ c #7D8F84", -"g$ c #6A8667", -"h$ c #D5D8D4", -"i$ c #6B6B6B", -"j$ c #9E9E9F", -"k$ c #7A8EA8", -"l$ c #2B374D", -"m$ c #313E56", -"n$ c #34425B", -"o$ c #36425A", -"p$ c #354257", -"q$ c #39465D", -"r$ c #3B4963", -"s$ c #64738B", -"t$ c #768CAD", -"u$ c #354C72", -"v$ c #2E3D5B", -"w$ c #1D273A", -"x$ c #3D4655", -"y$ c #A7BACE", -"z$ c #607799", -"A$ c #617494", -"B$ c #191B1B", -"C$ c #445675", -"D$ c #3A4A65", -"E$ c #6C7A91", -"F$ c #ECECEA", -"G$ c #EAEAE9", -"H$ c #EAEAE8", -"I$ c #F7F6F4", -"J$ c #B5B9B6", -"K$ c #D7DCD9", -"L$ c #7B8982", -"M$ c #A9AEAD", -"N$ c #517257", -"O$ c #839284", -"P$ c #DEDEDD", -"Q$ c #D8D9D9", -"R$ c #F3F2EE", -"S$ c #51698C", -"T$ c #313F55", -"U$ c #35435B", -"V$ c #36445A", -"W$ c #35425C", -"X$ c #37465D", -"Y$ c #3D4A62", -"Z$ c #516079", -"`$ c #47536A", -" % c #354561", -".% c #212F46", -"+% c #0F1624", -"@% c #1A2231", -"#% c #99A5B7", -"$% c #97A8C3", -"%% c #6A7DA0", -"&% c #394559", -"*% c #1C1D26", -"=% c #35435C", -"-% c #344159", -";% c #8E96A2", -">% c #E9E9E8", -",% c #E9E9E7", -"'% c #F6F5F5", -")% c #70827F", -"!% c #C6D0C3", -"~% c #445344", -"{% c #637161", -"]% c #4B6C4C", -"^% c #CAC8C8", -"/% c #3D5271", -"(% c #3A4863", -"_% c #384862", -":% c #3E4C65", -"<% c #424D67", -"[% c #45536C", -"}% c #4D5A74", -"|% c #66768F", -"1% c #76869D", -"2% c #2A3243", -"3% c #151A27", -"4% c #252C3A", -"5% c #B2BBCE", -"6% c #C3D0E3", -"7% c #7B8CA9", -"8% c #51627E", -"9% c #171C22", -"0% c #141920", -"a% c #242C3A", -"b% c #3F4B60", -"c% c #BDC0C6", -"d% c #EBEBE9", -"e% c #D1D7D3", -"f% c #4F5753", -"g% c #27322D", -"h% c #57655B", -"i% c #7E8B86", -"j% c #F0EFED", -"k% c #3E516C", -"l% c #3F4E68", -"m% c #3C4A64", -"n% c #4C5A74", -"o% c #55637C", -"p% c #5A6881", -"q% c #707D95", -"r% c #8493A6", -"s% c #BFC8D8", -"t% c #D8E4F0", -"u% c #CCD5E4", -"v% c #E2E8F1", -"w% c #D2DAE9", -"x% c #8D9DB7", -"y% c #526380", -"z% c #323E53", -"A% c #080B11", -"B% c #0E1217", -"C% c #272E3A", -"D% c #747D8A", -"E% c #D6D7D8", -"F% c #E8E8E7", -"G% c #E8E8E6", -"H% c #D2D2D0", -"I% c #B3B7B4", -"J% c #BFC1BF", -"K% c #EBE8E7", -"L% c #5A718E", -"M% c #3F4C65", -"N% c #38475F", -"O% c #68768E", -"P% c #6E7C92", -"Q% c #78879B", -"R% c #959FB1", -"S% c #AAB4C1", -"T% c #C4CBD8", -"U% c #D7DCE6", -"V% c #D3D9E1", -"W% c #CCD3DC", -"X% c #8C9CB4", -"Y% c #52627B", -"Z% c #38475E", -"`% c #080E1A", -" & c #060910", -".& c #0E0F14", -"+& c #4F5869", -"@& c #B6B8BC", -"#& c #DDDDDC", -"$& c #E2E2E1", -"%& c #E5E5E4", -"&& c #E6E6E5", -"*& c #F2F1F1", -"=& c #F2F1F0", -"-& c #93A8C2", -";& c #2F3E56", -">& c #6C7A93", -",& c #939EAE", -"'& c #A9B3C0", -")& c #BDC3CB", -"!& c #C8CCD2", -"~& c #CDCFD5", -"{& c #CBD2DB", -"]& c #C7CFDC", -"^& c #A4B2C7", -"/& c #4C576D", -"(& c #262C3C", -"_& c #252D3B", -":& c #232C3D", -"<& c #323B4B", -"[& c #464B5A", -"}& c #959697", -"|& c #BDBDBC", -"1& c #C9C9C9", -"2& c #D6D6D5", -"3& c #E2E2E0", -"4& c #E7E7E6", -"5& c #E6E6E4", -"6& c #C8D6E7", -"7& c #515D76", -"8& c #33415A", -"9& c #66728A", -"0& c #C0C7D2", -"a& c #CACED7", -"b& c #CCCDD2", -"c& c #CBCED1", -"d& c #C8CED3", -"e& c #C2CDDB", -"f& c #A2B1C5", -"g& c #586377", -"h& c #181F27", -"i& c #363B40", -"j& c #575857", -"k& c #626261", -"l& c #656463", -"m& c #787877", -"n& c #929291", -"o& c #9F9F9D", -"p& c #B0B0AE", -"q& c #C3C3C2", -"r& c #D1D1D0", -"s& c #DCDCDB", -"t& c #DFE4EB", -"u& c #5F708B", -"v& c #717E92", -"w& c #4F5E78", -"x& c #8391A4", -"y& c #A9B4C2", -"z& c #B1BBC5", -"A& c #BAC3CE", -"B& c #D5DDE8", -"C& c #9EA7B9", -"D& c #444D63", -"E& c #1F242F", -"F& c #2D2F33", -"G& c #424242", -"H& c #4D4D4D", -"I& c #515150", -"J& c #575756", -"K& c #60605F", -"L& c #747473", -"M& c #838381", -"N& c #989897", -"O& c #B3B3B2", -"P& c #C6C6C4", -"Q& c #D3D3D2", -"R& c #F0EFEE", -"S& c #D0D1D3", -"T& c #959FB4", -"U& c #5B697E", -"V& c #9DA7B7", -"W& c #D8DEE4", -"X& c #D4DAE1", -"Y& c #DBE1E5", -"Z& c #DBDDE3", -"`& c #818894", -" * c #1E293A", -".* c #1B222B", -"+* c #222425", -"@* c #313131", -"#* c #343434", -"$* c #363635", -"%* c #3A3A3A", -"&* c #40403F", -"** c #484847", -"=* c #585858", -"-* c #6B6B6A", -";* c #838382", -">* c #A5A5A3", -",* c #BCBCBA", -"'* c #CFCFCE", -")* c #EFEFEF", -"!* c #E3E3E2", -"~* c #D9D9D8", -"{* c #BCBCBB", -"]* c #9DA0A4", -"^* c #616678", -"/* c #2F3A4F", -"(* c #2C3649", -"_* c #394250", -":* c #111923", -"<* c #010613", -"[* c #0A0F16", -"}* c #1F2225", -"|* c #262628", -"1* c #282828", -"2* c #292828", -"3* c #292929", -"4* c #2D2D2C", -"5* c #2F2F2F", -"6* c #343433", -"7* c #3D3D3C", -"8* c #5C5C5C", -"9* c #A1A1A0", -"0* c #B9B9B8", -"a* c #CECECC", -"b* c #E4E4E2", -"c* c #D7D7D5", -"d* c #989896", -"e* c #717174", -"f* c #464B51", -"g* c #2F353C", -"h* c #23272C", -"i* c #222529", -"j* c #25272A", -"k* c #2E2F31", -"l* c #313030", -"m* c #313130", -"n* c #333332", -"o* c #363636", -"p* c #3C3C3C", -"q* c #545454", -"r* c #686867", -"s* c #848483", -"t* c #A8A8A7", -"u* c #C0C0BE", -"v* c #D3D3D1", -"w* c #D9D9D7", -"x* c #C0C0BF", -"y* c #A3A3A2", -"z* c #888886", -"A* c #6E6D6C", -"B* c #5F6061", -"C* c #585859", -"D* c #525252", -"E* c #A3A3A1", -"F* c #A2A2A0", -"G* c #A2A1A0", -"H* c #A2A2A1", -"I* c #A3A2A1", -"J* c #A4A3A2", -"K* c #A4A4A2", -"L* c #A6A6A4", -"M* c #A9A8A6", -"N* c #ABAAA8", -"O* c #AFAEAB", -"P* c #B3B1AE", -"Q* c #B5B4B1", -"R* c #B8B6B2", -"S* c #BAB8B4", -"T* c #6E6B62", -"U* c #DEDEDC", -"V* c #D1D1CF", -"W* c #BFBFBE", -"X* c #AFAFAF", -"Y* c #9F9F9F", -"Z* c #919190", -"`* c #888888", -" = c #302E28", -".= c #2E2C27", -"+= c #2D2B26", -"@= c #312F29", -"#= c #33312B", -"$= c #36332D", -"%= c #38362F", -"&= c #3D3A33", -"*= c #413E36", -"== c #47433B", -"-= c #4D4940", -";= c #514D44", -">= c #535046", -",= c #565248", -"'= c #23211D", -")= c #EBEAE9", -"!= c #DADAD9", -"~= c #C9C9C7", -"{= c #B6B6B6", -"]= c #B2B0AD", -"^= c #423F37", -"/= c #E3E2E1", -"(= c #4E4B44", -"_= c #403D36", -":= c #413E37", -"<= c #908E8A", -"[= c #46433B", -"}= c #D8D7D5", -"|= c #75726A", -"1= c #ACAAA5", -"2= c #D7D6D3", -"3= c #DBDAD8", -"4= c #86837C", -"5= c #D5D5D4", -"6= c #B6B5B1", -"7= c #4E4A41", -"8= c #D5D4D2", -"9= c #514E46", -"0= c #5E5B52", -"a= c #504D43", -"b= c #545147", -"c= c #8A8780", -"d= c #E3E3E1", -"e= c #D2D1CE", -"f= c #7B7770", -"g= c #58544A", -"h= c #7C7971", -"i= c #E7E7E5", -"j= c #CCCBC8", -"k= c #C4C2BF", -"l= c #C4C3BF", -"m= c #FBFAFA", -"n= c #817E76", -"o= c #D1D0CD", -"p= c #67635A", -"q= c #F5F4F4", -"r= c #67645B", -"s= c #908E87", -"t= c #E5E4E3", -"u= c #6F6C63", -"v= c #8B8881", -"w= c #C0BEBA", -"x= c #8C8982", -"y= c #C8C7C4", -"z= c #656259", -"A= c #77736B", -"B= c #E4E4E3", -"C= c #D3D2CF", -"D= c #76736B", -"E= c #59554B", -"F= c #E7E6E5", -"G= c #AFADA8", -"H= c #DFDFDD", -"I= c #D0CFCC", -"J= c #736F67", -"K= c #A9A9A7", -"L= c #8D8D8D", -"M= c #E1E1DF", -"N= c #9A9A9A", -"O= c #8C8C8C", -" . . . . . . . . . . . . . + @ # + . . . . . . . . . . . . . . . . . $ % ", -". & * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * = - ; . ", -". * * * * * * * * * * * * * * * * * * * > * * , , , , , , , , , , , , ' = ) ! . ", -". * * * * * * ~ * * { ] ^ / ( _ : < * * * , [ [ , , , , , , , , , , , } | * 1 2 . ", -". * * * * * * ~ * * 3 4 5 6 7 8 9 0 * , , , , , , , , , , , , , , , , } a * * ) b c ", -". * * * * * * * * * d e f g h i j k , , , , , l , , , , , , , , , m m = n * m * o p q ", -". * * * * * * * * * * r s t u v w x , , , , , l , , y z A m m m m m m B C * D E * F G . ", -". * * * * * * * * * * H I J K L M N , , , , l m z O P Q R S T ' E E E U V W X F n Y Z ` . ", -". * * * * * * * * m ...+.@., #.$.%., , , , &.*.=.-.;.>.,.'.).!.~.E d {.].^./.(._._.:.<.. ", -". * * * * [. .m * }.|.1.2.3.4.5.6.7.8.m 9.0.a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.! p.q.r.s.t.u.. ", -". * * , n.v.w.x.y.z.A.B.C.D.E.F.G.H.I.m J.K.L.M.N.O.P.Q.R.S.T.U.V.W.X.D ' } } Y.Z.Z `.s.. ", -". * * , +.+++@+#+$+%+&+*+=+E -+;+>+,+,+'+)+!+~+{+]+^+/+(+_+:+<+[+}+|+} X.1+2+3+3+3+4+<.. ", -". * * , 5+6+7+8+9+0+1 a+b+c+E d+e+` f+g+h+i+j+k+l+m+n+o+p+q+r+s+t+u+v+= } 3+3+B B o.o.w+. ", -". * , , 9.x+y+z+A+B+c+E E E E E E d C+D+E+F+G+l+m+H+I+J+K+L+M+N+O+P+Q+B B B U {.o.R+R+C . ", -". * m m m S+T+U+V+W+X.E E d ' ' ' ' X+Y+Z+`+ @I+.@.@+@^+@@#@$@%@&@*@=@o.U {.R+R+R+-@-@C . ", -". * m #.E ' ;@>@,@'@5+' ' ' ' 5+5+m.)@!@~@{@]@^@/@(@_@:@<@[@}@|@1@2@3@{.R+R+n.n.-@4@4@C . ", -". * E ' 5@6@7@8@9@0@} ' 5+5+m.m.m.a@b@c@d@l+e@f@g@h@i@j@k@l@m@n@o@p@q@n.n.-@r@4@4@s@s@C . ", -". * d [.t@u@v@w@x@{.m.m.m.m.m.[.m.y@z@A@B@C@D@E@F@G@H@I@J@K@L@M@N@O@P@-@-@r@s@s@< Q@R@C . ", -". * ' S@T@U@V@W@X@m.m.[.[.[.D Y@Z@`@ #.#+#@#D@##$#%#&#*#=#-#;#>#,#'#)#4@!#< < Q@~#~#{#C . ", -". * 5+3+]#^#/#(#_#[.D :#<#D X.[#}#|#1#2#3#f@4#5#6#7#8#9#0#a#b#c#d#e#f#< < g#g#~#{#h#h#C . ", -". * m.X.i#j#k#l#m#D n#o#p#q#} r#s#t#u#v#w#^@x#y#z#A#B#C#D#E#F#G#H#I#J#|+~#~#{#h#h#W K#C . ", -". * [.L#M#N#[#O#O#1+P#Q#R#S#1+T#U#V#W#X#Y#Z#`# $.$+$@$#$$$%$&$*$=$-$;$>${#h#4+4+K#K#K#C . ", -". * D ,$X.Y@[#[#} '$)$!$~${$3+]$^$/$($_$:$<$[$}$|$1$2$3$4$5$6$7$8$9$0$a$4+4+K#K#b$b$b$C . ", -". * [#[#[#n#c$d$e$f$g$h$i$j${.k$l$m$n$o$p$q$r$s$t$u$v$w$x$y$z$A$B$C$D$E$K#F$b$b$b$G$H$C . ", -". * X.1+I$J$K$L$M$N$O$< P$Q$R$S$T$U$V$W$X$Y$Z$`$ %.%+%@%#%$%%%&%*%=%-%;%b$b$b$G$>%>%,%C . ", -". * = = '%)%!%~%{%]%^%o.R+R+{./%(%_%:%<%[%}%|%1%2%3%4%5%6%7%8%9%0%a%b%c%d%>%>%>%,%,%,%C . ", -". * 2+2+2+e%f%g%h%i%j%R+-@1 -@k%l%m%n%o%p%q%r%s%t%u%v%w%x%y%z%A%B%C%D%E%F%F%>%,%F%F%G%C . ", -". * 3+U {.{.H%I%J%K%-@4@4@4@4@L%M%N%O%P%Q%R%S%T%U%V%W%X%Y%Z%`% &.&+&@&#&$&%&&&F%G%G%G%C . ", -". * {.{.R+n.*&=&=&4@4@4@s@< Q@-&M%;&>&,&'&)&!&~&{&]&^&/&(&_&:&<&[&}&|&1&2&#&3&4&4&4&5&C . ", -". * n.-@-@-@-@4@4@s@< < < ~#b$6&7&8&9&0&a&b&c&d&e&f&g&h&i&j&k&l&m&n&o&p&q&r&s&4&5&5&%&C . ", -". * -@-@-@4@< < < < < Q@R@G$%&t&u&v&w&x&y&z&A&B&C&D&E&F&G&H&I&J&K&L&M&N&O&P&Q&%&%&%&%&C . ", -". * 1 4@< < j%R&Q@Q@R@~#h#&&P$S&T&U&V&W&X&Y&Z&`& *.*+*@*#*$*%*&***=*-*;*>*,*'*%&=+=+=+C . ", -". * < < )*Q@Q@Q@R@~#~#K#G$!*~*{*]*^*/*(*_*:*<*[*}*|*1*2*3*4*5*6*7*>@8*m&9*0*a*=+=+=+b*C . ", -". * Q@Q@Q@Q@R@~#{#K#K#K#>%!*c*,*d*e*f*g*h*i*j*k*l*m*5*@*@*n*o*p*u.q*r*s*t*u*v*=+=+b*b*C . ", -". * Q@Q@~#~#{#K#K#K#K#b$>%!*w*x*y*z*A*B*C*D*E*F*F*F*G*F*H*I*J*K*L*M*N*O*P*Q*R*S*S*S*S*S*S*S*S*T*", -". * ~#~#4+K#K#F$b$b$b$b$H$5&U*V*W*X*Y*N&Z*`*N* =.=+=+=.= =@=#=$=%=&=*===-=;=>=,=,=,=,=,=,=,=,='=", -". * 4+K#F$)=)=)=b$d%d%G$H$G%b*!=H%~=x*{*0*{=]=^=* /=(=_=:=<=* * [=* * * m.}=|=,=1=2=D X.3=4=,='=", -". * F$b$b$b$d%G$G$G$G$H$H$G%5&3&#&~*5=Q&Q&H%6=7=* * 8=9=0={.* * a=* * b=c=* d=,=e=f=g=h=* R+,='=", -". * d%d%G$G$G$G$G$H$H$G%G%G%G%i=i=i=i=i=&&5&S*,=* j=* k=l=j=* * ,=* * ,=g=* m=,=,=,=,=n=* o=,='=", -". * G$G$G$H$H$>%>%F%G%G%G%i=i=i=i=i=5&5&=+=+S*,=* p={.* q=r=* * ,=* * ,=s=* o=,=,=,=* * t=u=,='=", -". * H$>%>%>%>%F%G%G%4&4&i=i=i=i=5&5&=+=+=+=+S*,=* ,=v=w=x=,=* * ,=* * * m#y=z=,=,=,=,=A=* )=,='=", -". * >%>%>%G%4&4&4&4&i=i=i=&&&&5&=+=+=+=+B=B=S*,=* ,=,=,=,=,=* * ,=* * ,=,=,=,=,=C=D=E=4=* F=,='=", -". * ,%4&4&4&4&i=i=i=&&&&&&5&=+=+=+B=B=b*b*b*S*,=* ,=,=,=,=,=* * ,=* * ,=,=,=,=,=G=H=m=q#I=J=,='=", -". * 4&i=i=i=&&&&&&&&5&5&=+B=B=B=b*b*b*b*b*b*S*,=,=,=,=,=,=,=,=,=,=,=,=,=,=,=,=,=,=,=,=,=,=,=,='=", -". * i=&&&&&&5&5&5&5&B=B=b*b*b*b*b*b*b*b*b*d=T*'='='='='='='='='='='='='='='='='='='='='='='='='=", -". * &&5&5&5&5&%&B=b*b*b*b*b*b*b*b*b*b*d=d=d=d=K=p p p y*y*y*y*E*E*E*E*E*E*E*E*E*E*E*E*L=. ", -". & 5&5&5&=+b*b*b*b*b*b*b*b*b*b*!*d=d=d=d=d=d=d=d=3&3&3&3&M=M=M=M=M=M=M=M=M=M=M=M=M=M=N=. ", -". Y C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C C N=O=. ", -" . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ", -" ", -" ", -" "};
--- a/src/madplug/plugin.c Fri Nov 30 04:55:41 2007 +0300 +++ b/src/madplug/plugin.c Sat Dec 01 05:15:43 2007 +0300 @@ -33,6 +33,7 @@ #include <audacious/vfs.h> #include <sys/stat.h> #include "SFMT.h" +#include "tuples.h" /* * Global variables @@ -625,7 +626,6 @@ #endif /* !NOGUI */ } -extern void audmad_get_file_info(char *filename); extern void audmad_configure(); static void __set_and_free(Tuple *tuple, gint nfield, gchar *name, gchar *value) @@ -794,6 +794,7 @@ aud_tuple_associate_string(tuple, FIELD_QUALITY, NULL, "lossy"); aud_tuple_associate_string(tuple, FIELD_CODEC, NULL, "MPEG Audio (MP3)"); + aud_tuple_associate_string(tuple, FIELD_MIMETYPE, NULL, "audio/mpeg"); if(local_fd) aud_vfs_fclose(fd); @@ -833,12 +834,12 @@ .seek = audmad_seek, .cleanup = audmad_cleanup, .get_song_info = audmad_get_song_info, - .file_info_box = audmad_get_file_info, .get_song_tuple = audmad_get_song_tuple, .is_our_file_from_vfs = audmad_is_our_fd, .vfs_extensions = fmts, .mseek = audmad_mseek, - .probe_for_tuple = audmad_probe_for_tuple + .probe_for_tuple = audmad_probe_for_tuple, + .update_song_tuple = audmad_update_song_tuple, }; InputPlugin *madplug_iplist[] = { &mad_ip, NULL };
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/madplug/tuples.c Sat Dec 01 05:15:43 2007 +0300 @@ -0,0 +1,374 @@ +/* + * mad plugin for audacious + * Copyright (C) 2005-2007 William Pitcock, Yoshiki Yazawa, Eugene Zagidullin + * + * Portions derived from xmms-mad: + * Copyright (C) 2001-2002 Sam Clegg - See COPYING + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; under version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include "config.h" + +#include "plugin.h" +#include "tuples.h" + +#include <math.h> +#include <string.h> + +#include <glib.h> +#include <glib/gprintf.h> + +#include <audacious/util.h> +#include <audacious/plugin.h> +#include <audacious/id3tag.h> + +/* yaz */ +#include <langinfo.h> + +#define DEBUG + +static void +update_id3_frame(struct id3_tag *tag, const char *frame_name, const char *data, int sjis) +{ + int res; + struct id3_frame *frame; + union id3_field *field; + id3_ucs4_t *ucs4; + + if (data == NULL) + return; + + // printf ("updating id3: %s: %s\n", frame_name, data); + + // + // An empty string removes the frame altogether. + // + if (strlen(data) == 0) { + while ((frame = id3_tag_findframe(tag, frame_name, 0))) { +#ifdef DEBUG + fprintf(stderr, "madplug: detachframe\n"); +#endif + id3_tag_detachframe(tag, frame); + } + return; + } + + frame = id3_tag_findframe(tag, frame_name, 0); + if (!frame) { +#ifdef DEBUG + printf("frame_new\n"); +#endif + frame = id3_frame_new(frame_name); + id3_tag_attachframe(tag, frame); + } + + // setup ucs4 string + if(sjis) { + ucs4 = id3_latin1_ucs4duplicate((id3_latin1_t *) data); + } + else { + ucs4 = id3_utf8_ucs4duplicate((id3_utf8_t *) data); + } + + // set encoding + field = id3_frame_field(frame, 0); + id3_field_settextencoding(field, sjis ? ID3_FIELD_TEXTENCODING_ISO_8859_1 : + ID3_FIELD_TEXTENCODING_UTF_8); + + // setup genre code + if (!strcmp(frame_name, ID3_FRAME_GENRE)) { + char *tmp; + int index = id3_genre_number(ucs4); + g_free(ucs4); + + if(index == -1) { // unknown genre. remove TCON frame. +#ifdef DEBUG + fprintf(stderr, "madplug: remove genre frame\n"); +#endif + id3_tag_detachframe(tag, frame); + } + else { // meaningful genre + tmp = g_strdup_printf("%d", index); + ucs4 = id3_latin1_ucs4duplicate((unsigned char *) tmp); + } + + } + + // write string + if (!strcmp(frame_name, ID3_FRAME_COMMENT)) { + field = id3_frame_field(frame, 3); + field->type = ID3_FIELD_TYPE_STRINGFULL; + res = id3_field_setfullstring(field, ucs4); + } + else { + field = id3_frame_field(frame, 1); + field->type = ID3_FIELD_TYPE_STRINGLIST; + res = id3_field_setstrings(field, 1, &ucs4); + } + + if (res != 0) + g_print("error setting id3 field: %s\n", frame_name); +} + +static void +update_id3_frame_from_tuple(struct id3_tag *id3tag, const char *field, Tuple *tuple, int fieldn, int sjis) +{ + int val; + char *text, *text2; + const char *encoding = sjis ? "SJIS" : "UTF-8"; + + if(aud_tuple_get_value_type(tuple, fieldn, NULL) == TUPLE_INT) { + val = aud_tuple_get_int(tuple, fieldn, NULL); + if(val > 0) { + text2 = g_strdup_printf("%d", val); +#ifdef DEBUG + fprintf(stderr, "madplug: updating field:\"%s\"=\"%s\", enc %s\n", field, text2, encoding); +#endif + update_id3_frame(id3tag, field, text2, 0); + g_free(text2); + } else { + update_id3_frame(id3tag, field, "", 0); /* will be detached */ + } + + } else if(aud_tuple_get_value_type(tuple, fieldn, NULL) == TUPLE_STRING) { + text = (char*)aud_tuple_get_string(tuple, fieldn, NULL); + text2 = g_convert(text, strlen(text), encoding, "UTF-8", NULL, NULL, NULL); +#ifdef DEBUG + fprintf(stderr, "madplug: updating field:\"%s\"=\"%s\", enc %s\n", field, text2, encoding); +#endif + update_id3_frame(id3tag, field, text2, sjis); + g_free(text2); + } +} + +gboolean +audmad_update_song_tuple(Tuple *tuple, VFSFile *fd) +{ + struct id3_file *id3file; + struct id3_tag *id3tag; + + if ((id3file = id3_file_vfsopen(fd, ID3_FILE_MODE_READWRITE)) == NULL) return FALSE; + + id3tag = id3_file_tag(id3file); + if (!id3tag) { +#ifdef DEBUG + fprintf(stderr, "no id3tag\n. append new tag.\n"); +#endif + id3tag = id3_tag_new(); + id3_tag_clearframes(id3tag); + id3tag->options |= ID3_TAG_OPTION_APPENDEDTAG | ID3_TAG_OPTION_ID3V1; + } + + id3_tag_options(id3tag, ID3_TAG_OPTION_ID3V1, ~0); /* enables id3v1. TODO: make id3v1 optional */ + + update_id3_frame_from_tuple(id3tag, ID3_FRAME_TITLE, tuple, FIELD_TITLE, audmad_config.sjis); + update_id3_frame_from_tuple(id3tag, ID3_FRAME_ARTIST, tuple, FIELD_ARTIST, audmad_config.sjis); + update_id3_frame_from_tuple(id3tag, ID3_FRAME_ALBUM, tuple, FIELD_ALBUM, audmad_config.sjis); + update_id3_frame_from_tuple(id3tag, ID3_FRAME_YEAR, tuple, FIELD_YEAR, audmad_config.sjis); + update_id3_frame_from_tuple(id3tag, ID3_FRAME_COMMENT, tuple, FIELD_COMMENT, audmad_config.sjis); + update_id3_frame_from_tuple(id3tag, ID3_FRAME_TRACK, tuple, FIELD_TRACK_NUMBER, audmad_config.sjis); + update_id3_frame_from_tuple(id3tag, ID3_FRAME_GENRE, tuple, FIELD_GENRE, audmad_config.sjis); + + if (id3_file_update(id3file) != 0) return FALSE; + + id3_file_close(id3file); + return TRUE; +} + +/*#endif // !NOGUI + +void audmad_get_file_info(char *fileurl) +{ +#ifndef NOGUI + gchar *title; + gchar message[128]; + static char const *const layer_str[3] = { "I", "II", "III" }; + static char const *const mode_str[4] = { + ("single channel"), ("dual channel"), "joint stereo", "stereo" + }; + gchar *tmp, *utf_filename; + gchar *realfn = NULL; +#ifdef DEBUG + { + tmp = aud_str_to_utf8(fileurl); + g_message("f: audmad_get_file_info: %s", tmp); + g_free(tmp); + tmp = NULL; + } +#endif + + if(!aud_vfs_is_remote(fileurl) && !aud_vfs_file_test(fileurl, G_FILE_TEST_EXISTS)) { + return; + } + + input_init(&info, fileurl, NULL); + + if(audmad_is_remote(fileurl)) { + info.remote = TRUE; + if(aud_vfs_is_streaming(info.infile)) + return; //file info dialog for remote streaming doesn't make sense. + } + + realfn = g_filename_from_uri(fileurl, NULL, NULL); + utf_filename = aud_str_to_utf8(realfn ? realfn : fileurl); + g_free(realfn); realfn = NULL; + create_window(); + + info.fileinfo_request = TRUE; + input_get_info(&info, info.remote ? TRUE : FALSE); + + tmp = g_path_get_basename(utf_filename); + title = g_strdup_printf(_("File Info - %s"), tmp); + g_free(tmp); tmp = NULL; + gtk_window_set_title(GTK_WINDOW(window), title); + g_free(title); + + gtk_entry_set_text(GTK_ENTRY(filename_entry), utf_filename); + gtk_editable_set_position(GTK_EDITABLE(filename_entry), -1); + + free(utf_filename); + + id3_frame_to_entry(ID3_FRAME_ARTIST, GTK_ENTRY(artist_entry)); + id3_frame_to_entry(ID3_FRAME_TITLE, GTK_ENTRY(title_entry)); + id3_frame_to_entry(ID3_FRAME_ALBUM, GTK_ENTRY(album_entry)); + +// year +// id3_frame_to_entry (ID3_FRAME_YEAR, GTK_ENTRY (year_entry)); +// to set year entry, we have to do manually because TYER is still used equally to TDRC. + gtk_entry_set_text(GTK_ENTRY(year_entry), ""); + if (info.tag) { + gchar *text = NULL; + text = input_id3_get_string(info.tag, "TDRC"); + if (!text) + text = input_id3_get_string(info.tag, "TYER"); + if (text) { + gtk_entry_set_text(GTK_ENTRY(year_entry), text); + g_free(text); + } + } + + id3_frame_to_entry(ID3_FRAME_TRACK, GTK_ENTRY(tracknum_entry)); + id3_frame_to_entry(ID3_FRAME_COMMENT, GTK_ENTRY(comment_entry)); + snprintf(message, 127, _("Layer %s"), layer_str[info.mpeg_layer - 1]); + gtk_label_set_text(GTK_LABEL(mpeg_level), message); + if (info.vbr) { + snprintf(message, 127, _("VBR (avg. %d kbps)"), info.bitrate / 1000); + } + else { + snprintf(message, 127, "%d kbps", info.bitrate / 1000); + } + gtk_label_set_text(GTK_LABEL(mpeg_bitrate), message); + snprintf(message, 127, _("%d Hz"), info.freq); + gtk_label_set_text(GTK_LABEL(mpeg_samplerate), message); + if (info.frames != -1) { + snprintf(message, 127, _("%d frames"), info.frames); + gtk_label_set_text(GTK_LABEL(mpeg_frames), message); + } + else { + gtk_label_set_text(GTK_LABEL(mpeg_frames), ""); + } + gtk_label_set_text(GTK_LABEL(mpeg_flags), mode_str[info.mode]); + { + guint sec = mad_timer_count(info.duration, MAD_UNITS_SECONDS); + snprintf(message, 127, _("%d:%02d (%d seconds)"), sec /60 ,sec % 60, sec); + } + gtk_label_set_text(GTK_LABEL(mpeg_duration), message); + + if (info.replaygain_album_str != NULL) { + snprintf(message, 127, _("RG_album=%4s (x%4.2f)"), + info.replaygain_album_str, info.replaygain_album_scale); + gtk_label_set_text(GTK_LABEL(mpeg_replaygain), message); + } + else + gtk_label_set_text(GTK_LABEL(mpeg_replaygain), ""); + + if (info.replaygain_track_str != NULL) { + snprintf(message, 127, _("RG_track=%4s (x%4.2f)"), + info.replaygain_track_str, info.replaygain_track_scale); + gtk_label_set_text(GTK_LABEL(mpeg_replaygain2), message); + } + else + gtk_label_set_text(GTK_LABEL(mpeg_replaygain2), ""); + + if (info.replaygain_album_peak_str != NULL) { + snprintf(message, 127, _("Peak album=%4s (%+5.3fdBFS)"), + info.replaygain_album_peak_str, + 20 * log10(info.replaygain_album_peak)); + gtk_label_set_text(GTK_LABEL(mpeg_replaygain3), message); + } + else + gtk_label_set_text(GTK_LABEL(mpeg_replaygain3), ""); + + if (info.replaygain_track_peak_str != NULL) { + snprintf(message, 127, _("Peak track=%4s (%+5.3fdBFS)"), + info.replaygain_track_peak_str, + 20 * log10(info.replaygain_track_peak)); + gtk_label_set_text(GTK_LABEL(mpeg_replaygain4), message); + } + else + gtk_label_set_text(GTK_LABEL(mpeg_replaygain3), ""); + + if (info.mp3gain_undo_str != NULL) { + snprintf(message, 127, _("mp3gain undo=%4s (%+5.3fdB)"), + info.mp3gain_undo_str, info.mp3gain_undo); + gtk_label_set_text(GTK_LABEL(mp3gain1), message); + } + else + gtk_label_set_text(GTK_LABEL(mp3gain1), ""); + + if (info.mp3gain_minmax_str != NULL) { + snprintf(message, 127, _("mp3gain minmax=%4s (max-min=%+6.3fdB)"), + info.mp3gain_minmax_str, info.mp3gain_minmax); + gtk_label_set_text(GTK_LABEL(mp3gain2), message); + } + else + gtk_label_set_text(GTK_LABEL(mp3gain2), ""); + + gtk_label_set_text(GTK_LABEL(mpeg_fileinfo), ""); + + + // work out the index of the genre in the list + { + const id3_ucs4_t *string; + id3_ucs4_t *genre; + struct id3_frame *frame; + union id3_field *field; + frame = id3_tag_findframe(info.tag, ID3_FRAME_GENRE, 0); + if (frame) { + field = id3_frame_field(frame, 1); + string = id3_field_getstrings(field, 0); + genre = mad_parse_genre(string); +#ifdef DEBUG + if (genre) { + gchar *utf = (gchar *)id3_ucs4_utf8duplicate(genre); + g_print("genre = %s\n", utf); + g_print("genre num = %d\n", id3_genre_number(genre)); + g_free(utf); + } +#endif + if (genre) { + gtk_list_select_item(GTK_LIST + (GTK_COMBO(genre_combo)->list), + id3_genre_number(genre)+1); //shift one for "Unknown". + g_free((void *)genre); + } + } + } + + gtk_widget_set_sensitive(id3_frame, TRUE); + +#endif // !NOGUI +}*/ +