[gnome-commander] Instead of using old gnome-vfs uri in the current state, use a GFile object



commit 67e424b0148b162854cb2b56800e1a390e0ffc8f
Author: Uwe Scholz <u scholz83 gmx de>
Date:   Fri Jan 1 21:58:53 2021 +0100

    Instead of using old gnome-vfs uri in the current state, use a GFile object

 libgcmd/gnome-cmd-state.h                |  6 +++---
 plugins/fileroller/file-roller-plugin.cc | 17 +++++------------
 src/gnome-cmd-file.cc                    |  3 ++-
 src/gnome-cmd-main-win.cc                |  4 ++--
 4 files changed, 12 insertions(+), 18 deletions(-)
---
diff --git a/libgcmd/gnome-cmd-state.h b/libgcmd/gnome-cmd-state.h
index 86954310..b6d38296 100644
--- a/libgcmd/gnome-cmd-state.h
+++ b/libgcmd/gnome-cmd-state.h
@@ -21,10 +21,10 @@
 
 #pragma once
 
-struct GnomeCmdState 
+struct GnomeCmdState
 {
-    GnomeVFSURI *active_dir_uri;
-    GnomeVFSURI *inactive_dir_uri;
+    GFile *activeDirGfile;
+    GFile *inactiveDirGfile;
     GList *active_dir_files;
     GList *inactive_dir_files;
     GList *active_dir_selected_files;
diff --git a/plugins/fileroller/file-roller-plugin.cc b/plugins/fileroller/file-roller-plugin.cc
index 83aaf452..b528d64a 100644
--- a/plugins/fileroller/file-roller-plugin.cc
+++ b/plugins/fileroller/file-roller-plugin.cc
@@ -228,34 +228,30 @@ inline void do_add_to_archive (const gchar *name, GnomeCmdState *state)
     gchar *t = g_strdup_printf ("--add-to=%s", name);
     gchar *arg = g_shell_quote (t);
     gchar *cmd = g_strdup_printf ("file-roller %s ", arg);
-    gchar *active_dir_path, *uri_str;
+    gchar *active_dir_path;
     GList *files;
     gint argc;
     gchar **argv;
 
     for (files = state->active_dir_selected_files; files; files = files->next)
     {
-        GnomeVFSURI *uri = GNOME_CMD_FILE_BASE (files->data)->uri;
-        gchar *uri_str_file = gnome_vfs_uri_to_string (uri, GNOME_VFS_URI_HIDE_PASSWORD);
-        gchar *path = gnome_vfs_get_local_path_from_uri (uri_str_file);
+        auto *gFile = GNOME_CMD_FILE_BASE (files->data)->gFile;
+        gchar *path = g_file_get_path (gFile);
         gchar *tmp = cmd;
         gchar *arg_file = g_shell_quote (path);
         cmd = g_strdup_printf ("%s %s", tmp, arg_file);
         g_free (arg_file);
         g_free (path);
         g_free (tmp);
-        g_free (uri_str_file);
     }
 
     g_printerr ("add: %s\n", cmd);
-    uri_str = gnome_vfs_uri_to_string (state->active_dir_uri, GNOME_VFS_URI_HIDE_PASSWORD);
-    active_dir_path = gnome_vfs_get_local_path_from_uri (uri_str);
+    active_dir_path = g_file_get_path (state->activeDirGfile);
     g_shell_parse_argv (cmd, &argc, &argv, NULL);
     g_spawn_async (active_dir_path, argv, NULL, G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, NULL);
     g_strfreev (argv);
 
     g_free (cmd);
-    g_free (uri_str);
     g_free (active_dir_path);
 }
 
@@ -478,9 +474,6 @@ static GList *create_popup_menu_items (GnomeCmdPlugin *plugin, GnomeCmdState *st
     if (num_files <= 0)
         return NULL;
 
-    if (!gnome_vfs_uri_is_local (GNOME_CMD_FILE_INFO (gnomeCmdFileInfoGList->data)->uri))
-        return NULL;
-
     FILE_ROLLER_PLUGIN (plugin)->priv->state = state;
 
     item = create_menu_item (_("Create Archive…"), TRUE, GTK_SIGNAL_FUNC (on_add_to_archive), plugin);
@@ -513,7 +506,7 @@ static GList *create_popup_menu_items (GnomeCmdPlugin *plugin, GnomeCmdState *st
 
                 if (activeDirId && inactiveDirId && g_str_equal(activeDirId, inactiveDirId))
                 {
-                    gchar *path = gnome_vfs_unescape_string (gnome_vfs_uri_get_path 
(state->inactive_dir_uri), NULL);
+                    auto path = GetGfileAttributeString(state->inactiveDirGfile, 
G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME);
 
                     text = g_strdup_printf (_("Extract to “%s”"), path);
                     item = create_menu_item (text, TRUE, GTK_SIGNAL_FUNC (on_extract_cwd), 
gnomeCmdFileBase->gFile);
diff --git a/src/gnome-cmd-file.cc b/src/gnome-cmd-file.cc
index 321a700c..e869d2b8 100644
--- a/src/gnome-cmd-file.cc
+++ b/src/gnome-cmd-file.cc
@@ -269,7 +269,8 @@ void gnome_cmd_file_setup (GnomeCmdFile *gnomeCmdFile, GnomeVFSFileInfo *info, G
 
     if (fUriString)
     {
-        gnomeCmdFile->gFile = g_file_new_for_path(fUriString);
+        GNOME_CMD_FILE_BASE (gnomeCmdFile)->gFile = g_file_new_for_path(fUriString);
+        gnomeCmdFile->gFile = GNOME_CMD_FILE_BASE (gnomeCmdFile)->gFile;
         g_free(fUriString);
 
         GError *error;
diff --git a/src/gnome-cmd-main-win.cc b/src/gnome-cmd-main-win.cc
index d4869851..c0a3c895 100644
--- a/src/gnome-cmd-main-win.cc
+++ b/src/gnome-cmd-main-win.cc
@@ -1429,8 +1429,8 @@ GnomeCmdState *GnomeCmdMainWin::get_state() const
     GnomeCmdDir *dir2 = fs2->get_directory();
 
     GnomeCmdState *state = &priv->state;
-    state->active_dir_uri = GNOME_CMD_FILE (dir1)->get_uri();
-    state->inactive_dir_uri = GNOME_CMD_FILE (dir2)->get_uri();
+    state->activeDirGfile = GNOME_CMD_FILE (dir1)->gFile;
+    state->inactiveDirGfile = GNOME_CMD_FILE (dir2)->gFile;
     state->active_dir_files = fs1->file_list()->get_visible_files();
     state->inactive_dir_files = fs2->file_list()->get_visible_files();
     state->active_dir_selected_files = fs1->file_list()->get_selected_files();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]