📄 fileinfo.c
字号:
/* XMMS - Cross-platform multimedia player * Copyright (C) 1998-2000 Peter Alm, Mikael Alm, Olle Hallnas, Thomas Nilsson and 4Front Technologies * Copyright (C) 1999,2000 H鍁ard Kv錶en * Copyright (C) 2002,2003,2004,2005 Daisuke Shimamura * * 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; either version 2 of the License, or * (at your option) any later version. * * 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 <stdlib.h>#include <string.h> /* for strlen() */#include <sys/types.h>#include <sys/stat.h>#include <unistd.h>#include <stdarg.h>#include <gtk/gtk.h>#include "FLAC/metadata.h"#include "charset.h"#include "configure.h"#include "plugin_common/tags.h"#include "plugin_common/locale_hack.h"static GtkWidget *window = NULL;static GList *genre_list = NULL;static GtkWidget *filename_entry, *tag_frame;static GtkWidget *title_entry, *artist_entry, *album_entry, *date_entry, *tracknum_entry, *comment_entry;static GtkWidget *genre_combo;static GtkWidget *flac_samplerate, *flac_channels, *flac_bits_per_sample, *flac_blocksize, *flac_filesize, *flac_samples, *flac_bitrate;static gchar *current_filename = NULL;static FLAC__StreamMetadata *tags_ = NULL;static const gchar *vorbis_genres[] ={ N_("Blues"), N_("Classic Rock"), N_("Country"), N_("Dance"), N_("Disco"), N_("Funk"), N_("Grunge"), N_("Hip-Hop"), N_("Jazz"), N_("Metal"), N_("New Age"), N_("Oldies"), N_("Other"), N_("Pop"), N_("R&B"), N_("Rap"), N_("Reggae"), N_("Rock"), N_("Techno"), N_("Industrial"), N_("Alternative"), N_("Ska"), N_("Death Metal"), N_("Pranks"), N_("Soundtrack"), N_("Euro-Techno"), N_("Ambient"), N_("Trip-Hop"), N_("Vocal"), N_("Jazz+Funk"), N_("Fusion"), N_("Trance"), N_("Classical"), N_("Instrumental"), N_("Acid"), N_("House"), N_("Game"), N_("Sound Clip"), N_("Gospel"), N_("Noise"), N_("Alt"), N_("Bass"), N_("Soul"), N_("Punk"), N_("Space"), N_("Meditative"), N_("Instrumental Pop"), N_("Instrumental Rock"), N_("Ethnic"), N_("Gothic"), N_("Darkwave"), N_("Techno-Industrial"), N_("Electronic"), N_("Pop-Folk"), N_("Eurodance"), N_("Dream"), N_("Southern Rock"), N_("Comedy"), N_("Cult"), N_("Gangsta Rap"), N_("Top 40"), N_("Christian Rap"), N_("Pop/Funk"), N_("Jungle"), N_("Native American"), N_("Cabaret"), N_("New Wave"), N_("Psychedelic"), N_("Rave"), N_("Showtunes"), N_("Trailer"), N_("Lo-Fi"), N_("Tribal"), N_("Acid Punk"), N_("Acid Jazz"), N_("Polka"), N_("Retro"), N_("Musical"), N_("Rock & Roll"), N_("Hard Rock"), N_("Folk"), N_("Folk/Rock"), N_("National Folk"), N_("Swing"), N_("Fast-Fusion"), N_("Bebob"), N_("Latin"), N_("Revival"), N_("Celtic"), N_("Bluegrass"), N_("Avantgarde"), N_("Gothic Rock"), N_("Progressive Rock"), N_("Psychedelic Rock"), N_("Symphonic Rock"), N_("Slow Rock"), N_("Big Band"), N_("Chorus"), N_("Easy Listening"), N_("Acoustic"), N_("Humour"), N_("Speech"), N_("Chanson"), N_("Opera"), N_("Chamber Music"), N_("Sonata"), N_("Symphony"), N_("Booty Bass"), N_("Primus"), N_("Porn Groove"), N_("Satire"), N_("Slow Jam"), N_("Club"), N_("Tango"), N_("Samba"), N_("Folklore"), N_("Ballad"), N_("Power Ballad"), N_("Rhythmic Soul"), N_("Freestyle"), N_("Duet"), N_("Punk Rock"), N_("Drum Solo"), N_("A Cappella"), N_("Euro-House"), N_("Dance Hall"), N_("Goa"), N_("Drum & Bass"), N_("Club-House"), N_("Hardcore"), N_("Terror"), N_("Indie"), N_("BritPop"), N_("Negerpunk"), N_("Polsk Punk"), N_("Beat"), N_("Christian Gangsta Rap"), N_("Heavy Metal"), N_("Black Metal"), N_("Crossover"), N_("Contemporary Christian"), N_("Christian Rock"), N_("Merengue"), N_("Salsa"), N_("Thrash Metal"), N_("Anime"), N_("JPop"), N_("Synthpop")};static void label_set_text(GtkWidget * label, char *str, ...){ va_list args; gchar *tempstr; va_start(args, str); tempstr = g_strdup_vprintf(str, args); va_end(args); gtk_label_set_text(GTK_LABEL(label), tempstr); g_free(tempstr);}static void set_entry_tag(GtkEntry * entry, const char * utf8){ if(utf8) { if(flac_cfg.title.convert_char_set) { char *text = convert_from_utf8_to_user(utf8); gtk_entry_set_text(entry, text); free(text); } else gtk_entry_set_text(entry, utf8); } else gtk_entry_set_text(entry, "");}static void get_entry_tag(GtkEntry * entry, const char *name){ gchar *text; char *utf8; text = gtk_entry_get_text(entry); if (!text || strlen(text) == 0) return; if(flac_cfg.title.convert_char_set) utf8 = convert_from_user_to_utf8(text); else utf8 = text; FLAC_plugin__tags_add_tag_utf8(tags_, name, utf8, /*separator=*/0); if(flac_cfg.title.convert_char_set) free(utf8);}static void show_tag(){ set_entry_tag(GTK_ENTRY(title_entry) , FLAC_plugin__tags_get_tag_utf8(tags_, "TITLE")); set_entry_tag(GTK_ENTRY(artist_entry) , FLAC_plugin__tags_get_tag_utf8(tags_, "ARTIST")); set_entry_tag(GTK_ENTRY(album_entry) , FLAC_plugin__tags_get_tag_utf8(tags_, "ALBUM")); set_entry_tag(GTK_ENTRY(date_entry) , FLAC_plugin__tags_get_tag_utf8(tags_, "DATE")); set_entry_tag(GTK_ENTRY(tracknum_entry) , FLAC_plugin__tags_get_tag_utf8(tags_, "TRACKNUMBER")); set_entry_tag(GTK_ENTRY(comment_entry) , FLAC_plugin__tags_get_tag_utf8(tags_, "DESCRIPTION")); set_entry_tag(GTK_ENTRY(GTK_COMBO(genre_combo)->entry), FLAC_plugin__tags_get_tag_utf8(tags_, "GENRE"));}static void save_tag(GtkWidget * w, gpointer data){ (void)w; (void)data; FLAC_plugin__tags_delete_tag(tags_, "TITLE"); FLAC_plugin__tags_delete_tag(tags_, "ARTIST"); FLAC_plugin__tags_delete_tag(tags_, "ALBUM"); FLAC_plugin__tags_delete_tag(tags_, "DATE"); FLAC_plugin__tags_delete_tag(tags_, "TRACKNUMBER"); FLAC_plugin__tags_delete_tag(tags_, "DESCRIPTION"); FLAC_plugin__tags_delete_tag(tags_, "GENRE"); get_entry_tag(GTK_ENTRY(title_entry) , "TITLE"); get_entry_tag(GTK_ENTRY(artist_entry) , "ARTIST"); get_entry_tag(GTK_ENTRY(album_entry) , "ALBUM"); get_entry_tag(GTK_ENTRY(date_entry) , "DATE"); get_entry_tag(GTK_ENTRY(tracknum_entry) , "TRACKNUMBER"); get_entry_tag(GTK_ENTRY(comment_entry) , "DESCRIPTION"); get_entry_tag(GTK_ENTRY(GTK_COMBO(genre_combo)->entry), "GENRE"); FLAC_plugin__tags_set(current_filename, tags_); gtk_widget_destroy(window);}static void remove_tag(GtkWidget * w, gpointer data){ (void)w; (void)data; FLAC_plugin__tags_delete_tag(tags_, "TITLE"); FLAC_plugin__tags_delete_tag(tags_, "ARTIST"); FLAC_plugin__tags_delete_tag(tags_, "ALBUM"); FLAC_plugin__tags_delete_tag(tags_, "DATE"); FLAC_plugin__tags_delete_tag(tags_, "TRACKNUMBER"); FLAC_plugin__tags_delete_tag(tags_, "DESCRIPTION"); FLAC_plugin__tags_delete_tag(tags_, "GENRE"); FLAC_plugin__tags_set(current_filename, tags_); gtk_widget_destroy(window);}static void show_file_info(){ FLAC__StreamMetadata streaminfo; struct stat _stat; gtk_label_set_text(GTK_LABEL(flac_samplerate), ""); gtk_label_set_text(GTK_LABEL(flac_channels), ""); gtk_label_set_text(GTK_LABEL(flac_bits_per_sample), ""); gtk_label_set_text(GTK_LABEL(flac_blocksize), ""); gtk_label_set_text(GTK_LABEL(flac_filesize), ""); gtk_label_set_text(GTK_LABEL(flac_samples), ""); gtk_label_set_text(GTK_LABEL(flac_bitrate), ""); if(!FLAC__metadata_get_streaminfo(current_filename, &streaminfo)) { return; } label_set_text(flac_samplerate, _("Samplerate: %d Hz"), streaminfo.data.stream_info.sample_rate); label_set_text(flac_channels, _("Channels: %d"), streaminfo.data.stream_info.channels); label_set_text(flac_bits_per_sample, _("Bits/Sample: %d"), streaminfo.data.stream_info.bits_per_sample); if(streaminfo.data.stream_info.min_blocksize == streaminfo.data.stream_info.max_blocksize) label_set_text(flac_blocksize, _("Blocksize: %d"), streaminfo.data.stream_info.min_blocksize);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -