file-roller r2335 - in trunk: . src



Author: paobac
Date: Sun Jun 22 09:13:35 2008
New Revision: 2335
URL: http://svn.gnome.org/viewvc/file-roller?rev=2335&view=rev

Log:
2008-06-22  Paolo Bacchilega  <paobac svn gnome org>

	* src/main.c (register_commands): added comment that explains how the
	priority is assigned.
	
	* src/fr-archive.c (create_command_from_mime_type): give priority to 
	the commands that can read and write over commands that can only read 
	a specific file format.

Modified:
   trunk/ChangeLog
   trunk/src/fr-archive.c
   trunk/src/main.c

Modified: trunk/src/fr-archive.c
==============================================================================
--- trunk/src/fr-archive.c	(original)
+++ trunk/src/fr-archive.c	Sun Jun 22 09:13:35 2008
@@ -512,16 +512,23 @@
 		return FALSE;
 	
 	archive->is_compressed_file = FALSE;
+
+	/* try with the WRITE capability even when loading, this way we give
+	 * priority to the commands that can read and write over commands 
+	 * that can only read a specific file format. */
+		
+	requested_capabilities |= FR_COMMAND_CAP_READ_WRITE;	
+	if (! archive->can_create_compressed_file)
+		requested_capabilities |= FR_COMMAND_CAP_ARCHIVE_MANY_FILES;
+	command_type = get_command_type_from_mime_type (mime_type, requested_capabilities);
 	
-	if (loading) {
-		requested_capabilities |= FR_COMMAND_CAP_READ;
-	}
-	else {
-		requested_capabilities |= FR_COMMAND_CAP_WRITE;	
-		if (! archive->can_create_compressed_file)
-			requested_capabilities |= FR_COMMAND_CAP_ARCHIVE_MANY_FILES;
+	/* if no command was found and we are loading, remove the write 
+	 * capability and try again */
+	
+	if ((command_type == 0) && loading) {	
+		requested_capabilities ^= FR_COMMAND_CAP_WRITE;
+		command_type = get_command_type_from_mime_type (mime_type, requested_capabilities);
 	}
-	command_type = get_command_type_from_mime_type (mime_type, requested_capabilities);
 	
 	if (command_type == 0)
 		return FALSE;

Modified: trunk/src/main.c
==============================================================================
--- trunk/src/main.c	(original)
+++ trunk/src/main.c	Sun Jun 22 09:13:35 2008
@@ -510,6 +510,14 @@
 static void
 register_commands (void)
 {
+	/* The order here is important. Commands registered earlier have higher
+	 * priority; for example zip archives will be opened using 7Z instead 
+	 * of ZIP.  However commands that can read and write a file format
+	 * have higher priority over commands that can only read the same 
+	 * format, regardless of the registration order; for example rar
+	 * archives will be opened with 7Z only if the rar utility is not 
+	 * installed because 7z cannot modify rar archives. */
+	 
 	register_command (FR_TYPE_COMMAND_TAR);
 	register_command (FR_TYPE_COMMAND_CFILE);
 	register_command (FR_TYPE_COMMAND_7Z);



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