Re: 'show properties' for launchers + PATCH



> The patch got lost in the Gnome 1 -> 2 move, but I can clean it up and
> resubmit it, if anyone is interested.

Cleaned up patch against current CVS is attached. This lets me rename
.desktop files on my desktop.

Doesn't work for the applications:/// URI -- I assume that's because
that vfs method is still broken. For any name I enter I get a message
box saying the name is invalid.

- Frank
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/nautilus/ChangeLog,v
retrieving revision 1.5293
diff -u -r1.5293 ChangeLog
--- ChangeLog	13 May 2002 22:11:55 -0000	1.5293
+++ ChangeLog	14 May 2002 03:38:05 -0000
@@ -1,3 +1,12 @@
+2002-05-13  Frank Worsley  <fworsley shaw ca>
+
+	* libnautilus-private/nautilus-file.c:
+	enable renaming of .desktop files by setting the Name
+	attribute within the .desktop file
+
+	* libnautilus-private/nautilus-link-desktop-file.c:
+	added nautilus_link_desktop_file_local_set_text
+
 2002-05-10  David Emory Watson  <dwatson cs ucr edu>
 
 	* src/file-manager/fm-list-view.c:
Index: libnautilus-private/nautilus-file.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file.c,v
retrieving revision 1.288
diff -u -r1.288 nautilus-file.c
--- libnautilus-private/nautilus-file.c	11 May 2002 23:53:49 -0000	1.288
+++ libnautilus-private/nautilus-file.c	14 May 2002 03:38:06 -0000
@@ -34,6 +34,7 @@
 #include "nautilus-global-preferences.h"
 #include "nautilus-lib-self-check-functions.h"
 #include "nautilus-link.h"
+#include "nautilus-link-desktop-file.h"
 #include "nautilus-metadata.h"
 #include "nautilus-trash-directory.h"
 #include "nautilus-trash-file.h"
@@ -754,7 +755,8 @@
 		return FALSE;
 	}
 
-	if (nautilus_file_is_mime_type (file, "application/x-gnome-app-info")) {
+	if (nautilus_file_is_mime_type (file, "application/x-gnome-app-info")
+	    && !nautilus_file_is_local (file)) {
 		return FALSE;
 	}
 	
@@ -971,6 +973,9 @@
 	Operation *op;
 	GnomeVFSFileInfo *partial_file_info;
 	GnomeVFSURI *vfs_uri;
+	char *uri;
+	char *path;
+	gboolean success;
 
 	g_return_if_fail (NAUTILUS_IS_FILE (file));
 	g_return_if_fail (new_name != NULL);
@@ -1018,6 +1023,37 @@
 		nautilus_file_changed (file);
 		(* callback) (file, GNOME_VFS_ERROR_NOT_SUPPORTED, callback_data);
 		return;
+	}
+	
+	if (nautilus_file_is_mime_type (file, "application/x-gnome-app-info")) {
+		
+		if (!nautilus_file_is_local (file)) {
+			/* don't want to rename non-local desktop files */
+			(* callback) (file, GNOME_VFS_ERROR_NOT_PERMITTED, callback_data);
+			return;
+		}
+		
+		uri = nautilus_file_get_uri (file);
+		path = gnome_vfs_get_local_path_from_uri (uri);
+		g_free (uri);           
+               
+		if (path != NULL) {
+			success = nautilus_link_desktop_file_local_set_text (path, new_name);
+			g_free (path);
+
+			if (success) {
+				nautilus_file_changed (file);
+				(* callback) (file, GNOME_VFS_OK, callback_data);
+				return;
+			} else {
+				(* callback) (file, GNOME_VFS_ERROR_GENERIC, callback_data);
+				return;
+			}
+		} else {
+			/* null path must mean there's no local path */
+			(* callback) (file, GNOME_VFS_ERROR_NOT_PERMITTED, callback_data);
+			return;
+		}
 	}
 
 	/* Set up a renaming operation. */
Index: libnautilus-private/nautilus-link-desktop-file.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-link-desktop-file.c,v
retrieving revision 1.15
diff -u -r1.15 nautilus-link-desktop-file.c
--- libnautilus-private/nautilus-link-desktop-file.c	2 May 2002 20:38:41 -0000	1.15
+++ libnautilus-private/nautilus-link-desktop-file.c	14 May 2002 03:38:06 -0000
@@ -178,6 +178,25 @@
 	return success;
 }
 
+gboolean
+nautilus_link_desktop_file_local_set_text (const char *path,
+					   const char *text)
+{
+	GnomeDesktopItem *desktop_file;
+	gboolean success;
+
+	desktop_file = gnome_desktop_item_new_from_file (path, 0, NULL);
+	if (desktop_file == NULL) {
+		return FALSE;
+	}
+
+	gnome_desktop_item_set_localestring (desktop_file, "Name", text);
+	success = gnome_desktop_item_save (desktop_file, NULL, FALSE, NULL);
+	gnome_desktop_item_unref (desktop_file);
+	
+	return success;
+}
+
 char *
 nautilus_link_desktop_file_local_get_text (const char *path)
 {
Index: libnautilus-private/nautilus-link-desktop-file.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-link-desktop-file.h,v
retrieving revision 1.7
diff -u -r1.7 nautilus-link-desktop-file.h
--- libnautilus-private/nautilus-link-desktop-file.h	28 Mar 2002 04:02:44 -0000	1.7
+++ libnautilus-private/nautilus-link-desktop-file.h	14 May 2002 03:38:06 -0000
@@ -35,6 +35,8 @@
 									       NautilusLinkType  type);
 gboolean         nautilus_link_desktop_file_local_set_icon                    (const char       *path,
 									       const char       *icon_name);
+gboolean	 nautilus_link_desktop_file_local_set_text		      (const char	*path,
+									       const char	*text);
 char *           nautilus_link_desktop_file_local_get_text                    (const char       *path);
 char *           nautilus_link_desktop_file_local_get_additional_text         (const char       *path);
 NautilusLinkType nautilus_link_desktop_file_local_get_link_type               (const char       *path);


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