[Nautilus-list] Request for merge : Mandrake patches



Hi all,

since Mandrake Linux 8.1 is finally out, I have now some time to try to
integrate Mdk patches in "official" nautilus sources..

I've attached all patches in this message and I'm waiting for our
comments/approval. 

These patches were done on the redhat-branch used in Rawhide. If you
thing some (or all) of theses patches should be merged, I'll redo them
for Nautilus CVS version..

Patch1 : nautilus-1.0.4-gmc.patch
I've already submitted this patch before but I didn't get any feedback.
In short, this patch add "support" for the desktop shell scripts used by
gmc when no ~/.gnome-desktop exists. This provides distributors a simple
way to configure icons to be put on standard desktop. This patch is
quite ugly and I'm wondering if I should try to replace this patch with
something like the copy of start-here.desktop in
src/nautilus-application.c but more generalised. It could be something
like copying content of $(datadir)/nautilus/default-desktop in user
desktop when run for the first time or when user has removed its
~/.gnome-desktop. It could be also used to locate icons more precisely :
our desktop/icon guy at Mandrake has already ask me how to specify
precise location for default icons (it is already available in KDE). For
the moment, I could only thing of copying a default
.nautilus-metafile.xml in desktop directory.

Patch2: nautilus-1.0.3-libnspr4.patch
I've also submit this patch already and Ramiro confirmed Ximian had a
similar one. We should try to integrate it and check it works on Redhat
system as well. This patch is used to build mozilla component when
libnspr4 is provided by a separate package than mozilla.

Patch3: nautilus-1.0.4-fs.patch
This patch adds support for JFS (this part of the patch was based on the
old version of nautilus-volume-monitor.c) and fixes mount error handling
(in short, we use LC_ALL=C locale before running mount to be able to
parse mount error message without any translation..

I plan to add supermount support in Nautilus as soon as we get a working
supermount implementation in Mandrake kernel :))

Patch4: nautilus-1.0.4-automount.patch
This is also a nautilus-volume-monitor patch. It prevent nautilus to
eject cd on automounted cdrom drives. Otherwise each time cd is auto
umounted, cdrom drive opens :((
I'm not sure of the #ifdef HAVE_SYS_MNTTAB_H part of the patch, since I
don't have any solaris system to test..

Patch5: nautilus-1.0.4-dynamic.patch

This is the most ugly patch I've done but I would really need your
review and I'd like to integrate it or something to get similar feature
:
In Mandrake Linux 8.1, we have implemented what we called "Dynamic
entries" which in fact are .desktop files which are created/destroyed
when devices are plugged/unplugged on the system (as an example, you
plug an USB Rio 500 and grio500 icon appears on our desktop. You unplug
it and it disappear). To add support in Nautilus, I've created a
desktop: url which is link to a NautilusMergedDirectory, which merges
$datadir/gnome/desktop and user desktop (the "dynamic" desktop files are
created by devfsd as root in $datadir/gnome/desktop). I had to do a lot
of little modification in nautilus since "desktop:/" was not recognized
everywhere as a good uri.. 

I'll be on vacations starting Wednesday for two weeks so don't be afraid
if I don't reply immediately :)

-- 
Frédéric Crozat
MandrakeSoft
--- nautilus-1.0.4/libnautilus-private/Makefile.am.gmc	Thu Aug 30 09:06:25 2001
+++ nautilus-1.0.4/libnautilus-private/Makefile.am	Thu Aug 30 09:06:29 2001
@@ -12,6 +12,7 @@
 	$(MEDUSA_CFLAGS) 				\
 	$(LIBRSVG_CFLAGS)				\
 	-DDATADIR=\""$(datadir)"\" 			\
+	-DLIBDIR="\"$(libdir)"\"			\
 	-DNAUTILUS_DATADIR=\""$(datadir)/nautilus"\" 	\
 	$(NULL)
 
--- nautilus-1.0.4/libnautilus-private/nautilus-file-utilities.c.gmc	Wed May  9 02:22:33 2001
+++ nautilus-1.0.4/libnautilus-private/nautilus-file-utilities.c	Thu Aug 30 09:07:58 2001
@@ -36,6 +36,9 @@
 #include <libgnomevfs/gnome-vfs-ops.h>
 #include <libgnomevfs/gnome-vfs-uri.h>
 #include <libgnomevfs/gnome-vfs-utils.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <dirent.h>
 
 #define NAUTILUS_USER_DIRECTORY_NAME ".nautilus"
 #define DEFAULT_NAUTILUS_DIRECTORY_MODE (0755)
@@ -144,6 +147,11 @@
 	} else {
 		desktop_directory = nautilus_get_gmc_desktop_directory ();
 		if (!g_file_exists (desktop_directory)) {
+  			struct dirent *dirent;
+  			DIR *dir;
+  			char * gmc_scripts_dir;
+  			struct stat st;
+
 			mkdir (desktop_directory, DEFAULT_DESKTOP_DIRECTORY_MODE);
 			/* FIXME bugzilla.eazel.com 1286: 
 			 * How should we handle the case where this mkdir fails? 
@@ -152,6 +160,49 @@
 			 * could be deleted after Nautilus was launched, and perhaps
 			 * there is some bad side-effect of not handling that case.
 			 */
+			/* let's initialize gmc desktop  */
+
+			gmc_scripts_dir = g_strdup (LIBDIR "/mc/desktop-scripts");
+			dir = opendir (gmc_scripts_dir);
+			if (dir) {
+				while ((dirent = readdir (dir)) != NULL) {
+					int len = strlen (dirent->d_name);
+					int links_extlen = strlen(".links");
+					char *fname;
+
+					fname = g_concat_dir_and_file (gmc_scripts_dir, dirent->d_name);
+					if (stat (fname, &st) < 0) {
+						g_free (fname);
+						continue;
+					}
+					if (S_ISDIR (st.st_mode)) {
+						g_free (fname);
+						continue;
+					}
+					if ((S_IXUSR & st.st_mode) || (S_IXGRP & st.st_mode) || (S_IXOTH & st.st_mode)) {
+				/* let's try running it */
+						char *command;
+
+						command = g_strconcat ("/bin/sh -c \"", fname, " --desktop-dir='", desktop_directory,"'\"", NULL);
+				
+						system (command);
+						g_free (command);
+						g_free (fname);
+						continue;
+					}
+
+					if (len < links_extlen){
+						g_free (fname);
+						continue;
+					}
+
+					if (strcmp (dirent->d_name + len - links_extlen, ".links")){
+						g_free (fname);
+						continue;
+					}
+				}
+			}
+			g_free(gmc_scripts_dir);
 		}
 	}
 
--- nautilus-1.0.3/configure.in.orig	Tue May  8 10:48:24 2001
+++ nautilus-1.0.3/configure.in	Wed May 23 15:12:23 2001
@@ -260,7 +260,7 @@
 	MOZILLA_COMPONENT_RPATH_FLAGS=-Wl,-rpath=$_mozilla_lib_place
 	dnl The '-I$_mozilla_include_place/nspr' is needed for Mozilla 0.9.x
 	dnl and is not used (yet harmless) by Mozilla 0.8.x
-	MOZILLA_COMPONENT_CFLAGS="-I$_mozilla_include_place -I$_mozilla_include_place/nspr -fno-rtti -fno-exceptions"
+	MOZILLA_COMPONENT_CFLAGS="`nspr-config --cflags` -I$_mozilla_include_place -fno-rtti -fno-exceptions"
 	MOZILLA_COMPONENT_LDFLAGS=-L$_mozilla_lib_place
 	MOZILLA_COMPONENT_LIBS="$_mozilla_gtk_moz_embed_libs \
 				$_mozilla_gtk_super_win_libs \
--- nautilus-1.0.4/libnautilus-private/nautilus-volume-monitor.c.fs	Mon Oct  1 17:39:28 2001
+++ nautilus-1.0.4/libnautilus-private/nautilus-volume-monitor.c	Mon Oct  1 17:39:28 2001
@@ -661,6 +661,7 @@
 	case NAUTILUS_VOLUME_EXT2:
 	case NAUTILUS_VOLUME_EXT3:
 	case NAUTILUS_VOLUME_FAT:
+	case NAUTILUS_VOLUME_JFS:
 	case NAUTILUS_VOLUME_HPFS:
 	case NAUTILUS_VOLUME_HSFS:
 	case NAUTILUS_VOLUME_MINIX:
@@ -696,6 +697,7 @@
 	case NAUTILUS_VOLUME_EXT2:
 	case NAUTILUS_VOLUME_EXT3:
 	case NAUTILUS_VOLUME_FAT:
+	case NAUTILUS_VOLUME_JFS:
 	case NAUTILUS_VOLUME_NFS:
 	case NAUTILUS_VOLUME_REISER:
 	case NAUTILUS_VOLUME_SMB:
@@ -814,6 +816,9 @@
 	case NAUTILUS_VOLUME_EXT3:
 		return make_volume_name_from_path (volume, _("Ext3 Volume"));
 
+	case NAUTILUS_VOLUME_JFS:
+		return make_volume_name_from_path (volume, _("JFS Volume"));
+
 	case NAUTILUS_VOLUME_FAT:
 	case NAUTILUS_VOLUME_VFAT:
 	case NAUTILUS_VOLUME_MSDOS:
@@ -897,6 +902,7 @@
 	case NAUTILUS_VOLUME_EXT2:
 	case NAUTILUS_VOLUME_EXT3:
 	case NAUTILUS_VOLUME_FAT:
+	case NAUTILUS_VOLUME_JFS:
 	case NAUTILUS_VOLUME_HPFS:
 	case NAUTILUS_VOLUME_MINIX:
 	case NAUTILUS_VOLUME_MSDOS:
@@ -1251,6 +1257,13 @@
 }
 
 static gboolean
+mount_volume_jfs_add (NautilusVolume *volume)
+{		
+	volume->volume_type = NAUTILUS_VOLUME_JFS;
+	return TRUE;
+}
+
+static gboolean
 mount_volume_udf_add (NautilusVolume *volume)
 {		
 	volume->volume_type = NAUTILUS_VOLUME_UDF;
@@ -1681,14 +1694,12 @@
 	is_floppy = strstr (mount_path, "floppy") != NULL;
 		
 	/* Determine a user readable message from the obscure pipe error */
-	/* Attention localizers: The strings being examined by strstr need to be identical
-	   to the errors returned to the terminal by mount. */
 	if (mount) {
-		if (strstr (detailed_msg, _("is write-protected, mounting read-only")) != NULL) {
+		if (strstr (detailed_msg, "is write-protected, mounting read-only") != NULL) {
 			/* This is not an error. Just an informative message from mount. */
 			return;
-		} else if ((strstr (detailed_msg, _("is not a valid block device")) != NULL) ||
-			   (strstr (detailed_msg, _("No medium found")) != NULL)) {
+		} else if ((strstr (detailed_msg, "is not a valid block device") != NULL) ||
+			   (strstr (detailed_msg, "No medium found") != NULL)) {
 			/* No media in drive */
 			if (is_floppy) {
 				/* Handle floppy case */
@@ -1699,7 +1710,7 @@
 				message = g_strdup_printf (_("Nautilus was unable to mount the volume. "
 							     "There is probably no media in the device."));
 			}
-		} else if (strstr (detailed_msg, _("wrong fs type, bad option, bad superblock on")) != NULL) {
+		} else if (strstr (detailed_msg, "wrong fs type, bad option, bad superblock on") != NULL) {
 			/* Unknown filesystem */
 			if (is_floppy) {
 				message = g_strdup_printf (_("Nautilus was unable to mount the floppy drive. "
@@ -1738,12 +1749,21 @@
 	MountThreadInfo *info;
 	info = arg;
 	
-	if (info != NULL) {	
+	if (info != NULL) {
+		gchar * old_locale;
 		open_error_pipe ();
+		
+		old_locale = g_getenv("LC_ALL");
+		putenv("LC_ALL=C");
 		file = popen (info->command, "r");
 		close_error_pipe (info->should_mount, info->mount_point);
 		pclose (file);
-		
+		if (old_locale) {
+			putenv(g_strdup_printf("LC_ALL=%s",old_locale));
+		}
+		else {
+			unsetenv("LC_ALL");
+		}
 		g_free (info->command);
 		g_free (info->mount_point);
 		g_free (info);
--- nautilus-1.0.4/libnautilus-private/nautilus-volume-monitor.h.fs	Mon Oct  1 17:39:28 2001
+++ nautilus-1.0.4/libnautilus-private/nautilus-volume-monitor.h	Mon Oct  1 17:40:47 2001
@@ -67,6 +67,7 @@
 	NAUTILUS_VOLUME_FAT,
 	NAUTILUS_VOLUME_HPFS,
 	NAUTILUS_VOLUME_HSFS,
+	NAUTILUS_VOLUME_JFS,
 	NAUTILUS_VOLUME_MINIX,
 	NAUTILUS_VOLUME_MSDOS,
 	NAUTILUS_VOLUME_NFS,
--- nautilus-1.0.4/libnautilus-private/nautilus-volume-monitor.c.orig	Fri Sep  7 17:14:24 2001
+++ nautilus-1.0.4/libnautilus-private/nautilus-volume-monitor.c	Thu Sep 13 16:12:59 2001
@@ -590,6 +590,64 @@
 
 #endif /* !SOLARIS_MNT */
 
+static gboolean 
+volume_is_automounted (const NautilusVolume *volume)
+{
+	FILE *file;
+	MountTableEntry *ent;
+	GList* autofs_list = NULL;
+	GList* p;
+	gboolean automounted = FALSE;
+	
+
+#ifdef HAVE_SYS_MNTTAB_H
+ 	MountTableEntry ent_storage;
+
+	file = setmntent (MOUNT_TABLE_PATH, "r");
+ 	if (file == NULL) {
+ 		return FALSE;
+ 	}
+ 
+ 	 /* Search for our device in the fstab */
+ 	ent = &ent_storage;
+	while (!getmntent (file, ent)) {
+		if (strstr (ent->mnt_fstype, "autofs") != NULL) {
+			g_list_append(autofs_list,g_strdup(ent->mnt_mountp));
+		}
+ 	}
+	fclose (file);
+
+#elif defined (HAVE_MNTENT_H)
+	file = setmntent (_PATH_MOUNTED, "r");
+	if (file == NULL) {
+		return FALSE;
+	}
+		
+	/* Search for our device in the fstab */
+	while ((ent = getmntent (file)) != NULL) {
+		if (strstr (ent->mnt_type, "autofs") != NULL) {
+			autofs_list = g_list_append(autofs_list,g_strdup(ent->mnt_dir));			
+		}
+	}
+	
+	endmntent(file);
+#else
+	ent = NULL;	
+	file = NULL;
+#endif
+	
+	for (p = autofs_list; p != NULL; p = p->next) {
+		if (strstr(volume->mount_path,p->data) != NULL) {
+			automounted = TRUE;
+			break;
+		}
+	}
+
+	eel_g_list_free_deep (autofs_list);
+	
+	return automounted;
+}
+
 char *
 nautilus_volume_monitor_get_volume_name (const NautilusVolume *volume)
 {
@@ -893,7 +951,9 @@
 	switch (volume->volume_type) {
 	case NAUTILUS_VOLUME_CDROM:
 	case NAUTILUS_VOLUME_HSFS:
-		pthread_create (&eject_thread, NULL, eject_device, g_strdup (volume->device_path));
+		if (!volume_is_automounted(volume)) {
+			pthread_create (&eject_thread, NULL, eject_device, g_strdup (volume->device_path));
+		}
 		break;
 
 	case NAUTILUS_VOLUME_AFFS:
--- nautilus-1.0.4/src/Nautilus_shell.oaf.in.dynamic	Thu Apr 12 01:16:47 2001
+++ nautilus-1.0.4/src/Nautilus_shell.oaf.in	Tue Sep 18 18:15:09 2001
@@ -24,6 +24,7 @@
   <oaf_attribute name="bonobo:additional_uri_schemes" type="stringv">
     <item value="gnome-trash"/>
     <item value="trash"/>
+    <item value="desktop"/>
   </oaf_attribute>
   <oaf_attribute name="nautilus:view_as_name" type="string" _value="Icons"/>
   <oaf_attribute name="nautilus:view_as_label" type="string" _value="View as Icons"/>
--- nautilus-1.0.4/src/nautilus-desktop-window.c.dynamic	Tue Sep 18 18:15:08 2001
+++ nautilus-1.0.4/src/nautilus-desktop-window.c	Tue Sep 18 18:15:09 2001
@@ -119,15 +119,12 @@
 void
 nautilus_desktop_window_update_directory (NautilusDesktopWindow *window)
 {
-	char *desktop_directory_path;
 	char *desktop_directory_uri;
 
 	g_assert (NAUTILUS_IS_DESKTOP_WINDOW (window));
+        
+        desktop_directory_uri = g_strdup("desktop:/");
 
-	desktop_directory_path = nautilus_get_desktop_directory ();
-	
-	desktop_directory_uri = gnome_vfs_get_uri_from_local_path (desktop_directory_path);
-	g_free (desktop_directory_path);
 	window->affect_desktop_on_next_location_change = TRUE;
 	nautilus_window_go_to (NAUTILUS_WINDOW (window), desktop_directory_uri);
 	g_free (desktop_directory_uri);
--- nautilus-1.0.4/src/nautilus-application.c.dynamic	Tue Sep 18 18:15:06 2001
+++ nautilus-1.0.4/src/nautilus-application.c	Tue Sep 18 18:15:09 2001
@@ -624,7 +624,7 @@
 		/* point to the Unix home folder */
 		eel_preferences_add_callback_while_alive (NAUTILUS_PREFERENCES_DESKTOP_IS_HOME_DIR,
 							       desktop_location_changed_callback,
-							       NULL,
+							       application,
 							       GTK_OBJECT (application));
 
 		/* CORBA C mapping doesn't allow NULL to be passed
@@ -776,8 +776,9 @@
 desktop_location_changed_callback (gpointer user_data)
 {
 	if (nautilus_application_desktop_window != NULL) {
-		nautilus_desktop_window_update_directory
-			(nautilus_application_desktop_window);
+		/* ugly hack since merged directory seems to prevent correct refresh */
+		nautilus_application_close_desktop ();
+		nautilus_application_open_desktop (NAUTILUS_APPLICATION(user_data));
 	}
 }
 
--- nautilus-1.0.4/libnautilus-private/nautilus-icon-dnd.c.dynamic	Tue Sep 18 18:15:08 2001
+++ nautilus-1.0.4/libnautilus-private/nautilus-icon-dnd.c	Tue Sep 18 19:53:02 2001
@@ -607,7 +607,11 @@
 		 */
 		result = eel_drag_items_in_trash (items);
 	} else {
-		result = eel_drag_items_local (container_uri_string, items);
+		if (eel_istr_has_prefix (container_uri_string, "desktop:")) {
+			result = nautilus_directory_contains_file(nautilus_directory_get("desktop:"),nautilus_file_get(((EelDragSelectionItem *)items->data)->uri));
+		} else {
+			result = eel_drag_items_local (container_uri_string, items);
+		}
 	}
 	g_free (container_uri_string);
 	
@@ -1062,9 +1066,15 @@
 			*non_default_action = 0;
 			return;
 		}
-		eel_drag_default_drop_action_for_icons (context, drop_target, 
-			container->details->dnd_info->drag_info.selection_list, 
-			default_action, non_default_action);
+		if (eel_istr_has_prefix (drop_target, "desktop:")) {
+			*default_action = GDK_ACTION_MOVE;
+			*non_default_action = GDK_ACTION_MOVE;
+		}
+		else {
+			eel_drag_default_drop_action_for_icons (context, drop_target, 
+								container->details->dnd_info->drag_info.selection_list, 
+								default_action, non_default_action);
+		}
 		g_free (drop_target);
 		break;
 
--- nautilus-1.0.4/libnautilus-private/nautilus-file-operations.c.dynamic	Tue Sep 18 18:15:08 2001
+++ nautilus-1.0.4/libnautilus-private/nautilus-file-operations.c	Tue Sep 18 20:41:18 2001
@@ -1709,6 +1709,8 @@
 	if (target_dir != NULL) {
 		if (eel_uri_is_trash (target_dir)) {
 			target_is_trash = TRUE;
+		} else if (eel_istr_has_prefix(target_dir,"desktop:")) {
+			target_dir_uri = gnome_vfs_uri_new (g_strconcat("file://",nautilus_get_desktop_directory(),NULL));
 		} else {
 			target_dir_uri = gnome_vfs_uri_new (target_dir);
 		}
@@ -2113,7 +2115,11 @@
 	eel_nullify_when_destroyed (&state->parent_view);
 
 	/* pass in the target directory and the new folder name as a destination URI */
-	parent_uri = gnome_vfs_uri_new (parent_dir);
+	if (eel_istr_has_prefix(parent_dir,"desktop:")) {
+		parent_uri = gnome_vfs_uri_new (g_strconcat("file://",nautilus_get_desktop_directory(),NULL));
+	} else {
+		parent_uri = gnome_vfs_uri_new (parent_dir);
+	}
 	/* localizers: the initial name of a new folder  */
 	uri = gnome_vfs_uri_append_file_name (parent_uri, _("untitled folder"));
 	target_uri_list = g_list_prepend (NULL, uri);
--- nautilus-1.0.4/libnautilus-private/nautilus-file.c.dynamic	Tue Sep 18 18:15:08 2001
+++ nautilus-1.0.4/libnautilus-private/nautilus-file.c	Tue Sep 18 18:15:09 2001
@@ -1569,7 +1569,7 @@
 	integer <<= 1;
 	integer |= !nautilus_file_can_read (file);
 	integer <<= 1;
-	integer |= !nautilus_file_can_write (file);
+	integer |= !nautilus_file_can_write (file) && !nautilus_file_is_in_desktop(file);
 	integer <<= 1;
 	integer |= nautilus_file_is_in_trash (file);
 
@@ -1586,7 +1586,7 @@
 		names = g_list_prepend
 			(names, g_strdup (NAUTILUS_FILE_EMBLEM_NAME_TRASH));
 	}
-	if (!nautilus_file_can_write (file)) {
+	if (!nautilus_file_can_write (file) && !nautilus_file_is_in_desktop(file)) {
 		names = g_list_prepend
 			(names, g_strdup (NAUTILUS_FILE_EMBLEM_NAME_CANT_WRITE));
 	}
@@ -2011,7 +2011,9 @@
 	/* This handles visiting other people's desktops, but it can arguably
 	 * be said that this might break and that we should lookup the passwd table.
 	 */
-	return strstr (file->details->directory->details->uri, "/.gnome-desktop") != NULL;
+
+	return ((strstr (file->details->directory->details->uri, "/.gnome-desktop") != NULL) 
+		|| (strstr (file->details->directory->details->uri, "/usr/share/gnome/desktop") != NULL)) ;
 }
 
 static gboolean
--- nautilus-1.0.4/libnautilus-private/nautilus-directory.c.dynamic	Tue Sep 18 18:15:08 2001
+++ nautilus-1.0.4/libnautilus-private/nautilus-directory.c	Tue Sep 18 18:15:09 2001
@@ -32,6 +32,7 @@
 #include "nautilus-file-utilities.h"
 #include "nautilus-global-preferences.h"
 #include "nautilus-lib-self-check-functions.h"
+#include "nautilus-merged-directory.h"
 #include "nautilus-metadata.h"
 #include "nautilus-metafile.h"
 #include "nautilus-trash-directory.h"
@@ -482,7 +483,14 @@
 	if (eel_uri_is_trash (uri)) {
 		directory = NAUTILUS_DIRECTORY (gtk_object_new (NAUTILUS_TYPE_TRASH_DIRECTORY, NULL));
 	} else {
-		directory = NAUTILUS_DIRECTORY (gtk_object_new (NAUTILUS_TYPE_VFS_DIRECTORY, NULL));
+		if (eel_istr_has_prefix (uri, "desktop:")) {
+			directory = NAUTILUS_DIRECTORY (gtk_object_new (NAUTILUS_TYPE_MERGED_DIRECTORY, NULL));
+			nautilus_merged_directory_add_real_directory(NAUTILUS_MERGED_DIRECTORY(directory),nautilus_directory_get(gnome_vfs_get_uri_from_local_path (nautilus_get_desktop_directory ())));
+			nautilus_merged_directory_add_real_directory(NAUTILUS_MERGED_DIRECTORY(directory),nautilus_directory_get("file://usr/share/gnome/desktop"));
+		}
+		else {
+			directory = NAUTILUS_DIRECTORY (gtk_object_new (NAUTILUS_TYPE_VFS_DIRECTORY, NULL));
+		}
 	}
 	gtk_object_ref (GTK_OBJECT (directory));
 	gtk_object_sink (GTK_OBJECT (directory));


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