gnome-commander r2391 - in branches/gcmd-1-3: . src



Author: epiotr
Date: Mon Jan  5 23:29:00 2009
New Revision: 2391
URL: http://svn.gnome.org/viewvc/gnome-commander?rev=2391&view=rev

Log:
Fix the bug introduced in rev. #2157 (viewing remote files)

Modified:
   branches/gcmd-1-3/ChangeLog
   branches/gcmd-1-3/src/gnome-cmd-file.cc
   branches/gcmd-1-3/src/gnome-cmd-file.h

Modified: branches/gcmd-1-3/src/gnome-cmd-file.cc
==============================================================================
--- branches/gcmd-1-3/src/gnome-cmd-file.cc	(original)
+++ branches/gcmd-1-3/src/gnome-cmd-file.cc	Mon Jan  5 23:29:00 2009
@@ -173,21 +173,27 @@
 }
 
 
-GnomeCmdFile *gnome_cmd_file_new_from_local_path (const char *local_full_path)
+GnomeCmdFile *gnome_cmd_file_new_from_uri (GnomeVFSURI *uri)
 {
-    g_return_val_if_fail (local_full_path != NULL, NULL);
-
-    gchar *text_uri = gnome_vfs_get_uri_from_local_path (local_full_path);
-
-    g_return_val_if_fail (text_uri != NULL, NULL);
+    g_return_val_if_fail (uri != NULL, NULL);
 
     const GnomeVFSFileInfoOptions infoOpts = (GnomeVFSFileInfoOptions) (GNOME_VFS_FILE_INFO_FOLLOW_LINKS|GNOME_VFS_FILE_INFO_GET_MIME_TYPE);
     GnomeVFSFileInfo *info = gnome_vfs_file_info_new ();
-    GnomeVFSResult res = gnome_vfs_get_file_info (text_uri, info, infoOpts);
 
-    g_free (text_uri);
+    if (gnome_vfs_get_file_info_uri (uri, info, infoOpts) != GNOME_VFS_OK)
+    {
+        gnome_vfs_file_info_unref (info);
+        return NULL;
+    }
+
+    GnomeVFSURI *parent = gnome_vfs_uri_get_parent (uri);
+    GnomeCmdPath *path = gnome_cmd_plain_path_new (gnome_vfs_uri_get_path (parent));
+    GnomeCmdDir *dir = gnome_cmd_dir_new (get_home_con(), path);
+
+    gnome_vfs_uri_unref (parent);
+    gtk_object_unref (GTK_OBJECT (path));
 
-    return res == GNOME_VFS_OK ? gnome_cmd_file_new (info, NULL) : NULL;
+    return gnome_cmd_file_new (info, dir);
 }
 
 
@@ -736,8 +742,13 @@
 }
 
 
-static void on_file_downloaded_for_view (GnomeCmdFile *f)
+static void on_file_downloaded_for_view (GnomeVFSURI *uri)
 {
+    GnomeCmdFile *f = gnome_cmd_file_new_from_uri (uri);
+
+    if (!f)
+        return;
+
     do_view_file (f);
     gnome_cmd_file_unref (f);
 }
@@ -765,16 +776,14 @@
 
     g_printerr ("Copying to: %s\n", path_str);
     gtk_object_destroy (GTK_OBJECT (path));
+    g_free (path_str);
 
     gnome_cmd_xfer_tmp_download (src_uri,
                                  dest_uri,
                                  GNOME_VFS_XFER_FOLLOW_LINKS,
                                  GNOME_VFS_XFER_OVERWRITE_MODE_REPLACE,
                                  GTK_SIGNAL_FUNC (on_file_downloaded_for_view),
-                                 gnome_cmd_file_new_from_local_path (path_str));
-
-    // FIXME: unref src_uri & dest_uri ?
-    g_free (path_str);
+                                 dest_uri);
 }
 
 

Modified: branches/gcmd-1-3/src/gnome-cmd-file.h
==============================================================================
--- branches/gcmd-1-3/src/gnome-cmd-file.h	(original)
+++ branches/gcmd-1-3/src/gnome-cmd-file.h	Mon Jan  5 23:29:00 2009
@@ -56,7 +56,7 @@
 
 GtkType gnome_cmd_file_get_type ();
 
-GnomeCmdFile *gnome_cmd_file_new_from_local_path (const gchar *local_full_path);
+GnomeCmdFile *gnome_cmd_file_new_from_uri (const gchar *local_full_path);
 GnomeCmdFile *gnome_cmd_file_new (GnomeVFSFileInfo *info, GnomeCmdDir *dir);
 void gnome_cmd_file_setup (GnomeCmdFile *f, GnomeVFSFileInfo *info, GnomeCmdDir *dir);
 



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