double-click on scripts behaviour



Hi,

Because of the switch to shared mime info, when the user double clicks
on an executable shell (or python, or perl) script, the dialog asking
whether the user wants to edit it, or run it is no longer displayed.
This happens because nautilus displays this dialog when it encounters a
text/xxx executable file, but in the shared mime database, most scripts
have an application/xxx mime type.
The attached patch special cases the various scripts mime types I could
find so that the dialog properly appears, but I'm not sure hard coding
these mime types in nautilus is the best way to do that. Maybe the
various scripts should be moved from application/xxx to test/xxx in the
shared mime database (incidentally, there's already a text/x-ksh for ksh
scripts, this should be made consistent with the other scripts mime
types somehow).

Thoughts?

Christophe
? nautilus.diff
? libnautilus-extension/Makefile
? libnautilus-extension/Makefile.in
? libnautilus-extension/libnautilus-extension.pc
Index: libnautilus-private/nautilus-file.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file.c,v
retrieving revision 1.345
diff -u -r1.345 nautilus-file.c
--- libnautilus-private/nautilus-file.c	31 Mar 2004 09:24:55 -0000	1.345
+++ libnautilus-private/nautilus-file.c	23 Apr 2004 12:48:40 -0000
@@ -5182,6 +5182,19 @@
 gboolean
 nautilus_file_contains_text (NautilusFile *file)
 {
+	/* FIXME: the shared mime db uses text/x-ksh while all the other
+	   scripts are application/xxx
+	*/
+	const gchar *script_mime_types[] = {
+		"application/x-shellscript", 
+		"application/x-csh",
+		"application/x-python",
+		"application/x-perl",
+		"application/x-ruby",
+		NULL
+	};
+	const gchar **it;
+
 	if (file == NULL) {
 		return FALSE;
 	}
@@ -5191,7 +5204,11 @@
 	if (file->details->info == NULL || file->details->info->mime_type == NULL) {
 		return FALSE;
 	}
-
+	for (it = script_mime_types; *it != NULL; it++) {
+		if (strcmp (file->details->info->mime_type, *it) == 0) {
+			return TRUE;
+		}
+	}
 	return eel_istr_has_prefix (file->details->info->mime_type, "text/");
 }
 

Attachment: signature.asc
Description: Ceci est une partie de message =?ISO-8859-1?Q?num=E9riquement?= =?ISO-8859-1?Q?_sign=E9e?=



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