[gnome-commander] Test via GIO if the '-' directory given in the commandline is existing
- From: Uwe Scholz <uwescholz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-commander] Test via GIO if the '-' directory given in the commandline is existing
- Date: Sun, 17 Jan 2021 22:09:49 +0000 (UTC)
commit 2fc0466ff60dae05507eefaadbd6883a016b1b7a
Author: Uwe Scholz <u scholz83 gmx de>
Date: Sun Jan 17 23:08:57 2021 +0100
Test via GIO if the '-' directory given in the commandline is existing
src/gnome-cmd-cmdline.cc | 7 +++----
src/gnome-cmd-con-home.cc | 7 +++++++
src/gnome-cmd-con.cc | 10 ++++++++++
src/gnome-cmd-con.h | 2 ++
src/gnome-cmd-dir.cc | 12 ++++++++++++
src/gnome-cmd-dir.h | 1 +
6 files changed, 35 insertions(+), 4 deletions(-)
---
diff --git a/src/gnome-cmd-cmdline.cc b/src/gnome-cmd-cmdline.cc
index e60db557..90128883 100644
--- a/src/gnome-cmd-cmdline.cc
+++ b/src/gnome-cmd-cmdline.cc
@@ -86,14 +86,13 @@ static void on_exec (GnomeCmdCmdline *cmdline, gboolean term)
if (strcmp (dest_dir, "-")==0)
{
- GnomeVFSURI *test_uri = gnome_cmd_dir_get_child_uri (fs->get_directory(), "-");
+ auto *testGFile = gnome_cmd_dir_get_child_gfile (fs->get_directory(), "-");
- if (gnome_vfs_uri_exists (test_uri))
+ if (g_file_query_exists (testGFile, nullptr))
fs->goto_directory(dest_dir);
else
fs->back();
-
- gnome_vfs_uri_unref (test_uri);
+ g_object_unref(testGFile);
}
else
fs->goto_directory(dest_dir);
diff --git a/src/gnome-cmd-con-home.cc b/src/gnome-cmd-con-home.cc
index 725f3d4e..9d863840 100644
--- a/src/gnome-cmd-con-home.cc
+++ b/src/gnome-cmd-con-home.cc
@@ -66,6 +66,12 @@ static GnomeVFSURI *home_create_uri (GnomeCmdCon *con, GnomeCmdPath *path)
}
+static GFile *home_create_gfile (GnomeCmdCon *con, GnomeCmdPath *path)
+{
+ return g_file_new_for_path(path->get_path());
+}
+
+
static GnomeCmdPath *home_create_path (GnomeCmdCon *con, const gchar *path_str)
{
return new GnomeCmdPlainPath(path_str);
@@ -104,6 +110,7 @@ static void class_init (GnomeCmdConHomeClass *klass)
con_class->cancel_open = home_cancel_open;
con_class->open_is_needed = home_open_is_needed;
con_class->create_uri = home_create_uri;
+ con_class->create_gfile = home_create_gfile;
con_class->create_path = home_create_path;
}
diff --git a/src/gnome-cmd-con.cc b/src/gnome-cmd-con.cc
index f83d0a81..1d9f88df 100644
--- a/src/gnome-cmd-con.cc
+++ b/src/gnome-cmd-con.cc
@@ -333,6 +333,16 @@ GnomeVFSURI *gnome_cmd_con_create_uri (GnomeCmdCon *con, GnomeCmdPath *path)
}
+GFile *gnome_cmd_con_create_gfile (GnomeCmdCon *con, GnomeCmdPath *path)
+{
+ g_return_val_if_fail (GNOME_CMD_IS_CON (con), nullptr);
+
+ GnomeCmdConClass *klass = GNOME_CMD_CON_GET_CLASS (con);
+
+ return klass->create_gfile (con, path);
+}
+
+
GnomeCmdPath *gnome_cmd_con_create_path (GnomeCmdCon *con, const gchar *path_str)
{
g_return_val_if_fail (GNOME_CMD_IS_CON (con), nullptr);
diff --git a/src/gnome-cmd-con.h b/src/gnome-cmd-con.h
index 40759fd4..c86b33c4 100644
--- a/src/gnome-cmd-con.h
+++ b/src/gnome-cmd-con.h
@@ -131,6 +131,7 @@ struct GnomeCmdConClass
gboolean (* close) (GnomeCmdCon *con);
gboolean (* open_is_needed) (GnomeCmdCon *con);
GnomeVFSURI *(* create_uri) (GnomeCmdCon *con, GnomeCmdPath *path);
+ GFile *(* create_gfile) (GnomeCmdCon *con, GnomeCmdPath *path);
GnomeCmdPath *(* create_path) (GnomeCmdCon *con, const gchar *path_str);
};
@@ -178,6 +179,7 @@ inline void gnome_cmd_con_set_uri (GnomeCmdCon *con, const std::string &uri)
}
GnomeVFSURI *gnome_cmd_con_create_uri (GnomeCmdCon *con, GnomeCmdPath *path);
+GFile *gnome_cmd_con_create_gfile (GnomeCmdCon *con, GnomeCmdPath *path);
GnomeCmdPath *gnome_cmd_con_create_path (GnomeCmdCon *con, const gchar *path_str);
diff --git a/src/gnome-cmd-dir.cc b/src/gnome-cmd-dir.cc
index df48ab70..afc7450b 100644
--- a/src/gnome-cmd-dir.cc
+++ b/src/gnome-cmd-dir.cc
@@ -634,6 +634,18 @@ GnomeVFSURI *gnome_cmd_dir_get_child_uri (GnomeCmdDir *dir, const gchar *filenam
}
+GFile *gnome_cmd_dir_get_child_gfile (GnomeCmdDir *dir, const gchar *filename)
+{
+ g_return_val_if_fail (GNOME_CMD_IS_DIR (dir), nullptr);
+
+ GnomeCmdPath *path = dir->priv->path->get_child(filename);
+ GFile *gFile = gnome_cmd_con_create_gfile (dir->priv->con, path);
+ delete path;
+
+ return gFile;
+}
+
+
GnomeVFSURI *gnome_cmd_dir_get_absolute_path_uri (GnomeCmdDir *dir, string absolute_filename)
{
g_return_val_if_fail (GNOME_CMD_IS_DIR (dir), nullptr);
diff --git a/src/gnome-cmd-dir.h b/src/gnome-cmd-dir.h
index 602ce1dd..4dbdea9e 100644
--- a/src/gnome-cmd-dir.h
+++ b/src/gnome-cmd-dir.h
@@ -132,6 +132,7 @@ GnomeVFSURI *gnome_cmd_dir_get_uri (GnomeCmdDir *dir);
gchar *gnome_cmd_dir_get_uri_str (GnomeCmdDir *dir);
GnomeVFSURI *gnome_cmd_dir_get_child_uri (GnomeCmdDir *dir, const gchar *filename);
+GFile *gnome_cmd_dir_get_child_gfile (GnomeCmdDir *dir, const gchar *filename);
GnomeVFSURI *gnome_cmd_dir_get_absolute_path_uri (GnomeCmdDir *dir, std::string absolute_filename);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]