[Nautilus-list] [PATCH] more desktop==home fixes



I've split the previous patch into two pieces and completed the changes
needed to allow nautilus to delete the home directory link when
desktop==home.

If possible, I would like to get the first of these into nautilus before
the GNOME 2 release.  patch-home-create is simple enough that I think we
can safely say it won't break anything.  patch-home-normal is more
complex because it involves some code cleanups -> it can probably wait
until after the release (unless someone more familiar with the nautilus
link code cares to review it).

patch-home-create:

2002-03-21  David Emory Watson  <dwatson cs ucr edu>

        * src/file-manager/fm-desktop-icon-view.c:
        (update_home_link_and_delete_copies): Don't recreate the home
        directory link when desktop==home.

patch-home-normal:

2002-03-22  David Emory Watson  <dwatson cs ucr edu>

        * src/file-manager/fm-directory-view.c: 
        (is_link_type_special): Move this into 

	* libnautilus-private/nautilus-link-desktop-file.h,
	libnautilus-private/nautilus-link-desktop-file.c:
	(nautilus_link_desktop_file_local_is_special_link): here and
	pretend that the home directory link is normal when 	desktop==home so
that the user can delete it.

	* src/file-manager/fm-directory-view.c:
	(special_link_in_selection): update.

	* libnautilus-private/nautilus-file-operations.c: 
	(is_special_link): update.
Index: src/file-manager/fm-desktop-icon-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-desktop-icon-view.c,v
retrieving revision 1.164
diff -p -u -r1.164 fm-desktop-icon-view.c
--- src/file-manager/fm-desktop-icon-view.c	7 Mar 2002 19:36:16 -0000	1.164
+++ src/file-manager/fm-desktop-icon-view.c	22 Mar 2002 18:13:51 -0000
@@ -879,7 +879,8 @@ update_home_link_and_delete_copies (void
 	
 	if (!update_link_and_delete_copies (nautilus_link_local_is_home_link,
 					    NULL,
-					    home_uri)) {
+					    home_uri)
+ 	    && !eel_preferences_get_boolean (NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR)) {
 		nautilus_link_local_create (desktop_directory,
 					    home_link_name,
 					    "desktop-home", 
Index: libnautilus-private/nautilus-file-operations.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file-operations.c,v
retrieving revision 1.149
diff -p -u -r1.149 nautilus-file-operations.c
--- libnautilus-private/nautilus-file-operations.c	1 Mar 2002 22:57:26 -0000	1.149
+++ libnautilus-private/nautilus-file-operations.c	22 Mar 2002 18:13:45 -0000
@@ -48,6 +48,7 @@
 #include "nautilus-file-changes-queue.h"
 #include "nautilus-global-preferences.h"
 #include "nautilus-link.h"
+#include "nautilus-link-desktop-file.h"
 #include "nautilus-trash-monitor.h"
 
 typedef enum {
@@ -981,19 +982,20 @@ is_special_link (const char *uri)
 	char *local_path;
 	gboolean is_special;
 
-	local_path = gnome_vfs_get_local_path_from_uri (uri);
-
 	/* FIXME: This should use some API to check if the file is a
 	 * link. Normally we use the MIME type. As things stand, this
 	 * will read files and try to parse them as XML, which could
 	 * result in a lot of output to the console, since the XML
 	 * parser reports errors directly there.
 	 */
-	is_special = local_path != NULL
-		&& nautilus_link_local_get_link_type (local_path) != NAUTILUS_LINK_GENERIC;
-	
+
+	local_path = gnome_vfs_get_local_path_from_uri (uri);
+	if (local_path == NULL) {
+		return FALSE;
+	}
+	is_special = nautilus_link_desktop_file_local_is_special_link (local_path);
 	g_free (local_path);
-	
+
 	return is_special;
 }
 
Index: libnautilus-private/nautilus-link-desktop-file.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-link-desktop-file.c,v
retrieving revision 1.13
diff -p -u -r1.13 nautilus-link-desktop-file.c
--- libnautilus-private/nautilus-link-desktop-file.c	1 Mar 2002 00:35:04 -0000	1.13
+++ libnautilus-private/nautilus-link-desktop-file.c	22 Mar 2002 18:13:46 -0000
@@ -31,12 +31,14 @@
 #include "nautilus-file-attributes.h"
 #include "nautilus-file-utilities.h"
 #include "nautilus-file.h"
+#include "nautilus-global-preferences.h"
 #include "nautilus-metadata.h"
 #include <eel/eel-glib-extensions.h>
 #include <eel/eel-gnome-extensions.h>
 #include <eel/eel-stock-dialogs.h>
 #include <eel/eel-string.h>
 #include <eel/eel-xml-extensions.h>
+#include <eel/eel-preferences.h>
 #include <libgnome/gnome-i18n.h>
 #include <libgnome/gnome-util.h>
 #include <libgnomevfs/gnome-vfs-utils.h>
@@ -253,6 +255,28 @@ gboolean
 nautilus_link_desktop_file_local_is_trash_link (const char *path)
 {
 	return (nautilus_link_desktop_file_local_get_link_type (path) ==  NAUTILUS_LINK_TRASH);
+}
+
+gboolean
+nautilus_link_desktop_file_local_is_special_link (const char *path)
+{
+	NautilusLinkType type;
+
+	type = nautilus_link_desktop_file_local_get_link_type (path);
+
+	switch (type) {
+	case NAUTILUS_LINK_HOME:
+		if (eel_preferences_get_boolean (NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR)) {
+ 			return FALSE;
+ 		}
+	case NAUTILUS_LINK_TRASH:
+	case NAUTILUS_LINK_MOUNT:
+		return TRUE;
+	case NAUTILUS_LINK_GENERIC:
+		return FALSE;
+	}
+
+	return FALSE;
 }
 
 static char *
Index: libnautilus-private/nautilus-link-desktop-file.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-link-desktop-file.h,v
retrieving revision 1.6
diff -p -u -r1.6 nautilus-link-desktop-file.h
--- libnautilus-private/nautilus-link-desktop-file.h	21 Feb 2002 19:26:46 -0000	1.6
+++ libnautilus-private/nautilus-link-desktop-file.h	22 Mar 2002 18:13:47 -0000
@@ -41,6 +41,7 @@ NautilusLinkType nautilus_link_desktop_f
 gboolean         nautilus_link_desktop_file_local_is_volume_link              (const char       *path);
 gboolean         nautilus_link_desktop_file_local_is_home_link                (const char       *path);
 gboolean         nautilus_link_desktop_file_local_is_trash_link               (const char       *path);
+gboolean         nautilus_link_desktop_file_local_is_special_link             (const char       *path);
 char *           nautilus_link_desktop_file_local_get_link_uri                (const char       *path);
 char *           nautilus_link_desktop_file_get_link_uri_given_file_contents  (const char       *uri,
 									       const char       *link_file_contents,
Index: src/file-manager/fm-directory-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-directory-view.c,v
retrieving revision 1.521
diff -p -u -r1.521 fm-directory-view.c
--- src/file-manager/fm-directory-view.c	18 Mar 2002 17:21:48 -0000	1.521
+++ src/file-manager/fm-directory-view.c	22 Mar 2002 18:14:05 -0000
@@ -69,6 +69,7 @@
 #include <libnautilus-private/nautilus-global-preferences.h>
 #include <libnautilus-private/nautilus-icon-factory.h>
 #include <libnautilus-private/nautilus-link.h>
+#include <libnautilus-private/nautilus-link-desktop-file.h>
 #include <libnautilus-private/nautilus-metadata.h>
 #include <libnautilus-private/nautilus-mime-actions.h>
 #include <libnautilus-private/nautilus-program-choosing.h>
@@ -2841,20 +2842,6 @@ fm_directory_link_type_in_selection (FMD
 	return saw_link;
 }
 
-static gboolean
-is_link_type_special (NautilusLinkType type)
-{
-	switch (type) {
-	case NAUTILUS_LINK_TRASH:
-	case NAUTILUS_LINK_HOME:
-	case NAUTILUS_LINK_MOUNT:
-		return TRUE;
-	case NAUTILUS_LINK_GENERIC:
-		return FALSE;
-	}
-	return FALSE;
-}
-
 /* special_link_in_selection
  * 
  * Return TRUE is one of our special links is the selection.
@@ -2885,7 +2872,7 @@ special_link_in_selection (FMDirectoryVi
 		/* FIXME: This reads the link file every single time. */
 		saw_link = path != NULL
 			&& nautilus_file_is_nautilus_link (file)
-			&& is_link_type_special (nautilus_link_local_get_link_type (path));
+			&& nautilus_link_desktop_file_local_is_special_link (path);
 		
 		g_free (path);
 		g_free (uri);


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