[easytag/wip/application-window: 62/74] Move file area to EtFileArea object
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag/wip/application-window: 62/74] Move file area to EtFileArea object
- Date: Mon, 4 Aug 2014 08:12:49 +0000 (UTC)
commit f1af91c2b4782fa9f3f3221fcd328346602dca8c
Author: David King <amigadave amigadave com>
Date: Sat Jul 19 09:19:38 2014 +0100
Move file area to EtFileArea object
Makefile.am | 2 +
po/POTFILES.in | 1 +
src/application_window.c | 183 +++++++----------------
src/application_window.h | 4 +
src/easytag.c | 12 +--
src/easytag.h | 22 ---
src/et_core.c | 280 +++++++++++-----------------------
src/et_core.h | 28 ++++
src/file_area.c | 381 ++++++++++++++++++++++++++++++++++++++++++++++
src/file_area.h | 57 +++++++
src/flac_header.c | 73 +++++----
src/flac_header.h | 45 +++---
src/monkeyaudio_header.c | 74 +++++-----
src/monkeyaudio_header.h | 48 +++----
src/mp4_header.cc | 88 +++++++-----
src/mp4_header.h | 3 +-
src/mpeg_header.c | 110 +++++++++-----
src/mpeg_header.h | 51 +++----
src/musepack_header.c | 108 +++++++-------
src/musepack_header.h | 48 +++----
src/ogg_header.c | 116 ++++++++------
src/ogg_header.h | 38 +++---
src/opus_header.c | 67 +++++----
src/opus_header.h | 3 +-
src/wavpack_header.c | 71 +++++----
src/wavpack_header.h | 45 +++---
26 files changed, 1138 insertions(+), 820 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 7f617e5..d11f644 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -54,6 +54,7 @@ easytag_SOURCES = \
src/easytag.c \
src/enums.c \
src/et_core.c \
+ src/file_area.c \
src/flac_header.c \
src/flac_tag.c \
src/gio_wrapper.cc \
@@ -104,6 +105,7 @@ easytag_headers = \
src/dlm.h \
src/easytag.h \
src/et_core.h \
+ src/file_area.h \
src/flac_header.h \
src/flac_tag.h \
src/genres.h \
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 0769306..e6c697b 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -14,6 +14,7 @@ src/cddb_dialog.c
src/charset.c
src/easytag.c
src/et_core.c
+src/file_area.c
src/flac_header.c
src/flac_tag.c
src/id3_tag.c
diff --git a/src/application_window.c b/src/application_window.c
index 6cceac7..e7323f2 100644
--- a/src/application_window.c
+++ b/src/application_window.c
@@ -27,6 +27,7 @@
#include "browser.h"
#include "cddb_dialog.h"
#include "easytag.h"
+#include "file_area.h"
#include "gtk2_compat.h"
#include "load_files_dialog.h"
#include "log.h"
@@ -256,38 +257,6 @@ et_application_window_tag_area_clear (EtApplicationWindow *self)
et_tag_area_clear (ET_TAG_AREA (priv->tag_area));
}
-
-/*
- * Clear the entry of file area
- */
-void
-Clear_File_Entry_Field (void)
-{
- g_return_if_fail (FileEntry != NULL);
-
- gtk_entry_set_text (GTK_ENTRY (FileEntry),"");
-}
-
-
-/*
- * Clear the header information
- */
-void
-Clear_Header_Fields (void)
-{
- g_return_if_fail (VersionValueLabel != NULL);
-
- /* Default values are MPs data */
- gtk_label_set_text (GTK_LABEL (VersionLabel), _("Encoder:"));
- gtk_label_set_text (GTK_LABEL (VersionValueLabel), "");
- gtk_label_set_text (GTK_LABEL (BitrateValueLabel), "");
- gtk_label_set_text (GTK_LABEL (SampleRateValueLabel), "");
- gtk_label_set_text (GTK_LABEL (ModeLabel), _("Mode:"));
- gtk_label_set_text (GTK_LABEL (ModeValueLabel), "");
- gtk_label_set_text (GTK_LABEL (SizeValueLabel), "");
- gtk_label_set_text (GTK_LABEL (DurationValueLabel), "");
-}
-
static GtkWidget *
create_browser_area (EtApplicationWindow *self)
{
@@ -308,104 +277,6 @@ create_browser_area (EtApplicationWindow *self)
return frame;
}
-
-static GtkWidget *
-create_file_area (void)
-{
- GtkWidget *vbox, *hbox;
- GtkWidget *separator;
-
- FileFrame = gtk_frame_new (_("File"));
- gtk_container_set_border_width (GTK_CONTAINER (FileFrame), 2);
-
- vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
- gtk_container_add (GTK_CONTAINER (FileFrame), vbox);
- gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
-
- /* HBox for FileEntry and IconBox */
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
-
- /* File index (position in list + list length) */
- FileIndex = gtk_label_new ("0/0:");
- gtk_box_pack_start (GTK_BOX (hbox), FileIndex, FALSE, FALSE, 0);
-
- /* Filename. */
- FileEntry = gtk_entry_new ();
- gtk_editable_set_editable (GTK_EDITABLE (FileEntry), TRUE);
- gtk_box_pack_start (GTK_BOX (hbox), FileEntry, TRUE, TRUE, 2);
-
- g_signal_connect (FileEntry, "populate-popup",
- G_CALLBACK (on_entry_populate_popup), NULL);
-
- /*
- * File Infos
- */
- HeaderInfosTable = et_grid_new (3, 5);
- gtk_container_add (GTK_CONTAINER (vbox), HeaderInfosTable);
- gtk_container_set_border_width (GTK_CONTAINER (HeaderInfosTable), 2);
- gtk_grid_set_row_spacing (GTK_GRID (HeaderInfosTable), 1);
- gtk_grid_set_column_spacing (GTK_GRID (HeaderInfosTable), 2);
-
- VersionLabel = gtk_label_new (_("Encoder:"));
- gtk_grid_attach (GTK_GRID (HeaderInfosTable), VersionLabel, 0, 0, 1, 1);
- VersionValueLabel = gtk_label_new ("");
- gtk_grid_attach (GTK_GRID (HeaderInfosTable), VersionValueLabel, 1, 0, 1,
- 1);
- gtk_misc_set_alignment (GTK_MISC (VersionLabel), 1.0, 0.5);
- gtk_misc_set_alignment (GTK_MISC (VersionValueLabel), 0.0, 0.5);
-
- BitrateLabel = gtk_label_new (_("Bitrate:"));
- gtk_grid_attach (GTK_GRID (HeaderInfosTable), BitrateLabel, 0, 1, 1, 1);
- BitrateValueLabel = gtk_label_new ("");
- gtk_grid_attach (GTK_GRID (HeaderInfosTable), BitrateValueLabel, 1, 1, 1,
- 1);
- gtk_misc_set_alignment (GTK_MISC (BitrateLabel), 1.0, 0.5);
- gtk_misc_set_alignment (GTK_MISC (BitrateValueLabel), 0.0, 0.5);
-
- /* Translators: Please try to keep this string as short as possible as it
- * is shown in a narrow column. */
- SampleRateLabel = gtk_label_new (_("Frequency:"));
- gtk_grid_attach (GTK_GRID (HeaderInfosTable), SampleRateLabel, 0, 2, 1, 1);
- SampleRateValueLabel = gtk_label_new("");
- gtk_grid_attach (GTK_GRID (HeaderInfosTable), SampleRateValueLabel, 1, 2,
- 1, 1);
- gtk_misc_set_alignment (GTK_MISC (SampleRateLabel), 1.0, 0.5);
- gtk_misc_set_alignment (GTK_MISC (SampleRateValueLabel), 0.0, 0.5);
-
- separator = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
- gtk_grid_attach (GTK_GRID (HeaderInfosTable), separator, 2, 0, 1, 4);
-
- ModeLabel = gtk_label_new(_("Mode:"));
- gtk_grid_attach (GTK_GRID (HeaderInfosTable), ModeLabel, 3, 0, 1, 1);
- ModeValueLabel = gtk_label_new ("");
- gtk_grid_attach (GTK_GRID (HeaderInfosTable), ModeValueLabel, 4, 0, 1, 1);
- gtk_misc_set_alignment (GTK_MISC (ModeLabel), 1.0, 0.5);
- gtk_misc_set_alignment (GTK_MISC (ModeValueLabel), 0.0, 0.5);
-
- SizeLabel = gtk_label_new (_("Size:"));
- gtk_grid_attach (GTK_GRID (HeaderInfosTable), SizeLabel, 3, 1, 1, 1);
- SizeValueLabel = gtk_label_new ("");
- gtk_grid_attach (GTK_GRID (HeaderInfosTable), SizeValueLabel, 4, 1, 1, 1);
- gtk_misc_set_alignment (GTK_MISC (SizeLabel), 1.0, 0.5);
- gtk_misc_set_alignment (GTK_MISC (SizeValueLabel), 0.0, 0.5);
-
- DurationLabel = gtk_label_new (_("Duration:"));
- gtk_grid_attach (GTK_GRID (HeaderInfosTable), DurationLabel, 3, 2, 1, 1);
- DurationValueLabel = gtk_label_new ("");
- gtk_grid_attach (GTK_GRID (HeaderInfosTable), DurationValueLabel, 4, 2, 1,
- 1);
- gtk_misc_set_alignment (GTK_MISC (DurationLabel), 1.0, 0.5);
- gtk_misc_set_alignment (GTK_MISC (DurationValueLabel), 0.0, 0.5);
-
- /* FIXME */
- #if 0
- if (SHOW_HEADER_INFO)
- gtk_widget_show_all(HeaderInfosTable);
- #endif
- return FileFrame;
-}
-
static void
et_application_window_show_cddb_dialog (EtApplicationWindow *self)
{
@@ -1808,7 +1679,7 @@ et_application_window_init (EtApplicationWindow *self)
gtk_paned_set_position (GTK_PANED (priv->hpaned), 600);
/* File */
- priv->file_area = create_file_area ();
+ priv->file_area = et_file_area_new ();
gtk_box_pack_start (GTK_BOX (vbox), priv->file_area, FALSE, FALSE, 0);
/* Tag */
@@ -2105,6 +1976,56 @@ et_application_window_tag_area_set_sensitive (EtApplicationWindow *self,
sensitive);
}
+void
+et_application_window_file_area_clear (EtApplicationWindow *self)
+{
+ EtApplicationWindowPrivate *priv;
+
+ g_return_if_fail (ET_APPLICATION_WINDOW (self));
+
+ priv = et_application_window_get_instance_private (self);
+
+ et_file_area_clear (ET_FILE_AREA (priv->file_area));
+}
+
+const gchar *
+et_application_window_file_area_get_filename (EtApplicationWindow *self)
+{
+ EtApplicationWindowPrivate *priv;
+
+ g_return_if_fail (ET_APPLICATION_WINDOW (self));
+
+ priv = et_application_window_get_instance_private (self);
+
+ return et_file_area_get_filename (ET_FILE_AREA (priv->file_area));
+}
+
+void
+et_application_window_file_area_set_file_fields (EtApplicationWindow *self,
+ ET_File *ETFile)
+{
+ EtApplicationWindowPrivate *priv;
+
+ g_return_if_fail (ET_APPLICATION_WINDOW (self));
+
+ priv = et_application_window_get_instance_private (self);
+
+ et_file_area_set_file_fields (ET_FILE_AREA (priv->file_area), ETFile);
+}
+
+void
+et_application_window_file_area_set_header_fields (EtApplicationWindow *self,
+ EtFileHeaderFields *fields)
+{
+ EtApplicationWindowPrivate *priv;
+
+ g_return_if_fail (ET_APPLICATION_WINDOW (self));
+
+ priv = et_application_window_get_instance_private (self);
+
+ et_file_area_set_header_fields (ET_FILE_AREA (priv->file_area), fields);
+}
+
/*
* Disable (FALSE) / Enable (TRUE) all user widgets in the file area
*/
diff --git a/src/application_window.h b/src/application_window.h
index 3dcd429..c0fcdc7 100644
--- a/src/application_window.h
+++ b/src/application_window.h
@@ -51,6 +51,10 @@ File_Tag * et_application_window_tag_area_create_file_tag (EtApplicationWindow *
gboolean et_application_window_tag_area_display_et_file (EtApplicationWindow *self, ET_File *ETFile);
void et_application_window_tag_area_clear (EtApplicationWindow *self);
void et_application_window_tag_area_set_sensitive (EtApplicationWindow *self, gboolean sensitive);
+const gchar * et_application_window_file_area_get_filename (EtApplicationWindow *self);
+void et_application_window_file_area_set_file_fields (EtApplicationWindow *self, ET_File *ETFile);
+void et_application_window_file_area_set_header_fields (EtApplicationWindow *self, EtFileHeaderFields
*fields);
+void et_application_window_file_area_clear (EtApplicationWindow *self);
void et_application_window_file_area_set_sensitive (EtApplicationWindow *self, gboolean sensitive);
void et_application_window_disable_command_actions (EtApplicationWindow *self);
void et_application_window_update_actions (EtApplicationWindow *self);
diff --git a/src/easytag.c b/src/easytag.c
index c9f0fdc..273484a 100644
--- a/src/easytag.c
+++ b/src/easytag.c
@@ -1203,10 +1203,8 @@ gboolean Read_Directory (gchar *path_real)
et_application_window_browser_clear (window);
/* Clear entry boxes */
- Clear_File_Entry_Field();
- Clear_Header_Fields();
+ et_application_window_file_area_clear (window);
et_application_window_tag_area_clear (window);
- gtk_label_set_text(GTK_LABEL(FileIndex),"0/0:");
// Set to unsensitive the Browser Area, to avoid to select another file while loading the first one
et_application_window_browser_set_sensitive (window, FALSE);
@@ -1340,15 +1338,9 @@ gboolean Read_Directory (gchar *path_real)
}else
{
/* Clear entry boxes */
- Clear_File_Entry_Field();
- Clear_Header_Fields();
+ et_application_window_file_area_clear (ET_APPLICATION_WINDOW (MainWindow));
et_application_window_tag_area_clear (ET_APPLICATION_WINDOW (MainWindow));
- if (FileIndex)
- gtk_label_set_text(GTK_LABEL(FileIndex),"0/0:");
-
-
-
/* Translators: No files, as in "0 files". */
et_application_window_browser_label_set_text (ET_APPLICATION_WINDOW (MainWindow),
_("No files")); /* See in ET_Display_Filename_To_UI */
diff --git a/src/easytag.h b/src/easytag.h
index 7427ec9..0cfe83d 100644
--- a/src/easytag.h
+++ b/src/easytag.h
@@ -41,24 +41,6 @@ gboolean Main_Stop_Button_Pressed;
GtkWidget *MainWindow;
-/* File Area */
-GtkWidget *FileFrame;
-GtkWidget *FileIndex;
-GtkWidget *FileEntry;
-GtkWidget *HeaderInfosTable; /* declarated here to show/hide file header infos */
-GtkWidget *VersionLabel;
-GtkWidget *VersionValueLabel;
-GtkWidget *BitrateLabel;
-GtkWidget *BitrateValueLabel;
-GtkWidget *SampleRateLabel;
-GtkWidget *SampleRateValueLabel;
-GtkWidget *ModeLabel;
-GtkWidget *ModeValueLabel;
-GtkWidget *SizeLabel;
-GtkWidget *SizeValueLabel;
-GtkWidget *DurationLabel;
-GtkWidget *DurationValueLabel;
-
gchar *INIT_DIRECTORY;
#ifndef errno
@@ -83,8 +65,4 @@ void Action_Main_Stop_Button_Pressed (void);
gboolean Read_Directory (gchar *path);
void Quit_MainWindow (void);
-void Clear_File_Entry_Field (void);
-void Clear_Header_Fields (void);
-
-
#endif /* __EASYTAG_H__ */
diff --git a/src/et_core.c b/src/et_core.c
index 2aabb50..367844e 100644
--- a/src/et_core.c
+++ b/src/et_core.c
@@ -158,9 +158,8 @@ static guint ET_Undo_Key_New (void);
static gboolean ET_Remove_File_From_Artist_Album_List (ET_File *ETFile);
-static void ET_Display_File_And_List_Status_To_UI (ET_File *ETFile);
static void ET_Display_Filename_To_UI (ET_File *ETFile);
-static gboolean ET_Display_File_Info_To_UI (ET_File_Info *ETFileInfo);
+static EtFileHeaderFields * ET_Display_File_Info_To_UI (ET_File *ETFile);
static gboolean ET_Save_File_Name_From_UI (ET_File *ETFile,
File_Name *FileName);
@@ -900,10 +899,8 @@ gboolean ET_Remove_File_From_File_List (ET_File *ETFile)
}else
{
// Reinit the tag and file area
- Clear_File_Entry_Field();
- Clear_Header_Fields();
+ et_application_window_file_area_clear (ET_APPLICATION_WINDOW (MainWindow));
et_application_window_tag_area_clear (ET_APPLICATION_WINDOW (MainWindow));
- gtk_label_set_text(GTK_LABEL(FileIndex),"0/0:");
et_application_window_update_actions (ET_APPLICATION_WINDOW (MainWindow));
}
@@ -2725,16 +2722,30 @@ gboolean ET_Set_Field_File_Tag_Picture (Picture **FileTagField, Picture *pic)
* Displaying functions *
************************/
+static void
+et_file_header_fields_free (EtFileHeaderFields *fields)
+{
+ g_free (fields->version);
+ g_free (fields->bitrate);
+ g_free (fields->samplerate);
+ g_free (fields->mode);
+ g_free (fields->size);
+ g_free (fields->duration);
+ g_slice_free (EtFileHeaderFields, fields);
+}
+
/*
* Display information of the file (Position + Header + Tag) to the user interface.
* Before doing it, it saves data of the file currently displayed
*/
void ET_Display_File_Data_To_UI (ET_File *ETFile)
{
+ EtApplicationWindow *window;
const ET_File_Description *ETFileDescription;
gchar *cur_filename;
gchar *cur_filename_utf8;
gchar *msg;
+ EtFileHeaderFields *fields;
#ifdef ENABLE_OPUS
GFile *file;
#endif
@@ -2750,85 +2761,98 @@ void ET_Display_File_Data_To_UI (ET_File *ETFile)
/* Save the current displayed file */
ETCore->ETFileDisplayed = ETFile;
+ window = ET_APPLICATION_WINDOW (MainWindow);
+
/* Display position in list + show/hide icon if file writable/read_only (cur_filename) */
- ET_Display_File_And_List_Status_To_UI(ETFile);
+ et_application_window_file_area_set_file_fields (window, ETFile);
/* Display filename (and his path) (value in FileNameNew) */
ET_Display_Filename_To_UI(ETFile);
/* Display tag data */
- et_application_window_tag_area_display_et_file (ET_APPLICATION_WINDOW (MainWindow),
- ETFile);
+ et_application_window_tag_area_display_et_file (window, ETFile);
/* Display controls in tag area */
- et_application_window_tag_area_display_controls (ET_APPLICATION_WINDOW (MainWindow),
- ETFile);
+ et_application_window_tag_area_display_controls (window, ETFile);
/* Display file data, header data and file type */
switch (ETFileDescription->FileType)
{
#if defined ENABLE_MP3 && defined ENABLE_ID3LIB
case MP3_FILE:
- gtk_frame_set_label(GTK_FRAME(FileFrame),_("MP3 File"));
- Mpeg_Header_Display_File_Info_To_UI(cur_filename,ETFile->ETFileInfo);
- break;
case MP2_FILE:
- gtk_frame_set_label(GTK_FRAME(FileFrame),_("MP2 File"));
- Mpeg_Header_Display_File_Info_To_UI(cur_filename,ETFile->ETFileInfo);
+ fields = Mpeg_Header_Display_File_Info_To_UI (cur_filename,
+ ETFile);
+ et_application_window_file_area_set_header_fields (window, fields);
+ et_mpeg_file_header_fields_free (fields);
break;
#endif
#ifdef ENABLE_OGG
case OGG_FILE:
- gtk_frame_set_label(GTK_FRAME(FileFrame),_("Ogg Vorbis File"));
- Ogg_Header_Display_File_Info_To_UI(cur_filename,ETFile->ETFileInfo);
+ fields = Ogg_Header_Display_File_Info_To_UI (cur_filename, ETFile);
+ et_application_window_file_area_set_header_fields (window, fields);
+ et_ogg_file_header_fields_free (fields);
break;
#endif
#ifdef ENABLE_SPEEX
case SPEEX_FILE:
- gtk_frame_set_label(GTK_FRAME(FileFrame),_("Speex File"));
- Ogg_Header_Display_File_Info_To_UI(cur_filename,ETFile->ETFileInfo);
+ fields = Ogg_Header_Display_File_Info_To_UI (cur_filename, ETFile);
+ et_application_window_file_area_set_header_fields (window, fields);
+ et_ogg_file_header_fields_free (fields);
break;
#endif
#ifdef ENABLE_FLAC
case FLAC_FILE:
- gtk_frame_set_label(GTK_FRAME(FileFrame),_("FLAC File"));
- Flac_Header_Display_File_Info_To_UI(cur_filename,ETFile->ETFileInfo);
+ fields = Flac_Header_Display_File_Info_To_UI (cur_filename,
+ ETFile);
+ et_application_window_file_area_set_header_fields (window, fields);
+ et_flac_file_header_fields_free (fields);
break;
#endif
case MPC_FILE:
- gtk_frame_set_label(GTK_FRAME(FileFrame),_("MusePack File"));
- Mpc_Header_Display_File_Info_To_UI(cur_filename,ETFile->ETFileInfo);
+ fields = Mpc_Header_Display_File_Info_To_UI (cur_filename, ETFile);
+ et_application_window_file_area_set_header_fields (window, fields);
+ et_mpc_file_header_fields_free (fields);
break;
case MAC_FILE:
- gtk_frame_set_label(GTK_FRAME(FileFrame),_("Monkey's Audio File"));
- Mac_Header_Display_File_Info_To_UI(cur_filename,ETFile->ETFileInfo);
+ fields = Mac_Header_Display_File_Info_To_UI (cur_filename,
+ ETFile);
+ et_application_window_file_area_set_header_fields (window, fields);
+ et_mac_file_header_fields_free (fields);
break;
#ifdef ENABLE_MP4
case MP4_FILE:
- gtk_frame_set_label(GTK_FRAME(FileFrame),_("MP4/AAC File"));
- Mp4_Header_Display_File_Info_To_UI(cur_filename,ETFile->ETFileInfo);
+ fields = Mp4_Header_Display_File_Info_To_UI (cur_filename, ETFile);
+ et_application_window_file_area_set_header_fields (window, fields);
+ et_mp4_file_header_fields_free (fields);
break;
#endif
#ifdef ENABLE_WAVPACK
case WAVPACK_FILE:
- gtk_frame_set_label(GTK_FRAME(FileFrame),_("Wavpack File"));
- Wavpack_Header_Display_File_Info_To_UI(cur_filename,ETFile->ETFileInfo);
+ fields = Wavpack_Header_Display_File_Info_To_UI (cur_filename,
+ ETFile);
+ et_application_window_file_area_set_header_fields (window, fields);
+ et_wavpack_file_header_fields_free (fields);
break;
#endif
#ifdef ENABLE_OPUS
case OPUS_FILE:
- gtk_frame_set_label (GTK_FRAME (FileFrame), _("Opus File"));
file = g_file_new_for_path (cur_filename);
- et_opus_header_display_file_info_to_ui (file, ETFile->ETFileInfo);
+ fields = et_opus_header_display_file_info_to_ui (file, ETFile);
+ et_application_window_file_area_set_header_fields (window, fields);
+ et_opus_file_header_fields_free (fields);
g_object_unref (file);
break;
#endif
case UNKNOWN_FILE:
default:
- gtk_frame_set_label(GTK_FRAME(FileFrame),_("File"));
- // Default displaying
- ET_Display_File_Info_To_UI(ETFile->ETFileInfo);
- Log_Print(LOG_ERROR,"ETFileInfo: Undefined file type %d for file
%s.",ETFileDescription->FileType,cur_filename_utf8);
+ /* Default displaying. */
+ fields = ET_Display_File_Info_To_UI (ETFile);
+ et_application_window_file_area_set_header_fields (window, fields);
+ et_file_header_fields_free (fields);
+ Log_Print (LOG_ERROR,
+ "ETFileInfo: Undefined file type %d for file %s.",
+ ETFileDescription->FileType, cur_filename_utf8);
break;
}
@@ -2837,119 +2861,10 @@ void ET_Display_File_Data_To_UI (ET_File *ETFile)
g_free(msg);
}
-
-/*
- * Toggle visibility of the small status icon if filename is read-only or not found.
- * Show the position of the current file in the list, by using the index and list length.
- */
-static void
-ET_Display_File_And_List_Status_To_UI (ET_File *ETFile)
-{
- GFile *file;
- gchar *text;
- gchar *cur_filename;
- GFileInfo *info;
- GError *error = NULL;
-
- g_return_if_fail (ETFile != NULL);
-
- cur_filename = ((File_Name *)((GList *)ETFile->FileNameCur)->data)->value;
-
- file = g_file_new_for_path (cur_filename);
-
- info = g_file_query_info (file, G_FILE_ATTRIBUTE_ACCESS_CAN_READ ","
- G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE,
- G_FILE_QUERY_INFO_NONE, NULL, &error);
-
- /* Show/hide 'AccessStatusIcon' */
- if (!info)
- {
- if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
- {
- /* No such file or directory. */
- GIcon *emblem_icon;
-
- emblem_icon = g_themed_icon_new ("emblem-unreadable");
-
- gtk_entry_set_icon_from_gicon (GTK_ENTRY (FileEntry),
- GTK_ENTRY_ICON_SECONDARY,
- emblem_icon);
- gtk_entry_set_icon_tooltip_text (GTK_ENTRY (FileEntry),
- GTK_ENTRY_ICON_SECONDARY,
- _("File not found"));
- g_object_unref (emblem_icon);
- }
- else
- {
- Log_Print (LOG_ERROR, _("Cannot query file information (%s)"),
- error->message);
- g_error_free (error);
- g_object_unref (file);
- return;
- }
- }
- else
- {
- gboolean readable, writable;
-
- readable = g_file_info_get_attribute_boolean (info,
- G_FILE_ATTRIBUTE_ACCESS_CAN_READ);
- writable = g_file_info_get_attribute_boolean (info,
- G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE);
-
- if (readable && writable)
- {
- /* User has all necessary permissions. */
- gtk_entry_set_icon_from_gicon (GTK_ENTRY (FileEntry),
- GTK_ENTRY_ICON_SECONDARY, NULL);
- }
- else if (!writable)
- {
- /* Read only file or permission denied. */
- GIcon *emblem_icon;
-
- emblem_icon = g_themed_icon_new ("emblem-readonly");
-
- gtk_entry_set_icon_from_gicon (GTK_ENTRY (FileEntry),
- GTK_ENTRY_ICON_SECONDARY,
- emblem_icon);
- gtk_entry_set_icon_tooltip_text (GTK_ENTRY (FileEntry),
- GTK_ENTRY_ICON_SECONDARY,
- _("Read-only file"));
- g_object_unref (emblem_icon);
-
- }
- else
- {
- /* Otherwise unreadable. */
- GIcon *emblem_icon;
-
- emblem_icon = g_themed_icon_new ("emblem-unreadable");
-
- gtk_entry_set_icon_from_gicon (GTK_ENTRY (FileEntry),
- GTK_ENTRY_ICON_SECONDARY,
- emblem_icon);
- gtk_entry_set_icon_tooltip_text (GTK_ENTRY (FileEntry),
- GTK_ENTRY_ICON_SECONDARY,
- _("File not found"));
- g_object_unref (emblem_icon);
- }
- g_object_unref (info);
- }
-
- /* Show position of current file in list */
- text = g_strdup_printf("%d/%d:",ETFile->IndexKey,ETCore->ETFileDisplayedList_Length);
- gtk_label_set_text(GTK_LABEL(FileIndex),text);
- g_object_unref (file);
- g_free(text);
-}
-
static void
ET_Display_Filename_To_UI (ET_File *ETFile)
{
- gchar *pos;
gchar *new_filename_utf8;
- gchar *basename_utf8;
gchar *dirname_utf8;
gchar *text;
@@ -2958,21 +2873,6 @@ ET_Display_Filename_To_UI (ET_File *ETFile)
new_filename_utf8 = ((File_Name *)((GList *)ETFile->FileNameNew)->data)->value_utf8;
/*
- * Set filename into FileEntry
- */
- basename_utf8 = g_path_get_basename(new_filename_utf8);
-
- // Remove the extension
- if ((pos=g_utf8_strrchr(basename_utf8, -1, '.'))!=NULL)
- *pos = 0;
- gtk_entry_set_text(GTK_ENTRY(FileEntry),basename_utf8);
- /*FIX ME : gchar *tmp = Try_To_Validate_Utf8_String(basename_utf8);
- g_free(tmp);*/
- g_free(basename_utf8);
- // Justify to the left text into FileEntry
- gtk_editable_set_position(GTK_EDITABLE(FileEntry),0);
-
- /*
* Set the path to the file into BrowserEntry (dirbrowser)
*/
dirname_utf8 = g_path_get_dirname(new_filename_utf8);
@@ -2991,59 +2891,51 @@ ET_Display_Filename_To_UI (ET_File *ETFile)
/*
* "Default" way to display File Info to the user interface.
*/
-static gboolean
-ET_Display_File_Info_To_UI(ET_File_Info *ETFileInfo)
+static EtFileHeaderFields *
+ET_Display_File_Info_To_UI (ET_File *ETFile)
{
- gchar *text;
+ EtFileHeaderFields *fields;
+ ET_File_Info *info;
gchar *time = NULL;
gchar *time1 = NULL;
gchar *size = NULL;
gchar *size1 = NULL;
+ info = ETFile->ETFileInfo;
+ fields = g_slice_new (EtFileHeaderFields);
+
+ fields->description = _("File");
+
/* MPEG, Layer versions */
- text = g_strdup_printf("%d, Layer %d",ETFileInfo->version,ETFileInfo->layer);
- gtk_label_set_text(GTK_LABEL(VersionValueLabel),text);
- g_free(text);
+ fields->version = g_strdup_printf ("%d, Layer %d", info->version,
+ info->layer);
/* Bitrate */
- text = g_strdup_printf(_("%d kb/s"),ETFileInfo->bitrate);
- gtk_label_set_text(GTK_LABEL(BitrateValueLabel),text);
- g_free(text);
+ fields->bitrate = g_strdup_printf (_("%d kb/s"), info->bitrate);
/* Samplerate */
- text = g_strdup_printf(_("%d Hz"),ETFileInfo->samplerate);
- gtk_label_set_text(GTK_LABEL(SampleRateValueLabel),text);
- g_free(text);
+ fields->samplerate = g_strdup_printf (_("%d Hz"), info->samplerate);
/* Mode */
- text = g_strdup_printf("%d",ETFileInfo->mode);
- gtk_label_set_text(GTK_LABEL(ModeValueLabel),text);
- g_free(text);
+ fields->mode = g_strdup_printf ("%d", info->mode);
/* Size */
- size = g_format_size (ETFileInfo->size);
+ size = g_format_size (info->size);
size1 = g_format_size (ETCore->ETFileDisplayedList_TotalSize);
- text = g_strdup_printf("%s (%s)",size,size1);
- gtk_label_set_text(GTK_LABEL(SizeValueLabel),text);
- g_free(size);
- g_free(size1);
- g_free(text);
+ fields->size = g_strdup_printf ("%s (%s)", size, size1);
+ g_free (size);
+ g_free (size1);
/* Duration */
- time = Convert_Duration(ETFileInfo->duration);
- time1 = Convert_Duration(ETCore->ETFileDisplayedList_TotalDuration);
- text = g_strdup_printf("%s (%s)",time,time1);
- gtk_label_set_text(GTK_LABEL(DurationValueLabel),text);
- g_free(time);
- g_free(time1);
- g_free(text);
+ time = Convert_Duration (info->duration);
+ time1 = Convert_Duration (ETCore->ETFileDisplayedList_TotalDuration);
+ fields->duration = g_strdup_printf ("%s (%s)", time, time1);
+ g_free (time);
+ g_free (time1);
- return TRUE;
+ return fields;
}
-
-
-
/********************
* Saving functions *
********************/
@@ -3141,8 +3033,9 @@ ET_Save_File_Name_From_UI (ET_File *ETFile, File_Name *FileName)
g_return_val_if_fail (ETFile != NULL && FileName != NULL, FALSE);
- filename_utf8 = gtk_entry_get_text(GTK_ENTRY(FileEntry));
- filename = filename_from_display(filename_utf8);
+ filename_utf8 = et_application_window_file_area_get_filename (ET_APPLICATION_WINDOW (MainWindow));
+ filename = filename_from_display (filename_utf8);
+
if (!filename)
{
// If translation fails...
@@ -3159,7 +3052,6 @@ ET_Save_File_Name_From_UI (ET_File *ETFile, File_Name *FileName)
gtk_dialog_run(GTK_DIALOG(msgdialog));
gtk_widget_destroy(msgdialog);
- g_free(filename);
g_free(filename_escaped_utf8);
return FALSE;
}
diff --git a/src/et_core.h b/src/et_core.h
index da62eec..11a1594 100644
--- a/src/et_core.h
+++ b/src/et_core.h
@@ -150,6 +150,34 @@ struct _ET_File_Info
gchar *mpc_version; /* MPC data : encoder version (also for Speex) */
};
+/*
+ * EtFileHeaderFields:
+ * @description: a description of the file type, such as MP3 File
+ * @version_label: the label for the encoder version, such as MPEG
+ * @version: the encoder version (such as 2, Layer III)
+ * @bitrate: the bitrate of the file (not the bit depth of the samples)
+ * @samplerate: the sample rate of the primary audio track, generally in Hz
+ * @mode_label: the label for the audio mode, for example Mode
+ * @mode: the audio mode (stereo, mono, and so on)
+ * @size: the size of the audio file
+ * @duration: the length of the primary audio track
+ *
+ * UI-visible strings, populated by the tagging support code to be displayed in
+ * the EtFileArea.
+ */
+typedef struct
+{
+ /*< public >*/
+ gchar *description;
+ gchar *version_label;
+ gchar *version;
+ gchar *bitrate;
+ gchar *samplerate;
+ gchar *mode_label;
+ gchar *mode;
+ gchar *size;
+ gchar *duration;
+} EtFileHeaderFields;
/*
* Structure for descripting supported files
diff --git a/src/file_area.c b/src/file_area.c
new file mode 100644
index 0000000..756423e
--- /dev/null
+++ b/src/file_area.c
@@ -0,0 +1,381 @@
+/* EasyTAG - tag editor for audio files
+ * Copyright (C) 2014 David King <amigadave amigadave com>
+ *
+ * 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., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "config.h"
+
+#include "file_area.h"
+
+#include <glib/gi18n.h>
+
+#include "charset.h"
+#include "et_core.h"
+#include "log.h"
+#include "tag_area.h"
+
+/* TODO: Use G_DEFINE_TYPE_WITH_PRIVATE. */
+G_DEFINE_TYPE (EtFileArea, et_file_area, GTK_TYPE_BIN)
+
+#define et_file_area_get_instance_private(area) (area->priv)
+
+struct _EtFileAreaPrivate
+{
+ GtkWidget *frame;
+
+ GtkWidget *index_label;
+ GtkWidget *name_entry;
+
+ GtkWidget *header_grid;
+
+ GtkWidget *version_label;
+ GtkWidget *version_value_label;
+ GtkWidget *bitrate_label;
+ GtkWidget *bitrate_value_label;
+ GtkWidget *samplerate_label;
+ GtkWidget *samplerate_value_label;
+ GtkWidget *mode_label;
+ GtkWidget *mode_value_label;
+ GtkWidget *size_label;
+ GtkWidget *size_value_label;
+ GtkWidget *duration_label;
+ GtkWidget *duration_value_label;
+};
+
+static void
+create_file_area (EtFileArea *self)
+{
+ EtFileAreaPrivate *priv;
+ GtkWidget *vbox, *hbox;
+ GtkWidget *separator;
+
+ priv = et_file_area_get_instance_private (self);
+
+ priv->frame = gtk_frame_new (_("File"));
+ gtk_container_add (GTK_CONTAINER (self), priv->frame);
+ gtk_container_set_border_width (GTK_CONTAINER (priv->frame), 2);
+
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+ gtk_container_add (GTK_CONTAINER (priv->frame), vbox);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
+
+ /* HBox for FileEntry and IconBox */
+ hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
+
+ /* File index (position in list + list length) */
+ priv->index_label = gtk_label_new ("0/0:");
+ gtk_box_pack_start (GTK_BOX (hbox), priv->index_label, FALSE, FALSE, 0);
+
+ /* Filename. */
+ priv->name_entry = gtk_entry_new ();
+ gtk_box_pack_start (GTK_BOX (hbox), priv->name_entry, TRUE, TRUE, 2);
+
+ g_signal_connect (priv->name_entry, "populate-popup",
+ G_CALLBACK (on_entry_populate_popup), NULL);
+
+ /* File information. */
+ priv->header_grid = gtk_grid_new ();
+ gtk_container_add (GTK_CONTAINER (vbox), priv->header_grid);
+ gtk_container_set_border_width (GTK_CONTAINER (priv->header_grid), 2);
+ gtk_grid_set_row_spacing (GTK_GRID (priv->header_grid), 1);
+ gtk_grid_set_column_spacing (GTK_GRID (priv->header_grid), 2);
+
+ priv->version_label = gtk_label_new (_("Encoder:"));
+ gtk_grid_attach (GTK_GRID (priv->header_grid), priv->version_label, 0, 0,
+ 1, 1);
+ priv->version_value_label = gtk_label_new ("");
+ gtk_grid_attach (GTK_GRID (priv->header_grid), priv->version_value_label,
+ 1, 0, 1, 1);
+ gtk_misc_set_alignment (GTK_MISC (priv->version_label), 1.0, 0.5);
+ gtk_misc_set_alignment (GTK_MISC (priv->version_value_label), 0.0, 0.5);
+
+ priv->bitrate_label = gtk_label_new (_("Bitrate:"));
+ gtk_grid_attach (GTK_GRID (priv->header_grid), priv->bitrate_label, 0, 1,
+ 1, 1);
+ priv->bitrate_value_label = gtk_label_new ("");
+ gtk_grid_attach (GTK_GRID (priv->header_grid), priv->bitrate_value_label,
+ 1, 1, 1, 1);
+ gtk_misc_set_alignment (GTK_MISC (priv->bitrate_label), 1.0, 0.5);
+ gtk_misc_set_alignment (GTK_MISC (priv->bitrate_value_label), 0.0, 0.5);
+
+ /* Translators: Please try to keep this string as short as possible as it
+ * is shown in a narrow column. */
+ priv->samplerate_label = gtk_label_new (_("Frequency:"));
+ gtk_grid_attach (GTK_GRID (priv->header_grid), priv->samplerate_label, 0,
+ 2, 1, 1);
+ priv->samplerate_value_label = gtk_label_new ("");
+ gtk_grid_attach (GTK_GRID (priv->header_grid),
+ priv->samplerate_value_label, 1, 2, 1, 1);
+ gtk_misc_set_alignment (GTK_MISC (priv->samplerate_label), 1.0, 0.5);
+ gtk_misc_set_alignment (GTK_MISC (priv->samplerate_value_label), 0.0, 0.5);
+
+ separator = gtk_separator_new (GTK_ORIENTATION_VERTICAL);
+ gtk_grid_attach (GTK_GRID (priv->header_grid), separator, 2, 0, 1, 4);
+
+ priv->mode_label = gtk_label_new(_("Mode:"));
+ gtk_grid_attach (GTK_GRID (priv->header_grid), priv->mode_label, 3, 0, 1,
+ 1);
+ priv->mode_value_label = gtk_label_new ("");
+ gtk_grid_attach (GTK_GRID (priv->header_grid), priv->mode_value_label, 4,
+ 0, 1, 1);
+ gtk_misc_set_alignment (GTK_MISC (priv->mode_label), 1.0, 0.5);
+ gtk_misc_set_alignment (GTK_MISC (priv->mode_value_label), 0.0, 0.5);
+
+ priv->size_label = gtk_label_new (_("Size:"));
+ gtk_grid_attach (GTK_GRID (priv->header_grid), priv->size_label, 3, 1, 1,
+ 1);
+ priv->size_value_label = gtk_label_new ("");
+ gtk_grid_attach (GTK_GRID (priv->header_grid), priv->size_value_label, 4,
+ 1, 1, 1);
+ gtk_misc_set_alignment (GTK_MISC (priv->size_label), 1.0, 0.5);
+ gtk_misc_set_alignment (GTK_MISC (priv->size_value_label), 0.0, 0.5);
+
+ priv->duration_label = gtk_label_new (_("Duration:"));
+ gtk_grid_attach (GTK_GRID (priv->header_grid), priv->duration_label, 3, 2,
+ 1, 1);
+ priv->duration_value_label = gtk_label_new ("");
+ gtk_grid_attach (GTK_GRID (priv->header_grid), priv->duration_value_label,
+ 4, 2, 1, 1);
+ gtk_misc_set_alignment (GTK_MISC (priv->duration_label), 1.0, 0.5);
+ gtk_misc_set_alignment (GTK_MISC (priv->duration_value_label), 0.0, 0.5);
+
+ /* FIXME */
+ #if 0
+ if (SHOW_HEADER_INFO)
+ gtk_widget_show_all(HeaderInfosTable);
+ #endif
+}
+
+static void
+et_file_area_init (EtFileArea *self)
+{
+ self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, ET_TYPE_FILE_AREA,
+ EtFileAreaPrivate);
+ create_file_area (self);
+
+ gtk_widget_show_all (GTK_WIDGET (self));
+}
+
+static void
+et_file_area_class_init (EtFileAreaClass *klass)
+{
+ g_type_class_add_private (klass, sizeof (EtFileAreaPrivate));
+}
+
+/*
+ * et_file_area_new:
+ *
+ * Create a new EtFileArea instance.
+ *
+ * Returns: a new #EtFileArea
+ */
+GtkWidget *
+et_file_area_new (void)
+{
+ return g_object_new (ET_TYPE_FILE_AREA, NULL);
+}
+
+void
+et_file_area_clear (EtFileArea *self)
+{
+ EtFileAreaPrivate *priv;
+ EtFileHeaderFields fields;
+
+ g_return_if_fail (ET_FILE_AREA (self));
+
+ priv = et_file_area_get_instance_private (self);
+
+ /* Default values are MPEG data. */
+ fields.description = _("File");
+ fields.version_label = _("Encoder:");
+ fields.version = "";
+ fields.bitrate = "";
+ fields.samplerate = "";
+ fields.mode_label = _("Mode:");
+ fields.mode = "";
+ fields.size = "";
+ fields.duration = "";
+
+ et_file_area_set_header_fields (self, &fields);
+
+ gtk_entry_set_text (GTK_ENTRY (priv->name_entry), "");
+ gtk_label_set_text (GTK_LABEL (priv->index_label), "0/0:");
+}
+
+void
+et_file_area_set_header_fields (EtFileArea *self,
+ EtFileHeaderFields *fields)
+{
+ EtFileAreaPrivate *priv;
+
+ g_return_if_fail (ET_FILE_AREA (self));
+ g_return_if_fail (fields != NULL);
+
+ priv = et_file_area_get_instance_private (self);
+
+ gtk_frame_set_label (GTK_FRAME (priv->frame), fields->description);
+ gtk_label_set_text (GTK_LABEL (priv->version_label),
+ fields->version_label);
+ gtk_label_set_text (GTK_LABEL (priv->version_value_label),
+ fields->version);
+ gtk_label_set_text (GTK_LABEL (priv->bitrate_value_label),
+ fields->bitrate);
+ gtk_label_set_text (GTK_LABEL (priv->samplerate_value_label),
+ fields->samplerate);
+ gtk_label_set_text (GTK_LABEL (priv->mode_label), fields->mode_label);
+ gtk_label_set_text (GTK_LABEL (priv->mode_value_label), fields->mode);
+ gtk_label_set_text (GTK_LABEL (priv->size_value_label), fields->size);
+ gtk_label_set_text (GTK_LABEL (priv->duration_value_label),
+ fields->duration);
+}
+
+/* Toggle visibility of the small status icon if filename is read-only or not
+ * found. Show the position of the current file in the list, by using the index
+ * and list length. */
+void
+et_file_area_set_file_fields (EtFileArea *self,
+ ET_File *ETFile)
+{
+ EtFileAreaPrivate *priv;
+ GFile *file;
+ gchar *text;
+ gchar *cur_filename;
+ gchar *basename_utf8;
+ gchar *pos;
+ GFileInfo *info;
+ GError *error = NULL;
+
+ g_return_if_fail (ET_FILE_AREA (self));
+ g_return_if_fail (ETFile != NULL);
+
+ priv = et_file_area_get_instance_private (self);
+
+ cur_filename = ((File_Name *)((GList *)ETFile->FileNameCur)->data)->value;
+
+ file = g_file_new_for_path (cur_filename);
+
+ info = g_file_query_info (file, G_FILE_ATTRIBUTE_ACCESS_CAN_READ ","
+ G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE,
+ G_FILE_QUERY_INFO_NONE, NULL, &error);
+
+ /* Show/hide 'AccessStatusIcon' */
+ if (!info)
+ {
+ if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_FOUND))
+ {
+ /* No such file or directory. */
+ GIcon *emblem_icon;
+
+ emblem_icon = g_themed_icon_new ("emblem-unreadable");
+
+ gtk_entry_set_icon_from_gicon (GTK_ENTRY (priv->name_entry),
+ GTK_ENTRY_ICON_SECONDARY,
+ emblem_icon);
+ gtk_entry_set_icon_tooltip_text (GTK_ENTRY (priv->name_entry),
+ GTK_ENTRY_ICON_SECONDARY,
+ _("File not found"));
+ g_object_unref (emblem_icon);
+ }
+ else
+ {
+ Log_Print (LOG_ERROR, _("Cannot query file information (%s)"),
+ error->message);
+ g_error_free (error);
+ g_object_unref (file);
+ return;
+ }
+ }
+ else
+ {
+ gboolean readable, writable;
+
+ readable = g_file_info_get_attribute_boolean (info,
+ G_FILE_ATTRIBUTE_ACCESS_CAN_READ);
+ writable = g_file_info_get_attribute_boolean (info,
+ G_FILE_ATTRIBUTE_ACCESS_CAN_WRITE);
+
+ if (readable && writable)
+ {
+ /* User has all necessary permissions. */
+ gtk_entry_set_icon_from_gicon (GTK_ENTRY (priv->name_entry),
+ GTK_ENTRY_ICON_SECONDARY, NULL);
+ }
+ else if (!writable)
+ {
+ /* Read only file or permission denied. */
+ GIcon *emblem_icon;
+
+ emblem_icon = g_themed_icon_new ("emblem-readonly");
+
+ gtk_entry_set_icon_from_gicon (GTK_ENTRY (priv->name_entry),
+ GTK_ENTRY_ICON_SECONDARY,
+ emblem_icon);
+ gtk_entry_set_icon_tooltip_text (GTK_ENTRY (priv->name_entry),
+ GTK_ENTRY_ICON_SECONDARY,
+ _("Read-only file"));
+ g_object_unref (emblem_icon);
+
+ }
+ else
+ {
+ /* Otherwise unreadable. */
+ GIcon *emblem_icon;
+
+ emblem_icon = g_themed_icon_new ("emblem-unreadable");
+
+ gtk_entry_set_icon_from_gicon (GTK_ENTRY (priv->name_entry),
+ GTK_ENTRY_ICON_SECONDARY,
+ emblem_icon);
+ gtk_entry_set_icon_tooltip_text (GTK_ENTRY (priv->name_entry),
+ GTK_ENTRY_ICON_SECONDARY,
+ _("File not found"));
+ g_object_unref (emblem_icon);
+ }
+ g_object_unref (info);
+ }
+
+ /* Set filename into name_entry. */
+ basename_utf8 = g_path_get_basename (((File_Name *)((GList *)ETFile->FileNameNew)->data)->value_utf8);
+
+ /* Remove the extension. */
+ if ((pos = g_utf8_strrchr (basename_utf8, -1, '.')) != NULL)
+ {
+ *pos = 0;
+ }
+
+ gtk_entry_set_text (GTK_ENTRY (priv->name_entry), basename_utf8);
+ g_free (basename_utf8);
+
+ /* Show position of current file in list */
+ text = g_strdup_printf ("%d/%d:", ETFile->IndexKey,
+ ETCore->ETFileDisplayedList_Length);
+ gtk_label_set_text (GTK_LABEL (priv->index_label), text);
+ g_object_unref (file);
+ g_free (text);
+}
+
+const gchar *
+et_file_area_get_filename (EtFileArea *self)
+{
+ EtFileAreaPrivate *priv;
+
+ g_return_val_if_fail (ET_FILE_AREA (self), NULL);
+
+ priv = et_file_area_get_instance_private (self);
+
+ return gtk_entry_get_text (GTK_ENTRY (priv->name_entry));
+}
diff --git a/src/file_area.h b/src/file_area.h
new file mode 100644
index 0000000..fd670f6
--- /dev/null
+++ b/src/file_area.h
@@ -0,0 +1,57 @@
+/* EasyTAG - tag editor for audio files
+ * Copyright (C) 2014 David King <amigadave amigadave com>
+ *
+ * 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., 51
+ * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef ET_FILE_AREA_H_
+#define ET_FILE_AREA_H_
+
+#include <gtk/gtk.h>
+
+#include "et_core.h"
+
+G_BEGIN_DECLS
+
+#define ET_TYPE_FILE_AREA (et_file_area_get_type ())
+#define ET_FILE_AREA(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), ET_TYPE_FILE_AREA, EtFileArea))
+
+typedef struct _EtFileArea EtFileArea;
+typedef struct _EtFileAreaClass EtFileAreaClass;
+typedef struct _EtFileAreaPrivate EtFileAreaPrivate;
+
+struct _EtFileArea
+{
+ /*< private >*/
+ GtkBin parent_instance;
+ EtFileAreaPrivate *priv;
+};
+
+struct _EtFileAreaClass
+{
+ /*< private >*/
+ GtkBinClass parent_class;
+};
+
+GType et_file_area_get_type (void);
+GtkWidget * et_file_area_new (void);
+void et_file_area_clear (EtFileArea *self);
+void et_file_area_set_header_fields (EtFileArea *self, EtFileHeaderFields *fields);
+void et_file_area_set_file_fields (EtFileArea *self, ET_File *ETFile);
+const gchar * et_file_area_get_filename (EtFileArea *self);
+
+G_END_DECLS
+
+#endif /* ET_FILE_AREA_H_ */
diff --git a/src/flac_header.c b/src/flac_header.c
index 535f7b0..2efb1e8 100644
--- a/src/flac_header.c
+++ b/src/flac_header.c
@@ -184,58 +184,65 @@ void error_callback_(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErro
file_info->abort_flag = true;
}
-
-
-
-gboolean Flac_Header_Display_File_Info_To_UI (gchar *filename_utf8, ET_File_Info *ETFileInfo)
+EtFileHeaderFields *
+Flac_Header_Display_File_Info_To_UI (gchar *filename_utf8,
+ ET_File *ETFile)
{
- gchar *text;
+ EtFileHeaderFields *fields;
+ ET_File_Info *info;
gchar *time = NULL;
gchar *time1 = NULL;
gchar *size = NULL;
gchar *size1 = NULL;
+ info = ETFile->ETFileInfo;
+ fields = g_slice_new (EtFileHeaderFields);
+
+ fields->description = _("FLAC File");
+
/* Nothing to display */
- //gtk_label_set_text(GTK_LABEL(VersionLabel),"");
- //gtk_label_set_text(GTK_LABEL(VersionValueLabel),"");
- gtk_label_set_text(GTK_LABEL(VersionLabel),_("Encoder:"));
- gtk_label_set_text(GTK_LABEL(VersionValueLabel),"flac");
+ fields->version_label = _("Encoder:");
+ fields->version = g_strdup ("flac");
/* Bitrate */
- text = g_strdup_printf(_("%d kb/s"),ETFileInfo->bitrate);
- gtk_label_set_text(GTK_LABEL(BitrateValueLabel),text);
- g_free(text);
+ fields->bitrate = g_strdup_printf (_("%d kb/s"), info->bitrate);
/* Samplerate */
- text = g_strdup_printf(_("%d Hz"),ETFileInfo->samplerate);
- gtk_label_set_text(GTK_LABEL(SampleRateValueLabel),text);
- g_free(text);
+ fields->samplerate = g_strdup_printf (_("%d Hz"), info->samplerate);
/* Mode */
- gtk_label_set_text(GTK_LABEL(ModeLabel),_("Channels:"));
- text = g_strdup_printf("%d",ETFileInfo->mode);
- gtk_label_set_text(GTK_LABEL(ModeValueLabel),text);
- g_free(text);
+ fields->mode_label = _("Channels:");
+ fields->mode = g_strdup_printf ("%d", info->mode);
/* Size */
- size = g_format_size (ETFileInfo->size);
+ size = g_format_size (info->size);
size1 = g_format_size (ETCore->ETFileDisplayedList_TotalSize);
- text = g_strdup_printf("%s (%s)",size,size1);
- gtk_label_set_text(GTK_LABEL(SizeValueLabel),text);
- g_free(size);
- g_free(size1);
- g_free(text);
+ fields->size = g_strdup_printf ("%s (%s)", size, size1);
+ g_free (size);
+ g_free (size1);
/* Duration */
- time = Convert_Duration(ETFileInfo->duration);
- time1 = Convert_Duration(ETCore->ETFileDisplayedList_TotalDuration);
- text = g_strdup_printf("%s (%s)",time,time1);
- gtk_label_set_text(GTK_LABEL(DurationValueLabel),text);
- g_free(time);
- g_free(time1);
- g_free(text);
+ time = Convert_Duration (info->duration);
+ time1 = Convert_Duration (ETCore->ETFileDisplayedList_TotalDuration);
+ fields->duration = g_strdup_printf ("%s (%s)", time, time1);
+ g_free (time);
+ g_free (time1);
- return TRUE;
+ return fields;
+}
+
+void
+et_flac_file_header_fields_free (EtFileHeaderFields *fields)
+{
+ g_return_if_fail (fields != NULL);
+
+ g_free (fields->version);
+ g_free (fields->bitrate);
+ g_free (fields->samplerate);
+ g_free (fields->mode);
+ g_free (fields->size);
+ g_free (fields->duration);
+ g_slice_free (EtFileHeaderFields, fields);
}
#endif /* ENABLE_FLAC */
diff --git a/src/flac_header.h b/src/flac_header.h
index 775f97f..40ffaee 100644
--- a/src/flac_header.h
+++ b/src/flac_header.h
@@ -1,41 +1,34 @@
-/* flac_header.h - 2002/07/03 */
-/*
- * EasyTAG - Tag editor for MP3 and Ogg Vorbis files
- * Copyright (C) 2000-2003 Jerome Couderc <easytag gmail com>
+/* EasyTAG - Tag editor for audio files
+ * Copyright (C) 2014 David King <amigadave amigadave com>
+ * Copyright (C) 2000-2003 Jerome Couderc <easytag gmail com>
*
- * 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 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.
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __FLAC_HEADER_H__
-#define __FLAC_HEADER_H__
-
+#ifndef ET_FLAC_HEADER_H_
+#define ET_FLAC_HEADER_H_
#include "et_core.h"
-/****************
- * Declarations *
- ****************/
-
-
/**************
* Prototypes *
**************/
gboolean Flac_Header_Read_File_Info (gchar *filename, ET_File_Info *ETFileInfo);
-gboolean Flac_Header_Display_File_Info_To_UI (gchar *filename, ET_File_Info *ETFileInfo);
-
+EtFileHeaderFields * Flac_Header_Display_File_Info_To_UI (gchar *filename, ET_File *ETFile);
+void et_flac_file_header_fields_free (EtFileHeaderFields *fields);
-#endif /* __FLAC_HEADER_H__ */
+#endif /* ET_FLAC_HEADER_H_ */
diff --git a/src/monkeyaudio_header.c b/src/monkeyaudio_header.c
index 30f9122..9952725 100644
--- a/src/monkeyaudio_header.c
+++ b/src/monkeyaudio_header.c
@@ -64,59 +64,61 @@ gboolean Mac_Header_Read_File_Info(gchar *filename, ET_File_Info *ETFileInfo)
return TRUE;
}
-
-
-gboolean Mac_Header_Display_File_Info_To_UI (gchar *filename_utf8, ET_File_Info *ETFileInfo)
+EtFileHeaderFields *
+Mac_Header_Display_File_Info_To_UI (gchar *filename_utf8,
+ ET_File *ETFile)
{
- gchar *text;
+ EtFileHeaderFields *fields;
+ ET_File_Info *info;
gchar *time = NULL;
gchar *time1 = NULL;
gchar *size = NULL;
gchar *size1 = NULL;
+ info = ETFile->ETFileInfo;
+ fields = g_slice_new (EtFileHeaderFields);
+
/* Mode changed to profile name */
- text = g_strdup_printf(_("Profile:"));
- gtk_label_set_text(GTK_LABEL(ModeLabel),text);
- g_free(text);
- text = g_strdup_printf("%s",ETFileInfo->mpc_profile);
- gtk_label_set_text(GTK_LABEL(ModeValueLabel),text);
- g_free(text);
+ fields->mode_label = _("Profile:");
+ fields->mode = info->mpc_profile;
/* Bitrate */
- text = g_strdup_printf(_("%d kb/s"),ETFileInfo->bitrate);
- gtk_label_set_text(GTK_LABEL(BitrateValueLabel),text);
- g_free(text);
+ fields->bitrate = g_strdup_printf (_("%d kb/s"), info->bitrate);
/* Samplerate */
- text = g_strdup_printf(_("%d Hz"),ETFileInfo->samplerate);
- gtk_label_set_text(GTK_LABEL(SampleRateValueLabel),text);
- g_free(text);
+ fields->samplerate = g_strdup_printf (_("%d Hz"), info->samplerate);
/* Version changed to encoder version */
- text = g_strdup_printf(_("Encoder:"));
- gtk_label_set_text(GTK_LABEL(VersionLabel),text);
- g_free(text);
- text = g_strdup_printf("%i.%i",ETFileInfo->version/1000,ETFileInfo->version%1000);
- gtk_label_set_text(GTK_LABEL(VersionValueLabel),text);
- g_free(text);
+ fields->version_label = _("Encoder:");
+ fields->version = g_strdup_printf ("%i.%i", info->version / 1000,
+ info->version % 1000);
/* Size */
- size = g_format_size (ETFileInfo->size);
+ size = g_format_size (info->size);
size1 = g_format_size (ETCore->ETFileDisplayedList_TotalSize);
- text = g_strdup_printf("%s (%s)",size,size1);
- gtk_label_set_text(GTK_LABEL(SizeValueLabel),text);
- g_free(size);
- g_free(size1);
- g_free(text);
+ fields->size = g_strdup_printf ("%s (%s)", size, size1);
+ g_free (size);
+ g_free (size1);
/* Duration */
- time = Convert_Duration(ETFileInfo->duration);
- time1 = Convert_Duration(ETCore->ETFileDisplayedList_TotalDuration);
- text = g_strdup_printf("%s (%s)",time,time1);
- gtk_label_set_text(GTK_LABEL(DurationValueLabel),text);
- g_free(time);
- g_free(time1);
- g_free(text);
+ time = Convert_Duration (info->duration);
+ time1 = Convert_Duration (ETCore->ETFileDisplayedList_TotalDuration);
+ fields->duration = g_strdup_printf ("%s (%s)", time, time1);
+ g_free (time);
+ g_free (time1);
- return TRUE;
+ return fields;
+}
+
+void
+et_mac_file_header_fields_free (EtFileHeaderFields *fields)
+{
+ g_return_if_fail (fields != NULL);
+
+ g_free (fields->bitrate);
+ g_free (fields->samplerate);
+ g_free (fields->version);
+ g_free (fields->size);
+ g_free (fields->duration);
+ g_slice_free (EtFileHeaderFields, fields);
}
diff --git a/src/monkeyaudio_header.h b/src/monkeyaudio_header.h
index 7eab16a..714621c 100644
--- a/src/monkeyaudio_header.h
+++ b/src/monkeyaudio_header.h
@@ -1,42 +1,34 @@
-/* monkeyaudio_header.h - 16 IV 2003 */
-/*
- * EasyTAG - Tag editor for MP3 and Ogg Vorbis files
- * Copyright (C) 2000-2003 Jerome Couderc <easytag gmail com>
- * Copyright (C) 2002-2003 Artur Polaczy�ski <artii o2 pl>
+/* EasyTAG - Tag editor for audio files
+ * Copyright (C) 2014 David King <amigadave amigadave com>
+ * Copyright (C) 2000-2003 Jerome Couderc <easytag gmail com>
+ * Copyright (C) 2002-2003 Artur Polaczy�ski <artii o2 pl>
*
- * 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 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.
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-
-#ifndef __MONKEYAUDIO_HEADER_H__
-#define __MONKEYAUDIO_HEADER_H__
-
+#ifndef ET_MONKEYAUDIO_HEADER_H_
+#define ET_MONKEYAUDIO_HEADER_H_
#include "et_core.h"
-/****************
- * Declarations *
- ****************/
-
-
/**************
* Prototypes *
**************/
gboolean Mac_Header_Read_File_Info(gchar *filename, ET_File_Info *ETFileInfo);
-gboolean Mac_Header_Display_File_Info_To_UI (gchar *filename, ET_File_Info *ETFileInfo);
-
+EtFileHeaderFields * Mac_Header_Display_File_Info_To_UI (gchar *filename, ET_File *ETFile);
+void et_mac_file_header_fields_free (EtFileHeaderFields *fields);
-#endif /* __MONKAYAUDIO_HEADER_H__ */
+#endif /* ET_MONKAYAUDIO_HEADER_H_ */
diff --git a/src/mp4_header.cc b/src/mp4_header.cc
index 549239e..88a39ce 100644
--- a/src/mp4_header.cc
+++ b/src/mp4_header.cc
@@ -104,67 +104,83 @@ gboolean Mp4_Header_Read_File_Info (gchar *filename, ET_File_Info *ETFileInfo)
return TRUE;
}
-
-
/*
* Mp4_Header_Display_File_Info_To_UI:
*
* Display header info in the main window
*/
-gboolean Mp4_Header_Display_File_Info_To_UI(gchar *filename, ET_File_Info *ETFileInfo)
+EtFileHeaderFields *
+Mp4_Header_Display_File_Info_To_UI (gchar *filename,
+ ET_File *ETFile)
{
- gchar *text;
+ EtFileHeaderFields *fields;
+ ET_File_Info *info;
gchar *time = NULL;
gchar *time1 = NULL;
gchar *size = NULL;
gchar *size1 = NULL;
+ info = ETFile->ETFileInfo;
+ fields = g_slice_new (EtFileHeaderFields);
+
+ fields->description = _("MP4/AAC File");
+
/* MPEG, Layer versions */
- gtk_label_set_text(GTK_LABEL(VersionLabel),ETFileInfo->mpc_version);
- //text = g_strdup_printf("%d",ETFileInfo->version);
- gtk_label_set_text(GTK_LABEL(VersionValueLabel),ETFileInfo->mpc_profile);
- //g_free(text);
+ fields->version_label = info->mpc_version;
+ fields->version = info->mpc_profile;
/* Bitrate */
- if (ETFileInfo->variable_bitrate)
- text = g_strdup_printf(_("~%d kb/s"),ETFileInfo->bitrate);
+ if (info->variable_bitrate)
+ {
+ fields->bitrate = g_strdup_printf (_("~%d kb/s"), info->bitrate);
+ }
else
- text = g_strdup_printf(_("%d kb/s"),ETFileInfo->bitrate);
- gtk_label_set_text(GTK_LABEL(BitrateValueLabel),text);
- g_free(text);
+ {
+ fields->bitrate = g_strdup_printf (_("%d kb/s"), info->bitrate);
+ }
/* Samplerate */
- text = g_strdup_printf(_("%d Hz"),ETFileInfo->samplerate);
- gtk_label_set_text(GTK_LABEL(SampleRateValueLabel),text);
- g_free(text);
+ fields->samplerate = g_strdup_printf (_("%d Hz"), info->samplerate);
/* Mode */
/* mpeg4ip library seems to always return -1 */
- gtk_label_set_text(GTK_LABEL(ModeLabel),_("Channels:"));
- if( ETFileInfo->mode == -1 )
- text = g_strdup_printf("Unknown");
+ fields->mode_label = _("Channels:");
+
+ if (info->mode == -1)
+ {
+ fields->mode = g_strdup ("Unknown");
+ }
else
- text = g_strdup_printf("%d",ETFileInfo->mode);
- gtk_label_set_text(GTK_LABEL(ModeValueLabel),text);
- g_free(text);
+ {
+ fields->mode = g_strdup_printf ("%d", info->mode);
+ }
/* Size */
- size = g_format_size (ETFileInfo->size);
+ size = g_format_size (info->size);
size1 = g_format_size (ETCore->ETFileDisplayedList_TotalSize);
- text = g_strdup_printf("%s (%s)",size,size1);
- gtk_label_set_text(GTK_LABEL(SizeValueLabel),text);
- if (size) g_free(size);
- if (size1) g_free(size1);
- g_free(text);
+ fields->size = g_strdup_printf ("%s (%s)", size, size1);
+ g_free (size);
+ g_free (size1);
/* Duration */
- time = Convert_Duration(ETFileInfo->duration);
- time1 = Convert_Duration(ETCore->ETFileDisplayedList_TotalDuration);
- text = g_strdup_printf("%s (%s)",time,time1);
- gtk_label_set_text(GTK_LABEL(DurationValueLabel),text);
- if (time) g_free(time);
- if (time1) g_free(time1);
- g_free(text);
+ time = Convert_Duration (info->duration);
+ time1 = Convert_Duration (ETCore->ETFileDisplayedList_TotalDuration);
+ fields->duration = g_strdup_printf ("%s (%s)", time, time1);
+ g_free (time);
+ g_free (time1);
- return TRUE;
+ return fields;
+}
+
+void
+et_mp4_file_header_fields_free (EtFileHeaderFields *fields)
+{
+ g_return_if_fail (fields != NULL);
+
+ g_free (fields->bitrate);
+ g_free (fields->samplerate);
+ g_free (fields->mode);
+ g_free (fields->size);
+ g_free (fields->duration);
+ g_slice_free (EtFileHeaderFields, fields);
}
diff --git a/src/mp4_header.h b/src/mp4_header.h
index 97de5b6..451eb3b 100644
--- a/src/mp4_header.h
+++ b/src/mp4_header.h
@@ -29,7 +29,8 @@
G_BEGIN_DECLS
gboolean Mp4_Header_Read_File_Info (gchar *filename, ET_File_Info *ETFileInfo);
-gboolean Mp4_Header_Display_File_Info_To_UI (gchar *filename, ET_File_Info *ETFileInfo);
+EtFileHeaderFields * Mp4_Header_Display_File_Info_To_UI (gchar *filename, ET_File *ETFile);
+void et_mp4_file_header_fields_free (EtFileHeaderFields *fields);
G_END_DECLS
diff --git a/src/mpeg_header.c b/src/mpeg_header.c
index ba46ff4..30d8231 100644
--- a/src/mpeg_header.c
+++ b/src/mpeg_header.c
@@ -175,68 +175,98 @@ Mpeg_Header_Read_File_Info (gchar *filename, ET_File_Info *ETFileInfo)
return TRUE;
}
-
-
-/*
- * Display header infos in the main window
- */
-gboolean Mpeg_Header_Display_File_Info_To_UI(gchar *filename_utf8, ET_File_Info *ETFileInfo)
+/* For displaying header information in the main window. */
+EtFileHeaderFields *
+Mpeg_Header_Display_File_Info_To_UI (gchar *filename_utf8,
+ ET_File *ETFile)
{
- gchar *text;
+ EtFileHeaderFields *fields;
+ ET_File_Info *info;
gchar *time = NULL;
gchar *time1 = NULL;
gchar *size = NULL;
gchar *size1 = NULL;
- gint ln_num = sizeof(layer_names)/sizeof(layer_names[0]);
+ gsize ln_num = G_N_ELEMENTS (layer_names);
+ info = ETFile->ETFileInfo;
+ fields = g_slice_new (EtFileHeaderFields);
+
+ switch (ETFile->ETFileDescription->FileType)
+ {
+ case MP3_FILE:
+ fields->description = _("MP3 File");
+ break;
+ case MP2_FILE:
+ fields->description = _("MP2 File");
+ break;
+ default:
+ g_assert_not_reached ();
+ }
/* MPEG, Layer versions */
- gtk_label_set_text(GTK_LABEL(VersionLabel),_("MPEG"));
- if (ETFileInfo->mpeg25)
- text = g_strdup_printf("2.5, Layer %s",(ETFileInfo->layer>=1 &&
ETFileInfo->layer<=ln_num)?layer_names[ETFileInfo->layer-1]:"?");
+ fields->version_label = _("MPEG");
+
+ if (info->mpeg25)
+ {
+ fields->version = g_strdup_printf ("2.5, Layer %s",
+ (info->layer >= 1
+ && info->layer <= ln_num)
+ ? layer_names[info->layer - 1] : "?");
+ }
else
- text = g_strdup_printf("%d, Layer %s",ETFileInfo->version,(ETFileInfo->layer>=1 &&
ETFileInfo->layer<=ln_num)?layer_names[ETFileInfo->layer-1]:"?");
- gtk_label_set_text(GTK_LABEL(VersionValueLabel),text);
- g_free(text);
+ {
+ fields->version = g_strdup_printf ("%d, Layer %s", info->version,
+ (info->layer >= 1
+ && info->layer <= ln_num)
+ ? layer_names[info->layer - 1] : "?");
+ }
/* Bitrate */
- if (ETFileInfo->variable_bitrate)
- text = g_strdup_printf(_("~%d kb/s"),ETFileInfo->bitrate);
+ if (info->variable_bitrate)
+ {
+ fields->bitrate = g_strdup_printf (_("~%d kb/s"), info->bitrate);
+ }
else
- text = g_strdup_printf(_("%d kb/s"),ETFileInfo->bitrate);
- gtk_label_set_text(GTK_LABEL(BitrateValueLabel),text);
- g_free(text);
+ {
+ fields->bitrate = g_strdup_printf (_("%d kb/s"), info->bitrate);
+ }
+
/* Samplerate */
- text = g_strdup_printf(_("%d Hz"),ETFileInfo->samplerate);
- gtk_label_set_text(GTK_LABEL(SampleRateValueLabel),text);
- g_free(text);
+ fields->samplerate = g_strdup_printf (_("%d Hz"), info->samplerate);
/* Mode */
- gtk_label_set_text(GTK_LABEL(ModeLabel),_("Mode:"));
- text = g_strdup_printf("%s",_(channel_mode_name(ETFileInfo->mode)));
- gtk_label_set_text(GTK_LABEL(ModeValueLabel),text);
- g_free(text);
+ fields->mode_label = _("Mode:");
+ fields->mode = _(channel_mode_name (info->mode));
/* Size */
- size = g_format_size (ETFileInfo->size);
+ size = g_format_size (info->size);
size1 = g_format_size (ETCore->ETFileDisplayedList_TotalSize);
- text = g_strdup_printf("%s (%s)",size,size1);
- gtk_label_set_text(GTK_LABEL(SizeValueLabel),text);
- g_free(size);
- g_free(size1);
- g_free(text);
+ fields->size = g_strdup_printf ("%s (%s)", size, size1);
+ g_free (size);
+ g_free (size1);
/* Duration */
- time = Convert_Duration(ETFileInfo->duration);
- time1 = Convert_Duration(ETCore->ETFileDisplayedList_TotalDuration);
- text = g_strdup_printf("%s (%s)",time,time1);
- gtk_label_set_text(GTK_LABEL(DurationValueLabel),text);
- g_free(time);
- g_free(time1);
- g_free(text);
+ time = Convert_Duration (info->duration);
+ time1 = Convert_Duration (ETCore->ETFileDisplayedList_TotalDuration);
+ fields->duration = g_strdup_printf ("%s (%s)", time, time1);
+ g_free (time);
+ g_free (time1);
- return TRUE;
+ return fields;
+}
+
+void
+et_mpeg_file_header_fields_free (EtFileHeaderFields *fields)
+{
+ g_return_if_fail (fields != NULL);
+
+ g_free (fields->version);
+ g_free (fields->bitrate);
+ g_free (fields->samplerate);
+ g_free (fields->size);
+ g_free (fields->duration);
+ g_slice_free (EtFileHeaderFields, fields);
}
#endif /* defined ENABLE_MP3 && defined ENABLE_ID3LIB */
diff --git a/src/mpeg_header.h b/src/mpeg_header.h
index fc49e41..25e6a1c 100644
--- a/src/mpeg_header.h
+++ b/src/mpeg_header.h
@@ -1,41 +1,34 @@
-/* mpeg_header.h - 2000/05/12 */
-/*
- * EasyTAG - Tag editor for MP3 and Ogg Vorbis files
- * Copyright (C) 2000-2003 Jerome Couderc <easytag gmail com>
+/* EasyTAG - Tag editor for audio files
+ * Copyright (C) 2014 David King <amigadave amigadave com>
+ * Copyright (C) 2000-2003 Jerome Couderc <easytag gmail com>
*
- * 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 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.
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __MPEG_HEADER_H__
-#define __MPEG_HEADER_H__
-
+#ifndef ET_MPEG_HEADER_H_
+#define ET_MPEG_HEADER_H_
#include "et_core.h"
-/****************
- * Declarations *
- ****************/
-
-
-/**************
- * Prototypes *
- **************/
+G_BEGIN_DECLS
-gboolean Mpeg_Header_Read_File_Info (gchar *filename, ET_File_Info *ETFileInfo);
-gboolean Mpeg_Header_Display_File_Info_To_UI (gchar *filename, ET_File_Info *ETFileInfo);
+gboolean Mpeg_Header_Read_File_Info (gchar *filename, ET_File_Info *ETFileInfo);
+EtFileHeaderFields * Mpeg_Header_Display_File_Info_To_UI (gchar *filename, ET_File *ETFile);
+void et_mpeg_file_header_fields_free (EtFileHeaderFields *fields);
+G_END_DECLS
-#endif /* __MPEG_HEADER_H__ */
+#endif /* ET_MPEG_HEADER_H_ */
diff --git a/src/musepack_header.c b/src/musepack_header.c
index 84f6be3..f80650d 100644
--- a/src/musepack_header.c
+++ b/src/musepack_header.c
@@ -1,22 +1,21 @@
-/* musepack_header.c */
-/*
- * EasyTAG - Tag editor for MP3, Ogg Vorbis and MPC files
- * Copyright (C) 2001-2003 Jerome Couderc <easytag gmail com>
- * Copyright (C) 2002-2003 Artur Polaczy�ski <artii o2 pl>
+/* EasyTAG - Tag editor for audio files
+ * Copyright (C) 2014 David King <amigadave amigadave com>
+ * Copyright (C) 2001-2003 Jerome Couderc <easytag gmail com>
+ * Copyright (C) 2002-2003 Artur Polaczy�ski <artii o2 pl>
*
- * 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 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.
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <config.h>
@@ -66,60 +65,63 @@ gboolean Mpc_Header_Read_File_Info (gchar *filename, ET_File_Info *ETFileInfo)
return TRUE;
}
-
-
-gboolean Mpc_Header_Display_File_Info_To_UI (gchar *filename_utf8, ET_File_Info *ETFileInfo)
+EtFileHeaderFields *
+Mpc_Header_Display_File_Info_To_UI (gchar *filename_utf8,
+ ET_File *ETFile)
{
- gchar *text;
+ EtFileHeaderFields *fields;
+ ET_File_Info *info;
gchar *time = NULL;
gchar *time1 = NULL;
gchar *size = NULL;
gchar *size1 = NULL;
+ info = ETFile->ETFileInfo;
+ fields = g_slice_new (EtFileHeaderFields);
+
+ fields->description = _("MusePack File");
+
/* Mode changed to profile name */
- text = g_strdup_printf(_("Profile:"));
- gtk_label_set_text(GTK_LABEL(ModeLabel),text);
- g_free(text);
- text = g_strdup_printf("%s (SV%d)",ETFileInfo->mpc_profile,ETFileInfo->version);
- gtk_label_set_text(GTK_LABEL(ModeValueLabel),text);
- g_free(text);
+ fields->mode_label = _("Profile:");
+ fields->mode = g_strdup_printf ("%s (SV%d)", info->mpc_profile,
+ info->version);
/* Bitrate */
- text = g_strdup_printf(_("%d kb/s"),ETFileInfo->bitrate);
- gtk_label_set_text(GTK_LABEL(BitrateValueLabel),text);
- g_free(text);
+ fields->bitrate = g_strdup_printf (_("%d kb/s"), info->bitrate);
/* Samplerate */
- text = g_strdup_printf(_("%d Hz"),ETFileInfo->samplerate);
- gtk_label_set_text(GTK_LABEL(SampleRateValueLabel),text);
- g_free(text);
+ fields->samplerate = g_strdup_printf (_("%d Hz"), info->samplerate);
/* Version changed to encoder version */
- text = g_strdup_printf(_("Encoder:"));
- gtk_label_set_text(GTK_LABEL(VersionLabel),text);
- g_free(text);
-
- text = g_strdup_printf("%s",ETFileInfo->mpc_version);
- gtk_label_set_text(GTK_LABEL(VersionValueLabel),text);
- g_free(text);
+ fields->version_label = _("Encoder:");
+ fields->version = info->mpc_version;
/* Size */
- size = g_format_size (ETFileInfo->size);
+ size = g_format_size (info->size);
size1 = g_format_size (ETCore->ETFileDisplayedList_TotalSize);
- text = g_strdup_printf("%s (%s)",size,size1);
- gtk_label_set_text(GTK_LABEL(SizeValueLabel),text);
- g_free(size);
- g_free(size1);
- g_free(text);
+ fields->size = g_strdup_printf ("%s (%s)", size, size1);
+ g_free (size);
+ g_free (size1);
/* Duration */
- time = Convert_Duration(ETFileInfo->duration);
- time1 = Convert_Duration(ETCore->ETFileDisplayedList_TotalDuration);
- text = g_strdup_printf("%s (%s)",time,time1);
- gtk_label_set_text(GTK_LABEL(DurationValueLabel),text);
- g_free(time);
- g_free(time1);
- g_free(text);
+ time = Convert_Duration (info->duration);
+ time1 = Convert_Duration (ETCore->ETFileDisplayedList_TotalDuration);
+ fields->duration = g_strdup_printf ("%s (%s)", time, time1);
+ g_free (time);
+ g_free (time1);
- return TRUE;
+ return fields;
+}
+
+void
+et_mpc_file_header_fields_free (EtFileHeaderFields *fields)
+{
+ g_return_if_fail (fields != NULL);
+
+ g_free (fields->mode);
+ g_free (fields->bitrate);
+ g_free (fields->samplerate);
+ g_free (fields->size);
+ g_free (fields->duration);
+ g_slice_free (EtFileHeaderFields, fields);
}
diff --git a/src/musepack_header.h b/src/musepack_header.h
index 99b3562..505d43b 100644
--- a/src/musepack_header.h
+++ b/src/musepack_header.h
@@ -1,42 +1,34 @@
-/* musepack_header.h - 26 XI 2002 */
-/*
- * EasyTAG - Tag editor for MP3 and Ogg Vorbis files
- * Copyright (C) 2000-2003 Jerome Couderc <easytag gmail com>
- * Copyright (C) 2002-2003 Artur Polaczy�ski <artii o2 pl>
+/* EasyTAG - Tag editor for audio files
+ * Copyright (C) 2014 David King <amigadave amigadave com>
+ * Copyright (C) 2000-2003 Jerome Couderc <easytag gmail com>
+ * Copyright (C) 2002-2003 Artur Polaczy�ski <artii o2 pl>
*
- * 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 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.
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-
-#ifndef __MUSEPACK_HEADER_H__
-#define __MUSEPACK_HEADER_H__
-
+#ifndef ET_MUSEPACK_HEADER_H_
+#define ET_MUSEPACK_HEADER_H_
#include "et_core.h"
-/****************
- * Declarations *
- ****************/
-
-
/**************
* Prototypes *
**************/
gboolean Mpc_Header_Read_File_Info (gchar *filename, ET_File_Info *ETFileInfo);
-gboolean Mpc_Header_Display_File_Info_To_UI (gchar *filename, ET_File_Info *ETFileInfo);
-
+EtFileHeaderFields * Mpc_Header_Display_File_Info_To_UI (gchar *filename, ET_File *ETFile);
+void et_mpc_file_header_fields_free (EtFileHeaderFields *fields);
-#endif /* __MUSEPACK_HEADER_H__ */
+#endif /* ET_MUSEPACK_HEADER_H_ */
diff --git a/src/ogg_header.c b/src/ogg_header.c
index 915cb3d..15563f9 100644
--- a/src/ogg_header.c
+++ b/src/ogg_header.c
@@ -1,21 +1,20 @@
-/* ogg_header.c - 2003/12/29 */
-/*
- * EasyTAG - Tag editor for MP3 and Ogg Vorbis files
- * Copyright (C) 2000-2003 Jerome Couderc <easytag gmail com>
+/* EasyTAG - Tag editor for audio files
+ * Copyright (C) 2014 David King <amigadave amigadave com>
+ * Copyright (C) 2000-2003 Jerome Couderc <easytag gmail com>
*
- * 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 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.
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include "config.h" /* For definition of ENABLE_OGG. */
@@ -377,61 +376,82 @@ gboolean Speex_Header_Read_File_Info (gchar *filename, ET_File_Info *ETFileInfo)
}
#endif
-gboolean Ogg_Header_Display_File_Info_To_UI (gchar *filename, ET_File_Info *ETFileInfo)
+EtFileHeaderFields *
+Ogg_Header_Display_File_Info_To_UI (gchar *filename, ET_File *ETFile)
{
- gchar *text;
+ EtFileHeaderFields *fields;
+ ET_File_Info *info;
gchar *time = NULL;
gchar *time1 = NULL;
gchar *size = NULL;
gchar *size1 = NULL;
+ info = ETFile->ETFileInfo;
+ fields = g_slice_new (EtFileHeaderFields);
+
+ switch (ETFile->ETFileDescription->FileType)
+ {
+ case OGG_FILE:
+ fields->description = _("Ogg Vorbis File");
+ break;
+ case SPEEX_FILE:
+ fields->description = _("Speex File");
+ break;
+ default:
+ g_assert_not_reached ();
+ }
+
/* Encoder version */
- gtk_label_set_text(GTK_LABEL(VersionLabel),_("Encoder:"));
- if (!ETFileInfo->mpc_version)
+ fields->version_label = _("Encoder:");
+
+ if (!info->mpc_version)
{
- text = g_strdup_printf("%d",ETFileInfo->version);
- gtk_label_set_text(GTK_LABEL(VersionValueLabel),text);
- g_free(text);
- }else
+ fields->version = g_strdup_printf ("%d", info->version);
+ }
+ else
{
- gtk_label_set_text(GTK_LABEL(VersionValueLabel),ETFileInfo->mpc_version);
+ fields->version = g_strdup (info->mpc_version);
}
/* Bitrate */
- text = g_strdup_printf(_("%d kb/s"),ETFileInfo->bitrate);
- gtk_label_set_text(GTK_LABEL(BitrateValueLabel),text);
- g_free(text);
+ fields->bitrate = g_strdup_printf (_("%d kb/s"), info->bitrate);
/* Samplerate */
- text = g_strdup_printf(_("%d Hz"),ETFileInfo->samplerate);
- gtk_label_set_text(GTK_LABEL(SampleRateValueLabel),text);
- g_free(text);
+ fields->samplerate = g_strdup_printf (_("%d Hz"), info->samplerate);
/* Mode */
- gtk_label_set_text(GTK_LABEL(ModeLabel),_("Channels:"));
- text = g_strdup_printf("%d",ETFileInfo->mode);
- gtk_label_set_text(GTK_LABEL(ModeValueLabel),text);
- g_free(text);
+ fields->mode_label = _("Channels:");
+ fields->mode = g_strdup_printf ("%d", info->mode);
/* Size */
- size = g_format_size (ETFileInfo->size);
+ size = g_format_size (info->size);
size1 = g_format_size (ETCore->ETFileDisplayedList_TotalSize);
- text = g_strdup_printf("%s (%s)",size,size1);
- gtk_label_set_text(GTK_LABEL(SizeValueLabel),text);
- g_free(size);
- g_free(size1);
- g_free(text);
+ fields->size = g_strdup_printf ("%s (%s)", size, size1);
+ g_free (size);
+ g_free (size1);
/* Duration */
- time = Convert_Duration(ETFileInfo->duration);
- time1 = Convert_Duration(ETCore->ETFileDisplayedList_TotalDuration);
- text = g_strdup_printf("%s (%s)",time,time1);
- gtk_label_set_text(GTK_LABEL(DurationValueLabel),text);
- g_free(time);
- g_free(time1);
- g_free(text);
+ time = Convert_Duration (info->duration);
+ time1 = Convert_Duration (ETCore->ETFileDisplayedList_TotalDuration);
+ fields->duration = g_strdup_printf ("%s (%s)", time, time1);
+ g_free (time);
+ g_free (time1);
- return TRUE;
+ return fields;
+}
+
+void
+et_ogg_file_header_fields_free (EtFileHeaderFields *fields)
+{
+ g_return_if_fail (fields != NULL);
+
+ g_free (fields->version);
+ g_free (fields->bitrate);
+ g_free (fields->samplerate);
+ g_free (fields->mode);
+ g_free (fields->size);
+ g_free (fields->duration);
+ g_slice_free (EtFileHeaderFields, fields);
}
#endif /* ENABLE_OGG */
diff --git a/src/ogg_header.h b/src/ogg_header.h
index 0817a31..89ceece 100644
--- a/src/ogg_header.h
+++ b/src/ogg_header.h
@@ -1,26 +1,25 @@
-/* ogg_header.h - 2003/12/29 */
-/*
- * EasyTAG - Tag editor for MP3 and Ogg Vorbis files
- * Copyright (C) 2000-2003 Jerome Couderc <easytag gmail com>
+/* EasyTAG - Tag editor for audio files
+ * Copyright (C) 2014 David King <amigadave amigadave com>
+ * Copyright (C) 2000-2003 Jerome Couderc <easytag gmail com>
*
- * 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 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.
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-#ifndef __OGG_HEADER_H__
-#define __OGG_HEADER_H__
+#ifndef ET_OGG_HEADER_H_
+#define ET_OGG_HEADER_H_
#include <glib.h>
@@ -78,9 +77,10 @@ typedef enum
gboolean Ogg_Header_Read_File_Info (const gchar *filename,
ET_File_Info *ETFileInfo);
-gboolean Ogg_Header_Display_File_Info_To_UI (gchar *filename, ET_File_Info *ETFileInfo);
+EtFileHeaderFields * Ogg_Header_Display_File_Info_To_UI (gchar *filename, ET_File *ETFile);
+void et_ogg_file_header_fields_free (EtFileHeaderFields *fields);
gboolean Speex_Header_Read_File_Info (gchar *filename, ET_File_Info *ETFileInfo);
-#endif /* __OGG_HEADER_H__ */
+#endif /* ET_OGG_HEADER_H_ */
diff --git a/src/opus_header.c b/src/opus_header.c
index a623893..31791f6 100644
--- a/src/opus_header.c
+++ b/src/opus_header.c
@@ -201,63 +201,72 @@ et_opus_read_file_info (GFile *gfile, ET_File_Info *ETFileInfo,
/*
* et_opus_header_display_file_info_to_ui:
* @filename: file to display info of
- * @ETFileInfo: ET_File_Info to display information
+ * @ETFile: ET_File to display information
*
- * Display header info from ET_File_Info.
+ * Display header info from ET_File.
*
- * Returns: %TRUE if successful, otherwise %FALSE
+ * Returns: a new #EtFileHeaderFields, free with
+ * et_opus_file_header_fields_free()
*/
-gboolean
+EtFileHeaderFields *
et_opus_header_display_file_info_to_ui (GFile *file,
- ET_File_Info *ETFileInfo)
+ ET_File *ETFile)
{
- gchar *text;
+ EtFileHeaderFields *fields;
+ ET_File_Info *info;
gchar *time = NULL;
gchar *time1 = NULL;
gchar *size = NULL;
gchar *size1 = NULL;
+ info = ETFile->ETFileInfo;
+ fields = g_slice_new (EtFileHeaderFields);
+
+ fields->description = _("Opus File");
+
/* Encoder version */
- gtk_label_set_text (GTK_LABEL (VersionLabel), _("Encoder:"));
- text = g_strdup_printf ("%d", ETFileInfo->version);
- gtk_label_set_text (GTK_LABEL (VersionValueLabel), text);
- g_free (text);
+ fields->version_label = _("Encoder:");
+ fields->version = g_strdup_printf ("%d", info->version);
/* Bitrate */
- text = g_strdup_printf (_("%d kb/s"), ETFileInfo->bitrate);
- gtk_label_set_text (GTK_LABEL (BitrateValueLabel), text);
- g_free (text);
+ fields->bitrate = g_strdup_printf (_("%d kb/s"), info->bitrate);
/* Samplerate */
- text = g_strdup_printf (_("%d Hz"), ETFileInfo->samplerate);
- gtk_label_set_text (GTK_LABEL (SampleRateValueLabel), text);
- g_free (text);
+ fields->samplerate = g_strdup_printf (_("%d Hz"), info->samplerate);
/* Mode */
- gtk_label_set_text (GTK_LABEL (ModeLabel), _("Channels:"));
- text = g_strdup_printf ("%d", ETFileInfo->mode);
- gtk_label_set_text (GTK_LABEL (ModeValueLabel), text);
- g_free (text);
+ fields->mode_label = _("Channels:");
+ fields->mode = g_strdup_printf ("%d", info->mode);
/* Size */
- size = g_format_size (ETFileInfo->size);
+ size = g_format_size (info->size);
size1 = g_format_size (ETCore->ETFileDisplayedList_TotalSize);
- text = g_strdup_printf ("%s (%s)", size, size1);
- gtk_label_set_text (GTK_LABEL (SizeValueLabel), text);
+ fields->size = g_strdup_printf ("%s (%s)", size, size1);
g_free (size);
g_free (size1);
- g_free (text);
/* Duration */
- time = Convert_Duration (ETFileInfo->duration);
+ time = Convert_Duration (info->duration);
time1 = Convert_Duration (ETCore->ETFileDisplayedList_TotalDuration);
- text = g_strdup_printf ("%s (%s)", time, time1);
- gtk_label_set_text (GTK_LABEL (DurationValueLabel), text);
+ fields->duration = g_strdup_printf ("%s (%s)", time, time1);
g_free (time);
g_free (time1);
- g_free (text);
- return TRUE;
+ return fields;
+}
+
+void
+et_opus_file_header_fields_free (EtFileHeaderFields *fields)
+{
+ g_return_if_fail (fields != NULL);
+
+ g_free (fields->version);
+ g_free (fields->bitrate);
+ g_free (fields->samplerate);
+ g_free (fields->mode);
+ g_free (fields->size);
+ g_free (fields->duration);
+ g_slice_free (EtFileHeaderFields, fields);
}
#endif /* ENABLE_OPUS */
diff --git a/src/opus_header.h b/src/opus_header.h
index 8feb0f6..604d2d2 100644
--- a/src/opus_header.h
+++ b/src/opus_header.h
@@ -60,6 +60,7 @@ typedef enum
gboolean et_opus_read_file_info (GFile *gfile, ET_File_Info *ETFileInfo, GError **error);
OggOpusFile * et_opus_open_file (GFile *gfile, GError **error);
-gboolean et_opus_header_display_file_info_to_ui (GFile *gfile, ET_File_Info *ETFileInfo);
+EtFileHeaderFields * et_opus_header_display_file_info_to_ui (GFile *gfile, ET_File *ETFile);
+void et_opus_file_header_fields_free (EtFileHeaderFields *fields);
#endif /* ET_OPUS_HEADER_H_ */
diff --git a/src/wavpack_header.c b/src/wavpack_header.c
index 3a0fb3a..6055c14 100644
--- a/src/wavpack_header.c
+++ b/src/wavpack_header.c
@@ -60,55 +60,66 @@ gboolean Wavpack_Header_Read_File_Info(gchar *filename, ET_File_Info *ETFileInfo
}
-gboolean Wavpack_Header_Display_File_Info_To_UI(gchar *filename_utf8, ET_File_Info *ETFileInfo)
+EtFileHeaderFields *
+Wavpack_Header_Display_File_Info_To_UI (gchar *filename_utf8,
+ ET_File *ETFile)
{
- gchar *text;
+ EtFileHeaderFields *fields;
+ ET_File_Info *info;
gchar *time = NULL;
gchar *time1 = NULL;
gchar *size = NULL;
gchar *size1 = NULL;
+ info = ETFile->ETFileInfo;
+ fields = g_slice_new (EtFileHeaderFields);
+
+ fields->description = _("Wavpack File");
+
/* Encoder version */
- gtk_label_set_text(GTK_LABEL(VersionLabel),_("Encoder:"));
- text = g_strdup_printf("%d",ETFileInfo->version);
- gtk_label_set_text(GTK_LABEL(VersionValueLabel),text);
- g_free(text);
+ fields->version_label = _("Encoder:");
+ fields->version = g_strdup_printf ("%d", info->version);
/* Bitrate */
- text = g_strdup_printf(_("%d kb/s"),ETFileInfo->bitrate);
- gtk_label_set_text(GTK_LABEL(BitrateValueLabel),text);
- g_free(text);
+ fields->bitrate = g_strdup_printf (_("%d kb/s"), info->bitrate);
/* Samplerate */
- text = g_strdup_printf(_("%d Hz"),ETFileInfo->samplerate);
- gtk_label_set_text(GTK_LABEL(SampleRateValueLabel),text);
- g_free(text);
+ fields->samplerate = g_strdup_printf (_("%d Hz"), info->samplerate);
/* Mode */
- gtk_label_set_text(GTK_LABEL(ModeLabel),_("Channels:"));
- text = g_strdup_printf("%d",ETFileInfo->mode);
- gtk_label_set_text(GTK_LABEL(ModeValueLabel),text);
- g_free(text);
+ fields->mode_label = _("Channels:");
+ fields->mode = g_strdup_printf ("%d", info->mode);
+ g_free (fields->mode);
/* Size */
- size = g_format_size (ETFileInfo->size);
+ size = g_format_size (info->size);
size1 = g_format_size (ETCore->ETFileDisplayedList_TotalSize);
- text = g_strdup_printf("%s (%s)",size,size1);
- gtk_label_set_text(GTK_LABEL(SizeValueLabel),text);
- g_free(size);
- g_free(size1);
- g_free(text);
+ fields->size = g_strdup_printf ("%s (%s)", size, size1);
+ g_free (size);
+ g_free (size1);
/* Duration */
- time = Convert_Duration(ETFileInfo->duration);
- time1 = Convert_Duration(ETCore->ETFileDisplayedList_TotalDuration);
- text = g_strdup_printf("%s (%s)",time,time1);
- gtk_label_set_text(GTK_LABEL(DurationValueLabel),text);
- g_free(time);
- g_free(time1);
- g_free(text);
+ time = Convert_Duration (info->duration);
+ time1 = Convert_Duration (ETCore->ETFileDisplayedList_TotalDuration);
+ fields->duration = g_strdup_printf ("%s (%s)", time, time1);
+ g_free (time);
+ g_free (time1);
- return TRUE;
+ return fields;
+}
+
+void
+et_wavpack_file_header_fields_free (EtFileHeaderFields *fields)
+{
+ g_return_if_fail (fields != NULL);
+
+ g_free (fields->version);
+ g_free (fields->bitrate);
+ g_free (fields->samplerate);
+ g_free (fields->mode);
+ g_free (fields->size);
+ g_free (fields->duration);
+ g_slice_free (EtFileHeaderFields, fields);
}
#endif /* ENABLE_WAVPACK */
diff --git a/src/wavpack_header.h b/src/wavpack_header.h
index 0ef31c5..6ff5c09 100644
--- a/src/wavpack_header.h
+++ b/src/wavpack_header.h
@@ -1,41 +1,34 @@
-/* wavpack_tag.c - 2007/02/15 */
-/*
- * EasyTAG - Tag editor for many file types
- * Copyright (C) 2007 Maarten Maathuis (madman2003 gmail com)
+/* EasyTAG - Tag editor for audio files
+ * Copyright (C) 2014 David King <amigadave amigadave com>
+ * Copyright (C) 2007 Maarten Maathuis (madman2003 gmail com)
*
- * 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 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.
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-
-#ifndef __WAVPACK_HEADER_H__
-#define __WAVPACK_HEADER_H__
+#ifndef ET_WAVPACK_HEADER_H_
+#define ET_WAVPACK_HEADER_H_
#include "et_core.h"
-/****************
- * Declarations *
- ****************/
-
-
/**************
* Prototypes *
**************/
gboolean Wavpack_Header_Read_File_Info (gchar *filename, ET_File_Info *ETFileInfo);
-gboolean Wavpack_Header_Display_File_Info_To_UI (gchar *filename_utf8, ET_File_Info *ETFileInfo);
-
+EtFileHeaderFields * Wavpack_Header_Display_File_Info_To_UI (gchar *filename_utf8, ET_File *ETFile);
+void et_wavpack_file_header_fields_free (EtFileHeaderFields *fields);
-#endif /* __WAVPACK_HEADER_H__ */
+#endif /* ET_WAVPACK_HEADER_H_ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]