[gnome-commander] Remove usage of GnomeVFSFileInfo->name
- From: Uwe Scholz <uwescholz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander] Remove usage of GnomeVFSFileInfo->name
- Date: Thu, 3 Jun 2021 18:07:55 +0000 (UTC)
commit 616adeba964a7b57b28483b77f386fa082c702ee
Author: Uwe Scholz <u scholz83 gmx de>
Date: Thu Jun 3 20:07:18 2021 +0200
Remove usage of GnomeVFSFileInfo->name
src/dialogs/gnome-cmd-advrename-dialog.cc | 7 +++----
src/dialogs/gnome-cmd-delete-dialog.cc | 2 +-
src/dialogs/gnome-cmd-make-copy-dialog.cc | 2 +-
src/dialogs/gnome-cmd-search-dialog.cc | 8 +++++---
src/gnome-cmd-file-list.cc | 12 +++++++-----
src/gnome-cmd-file-popmenu.cc | 6 ++++--
src/gnome-cmd-file-selector.cc | 7 +++++--
src/gnome-cmd-file.cc | 6 +++---
src/gnome-cmd-file.h | 2 +-
src/gnome-cmd-quicksearch-popup.cc | 4 +++-
10 files changed, 33 insertions(+), 23 deletions(-)
---
diff --git a/src/dialogs/gnome-cmd-advrename-dialog.cc b/src/dialogs/gnome-cmd-advrename-dialog.cc
index 2c31ee976..b7d698c95 100644
--- a/src/dialogs/gnome-cmd-advrename-dialog.cc
+++ b/src/dialogs/gnome-cmd-advrename-dialog.cc
@@ -459,10 +459,9 @@ void GnomeCmdAdvrenameDialog::Private::on_dialog_response (GnomeCmdAdvrenameDial
COL_NEW_NAME, &new_name,
-1);
- gchar *old_name = g_strdup (f->info->name);
GnomeVFSResult result = GNOME_VFS_OK;
- if (strcmp (f->info->name, new_name) != 0)
+ if (strcmp (g_file_info_get_display_name(f->gFileInfo), new_name) != 0)
result = f->rename(new_name);
gtk_list_store_set (GTK_LIST_STORE (dialog->files), &i,
@@ -470,11 +469,11 @@ void GnomeCmdAdvrenameDialog::Private::on_dialog_response (GnomeCmdAdvrenameDial
COL_RENAME_FAILED, result!=GNOME_VFS_OK,
-1);
- if (!new_focused_file_name && (result == GNOME_VFS_OK) && !strcmp(old_focused_file_name,
old_name))
+ if (!new_focused_file_name && (result == GNOME_VFS_OK)
+ && !strcmp(old_focused_file_name, g_file_info_get_display_name(f->gFileInfo)))
new_focused_file_name = g_strdup(new_name);
g_free (new_name);
- g_free (old_name);
}
if (new_focused_file_name)
{
diff --git a/src/dialogs/gnome-cmd-delete-dialog.cc b/src/dialogs/gnome-cmd-delete-dialog.cc
index 46b6e716b..be477316b 100644
--- a/src/dialogs/gnome-cmd-delete-dialog.cc
+++ b/src/dialogs/gnome-cmd-delete-dialog.cc
@@ -170,7 +170,7 @@ static void perform_delete_operation (DeleteData *data)
{
GnomeCmdFile *f = (GnomeCmdFile *) i->data;
- if (f->is_dotdot || strcmp(f->info->name, ".") == 0)
+ if (f->is_dotdot || strcmp(g_file_info_get_display_name(f->gFileInfo), ".") == 0)
continue;
GnomeVFSURI *uri = f->get_uri();
diff --git a/src/dialogs/gnome-cmd-make-copy-dialog.cc b/src/dialogs/gnome-cmd-make-copy-dialog.cc
index 7f0903196..f0e9e1b96 100644
--- a/src/dialogs/gnome-cmd-make-copy-dialog.cc
+++ b/src/dialogs/gnome-cmd-make-copy-dialog.cc
@@ -148,7 +148,7 @@ GtkWidget *gnome_cmd_make_copy_dialog_new (GnomeCmdFile *f, GnomeCmdDir *dir)
GTK_SIGNAL_FUNC (on_cancel),
dialog);
- gnome_cmd_string_dialog_set_value (GNOME_CMD_STRING_DIALOG (dialog), 0, f->info->name);
+ gnome_cmd_string_dialog_set_value (GNOME_CMD_STRING_DIALOG (dialog), 0,
g_file_info_get_display_name(f->gFileInfo));
return GTK_WIDGET (dialog);
}
diff --git a/src/dialogs/gnome-cmd-search-dialog.cc b/src/dialogs/gnome-cmd-search-dialog.cc
index f85d1ecd6..82325d98f 100644
--- a/src/dialogs/gnome-cmd-search-dialog.cc
+++ b/src/dialogs/gnome-cmd-search-dialog.cc
@@ -103,7 +103,7 @@ struct SearchData
gchar *build_search_command();
void search_dir_r(GnomeCmdDir *dir, long level); /**< searches a given directory for files that matches
the criteria given by data */
- gboolean name_matches(gchar *name) { return name_filter->match(name); } /**< determines if the
name of a file matches an regexp */
+ gboolean name_matches(const char *name) { return name_filter->match(name); } /**< determines if the
name of a file matches an regexp */
gboolean content_matches(GnomeCmdFile *f); /**< determines if the
content of a file matches an regexp */
gboolean read_search_file(SearchFileData *, GnomeCmdFile *f); /**< loads a file in
chunks and returns the content */
gboolean start_generic_search();
@@ -415,7 +415,9 @@ void SearchData::search_dir_r(GnomeCmdDir *dir, long level)
if (GNOME_CMD_IS_DIR (f) && level!=0)
{
// we don't want to go backwards or to follow symlinks
- if (!f->is_dotdot && strcmp (f->info->name, ".") != 0 && !GNOME_VFS_FILE_INFO_SYMLINK (f->info))
+ if (!f->is_dotdot
+ && strcmp (g_file_info_get_display_name(f->gFileInfo), ".") != 0
+ && !GNOME_VFS_FILE_INFO_SYMLINK (f->info))
{
GnomeCmdDir *new_dir = GNOME_CMD_DIR (f);
@@ -430,7 +432,7 @@ void SearchData::search_dir_r(GnomeCmdDir *dir, long level)
else // if the file is a regular one, it
might match the search criteria
if (f->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) == G_FILE_TYPE_DIRECTORY)
{
- if (!name_matches(f->info->name)) // if the name doesn't match, let's
go to the next file
+ if (!name_matches(g_file_info_get_display_name(f->gFileInfo))) // if
the name doesn't match, let's go to the next file
continue;
if (dialog->defaults.default_profile.content_search && !content_matches(f)) //
if the user wants to we should do some content matching here
diff --git a/src/gnome-cmd-file-list.cc b/src/gnome-cmd-file-list.cc
index 8f8bcbfdc..0f0481582 100644
--- a/src/gnome-cmd-file-list.cc
+++ b/src/gnome-cmd-file-list.cc
@@ -638,7 +638,7 @@ void GnomeCmdFileList::toggle_with_pattern(Filter &pattern, gboolean mode)
{
auto f = static_cast<GnomeCmdFile*> (i->data);
- if (f && f->info && pattern.match(f->info->name))
+ if (f && f->info && pattern.match(g_file_info_get_display_name(f->gFileInfo)))
{
if (mode)
select_file(f);
@@ -651,7 +651,7 @@ void GnomeCmdFileList::toggle_with_pattern(Filter &pattern, gboolean mode)
{
auto f = static_cast<GnomeCmdFile*> (i->data);
- if (f && !GNOME_CMD_IS_DIR (f) && f->info && pattern.match(f->info->name))
+ if (f && !GNOME_CMD_IS_DIR (f) && f->info &&
pattern.match(g_file_info_get_display_name(f->gFileInfo)))
{
if (mode)
select_file(f);
@@ -2398,7 +2398,7 @@ void gnome_cmd_file_list_view (GnomeCmdFileList *fl, gint internal_viewer)
return;
if (f->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) == G_FILE_TYPE_DIRECTORY)
- gnome_cmd_show_message (*main_win, _("Not an ordinary file."), f->info->name);
+ gnome_cmd_show_message (*main_win, _("Not an ordinary file."),
g_file_info_get_display_name(f->gFileInfo));
else
gnome_cmd_file_view (f, internal_viewer);
}
@@ -2413,7 +2413,7 @@ void gnome_cmd_file_list_edit (GnomeCmdFileList *fl)
if (!f) return;
if (f->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) == G_FILE_TYPE_DIRECTORY)
- gnome_cmd_show_message (*main_win, _("Not an ordinary file."), f->info->name);
+ gnome_cmd_show_message (*main_win, _("Not an ordinary file."),
g_file_info_get_display_name(f->gFileInfo));
else
gnome_cmd_file_edit (f);
}
@@ -3085,7 +3085,9 @@ static void drag_data_received (GtkWidget *widget, GdkDragContext *context, gint
// the drop was over a directory in the list, which means that the
// xfer should be done to that directory instead of the current one in the list
if (f && f->GetGfileAttributeUInt32(G_FILE_ATTRIBUTE_STANDARD_TYPE) == G_FILE_TYPE_DIRECTORY)
- to = f->is_dotdot ? gnome_cmd_dir_get_parent (to) : gnome_cmd_dir_get_child (to, f->info->name);
+ to = f->is_dotdot
+ ? gnome_cmd_dir_get_parent (to)
+ : gnome_cmd_dir_get_child (to, g_file_info_get_display_name(f->gFileInfo));
// transform the drag data to a list with URIs
GList *uri_list = strings_to_uris ((gchar *) selection_data->data);
diff --git a/src/gnome-cmd-file-popmenu.cc b/src/gnome-cmd-file-popmenu.cc
index af9942fe8..0915d34d3 100644
--- a/src/gnome-cmd-file-popmenu.cc
+++ b/src/gnome-cmd-file-popmenu.cc
@@ -241,7 +241,9 @@ static void cb_exec_default (GtkMenuItem *menu_item, GList *files)
data->files = g_list_append (data->files, file);
}
else
- gnome_cmd_show_message (nullptr, file->info->name, _("Couldn’t retrieve MIME type of the
file."));
+ gnome_cmd_show_message (nullptr,
+ g_file_info_get_display_name(file->gFileInfo),
+ _("Couldn’t retrieve MIME type of the file."));
}
g_hash_table_foreach (gHashTable, (GHFunc) htcb_exec_with_app, nullptr);
@@ -449,7 +451,7 @@ inline gboolean fav_app_matches_files (GnomeCmdApp *app, GList *files)
for (; patterns; patterns = patterns->next)
{
auto pattern = (gchar *) patterns->data;
- ok |= fnmatch (pattern, gnomeCmdFile->info->name, fn_flags) == 0;
+ ok |= fnmatch (pattern, g_file_info_get_display_name(gnomeCmdFile->gFileInfo), fn_flags)
== 0;
}
if (!ok) return FALSE;
diff --git a/src/gnome-cmd-file-selector.cc b/src/gnome-cmd-file-selector.cc
index 7e0ae7628..8b9638a56 100644
--- a/src/gnome-cmd-file-selector.cc
+++ b/src/gnome-cmd-file-selector.cc
@@ -1178,8 +1178,11 @@ void gnome_cmd_file_selector_show_new_textfile_dialog (GnomeCmdFileSelector *fs)
GnomeCmdFile *f = fs->file_list()->get_selected_file();
if (f)
- gnome_cmd_string_dialog_set_value (GNOME_CMD_STRING_DIALOG (dialog), 0, f->info->name);
-
+ {
+ gnome_cmd_string_dialog_set_value (GNOME_CMD_STRING_DIALOG (dialog),
+ 0,
+ g_file_info_get_display_name(f->gFileInfo));
+ }
g_object_ref (dialog);
gtk_widget_show (dialog);
}
diff --git a/src/gnome-cmd-file.cc b/src/gnome-cmd-file.cc
index 1509ca100..22bfad130 100644
--- a/src/gnome-cmd-file.cc
+++ b/src/gnome-cmd-file.cc
@@ -104,8 +104,8 @@ static void gnome_cmd_file_finalize (GObject *object)
delete f->metadata;
- if (f->info && f->info->name[0] != '.')
- DEBUG ('f', "file destroying 0x%p %s\n", f, f->info->name);
+ if (f->gFileInfo && strcmp(g_file_info_get_display_name(f->gFileInfo), "..") != 0)
+ DEBUG ('f', "file destroying 0x%p %s\n", f, g_file_info_get_display_name(f->gFileInfo));
g_free (f->collate_key);
gnome_vfs_file_info_unref (f->info);
@@ -521,7 +521,7 @@ gchar *GnomeCmdFile::get_quoted_name()
{
g_return_val_if_fail (info != nullptr, nullptr);
- return quote_if_needed (info->name);
+ return quote_if_needed (g_file_info_get_display_name(gFileInfo));
}
diff --git a/src/gnome-cmd-file.h b/src/gnome-cmd-file.h
index 416f149df..628e494ba 100644
--- a/src/gnome-cmd-file.h
+++ b/src/gnome-cmd-file.h
@@ -68,7 +68,7 @@ struct GnomeCmdFile
GnomeVFSURI *get_uri(const gchar *name=NULL);
gchar *get_uri_str();
- char *get_collation_fname() const { return collate_key ? collate_key : info->name; }
+ char *get_collation_fname() const { return collate_key ? collate_key : g_file_get_basename(gFile); }
const gchar *get_extension();
const gchar *get_owner();
diff --git a/src/gnome-cmd-quicksearch-popup.cc b/src/gnome-cmd-quicksearch-popup.cc
index 3377bbc79..8357471e4 100644
--- a/src/gnome-cmd-quicksearch-popup.cc
+++ b/src/gnome-cmd-quicksearch-popup.cc
@@ -85,7 +85,9 @@ static void set_filter (GnomeCmdQuicksearchPopup *popup, const gchar *text)
{
auto f = static_cast<GnomeCmdFile*> (files->data);
- if (gnome_cmd_filter_fnmatch (pattern, f->info->name, gnome_cmd_data.options.case_sens_sort))
+ if (gnome_cmd_filter_fnmatch (pattern,
+ g_file_info_get_display_name(f->gFileInfo),
+ gnome_cmd_data.options.case_sens_sort))
{
if (first)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]