patches from Miroslav for file info dialog and tag editing
This commit is contained in:
parent
eb3c586a01
commit
ee3032a09f
@ -36,7 +36,7 @@ LIBTOOL = $(top_builddir)/libtool-disable-static
|
||||
|
||||
xmmsinputplugin_LTLIBRARIES = libxmms-flac.la
|
||||
|
||||
plugin_sources = charset.c configure.c plugin.c wrap_id3.c
|
||||
plugin_sources = charset.c configure.c plugin.c wrap_id3.c fileinfo.c
|
||||
|
||||
if FLaC__HAS_ID3LIB
|
||||
libxmms_flac_la_SOURCES = $(plugin_sources)
|
||||
|
@ -29,6 +29,7 @@ OBJS = \
|
||||
charset.o \
|
||||
configure.o \
|
||||
plugin.o \
|
||||
fileinfo.o \
|
||||
wrap_id3.o
|
||||
|
||||
include $(topdir)/build/lib.mk
|
||||
|
@ -17,107 +17,231 @@
|
||||
* 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 <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <stdarg.h>
|
||||
#include "FLAC/all.h"
|
||||
#include "id3_tag.h"
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "FLAC/metadata.h"
|
||||
#include "charset.h"
|
||||
#include "configure.h"
|
||||
|
||||
gboolean get_file_info(char *filename, flac_file_info_struct *tmp_file_info)
|
||||
{
|
||||
FLAC__StreamMetadata streaminfo;
|
||||
|
||||
if(0 == filename)
|
||||
filename = "";
|
||||
|
||||
if(!FLAC__metadata_get_streaminfo(filename, &streaminfo)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
tmp_file_info->sample_rate = streaminfo.data.stream_info.sample_rate;
|
||||
tmp_file_info->channels = streaminfo.data.stream_info.channels;
|
||||
tmp_file_info->bits_per_sample = streaminfo.data.stream_info.bits_per_sample;
|
||||
tmp_file_info->total_samples = streaminfo.data.stream_info.total_samples;
|
||||
|
||||
tmp_file_info->length_in_msec = streaminfo.data.stream_info.total_samples * 10 / (streaminfo.data.stream_info.sample_rate / 100);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
#include "plugin_common/vorbiscomment.h"
|
||||
#include "plugin_common/locale_hack.h"
|
||||
|
||||
static GtkWidget *window = NULL;
|
||||
static GtkWidget *filename_entry, *id3_frame;
|
||||
static GtkWidget *title_entry, *artist_entry, *album_entry, *year_entry, *tracknum_entry, *comment_entry;
|
||||
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_level, *flac_bitrate, *flac_samplerate, *flac_flags;
|
||||
static GtkWidget *flac_fileinfo, *flac_genre;
|
||||
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_Plugin__CanonicalTag *canonical_tag = NULL;
|
||||
|
||||
extern gchar *flac_filename;
|
||||
extern gint flac_bitrate, flac_frequency, flac_layer, flac_lsf, flac_mode;
|
||||
extern gboolean flac_stereo, flac_flac25;
|
||||
|
||||
#define MAX_STR_LEN 100
|
||||
|
||||
static void set_entry_tag(GtkEntry * entry, gchar * tag, gint length)
|
||||
static const gchar *vorbis_genres[] =
|
||||
{
|
||||
gint stripped_len;
|
||||
gchar *text;
|
||||
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")
|
||||
};
|
||||
|
||||
stripped_len = flac_strip_spaces(tag, length);
|
||||
text = g_strdup_printf("%-*.*s", stripped_len, stripped_len, tag);
|
||||
gtk_entry_set_text(entry, text);
|
||||
g_free(text);
|
||||
static void local__safe_free(void *object)
|
||||
{
|
||||
if(0 != object)
|
||||
free(object);
|
||||
}
|
||||
|
||||
static void get_entry_tag(GtkEntry * entry, gchar * tag, gint length)
|
||||
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, gchar * tag)
|
||||
{
|
||||
char *text;
|
||||
|
||||
if(tag) {
|
||||
if(flac_cfg.title.convert_char_set) {
|
||||
text = convert_from_file_to_user(tag);
|
||||
gtk_entry_set_text(entry, text);
|
||||
free(text);
|
||||
}
|
||||
else
|
||||
gtk_entry_set_text(entry, tag);
|
||||
}
|
||||
else
|
||||
gtk_entry_set_text(entry, "");
|
||||
}
|
||||
|
||||
static char *get_entry_tag(GtkEntry * entry)
|
||||
{
|
||||
gchar *text;
|
||||
|
||||
text = gtk_entry_get_text(entry);
|
||||
memset(tag, ' ', length);
|
||||
memcpy(tag, text, strlen(text) > length ? length : strlen(text));
|
||||
if (!text || strlen(text) == 0)
|
||||
return 0;
|
||||
if(flac_cfg.title.convert_char_set)
|
||||
return convert_from_user_to_file(text);
|
||||
else
|
||||
return strdup(text);
|
||||
}
|
||||
|
||||
static gint genre_comp_func(gconstpointer a, gconstpointer b)
|
||||
static void show_tag()
|
||||
{
|
||||
return strcasecmp(a, b);
|
||||
set_entry_tag(GTK_ENTRY(title_entry), canonical_tag->title);
|
||||
set_entry_tag(GTK_ENTRY(artist_entry), canonical_tag->composer);
|
||||
set_entry_tag(GTK_ENTRY(album_entry), canonical_tag->album);
|
||||
set_entry_tag(GTK_ENTRY(date_entry), canonical_tag->year_recorded);
|
||||
set_entry_tag(GTK_ENTRY(tracknum_entry), canonical_tag->track_number);
|
||||
set_entry_tag(GTK_ENTRY(comment_entry), canonical_tag->comment);
|
||||
set_entry_tag(GTK_ENTRY(GTK_COMBO(genre_combo)->entry), canonical_tag->genre);
|
||||
}
|
||||
|
||||
static gchar* channel_mode_name(int mode)
|
||||
static void save_tag(GtkWidget * w, gpointer data)
|
||||
{
|
||||
static const gchar *channel_mode[] = {N_("Mono"), N_("Stereo")};
|
||||
if (mode < 1 || mode > 2)
|
||||
return "";
|
||||
return gettext(channel_mode[mode]);
|
||||
(void)w;
|
||||
(void)data;
|
||||
|
||||
local__safe_free(canonical_tag->title);
|
||||
local__safe_free(canonical_tag->composer);
|
||||
local__safe_free(canonical_tag->album);
|
||||
local__safe_free(canonical_tag->year_recorded);
|
||||
local__safe_free(canonical_tag->track_number);
|
||||
local__safe_free(canonical_tag->comment);
|
||||
local__safe_free(canonical_tag->genre);
|
||||
canonical_tag->title = get_entry_tag(GTK_ENTRY(title_entry));
|
||||
canonical_tag->composer = get_entry_tag(GTK_ENTRY(artist_entry));
|
||||
canonical_tag->album = get_entry_tag(GTK_ENTRY(album_entry));
|
||||
canonical_tag->year_recorded = get_entry_tag(GTK_ENTRY(date_entry));
|
||||
canonical_tag->track_number = get_entry_tag(GTK_ENTRY(tracknum_entry));
|
||||
canonical_tag->comment = get_entry_tag(GTK_ENTRY(comment_entry));
|
||||
canonical_tag->genre = get_entry_tag(GTK_ENTRY(GTK_COMBO(genre_combo)->entry));
|
||||
|
||||
FLAC_plugin__vorbiscomment_set(current_filename, canonical_tag);
|
||||
gtk_widget_destroy(window);
|
||||
}
|
||||
|
||||
static void remove_tag(GtkWidget * w, gpointer data)
|
||||
{
|
||||
(void)w;
|
||||
(void)data;
|
||||
|
||||
local__safe_free(canonical_tag->title);
|
||||
local__safe_free(canonical_tag->composer);
|
||||
local__safe_free(canonical_tag->album);
|
||||
local__safe_free(canonical_tag->year_recorded);
|
||||
local__safe_free(canonical_tag->track_number);
|
||||
local__safe_free(canonical_tag->comment);
|
||||
local__safe_free(canonical_tag->genre);
|
||||
|
||||
canonical_tag->title = canonical_tag->composer = canonical_tag->album = canonical_tag->year_recorded = canonical_tag->track_number = canonical_tag->comment = canonical_tag->genre = 0;
|
||||
|
||||
FLAC_plugin__vorbiscomment_set(current_filename, canonical_tag);
|
||||
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);
|
||||
else
|
||||
label_set_text(flac_blocksize, _("Blocksize: variable\n min/max: %d/%d"), streaminfo.data.stream_info.min_blocksize, streaminfo.data.stream_info.max_blocksize);
|
||||
|
||||
if (streaminfo.data.stream_info.total_samples)
|
||||
label_set_text(flac_samples, _("Samples: %llu\nLength: %d:%.2d"),
|
||||
streaminfo.data.stream_info.total_samples,
|
||||
(int)(streaminfo.data.stream_info.total_samples / streaminfo.data.stream_info.sample_rate / 60),
|
||||
(int)(streaminfo.data.stream_info.total_samples / streaminfo.data.stream_info.sample_rate % 60));
|
||||
|
||||
if(!stat(current_filename, &_stat) && S_ISREG(_stat.st_mode)) {
|
||||
label_set_text(flac_filesize, _("Filesize: %ld B"), _stat.st_size);
|
||||
if (streaminfo.data.stream_info.total_samples)
|
||||
label_set_text(flac_bitrate, _("Avg. bitrate: %.1f kb/s\nCompression ratio: %.1f%%"),
|
||||
8.0 * (float)(_stat.st_size) / (1000.0 * (float)streaminfo.data.stream_info.total_samples / (float)streaminfo.data.stream_info.sample_rate),
|
||||
100.0 * (float)_stat.st_size / (float)(streaminfo.data.stream_info.bits_per_sample / 8 * streaminfo.data.stream_info.channels * streaminfo.data.stream_info.total_samples));
|
||||
}
|
||||
}
|
||||
|
||||
void FLAC_XMMS__file_info_box(char *filename)
|
||||
{
|
||||
gint i;
|
||||
FILE *fh;
|
||||
gchar *tmp, *title;
|
||||
|
||||
gboolean rc;
|
||||
|
||||
#ifdef FLAC__HAS_ID3LIB
|
||||
File_Tag tag;
|
||||
Initialize_File_Tag_Item (&tag);
|
||||
rc = Id3tag_Read_File_Tag (filename, &tag);
|
||||
#else
|
||||
id3v2_struct tag;
|
||||
memset(&tag, 0, sizeof(tag));
|
||||
rc = get_id3v1_tag_as_v2_(filename, &tag);
|
||||
#endif
|
||||
unsigned i;
|
||||
gchar *title;
|
||||
|
||||
if (!window)
|
||||
{
|
||||
GtkWidget *vbox, *hbox, *left_vbox, *table;
|
||||
GtkWidget *flac_frame, *flac_box;
|
||||
GtkWidget *label, *filename_hbox;
|
||||
GtkWidget *bbox, *save, *remove_id3, *cancel;
|
||||
GtkWidget *bbox, *save, *remove, *cancel;
|
||||
|
||||
window = gtk_window_new(GTK_WINDOW_DIALOG);
|
||||
gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, FALSE);
|
||||
@ -142,54 +266,54 @@ void FLAC_XMMS__file_info_box(char *filename)
|
||||
left_vbox = gtk_vbox_new(FALSE, 10);
|
||||
gtk_box_pack_start(GTK_BOX(hbox), left_vbox, FALSE, FALSE, 0);
|
||||
|
||||
id3_frame = gtk_frame_new(_("ID3 Tag:"));
|
||||
gtk_box_pack_start(GTK_BOX(left_vbox), id3_frame, FALSE, FALSE, 0);
|
||||
tag_frame = gtk_frame_new(_("Tag:"));
|
||||
gtk_box_pack_start(GTK_BOX(left_vbox), tag_frame, FALSE, FALSE, 0);
|
||||
|
||||
table = gtk_table_new(5, 5, FALSE);
|
||||
gtk_container_set_border_width(GTK_CONTAINER(table), 5);
|
||||
gtk_container_add(GTK_CONTAINER(id3_frame), table);
|
||||
gtk_container_add(GTK_CONTAINER(tag_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_with_max_length(30);
|
||||
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_with_max_length(30);
|
||||
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_with_max_length(30);
|
||||
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_with_max_length(30);
|
||||
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:"));
|
||||
label = gtk_label_new(_("Date:"));
|
||||
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_with_max_length(4);
|
||||
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);
|
||||
date_entry = gtk_entry_new();
|
||||
gtk_widget_set_usize(date_entry, 40, -1);
|
||||
gtk_table_attach(GTK_TABLE(table), date_entry, 1, 2, 4, 5, GTK_FILL | GTK_EXPAND | GTK_SHRINK, GTK_FILL | GTK_EXPAND | GTK_SHRINK, 0, 5);
|
||||
|
||||
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_with_max_length(3);
|
||||
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);
|
||||
|
||||
@ -198,13 +322,14 @@ void FLAC_XMMS__file_info_box(char *filename)
|
||||
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);
|
||||
gtk_entry_set_editable(GTK_ENTRY(GTK_COMBO(genre_combo)->entry), TRUE);
|
||||
|
||||
if (!genre_list)
|
||||
{
|
||||
for (i = 0; i < GENRE_MAX; i++)
|
||||
genre_list = g_list_prepend(genre_list, (char *) flac_id3_genres[i]);
|
||||
for (i = 0; i < sizeof(vorbis_genres) / sizeof(*vorbis_genres) ; i++)
|
||||
genre_list = g_list_prepend(genre_list, (char *)vorbis_genres[i]);
|
||||
genre_list = g_list_prepend(genre_list, "");
|
||||
genre_list = g_list_sort(genre_list, genre_comp_func);
|
||||
genre_list = g_list_sort(genre_list, (GCompareFunc)g_strcasecmp);
|
||||
}
|
||||
gtk_combo_set_popdown_strings(GTK_COMBO(genre_combo), genre_list);
|
||||
|
||||
@ -216,15 +341,15 @@ void FLAC_XMMS__file_info_box(char *filename)
|
||||
gtk_box_pack_start(GTK_BOX(left_vbox), bbox, FALSE, FALSE, 0);
|
||||
|
||||
save = gtk_button_new_with_label(_("Save"));
|
||||
gtk_signal_connect(GTK_OBJECT(save), "clicked", GTK_SIGNAL_FUNC(save_cb), NULL);
|
||||
gtk_signal_connect(GTK_OBJECT(save), "clicked", GTK_SIGNAL_FUNC(save_tag), NULL);
|
||||
GTK_WIDGET_SET_FLAGS(save, GTK_CAN_DEFAULT);
|
||||
gtk_box_pack_start(GTK_BOX(bbox), save, TRUE, TRUE, 0);
|
||||
gtk_widget_grab_default(save);
|
||||
|
||||
remove_id3 = gtk_button_new_with_label(_("Remove ID3"));
|
||||
gtk_signal_connect(GTK_OBJECT(remove_id3), "clicked", GTK_SIGNAL_FUNC(remove_id3_cb), NULL);
|
||||
GTK_WIDGET_SET_FLAGS(remove_id3, GTK_CAN_DEFAULT);
|
||||
gtk_box_pack_start(GTK_BOX(bbox), remove_id3, TRUE, TRUE, 0);
|
||||
remove= gtk_button_new_with_label(_("Remove Tag"));
|
||||
gtk_signal_connect(GTK_OBJECT(remove), "clicked", GTK_SIGNAL_FUNC(remove_tag), NULL);
|
||||
GTK_WIDGET_SET_FLAGS(remove, GTK_CAN_DEFAULT);
|
||||
gtk_box_pack_start(GTK_BOX(bbox), remove, TRUE, TRUE, 0);
|
||||
|
||||
cancel = gtk_button_new_with_label(_("Cancel"));
|
||||
gtk_signal_connect_object(GTK_OBJECT(cancel), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), GTK_OBJECT(window));
|
||||
@ -239,36 +364,48 @@ void FLAC_XMMS__file_info_box(char *filename)
|
||||
gtk_container_set_border_width(GTK_CONTAINER(flac_box), 10);
|
||||
gtk_box_set_spacing(GTK_BOX(flac_box), 0);
|
||||
|
||||
flac_level = gtk_label_new("");
|
||||
gtk_widget_set_usize(flac_level, 120, -2);
|
||||
gtk_misc_set_alignment(GTK_MISC(flac_level), 0, 0);
|
||||
gtk_box_pack_start(GTK_BOX(flac_box), flac_level, FALSE, FALSE, 0);
|
||||
flac_samplerate = gtk_label_new("");
|
||||
gtk_misc_set_alignment(GTK_MISC(flac_samplerate), 0, 0);
|
||||
gtk_label_set_justify(GTK_LABEL(flac_samplerate), GTK_JUSTIFY_LEFT);
|
||||
gtk_box_pack_start(GTK_BOX(flac_box), flac_samplerate, FALSE, FALSE, 0);
|
||||
|
||||
flac_channels = gtk_label_new("");
|
||||
gtk_misc_set_alignment(GTK_MISC(flac_channels), 0, 0);
|
||||
gtk_label_set_justify(GTK_LABEL(flac_channels), GTK_JUSTIFY_LEFT);
|
||||
gtk_box_pack_start(GTK_BOX(flac_box), flac_channels, FALSE, FALSE, 0);
|
||||
|
||||
flac_bits_per_sample = gtk_label_new("");
|
||||
gtk_misc_set_alignment(GTK_MISC(flac_bits_per_sample), 0, 0);
|
||||
gtk_label_set_justify(GTK_LABEL(flac_bits_per_sample), GTK_JUSTIFY_LEFT);
|
||||
gtk_box_pack_start(GTK_BOX(flac_box), flac_bits_per_sample, FALSE, FALSE, 0);
|
||||
|
||||
flac_blocksize = gtk_label_new("");
|
||||
gtk_misc_set_alignment(GTK_MISC(flac_blocksize), 0, 0);
|
||||
gtk_label_set_justify(GTK_LABEL(flac_blocksize), GTK_JUSTIFY_LEFT);
|
||||
gtk_box_pack_start(GTK_BOX(flac_box), flac_blocksize, FALSE, FALSE, 0);
|
||||
|
||||
flac_filesize = gtk_label_new("");
|
||||
gtk_misc_set_alignment(GTK_MISC(flac_filesize), 0, 0);
|
||||
gtk_label_set_justify(GTK_LABEL(flac_filesize), GTK_JUSTIFY_LEFT);
|
||||
gtk_box_pack_start(GTK_BOX(flac_box), flac_filesize, FALSE, FALSE, 0);
|
||||
|
||||
flac_samples = gtk_label_new("");
|
||||
gtk_misc_set_alignment(GTK_MISC(flac_samples), 0, 0);
|
||||
gtk_label_set_justify(GTK_LABEL(flac_samples), GTK_JUSTIFY_LEFT);
|
||||
gtk_box_pack_start(GTK_BOX(flac_box), flac_samples, FALSE, FALSE, 0);
|
||||
|
||||
flac_bitrate = gtk_label_new("");
|
||||
gtk_misc_set_alignment(GTK_MISC(flac_bitrate), 0, 0);
|
||||
gtk_label_set_justify(GTK_LABEL(flac_bitrate), GTK_JUSTIFY_LEFT);
|
||||
gtk_box_pack_start(GTK_BOX(flac_box), flac_bitrate, FALSE, FALSE, 0);
|
||||
|
||||
flac_samplerate = gtk_label_new("");
|
||||
gtk_misc_set_alignment(GTK_MISC(flac_samplerate), 0, 0);
|
||||
gtk_box_pack_start(GTK_BOX(flac_box), flac_samplerate, FALSE, FALSE, 0);
|
||||
|
||||
flac_flags = gtk_label_new("");
|
||||
gtk_misc_set_alignment(GTK_MISC(flac_flags), 0, 0);
|
||||
gtk_label_set_justify(GTK_LABEL(flac_flags), GTK_JUSTIFY_LEFT);
|
||||
gtk_box_pack_start(GTK_BOX(flac_box), flac_flags, FALSE, FALSE, 0);
|
||||
|
||||
flac_fileinfo = gtk_label_new("");
|
||||
gtk_misc_set_alignment(GTK_MISC(flac_fileinfo), 0, 0);
|
||||
gtk_label_set_justify(GTK_LABEL(flac_fileinfo), GTK_JUSTIFY_LEFT);
|
||||
gtk_box_pack_start(GTK_BOX(flac_box), flac_fileinfo, FALSE, FALSE, 0);
|
||||
|
||||
gtk_widget_show_all(window);
|
||||
}
|
||||
|
||||
if (current_filename)
|
||||
if(current_filename)
|
||||
g_free(current_filename);
|
||||
current_filename = g_strdup(filename);
|
||||
if(!(current_filename = g_strdup(filename)))
|
||||
return;
|
||||
|
||||
title = g_strdup_printf(_("File Info - %s"), g_basename(filename));
|
||||
gtk_window_set_title(GTK_WINDOW(window), title);
|
||||
@ -277,46 +414,15 @@ void FLAC_XMMS__file_info_box(char *filename)
|
||||
gtk_entry_set_text(GTK_ENTRY(filename_entry), filename);
|
||||
gtk_editable_set_position(GTK_EDITABLE(filename_entry), -1);
|
||||
|
||||
if (tag.title != NULL && strlen(tag.title) > 0)
|
||||
{
|
||||
gtk_entry_set_text(GTK_ENTRY(title_entry), tag.title);
|
||||
}
|
||||
if(canonical_tag)
|
||||
FLAC_plugin__canonical_tag_clear(canonical_tag);
|
||||
else
|
||||
{
|
||||
title = g_strdup(g_basename(filename));
|
||||
if ((tmp = strrchr(title, '.')) != NULL)
|
||||
*tmp = '\0';
|
||||
gtk_entry_set_text(GTK_ENTRY(title_entry), title);
|
||||
g_free(title);
|
||||
}
|
||||
canonical_tag = FLAC_plugin__canonical_tag_new();
|
||||
|
||||
gtk_entry_set_text(GTK_ENTRY(artist_entry), tag.artist);
|
||||
gtk_entry_set_text(GTK_ENTRY(album_entry), tag.album);
|
||||
gtk_entry_set_text(GTK_ENTRY(year_entry), tag.year);
|
||||
gtk_entry_set_text(GTK_ENTRY(tracknum_entry), tag.track);
|
||||
gtk_entry_set_text(GTK_ENTRY(comment_entry), tag.comment);
|
||||
gtk_entry_set_text(GTK_ENTRY(genre_entry), tag.genre);
|
||||
FLAC_plugin__vorbiscomment_get(current_filename, canonical_tag);
|
||||
|
||||
gtk_label_set_text(GTK_LABEL(flac_level), "");
|
||||
gtk_label_set_text(GTK_LABEL(flac_bitrate), "");
|
||||
gtk_label_set_text(GTK_LABEL(flac_samplerate), "");
|
||||
gtk_label_set_text(GTK_LABEL(flac_flags), "");
|
||||
gtk_label_set_text(GTK_LABEL(flac_fileinfo), "");
|
||||
show_tag();
|
||||
show_file_info();
|
||||
|
||||
if (!strncasecmp(filename, "http://", 7))
|
||||
{
|
||||
file_info_http(filename);
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_widget_set_sensitive(id3_frame, TRUE);
|
||||
|
||||
label_set_text(flac_bitrate, _("Bits/Samples: %d"), tmp_file_info->bits_per_sample);
|
||||
/* tmp_file_info->length_in_msec */
|
||||
|
||||
label_set_text(flac_samplerate, _("Samplerate: %ld Hz"), tmp_file_info->sample_rate);
|
||||
label_set_text(flac_channel, _("Channel: %s"), channel_mode_name(tmp_file_info->channel);
|
||||
#if 0
|
||||
label_set_text(flac_fileinfo, _("%d frames\nFilesize: %lu B"), num_frames, ftell(fh));
|
||||
#endif
|
||||
gtk_widget_set_sensitive(tag_frame, TRUE);
|
||||
}
|
||||
|
@ -47,6 +47,7 @@
|
||||
#endif
|
||||
#define min(x,y) ((x)<(y)?(x):(y))
|
||||
|
||||
extern void FLAC_XMMS__file_info_box(char *filename);
|
||||
|
||||
typedef struct {
|
||||
FLAC__bool abort_flag;
|
||||
@ -108,7 +109,7 @@ InputPlugin flac_ip =
|
||||
NULL,
|
||||
NULL,
|
||||
FLAC_XMMS__get_song_info,
|
||||
NULL, /* file_info_box */
|
||||
FLAC_XMMS__file_info_box,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user