[gnome-commander] Use the (const) GFileInfo display name instead of the one provided by Gnome-VFS
- From: Uwe Scholz <uwescholz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander] Use the (const) GFileInfo display name instead of the one provided by Gnome-VFS
- Date: Tue, 11 May 2021 21:10:02 +0000 (UTC)
commit cadb9ef099b2d5e84c835023c47afc8f65601967
Author: Uwe Scholz <u scholz83 gmx de>
Date: Tue May 11 23:09:30 2021 +0200
Use the (const) GFileInfo display name instead of the one provided by Gnome-VFS
libgcmd/libgcmd-utils.cc | 2 +-
src/dialogs/gnome-cmd-advrename-dialog.cc | 2 +-
src/dialogs/gnome-cmd-delete-dialog.cc | 8 ++------
src/dialogs/gnome-cmd-file-props-dialog.cc | 4 +---
src/dialogs/gnome-cmd-prepare-copy-dialog.cc | 4 +---
src/dialogs/gnome-cmd-prepare-move-dialog.cc | 4 +---
src/dialogs/gnome-cmd-prepare-xfer-dialog.cc | 6 ++----
src/dialogs/gnome-cmd-rename-dialog.cc | 6 +-----
src/gnome-cmd-file-list.cc | 14 ++++----------
src/gnome-cmd-file-selector.cc | 8 ++------
src/gnome-cmd-file.h | 10 +++++-----
11 files changed, 21 insertions(+), 47 deletions(-)
---
diff --git a/libgcmd/libgcmd-utils.cc b/libgcmd/libgcmd-utils.cc
index 9aa512a1..dcb1324a 100644
--- a/libgcmd/libgcmd-utils.cc
+++ b/libgcmd/libgcmd-utils.cc
@@ -45,7 +45,7 @@ gchar *get_utf8 (const gchar *unknown)
if (g_utf8_validate (unknown, -1, NULL))
out = g_strdup (unknown);
- else
+ else
{
gsize i;
out = g_locale_to_utf8 (unknown, strlen (unknown), &i, &i, NULL);
diff --git a/src/dialogs/gnome-cmd-advrename-dialog.cc b/src/dialogs/gnome-cmd-advrename-dialog.cc
index ae5f60ec..2c31ee97 100644
--- a/src/dialogs/gnome-cmd-advrename-dialog.cc
+++ b/src/dialogs/gnome-cmd-advrename-dialog.cc
@@ -439,7 +439,7 @@ void GnomeCmdAdvrenameDialog::Private::on_dialog_size_allocate (GtkWidget *widge
void GnomeCmdAdvrenameDialog::Private::on_dialog_response (GnomeCmdAdvrenameDialog *dialog, int response_id,
gpointer unused)
{
GtkTreeIter i;
- gchar *old_focused_file_name = NULL;
+ const gchar *old_focused_file_name = NULL;
gchar *new_focused_file_name = NULL;
switch (response_id)
diff --git a/src/dialogs/gnome-cmd-delete-dialog.cc b/src/dialogs/gnome-cmd-delete-dialog.cc
index d61aa14a..46b6e716 100644
--- a/src/dialogs/gnome-cmd-delete-dialog.cc
+++ b/src/dialogs/gnome-cmd-delete-dialog.cc
@@ -306,9 +306,8 @@ static GList *remove_items_from_list_to_be_deleted(GList *files)
if (num_dirs != 1 || num_files != 0) // num_dirs = 1 -> this is the folder to be deleted
{
gchar *msg = NULL;
- gchar *fname = get_utf8 (gnomeCmdFile->get_name());
- msg = g_strdup_printf (_("The directory “%s” is not empty. Do you really want to delete
it?"), fname);
+ msg = g_strdup_printf (_("The directory “%s” is not empty. Do you really want to delete
it?"), gnomeCmdFile->get_name());
guiResponse = run_simple_dialog (*main_win, FALSE, GTK_MESSAGE_WARNING, msg, _("Delete"),
gnome_cmd_data.options.confirm_delete_default==GTK_BUTTONS_CANCEL ? 0 : 3,
_("Cancel"), _("Skip"),
@@ -318,7 +317,6 @@ static GList *remove_items_from_list_to_be_deleted(GList *files)
if (guiResponse != SKIP && guiResponse != DELETEALL && guiResponse != DELETE)
guiResponse = CANCEL; // Set to zero for the case the user presses ESCAPE in the warning
dialog)
- g_free(fname);
g_free(msg);
if (guiResponse == CANCEL || guiResponse == DELETEALL)
@@ -373,9 +371,7 @@ void gnome_cmd_delete_dialog_show (GList *files)
if (f->is_dotdot)
return;
- gchar *fname = get_utf8 (f->info->name);
- msg = g_strdup_printf (_("Do you want to delete “%s”?"), fname);
- g_free (fname);
+ msg = g_strdup_printf (_("Do you want to delete “%s”?"), f->get_name());
}
else
msg = g_strdup_printf (ngettext("Do you want to delete the selected file?",
diff --git a/src/dialogs/gnome-cmd-file-props-dialog.cc b/src/dialogs/gnome-cmd-file-props-dialog.cc
index 086fb4a7..24879c38 100644
--- a/src/dialogs/gnome-cmd-file-props-dialog.cc
+++ b/src/dialogs/gnome-cmd-file-props-dialog.cc
@@ -344,9 +344,7 @@ static GtkWidget *create_properties_tab (GnomeCmdFilePropsDialogPrivate *data)
label = create_bold_label (dialog, GNOME_CMD_IS_DIR (data->f) ? _("Directory name:") : _("File name:"));
table_add (table, label, 0, y, GTK_FILL);
- fname = get_utf8 (data->f->get_name());
- data->filename_entry = create_entry (dialog, "filename_entry", fname);
- g_free (fname);
+ data->filename_entry = create_entry (dialog, "filename_entry", data->f->get_name());
table_add (table, data->filename_entry, 1, y++, (GtkAttachOptions) (GTK_FILL|GTK_EXPAND));
gtk_editable_set_position (GTK_EDITABLE (data->filename_entry), 0);
diff --git a/src/dialogs/gnome-cmd-prepare-copy-dialog.cc b/src/dialogs/gnome-cmd-prepare-copy-dialog.cc
index d1413bd5..5a9b6a0a 100644
--- a/src/dialogs/gnome-cmd-prepare-copy-dialog.cc
+++ b/src/dialogs/gnome-cmd-prepare-copy-dialog.cc
@@ -136,9 +136,7 @@ void gnome_cmd_prepare_copy_dialog_show (GnomeCmdFileSelector *from, GnomeCmdFil
if (num_files == 1)
{
GnomeCmdFile *f = (GnomeCmdFile *) data->dialog->src_files->data;
- gchar *fname = get_utf8 (f->info->name);
- dest_dir_frame_msg = g_strdup_printf (_("Copy “%s” to"), fname);
- g_free (fname);
+ dest_dir_frame_msg = g_strdup_printf (_("Copy “%s” to"), f->get_name());
}
else
dest_dir_frame_msg = g_strdup_printf (ngettext("copy %d file to","copy %d files to",num_files),
num_files);
diff --git a/src/dialogs/gnome-cmd-prepare-move-dialog.cc b/src/dialogs/gnome-cmd-prepare-move-dialog.cc
index 73ef515d..ad9ab2cd 100644
--- a/src/dialogs/gnome-cmd-prepare-move-dialog.cc
+++ b/src/dialogs/gnome-cmd-prepare-move-dialog.cc
@@ -122,9 +122,7 @@ void gnome_cmd_prepare_move_dialog_show (GnomeCmdFileSelector *from, GnomeCmdFil
if (num_files == 1)
{
GnomeCmdFile *f = (GnomeCmdFile *) data->dialog->src_files->data;
- gchar *fname = get_utf8 (f->info->name);
- dest_dir_frame_msg = g_strdup_printf (_("Move “%s” to"), fname);
- g_free (fname);
+ dest_dir_frame_msg = g_strdup_printf (_("Move “%s” to"), f->get_name());
}
else
dest_dir_frame_msg = g_strdup_printf (ngettext("move %d file to","move %d files to",num_files),
num_files);
diff --git a/src/dialogs/gnome-cmd-prepare-xfer-dialog.cc b/src/dialogs/gnome-cmd-prepare-xfer-dialog.cc
index 89ff5d03..15431d11 100644
--- a/src/dialogs/gnome-cmd-prepare-xfer-dialog.cc
+++ b/src/dialogs/gnome-cmd-prepare-xfer-dialog.cc
@@ -401,7 +401,7 @@ GtkWidget *gnome_cmd_prepare_xfer_dialog_new (GnomeCmdFileSelector *from, GnomeC
if (num_files == 1)
{
GnomeCmdFile *f = (GnomeCmdFile *) dialog->src_files->data;
- dest_str = get_utf8 (f->info->name);
+ dest_str = g_strdup (f->get_name());
}
}
else
@@ -411,10 +411,9 @@ GtkWidget *gnome_cmd_prepare_xfer_dialog_new (GnomeCmdFileSelector *from, GnomeC
gchar *t = GNOME_CMD_FILE (dialog->default_dest_dir)->get_real_path();
gchar *path = get_utf8 (t);
- gchar *fname = get_utf8 (f->info->name);
g_free (t);
- dest_str = g_build_filename (path, fname, NULL);
+ dest_str = g_build_filename (path, f->get_name(), NULL);
if (path_points_at_directory (to, dest_str))
{
g_free (dest_str);
@@ -422,7 +421,6 @@ GtkWidget *gnome_cmd_prepare_xfer_dialog_new (GnomeCmdFileSelector *from, GnomeC
}
g_free (path);
- g_free (fname);
}
else
{
diff --git a/src/dialogs/gnome-cmd-rename-dialog.cc b/src/dialogs/gnome-cmd-rename-dialog.cc
index a1222490..b6cca36c 100644
--- a/src/dialogs/gnome-cmd-rename-dialog.cc
+++ b/src/dialogs/gnome-cmd-rename-dialog.cc
@@ -144,16 +144,12 @@ GtkWidget *gnome_cmd_rename_dialog_new (GnomeCmdFile *f, gint x, gint y, gint wi
gtk_container_add (GTK_CONTAINER (dialog), GTK_WIDGET (dialog->priv->textbox));
gtk_widget_set_style (GTK_WIDGET (dialog->priv->textbox), list_style);
- gchar *fname = get_utf8 (f->get_name());
-
- gtk_entry_set_text (dialog->priv->textbox, fname);
+ gtk_entry_set_text (dialog->priv->textbox, f->get_name());
gtk_window_set_focus (GTK_WINDOW (dialog), GTK_WIDGET (dialog->priv->textbox));
gtk_widget_grab_focus (GTK_WIDGET (dialog->priv->textbox));
gtk_editable_select_region (GTK_EDITABLE (dialog->priv->textbox), 0, -1);
gtk_widget_show (GTK_WIDGET (dialog->priv->textbox));
- g_free (fname);
-
return GTK_WIDGET (dialog);
}
diff --git a/src/gnome-cmd-file-list.cc b/src/gnome-cmd-file-list.cc
index da984c52..cc808e13 100644
--- a/src/gnome-cmd-file-list.cc
+++ b/src/gnome-cmd-file-list.cc
@@ -326,12 +326,10 @@ FileFormatData::FileFormatData(GnomeCmdFileList *fl, GnomeCmdFile *f, gboolean t
if (gnome_cmd_data.options.ext_disp_mode == GNOME_CMD_EXT_DISP_STRIPPED
&& f->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) == G_FILE_TYPE_REGULAR)
{
- gchar *t = strip_extension (f->get_name());
- fname = get_utf8 (t);
- g_free (t);
+ fname = strip_extension (f->get_name());
}
else
- fname = get_utf8 (f->get_name());
+ fname = g_strdup(f->get_name());
if (fl->priv->base_dir != nullptr)
text[GnomeCmdFileList::COLUMN_DIR] = g_strconcat(get_utf8("."), dpath +
(strlen(fl->priv->base_dir)-1), nullptr);
@@ -1272,12 +1270,10 @@ static void mime_exec_single (GnomeCmdFile *f)
{
if (f->has_mime_type("application/x-executable") ||
f->has_mime_type("application/x-executable-binary"))
{
- gchar *fname = get_utf8 (f->info->name);
- gchar *msg = g_strdup_printf (_("“%s” seems to be a binary executable file but it lacks the
executable bit. Do you want to set it and then run the file?"), fname);
+ gchar *msg = g_strdup_printf (_("“%s” seems to be a binary executable file but it lacks the
executable bit. Do you want to set it and then run the file?"), f->get_name());
gint ret = run_simple_dialog (*main_win, FALSE, GTK_MESSAGE_QUESTION, msg,
_("Make Executable?"),
-1, _("Cancel"), _("OK"), nullptr);
- g_free (fname);
g_free (msg);
if (ret != 1) return; else
@@ -1301,11 +1297,9 @@ static void mime_exec_single (GnomeCmdFile *f)
else
if (f->mime_begins_with("text/"))
{
- gchar *fname = get_utf8 (f->info->name);
- gchar *msg = g_strdup_printf (_("“%s” is an executable text file. Do you want to run it, or
display its contents?"), fname);
+ gchar *msg = g_strdup_printf (_("“%s” is an executable text file. Do you want to run it, or
display its contents?"), f->get_name());
gint ret = run_simple_dialog (*main_win, FALSE, GTK_MESSAGE_QUESTION, msg, _("Run or
Display"),
-1, _("Cancel"), _("Display"), _("Run"), nullptr);
- g_free (fname);
g_free (msg);
if (ret != 1)
diff --git a/src/gnome-cmd-file-selector.cc b/src/gnome-cmd-file-selector.cc
index 0adabb00..0dba9a89 100644
--- a/src/gnome-cmd-file-selector.cc
+++ b/src/gnome-cmd-file-selector.cc
@@ -1320,16 +1320,14 @@ void gnome_cmd_file_selector_create_symlink (GnomeCmdFileSelector *fs, GnomeCmdF
{
const gchar *labels[] = {_("Symbolic link name:")};
- gchar *fname = get_utf8 (f->get_name());
#if defined (__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
#endif
- gchar *text = g_strdup_printf (gnome_cmd_data_get_symlink_prefix (), fname);
+ gchar *text = g_strdup_printf (gnome_cmd_data_get_symlink_prefix (), f->get_name());
#if defined (__GNUC__)
#pragma GCC diagnostic pop
#endif
- g_free (fname);
GtkWidget *dialog = gnome_cmd_string_dialog_new (_("Create Symbolic Link"),
labels,
@@ -1353,19 +1351,17 @@ void gnome_cmd_file_selector_create_symlinks (GnomeCmdFileSelector *fs, GList *f
for (; files; files=files->next)
{
auto f = static_cast<GnomeCmdFile*> (files->data);
- gchar *fname = get_utf8 (f->get_name());
#if defined (__GNUC__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wformat-nonliteral"
#endif
- gchar *symlink_name = g_strdup_printf (gnome_cmd_data_get_symlink_prefix (), fname);
+ gchar *symlink_name = g_strdup_printf (gnome_cmd_data_get_symlink_prefix (), f->get_name());
#if defined (__GNUC__)
#pragma GCC diagnostic pop
#endif
GnomeVFSURI *uri = gnome_cmd_dir_get_child_uri (fs->get_directory(), symlink_name);
- g_free (fname);
g_free (symlink_name);
GnomeVFSResult result;
diff --git a/src/gnome-cmd-file.h b/src/gnome-cmd-file.h
index e97f8c4c..2aa2be60 100644
--- a/src/gnome-cmd-file.h
+++ b/src/gnome-cmd-file.h
@@ -57,7 +57,7 @@ struct GnomeCmdFile
void invalidate_metadata();
- gchar *get_name();
+ const gchar *get_name();
gchar *get_quoted_name();
gchar *get_path();
gchar *get_real_path();
@@ -120,10 +120,10 @@ struct GnomeCmdFileClass
};
-inline gchar *GnomeCmdFile::get_name()
+inline const gchar *GnomeCmdFile::get_name()
{
- g_return_val_if_fail (info != NULL, NULL);
- return info->name;
+ g_return_val_if_fail (gFileInfo != NULL, NULL);
+ return g_file_info_get_display_name(gFileInfo);
}
GnomeCmdFile *gnome_cmd_file_new_from_uri (GnomeVFSURI *uri);
@@ -146,7 +146,7 @@ inline void gnome_cmd_file_unref (GnomeCmdFile *f)
f->unref();
}
-inline gchar *gnome_cmd_file_get_name (GnomeCmdFile *f)
+inline const gchar *gnome_cmd_file_get_name (GnomeCmdFile *f)
{
g_return_val_if_fail (f != NULL, NULL);
return f->get_name();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]