[gnome-commander] GnomeCmdCon: support for new class member: root_path



commit e4d0a5071ab3996a82d287d8e99434678200a7ce
Author: Piotr Eljasiak <epiotr src gnome org>
Date:   Thu Apr 28 21:55:38 2011 +0200

    GnomeCmdCon: support for new class member: root_path

 src/gnome-cmd-con-device.cc |    5 ++++-
 src/gnome-cmd-con-ftp.cc    |    3 +++
 src/gnome-cmd-con.cc        |    2 ++
 src/gnome-cmd-con.h         |   13 +++++++++++++
 4 files changed, 22 insertions(+), 1 deletions(-)
---
diff --git a/src/gnome-cmd-con-device.cc b/src/gnome-cmd-con-device.cc
index 0d3f562..e68d4fb 100644
--- a/src/gnome-cmd-con-device.cc
+++ b/src/gnome-cmd-con-device.cc
@@ -384,6 +384,7 @@ GtkType gnome_cmd_con_device_get_type ()
 GnomeCmdConDevice *gnome_cmd_con_device_new (const gchar *alias, const gchar *device_fn, const gchar *mountp, const gchar *icon_path)
 {
     GnomeCmdConDevice *dev = (GnomeCmdConDevice *) g_object_new (GNOME_CMD_TYPE_CON_DEVICE, NULL);
+    GnomeCmdCon *con = GNOME_CMD_CON (dev);
 
     gnome_cmd_con_device_set_device_fn (dev, device_fn);
     gnome_cmd_con_device_set_mountp (dev, mountp);
@@ -392,7 +393,9 @@ GnomeCmdConDevice *gnome_cmd_con_device_new (const gchar *alias, const gchar *de
     gnome_cmd_con_device_set_vfs_volume(dev, NULL);
     gnome_cmd_con_device_set_alias (dev, alias);
 
-    GNOME_CMD_CON (dev)->open_msg = g_strdup_printf (_("Mounting %s"), alias);
+    gnome_cmd_con_set_root_path (con, mountp);
+
+    con->open_msg = g_strdup_printf (_("Mounting %s"), alias);
 
     return dev;
 }
diff --git a/src/gnome-cmd-con-ftp.cc b/src/gnome-cmd-con-ftp.cc
index 7bf98b5..4dda10d 100644
--- a/src/gnome-cmd-con-ftp.cc
+++ b/src/gnome-cmd-con-ftp.cc
@@ -245,6 +245,7 @@ GnomeCmdConFtp *gnome_cmd_con_ftp_new (const gchar *alias, const string &text_ur
 
     const gchar *host = gnome_vfs_uri_get_host_name (uri);      // do not g_free
     const gchar *password = gnome_vfs_uri_get_password (uri);   // do not g_free
+    gchar *path = gnome_vfs_unescape_string (gnome_vfs_uri_get_path (uri), NULL);
 
     GnomeCmdConFtp *server = (GnomeCmdConFtp *) g_object_new (GNOME_CMD_TYPE_CON_FTP, NULL);
 
@@ -255,12 +256,14 @@ GnomeCmdConFtp *gnome_cmd_con_ftp_new (const gchar *alias, const string &text_ur
     gnome_cmd_con_set_alias (con, alias);
     gnome_cmd_con_set_uri (con, text_uri);
     gnome_cmd_con_set_host_name (con, host);
+    gnome_cmd_con_set_root_path (con, path);
 
     gnome_cmd_con_ftp_set_host_name (server, host);
 
     con->method = gnome_cmd_con_get_scheme (uri);
     con->gnome_auth = !password && con->method!=CON_ANON_FTP;          // ?????????
 
+    g_free (path);
     gnome_vfs_uri_unref (uri);
 
     return server;
diff --git a/src/gnome-cmd-con.cc b/src/gnome-cmd-con.cc
index 7b8320e..b9b5784 100644
--- a/src/gnome-cmd-con.cc
+++ b/src/gnome-cmd-con.cc
@@ -87,6 +87,7 @@ static void destroy (GtkObject *object)
     g_free (con->uri);
 
     delete con->base_path;
+    g_string_free (con->root_path, TRUE);
     g_free (con->open_text);
     g_free (con->open_tooltip);
     gnome_cmd_pixmap_free (con->open_pixmap);
@@ -173,6 +174,7 @@ static void init (GnomeCmdCon *con)
 
     con->base_path = NULL;
     con->base_info = NULL;
+    con->root_path = g_string_sized_new (128);
     con->open_msg = NULL;
     con->should_remember_dir = FALSE;
     con->needs_open_visprog = FALSE;
diff --git a/src/gnome-cmd-con.h b/src/gnome-cmd-con.h
index 4957edb..fd96a82 100644
--- a/src/gnome-cmd-con.h
+++ b/src/gnome-cmd-con.h
@@ -81,6 +81,7 @@ struct GnomeCmdCon
     gchar               *open_msg;
     GnomeCmdPath        *base_path;
     GnomeVFSFileInfo    *base_info;
+    GString             *root_path;             // root path of the connection, used for calculation of relative paths
     gboolean            should_remember_dir;
     gboolean            needs_open_visprog;
     gboolean            needs_list_visprog;
@@ -209,6 +210,18 @@ inline void gnome_cmd_con_set_host_name (GnomeCmdCon *con, const std::string &ho
 GnomeCmdDir *gnome_cmd_con_get_default_dir (GnomeCmdCon *con);
 void gnome_cmd_con_set_default_dir (GnomeCmdCon *con, GnomeCmdDir *dir);
 
+inline gchar *gnome_cmd_con_get_root_path (GnomeCmdCon *con)
+{
+    g_return_val_if_fail (GNOME_CMD_IS_CON (con), NULL);
+    return con->root_path->str;
+}
+
+inline void gnome_cmd_con_set_root_path (GnomeCmdCon *con, const gchar *path=NULL)
+{
+    g_return_if_fail (GNOME_CMD_IS_CON (con));
+    g_string_assign (con->root_path, path);
+}
+
 inline gboolean gnome_cmd_con_should_remember_dir (GnomeCmdCon *con)
 {
     g_return_val_if_fail (GNOME_CMD_IS_CON (con), FALSE);



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