Commit 594e9575 authored by David King's avatar David King

Move file area to EtFileArea object

parent fc874a72
......@@ -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 \
......
......@@ -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
......
......@@ -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)
{
......@@ -1842,7 +1713,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 */
......@@ -2139,6 +2010,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_val_if_fail (ET_APPLICATION_WINDOW (self), NULL);
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
*/
......
......@@ -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);
......
......@@ -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 */
......
......@@ -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__ */
......@@ -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;
......@@ -2957,21 +2872,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)
*/
......@@ -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)
{