gcmd-devel
[Top][All Lists]
Advanced

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

[gcmd-dev] fix for bug #377490


From: Koos Jan Niesink
Subject: [gcmd-dev] fix for bug #377490
Date: Mon, 22 Jan 2007 17:56:55 +0000 (GMT)

Hello,

I added support for creating directories with an absolute pathname in 
gnome-commander, because it wasn't possible before and I considered this as 
necessary for a file manager like gnome-commander.

While doing this I encountered a few problems:
1. Previously, in some cases when a directory was created it was displayed in 
the wrong directory (see bug description). This happens with the following 
command 'F7: ../testdir', this displays two times 'testdir' one in the current 
directory (after ctr+r this one dissappears) and the really created one in the 
parent directory. I think this has something to do with the function 
'gnome_cmd_dir_file_created' from 'gnome-cmd-dir.c'. My solution to this 
problem was to check whether the created directory is in the working directory 
(or active pane). 

2. Creating nested directories like 'F7: dir1/dir2' doesn't work yet. 
At first I thought this was an gnomevfs issue, because the function 
gnome_vfs_make_directory_for_uri creates only one directory at a time. To make 
this work I think path string must be split into multiple pathnames and call 
the function gnome_vfs_make_directory_for_uri for each directory.

What do you think of it?

koos


                
---------------------------------
 Copy addresses and emails from any email account to Yahoo! Mail - quick, easy 
and free. Do it now...
--- /home/koos/downloads/software_install/gnome-cmd-mkdir-dialog.c      
2007-01-22 18:32:22.000000000 +0100
+++ gnome-cmd-mkdir-dialog.c    2007-01-22 18:24:30.000000000 +0100
@@ -40,6 +40,7 @@
 {
     const gchar *filename = values[0];
 
+
     // dont create any directory if no name was passed or cancel was selected
     if (filename == NULL || *filename == 0)
     {
@@ -47,7 +48,16 @@
         return FALSE;
     }
 
-    GnomeVFSURI *uri = gnome_cmd_dir_get_child_uri (dialog->priv->dir, 
filename);
+       GnomeVFSURI *uri;
+
+       if (g_path_is_absolute (filename))
+       {               
+               gchar *uri_str = gnome_vfs_get_uri_from_local_path (filename);
+               uri = gnome_vfs_uri_new (uri_str);
+               g_free (uri_str);
+       } else {
+       uri = gnome_cmd_dir_get_child_uri (dialog->priv->dir, filename);
+       }
 
     GnomeVFSResult result = gnome_vfs_make_directory_for_uri (uri,
                                                               
GNOME_VFS_PERM_USER_READ|GNOME_VFS_PERM_USER_WRITE|GNOME_VFS_PERM_USER_EXEC|
@@ -56,10 +66,23 @@
     if (result == GNOME_VFS_OK)
     {
         gchar *uri_str = gnome_vfs_uri_to_string (uri, 0);
-        gnome_cmd_dir_file_created (dialog->priv->dir, uri_str);
-        g_free (uri_str);
+               gchar *uri_str_dirname = g_path_get_dirname (uri_str);
+               gchar *str_working_directory = gnome_cmd_dir_get_display_path 
(dialog->priv->dir);              
+               gchar *uri_str_working_directory = 
gnome_vfs_get_uri_from_local_path (str_working_directory);
+
+               if (g_strcasecmp (uri_str_dirname, uri_str_working_directory) 
== 0)
+               {
+                       if (g_path_is_absolute (filename))
+                               filename = g_path_get_basename (filename);
+                       gnome_cmd_dir_file_created (dialog->priv->dir, uri_str);
+                       gnome_cmd_file_list_focus_file 
(gnome_cmd_main_win_get_active_fs (main_win)->list, filename, TRUE);
+               }
+
+               g_free (uri_str);
+               g_free (uri_str_dirname);
+               g_free (str_working_directory);
+               g_free (uri_str_working_directory);
 
-        gnome_cmd_file_list_focus_file (gnome_cmd_main_win_get_active_fs 
(main_win)->list, filename, TRUE);
         gnome_cmd_dir_unref (dialog->priv->dir);
         gnome_vfs_uri_unref (uri);
         return TRUE;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]