[easytag] Use const when fetching File_Name from an ET_File
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag] Use const when fetching File_Name from an ET_File
- Date: Sun, 21 Dec 2014 10:59:35 +0000 (UTC)
commit 6532af69270ae1a030d48d389c13aa4bd122a190
Author: David King <amigadave amigadave com>
Date: Sun Dec 21 10:37:09 2014 +0000
Use const when fetching File_Name from an ET_File
src/application_window.c | 6 +++---
src/browser.c | 27 ++++++++++++++-------------
src/easytag.c | 26 ++++++++++++--------------
src/et_core.c | 3 +--
src/file_area.c | 2 +-
src/playlist_dialog.c | 9 ++++++---
src/scan_dialog.c | 4 ++--
src/tag_area.c | 4 ++--
8 files changed, 41 insertions(+), 40 deletions(-)
---
diff --git a/src/application_window.c b/src/application_window.c
index 88ba713..022da68 100644
--- a/src/application_window.c
+++ b/src/application_window.c
@@ -287,8 +287,8 @@ delete_file (ET_File *ETFile, gboolean multiple_files, GError **error)
{
GtkWidget *msgdialog;
GtkWidget *msgdialog_check_button = NULL;
- gchar *cur_filename;
- gchar *cur_filename_utf8;
+ const gchar *cur_filename;
+ const gchar *cur_filename_utf8;
gchar *basename_utf8;
gint response;
gint stop_loop;
@@ -1481,7 +1481,7 @@ run_audio_player_using_directory (GError **error)
for (l = g_list_first (ETCore->ETFileList); l != NULL; l = g_list_next (l))
{
ET_File *etfile = (ET_File *)l->data;
- gchar *path = ((File_Name *)etfile->FileNameCur->data)->value;
+ const gchar *path = ((File_Name *)etfile->FileNameCur->data)->value;
file_list = g_list_prepend (file_list, g_file_new_for_path (path));
}
diff --git a/src/browser.c b/src/browser.c
index 96606ee..045f6d0 100644
--- a/src/browser.c
+++ b/src/browser.c
@@ -344,7 +344,7 @@ et_browser_run_player_for_album_list (EtBrowser *self)
for (; l != NULL; l = g_list_next (l))
{
ET_File *etfile = (ET_File *)l->data;
- gchar *path = ((File_Name *)etfile->FileNameCur->data)->value;
+ const gchar *path = ((File_Name *)etfile->FileNameCur->data)->value;
file_list = g_list_prepend (file_list, g_file_new_for_path (path));
}
@@ -386,7 +386,7 @@ et_browser_run_player_for_artist_list (EtBrowser *self)
for (m = l->data; m != NULL; m = g_list_next (m))
{
ET_File *etfile = (ET_File *)m->data;
- gchar *path = ((File_Name *)etfile->FileNameCur->data)->value;
+ const gchar *path = ((File_Name *)etfile->FileNameCur->data)->value;
file_list = g_list_prepend (file_list, g_file_new_for_path (path));
}
}
@@ -421,7 +421,7 @@ et_browser_run_player_for_selection (EtBrowser *self)
for (l = selfilelist; l != NULL; l = g_list_next (l))
{
ET_File *etfile = et_browser_get_et_file_from_path (self, l->data);
- gchar *path = ((File_Name *)etfile->FileNameCur->data)->value;
+ const gchar *path = ((File_Name *)etfile->FileNameCur->data)->value;
file_list = g_list_prepend (file_list, g_file_new_for_path (path));
}
@@ -1261,8 +1261,8 @@ et_browser_load_file_list (EtBrowser *self,
for (l = g_list_first (etfilelist); l != NULL; l = g_list_next (l))
{
guint fileKey = ((ET_File *)l->data)->ETFileKey;
- gchar *current_filename_utf8 = ((File_Name *)((ET_File *)l->data)->FileNameCur->data)->value_utf8;
- gchar *basename_utf8 = g_path_get_basename(current_filename_utf8);
+ const gchar *current_filename_utf8 = ((File_Name *)((ET_File
*)l->data)->FileNameCur->data)->value_utf8;
+ gchar *basename_utf8 = g_path_get_basename (current_filename_utf8);
File_Tag *FileTag = ((File_Tag *)((ET_File *)l->data)->FileTag->data);
gchar *track;
gchar *disc;
@@ -1272,7 +1272,7 @@ et_browser_load_file_list (EtBrowser *self,
{
gchar *dir1_utf8;
gchar *dir2_utf8;
- gchar *previous_filename_utf8 = ((File_Name *)((ET_File
*)l->prev->data)->FileNameCur->data)->value_utf8;
+ const gchar *previous_filename_utf8 = ((File_Name *)((ET_File
*)l->prev->data)->FileNameCur->data)->value_utf8;
dir1_utf8 = g_path_get_dirname(previous_filename_utf8);
dir2_utf8 = g_path_get_dirname(current_filename_utf8);
@@ -1342,9 +1342,6 @@ void
et_browser_refresh_list (EtBrowser *self)
{
EtBrowserPrivate *priv;
- ET_File *ETFile;
- File_Tag *FileTag;
- File_Name *FileName;
//GtkTreeIter iter;
GtkTreePath *currentPath = NULL;
GtkTreeIter iter;
@@ -1374,6 +1371,9 @@ et_browser_refresh_list (EtBrowser *self)
valid = gtk_tree_model_get_iter(GTK_TREE_MODEL(priv->file_model), &iter, currentPath);
while (valid)
{
+ const ET_File *ETFile;
+ const File_Tag *FileTag;
+ const File_Name *FileName;
// Refresh filename and other fields
gtk_tree_model_get(GTK_TREE_MODEL(priv->file_model), &iter,
LIST_FILE_POINTER, &ETFile, -1);
@@ -1465,9 +1465,9 @@ et_browser_refresh_file_in_list (EtBrowser *self,
GVariant *variant;
GtkTreeSelection *selection;
GtkTreeIter selectedIter;
- ET_File *etfile;
- File_Tag *FileTag;
- File_Name *FileName;
+ const ET_File *etfile;
+ const File_Tag *FileTag;
+ const File_Name *FileName;
gboolean row_found = FALSE;
gchar *current_basename_utf8;
gchar *track;
@@ -4720,7 +4720,6 @@ Run_Program_With_Selected_Files (EtBrowser *self)
{
EtBrowserPrivate *priv;
gchar *program_name;
- ET_File *ETFile;
GList *selected_paths;
GList *l;
GList *args_list = NULL;
@@ -4744,6 +4743,8 @@ Run_Program_With_Selected_Files (EtBrowser *self)
if (gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->file_model), &iter,
(GtkTreePath *)l->data))
{
+ const ET_File *ETFile;
+
gtk_tree_model_get (GTK_TREE_MODEL (priv->file_model), &iter,
LIST_FILE_POINTER, &ETFile, -1);
diff --git a/src/easytag.c b/src/easytag.c
index 67b4a4e..5d07bac 100644
--- a/src/easytag.c
+++ b/src/easytag.c
@@ -175,11 +175,11 @@ Save_List_Of_Files (GList *etfilelist, gboolean force_saving_files)
GFile *file;
GFileInfo *fileinfo;
- ET_File *ETFile = (ET_File *)l->data;
- File_Tag *FileTag = (File_Tag *)ETFile->FileTag->data;
- File_Name *FileName = (File_Name *)ETFile->FileNameNew->data;
- gchar *filename_cur = ((File_Name *)ETFile->FileNameCur->data)->value;
- gchar *filename_cur_utf8 = ((File_Name *)ETFile->FileNameCur->data)->value_utf8;
+ const ET_File *ETFile = (ET_File *)l->data;
+ const File_Tag *FileTag = (File_Tag *)ETFile->FileTag->data;
+ const File_Name *FileName = (File_Name *)ETFile->FileNameNew->data;
+ const gchar *filename_cur = ((File_Name *)ETFile->FileNameCur->data)->value;
+ const gchar *filename_cur_utf8 = ((File_Name *)ETFile->FileNameCur->data)->value_utf8;
gchar *basename_cur_utf8 = g_path_get_basename(filename_cur_utf8);
// Count only the changed files or all files if force_saving_files==TRUE
@@ -376,13 +376,11 @@ static gint
Save_File (ET_File *ETFile, gboolean multiple_files,
gboolean force_saving_files)
{
- File_Tag *FileTag;
- File_Name *FileNameNew;
+ const File_Tag *FileTag;
+ const File_Name *FileNameNew;
gint stop_loop = 0;
- //struct stat statbuf;
- //gchar *filename_cur = ((File_Name *)ETFile->FileNameCur->data)->value;
- gchar *filename_cur_utf8 = ((File_Name *)ETFile->FileNameCur->data)->value_utf8;
- gchar *filename_new_utf8 = ((File_Name *)ETFile->FileNameNew->data)->value_utf8;
+ const gchar *filename_cur_utf8 = ((File_Name *)ETFile->FileNameCur->data)->value_utf8;
+ const gchar *filename_new_utf8 = ((File_Name *)ETFile->FileNameNew->data)->value_utf8;
gchar *basename_cur_utf8, *basename_new_utf8;
gchar *dirname_cur_utf8, *dirname_new_utf8;
@@ -632,8 +630,8 @@ Save_File (ET_File *ETFile, gboolean multiple_files,
{
gboolean rc;
GError *error = NULL;
- gchar *cur_filename = ((File_Name *)ETFile->FileNameCur->data)->value;
- gchar *new_filename = ((File_Name *)ETFile->FileNameNew->data)->value;
+ const gchar *cur_filename = ((File_Name *)ETFile->FileNameCur->data)->value;
+ const gchar *new_filename = ((File_Name *)ETFile->FileNameNew->data)->value;
rc = et_rename_file (cur_filename, new_filename, &error);
// if 'SF_HideMsgbox_Rename_File is TRUE', then errors are displayed only in log
@@ -848,7 +846,7 @@ static gboolean
Write_File_Tag (ET_File *ETFile, gboolean hide_msgbox)
{
GError *error = NULL;
- gchar *cur_filename_utf8 = ((File_Name *)ETFile->FileNameCur->data)->value_utf8;
+ const gchar *cur_filename_utf8 = ((File_Name *)ETFile->FileNameCur->data)->value_utf8;
gchar *msg = NULL;
gchar *basename_utf8;
GtkWidget *msgdialog;
diff --git a/src/et_core.c b/src/et_core.c
index e2f60f6..b539419 100644
--- a/src/et_core.c
+++ b/src/et_core.c
@@ -23,7 +23,6 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
-#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <sys/stat.h>
@@ -4531,7 +4530,7 @@ ET_Get_Number_Of_Files_In_Directory (const gchar *path_utf8)
for (l = g_list_first (ETCore->ETFileList); l != NULL; l = g_list_next (l))
{
ET_File *ETFile = (ET_File *)l->data;
- gchar *cur_filename_utf8 = ((File_Name *)((GList *)ETFile->FileNameCur)->data)->value_utf8;
+ const gchar *cur_filename_utf8 = ((File_Name *)((GList *)ETFile->FileNameCur)->data)->value_utf8;
gchar *dirname_utf8 = g_path_get_dirname(cur_filename_utf8);
if (g_utf8_collate(dirname_utf8, path_utf8) == 0)
diff --git a/src/file_area.c b/src/file_area.c
index 67c2ba4..c197950 100644
--- a/src/file_area.c
+++ b/src/file_area.c
@@ -242,7 +242,7 @@ et_file_area_set_file_fields (EtFileArea *self,
EtFileAreaPrivate *priv;
GFile *file;
gchar *text;
- gchar *cur_filename;
+ const gchar *cur_filename;
gchar *basename_utf8;
gchar *pos;
GFileInfo *info;
diff --git a/src/playlist_dialog.c b/src/playlist_dialog.c
index 7eb6293..f0c6447 100644
--- a/src/playlist_dialog.c
+++ b/src/playlist_dialog.c
@@ -71,13 +71,10 @@ write_playlist (EtPlaylistDialog *self, GFile *file, GError **error)
GFile *parent;
GFileOutputStream *ostream;
GString *to_write;
- ET_File *etfile;
GList *l;
GList *etfilelist = NULL;
- gchar *filename;
gchar *basedir;
gchar *temp;
- gint duration;
EtPlaylistContent playlist_content;
g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
@@ -133,6 +130,8 @@ write_playlist (EtPlaylistDialog *self, GFile *file, GError **error)
for (l = selfilelist; l != NULL; l = g_list_next (l))
{
+ ET_File *etfile;
+
etfile = et_application_window_browser_get_et_file_from_path (ET_APPLICATION_WINDOW (MainWindow),
l->data);
etfilelist = g_list_prepend (etfilelist, etfile);
@@ -148,6 +147,10 @@ write_playlist (EtPlaylistDialog *self, GFile *file, GError **error)
for (l = etfilelist; l != NULL; l = g_list_next (l))
{
+ const ET_File *etfile;
+ const gchar *filename;
+ gint duration;
+
etfile = (ET_File *)l->data;
filename = ((File_Name *)etfile->FileNameCur->data)->value;
duration = ((ET_File_Info *)etfile->ETFileInfo)->duration;
diff --git a/src/scan_dialog.c b/src/scan_dialog.c
index 15e7d50..95333e0 100644
--- a/src/scan_dialog.c
+++ b/src/scan_dialog.c
@@ -1007,8 +1007,8 @@ Scan_Rename_File_Prefix_Path (EtScanDialog *self)
gchar *path_tmp;
const gchar *combo_text = NULL;
gchar *combo_tmp;
- ET_File *ETFile = ETCore->ETFileDisplayed;
- gchar *filename_utf8_cur;
+ const ET_File *ETFile = ETCore->ETFileDisplayed;
+ const gchar *filename_utf8_cur;
gchar *path_utf8_cur;
if (!ETFile)
diff --git a/src/tag_area.c b/src/tag_area.c
index 61dfa44..0850c79 100644
--- a/src/tag_area.c
+++ b/src/tag_area.c
@@ -384,7 +384,7 @@ on_apply_to_selection (GObject *object,
while (etfilelist && etfilelistfull)
{
// To get the path of the file
- File_Name *FileNameCur = (File_Name *)((ET_File *)etfilelistfull->data)->FileNameCur->data;
+ const File_Name *FileNameCur = (File_Name *)((ET_File *)etfilelistfull->data)->FileNameCur->data;
// The ETFile in the selected file list
etfile = etfilelist->data;
@@ -1522,7 +1522,7 @@ on_picture_add_button_clicked (GObject *object,
// Starting directory (the same of the current file)
if (ETCore->ETFileDisplayed)
{
- gchar *cur_filename_utf8 = ((File_Name *)((GList
*)ETCore->ETFileDisplayed->FileNameCur)->data)->value_utf8;
+ const gchar *cur_filename_utf8 = ((File_Name *)((GList
*)ETCore->ETFileDisplayed->FileNameCur)->data)->value_utf8;
init_dir = g_path_get_dirname(cur_filename_utf8);
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(FileSelectionWindow),init_dir);
}else
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]