Blame SOURCES/0001-Revert-Remove-nautilus-extension.patch

e3fc0f
From 366a5147bd097a877d85295a36fb062213355a36 Mon Sep 17 00:00:00 2001
e3fc0f
From: Carlos Soriano <csoriano@gnome.org>
e3fc0f
Date: Wed, 1 Mar 2017 20:49:53 +0100
e3fc0f
Subject: [PATCH] Revert "Remove nautilus extension"
e3fc0f
e3fc0f
This reverts commit da09ee41ca7c9b63082cf2a35ae19701c34adca7.
e3fc0f
e3fc0f
Some of the main compressed archive formats are not still supported by
e3fc0f
libarchive, for example, RAR5.
e3fc0f
e3fc0f
This is a major issue for the Nautilus builtin compression handling, so
e3fc0f
for now, and until libarchive adds support for RAR5, let's enable the
e3fc0f
nautilus extension of file-roller for the "Extract here" menu item.
e3fc0f
e3fc0f
See https://github.com/libarchive/libarchive/issues/373 for libarchive
e3fc0f
support of RAR5.
e3fc0f
e3fc0f
https://bugzilla.gnome.org/show_bug.cgi?id=772765
e3fc0f
---
e3fc0f
 Makefile.am                    |   7 +
e3fc0f
 README                         |   1 +
e3fc0f
 configure.ac                   |  27 +++
e3fc0f
 nautilus/Makefile.am           |  23 +++
e3fc0f
 nautilus/fileroller-module.c   |  56 ++++++
e3fc0f
 nautilus/nautilus-fileroller.c | 447 +++++++++++++++++++++++++++++++++++++++++
e3fc0f
 nautilus/nautilus-fileroller.h |  51 +++++
e3fc0f
 po/POTFILES.in                 |   3 +
e3fc0f
 8 files changed, 615 insertions(+)
e3fc0f
 create mode 100644 nautilus/Makefile.am
e3fc0f
 create mode 100644 nautilus/fileroller-module.c
e3fc0f
 create mode 100644 nautilus/nautilus-fileroller.c
e3fc0f
 create mode 100644 nautilus/nautilus-fileroller.h
e3fc0f
e3fc0f
diff --git a/Makefile.am b/Makefile.am
e3fc0f
index a9acd51..0a21675 100644
e3fc0f
--- a/Makefile.am
e3fc0f
+++ b/Makefile.am
e3fc0f
@@ -1,9 +1,16 @@
e3fc0f
 ACLOCAL_AMFLAGS=-I m4 ${ACLOCAL_FLAGS}
e3fc0f
 
e3fc0f
+if ENABLE_NAUTILUS_ACTIONS
e3fc0f
+NAUTILUS = nautilus
e3fc0f
+else
e3fc0f
+NAUTILUS =
e3fc0f
+endif
e3fc0f
+
e3fc0f
 SUBDIRS =		\
e3fc0f
 	data		\
e3fc0f
 	src		\
e3fc0f
 	help		\
e3fc0f
+	$(NAUTILUS)	\
e3fc0f
 	po
e3fc0f
 
e3fc0f
 distcleancheck_listfiles = find . -type f -print | grep -v 'omf\.out'
e3fc0f
diff --git a/README b/README
e3fc0f
index 2b55dc9..1ce5348 100644
e3fc0f
--- a/README
e3fc0f
+++ b/README
e3fc0f
@@ -70,6 +70,7 @@
e3fc0f
   	* libgnome >= 2.6.0
e3fc0f
   	* libgnomeui >= 2.6.0
e3fc0f
         * libglade >= 2.4.0
e3fc0f
+        * libnautilus-extension >= 2.22.2 (optional)
e3fc0f
 
e3fc0f
 * Install
e3fc0f
 
e3fc0f
diff --git a/configure.ac b/configure.ac
e3fc0f
index 586ebcd..b096b60 100644
e3fc0f
--- a/configure.ac
e3fc0f
+++ b/configure.ac
e3fc0f
@@ -23,6 +23,7 @@ AC_PATH_PROG(GLIB_COMPILE_RESOURCES, glib-compile-resources)
e3fc0f
 GLIB_REQUIRED=2.36.0
e3fc0f
 GIO_REQUIRED=2.36.0
e3fc0f
 GTK_REQUIRED=3.13.2
e3fc0f
+NAUTILUS_REQUIRED=2.22.2
e3fc0f
 JSON_GLIB_REQUIRED=0.14.0
e3fc0f
 LIBNOTIFY_REQUIRED=0.4.3
e3fc0f
 LIBARCHIVE_REQUIRED=3.0.0
e3fc0f
@@ -97,6 +98,30 @@ AC_SUBST(FR_LIBS)
e3fc0f
 
e3fc0f
 dnl ******************************
e3fc0f
 dnl
e3fc0f
+dnl nautilus actions
e3fc0f
+dnl
e3fc0f
+AC_ARG_ENABLE([nautilus_actions],
e3fc0f
+	      [AS_HELP_STRING([--disable-nautilus-actions],
e3fc0f
+			      [do not build the nautilus context menu actions])],,
e3fc0f
+	      [enable_nautilus_actions=yes])
e3fc0f
+
e3fc0f
+if test x"$enable_nautilus_actions" != x"no" ; then
e3fc0f
+	PKG_CHECK_MODULES(NAUTILUS,					\
e3fc0f
+			  		  [libnautilus-extension >= $NAUTILUS_REQUIRED	\
e3fc0f
+			 		   glib-2.0					\
e3fc0f
+			  		   gio-2.0],
e3fc0f
+		  			  [enable_nautilus_actions=yes],
e3fc0f
+					  [enable_nautilus_actions=no])
e3fc0f
+	NAUTILUS_EXTENSION_DIR=`$PKG_CONFIG --variable=extensiondir libnautilus-extension`
e3fc0f
+fi
e3fc0f
+
e3fc0f
+AC_SUBST(NAUTILUS_CFLAGS)
e3fc0f
+AC_SUBST(NAUTILUS_LIBS)
e3fc0f
+AC_SUBST(NAUTILUS_EXTENSION_DIR)
e3fc0f
+AM_CONDITIONAL(ENABLE_NAUTILUS_ACTIONS, test x"$enable_nautilus_actions" != x"no")
e3fc0f
+
e3fc0f
+dnl ******************************
e3fc0f
+dnl
e3fc0f
 dnl json-glib-1.0
e3fc0f
 dnl
e3fc0f
 PKG_CHECK_MODULES(JSON_GLIB,
e3fc0f
@@ -278,6 +303,7 @@ AC_CONFIG_FILES([Makefile
e3fc0f
 		 src/commands/Makefile
e3fc0f
 		 src/sh/Makefile
e3fc0f
 		 src/ui/Makefile
e3fc0f
+		 nautilus/Makefile
e3fc0f
 		 help/Makefile
e3fc0f
 		 po/Makefile.in])
e3fc0f
 AC_OUTPUT
e3fc0f
@@ -293,6 +319,7 @@ Configuration:
e3fc0f
 	Disable deprecated code : ${disable_deprecated}
e3fc0f
 	Run in place            : ${enable_run_in_place}
e3fc0f
 	Internal mkdtemp        : ${mkdtemp_missing}
e3fc0f
+	Nautilus module         : ${enable_nautilus_actions}
e3fc0f
 	PackageKit support      : ${enable_packagekit}
e3fc0f
 	Use libmagic            : ${enable_magic}
e3fc0f
 	JSON support            : ${enable_json_glib}
e3fc0f
diff --git a/nautilus/Makefile.am b/nautilus/Makefile.am
e3fc0f
new file mode 100644
e3fc0f
index 0000000..55bb742
e3fc0f
--- /dev/null
e3fc0f
+++ b/nautilus/Makefile.am
e3fc0f
@@ -0,0 +1,23 @@
e3fc0f
+AM_CPPFLAGS =						\
e3fc0f
+	-DLOCALEDIR=\"$(localedir)\" 			\
e3fc0f
+	-I$(top_srcdir)					\
e3fc0f
+	-I$(top_builddir)				\
e3fc0f
+	$(DISABLE_DEPRECATED)				\
e3fc0f
+	$(NAUTILUS_CFLAGS)				\
e3fc0f
+	$(FR_CFLAGS)					\
e3fc0f
+	$(JSON_GLIB_CFLAGS)				\
e3fc0f
+	$(LIBNOTIFY_CFLAGS)
e3fc0f
+
e3fc0f
+nautilus_extensiondir=$(NAUTILUS_EXTENSION_DIR)
e3fc0f
+
e3fc0f
+nautilus_extension_LTLIBRARIES=libnautilus-fileroller.la
e3fc0f
+
e3fc0f
+libnautilus_fileroller_la_SOURCES =     \
e3fc0f
+	nautilus-fileroller.c           \
e3fc0f
+	nautilus-fileroller.h           \
e3fc0f
+	fileroller-module.c
e3fc0f
+
e3fc0f
+libnautilus_fileroller_la_LDFLAGS = -module -avoid-version -no-undefined
e3fc0f
+libnautilus_fileroller_la_LIBADD  = $(NAUTILUS_LIBS)
e3fc0f
+
e3fc0f
+-include $(top_srcdir)/git.mk
e3fc0f
diff --git a/nautilus/fileroller-module.c b/nautilus/fileroller-module.c
e3fc0f
new file mode 100644
e3fc0f
index 0000000..4a45750
e3fc0f
--- /dev/null
e3fc0f
+++ b/nautilus/fileroller-module.c
e3fc0f
@@ -0,0 +1,56 @@
e3fc0f
+/*
e3fc0f
+ *  File-Roller
e3fc0f
+ *
e3fc0f
+ *  Copyright (C) 2004 Free Software Foundation, Inc.
e3fc0f
+ *
e3fc0f
+ *  This library is free software; you can redistribute it and/or
e3fc0f
+ *  modify it under the terms of the GNU General Public
e3fc0f
+ *  License as published by the Free Software Foundation; either
e3fc0f
+ *  version 2 of the License, or (at your option) any later version.
e3fc0f
+ *
e3fc0f
+ *  This library is distributed in the hope that it will be useful,
e3fc0f
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
e3fc0f
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
e3fc0f
+ *  Library General Public License for more details.
e3fc0f
+ *
e3fc0f
+ *  You should have received a copy of the GNU General Public
e3fc0f
+ *  License along with this library; if not, write to the Free
e3fc0f
+ *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
e3fc0f
+ *
e3fc0f
+ *  Author: Paolo Bacchilega <paobac@cvs.gnome.org>
e3fc0f
+ *
e3fc0f
+ */
e3fc0f
+
e3fc0f
+#include <config.h>
e3fc0f
+#include <libnautilus-extension/nautilus-extension-types.h>
e3fc0f
+#include <libnautilus-extension/nautilus-column-provider.h>
e3fc0f
+#include <glib/gi18n-lib.h>
e3fc0f
+#include "nautilus-fileroller.h"
e3fc0f
+
e3fc0f
+
e3fc0f
+void
e3fc0f
+nautilus_module_initialize (GTypeModule*module)
e3fc0f
+{
e3fc0f
+	nautilus_fr_register_type (module);
e3fc0f
+
e3fc0f
+	bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
e3fc0f
+	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
e3fc0f
+}
e3fc0f
+
e3fc0f
+
e3fc0f
+void
e3fc0f
+nautilus_module_shutdown (void)
e3fc0f
+{
e3fc0f
+}
e3fc0f
+
e3fc0f
+
e3fc0f
+void
e3fc0f
+nautilus_module_list_types (const GType **types,
e3fc0f
+			    int          *num_types)
e3fc0f
+{
e3fc0f
+	static GType type_list[1];
e3fc0f
+
e3fc0f
+	type_list[0] = NAUTILUS_TYPE_FR;
e3fc0f
+	*types = type_list;
e3fc0f
+	*num_types = 1;
e3fc0f
+}
e3fc0f
diff --git a/nautilus/nautilus-fileroller.c b/nautilus/nautilus-fileroller.c
e3fc0f
new file mode 100644
e3fc0f
index 0000000..285c83d
e3fc0f
--- /dev/null
e3fc0f
+++ b/nautilus/nautilus-fileroller.c
e3fc0f
@@ -0,0 +1,447 @@
e3fc0f
+/*
e3fc0f
+ *  File-Roller
e3fc0f
+ *
e3fc0f
+ *  Copyright (C) 2004 Free Software Foundation, Inc.
e3fc0f
+ *
e3fc0f
+ *  This library is free software; you can redistribute it and/or
e3fc0f
+ *  modify it under the terms of the GNU General Public
e3fc0f
+ *  License as published by the Free Software Foundation; either
e3fc0f
+ *  version 2 of the License, or (at your option) any later version.
e3fc0f
+ *
e3fc0f
+ *  This library is distributed in the hope that it will be useful,
e3fc0f
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
e3fc0f
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
e3fc0f
+ *  Library General Public License for more details.
e3fc0f
+ *
e3fc0f
+ *  You should have received a copy of the GNU General Public
e3fc0f
+ *  License along with this library; if not, write to the Free
e3fc0f
+ *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
e3fc0f
+ *
e3fc0f
+ *  Author: Paolo Bacchilega <paobac@cvs.gnome.org>
e3fc0f
+ *
e3fc0f
+ */
e3fc0f
+
e3fc0f
+#include <config.h>
e3fc0f
+#include <string.h>
e3fc0f
+#include <glib/gi18n.h>
e3fc0f
+#include <gio/gio.h>
e3fc0f
+#include <libnautilus-extension/nautilus-extension-types.h>
e3fc0f
+#include <libnautilus-extension/nautilus-file-info.h>
e3fc0f
+#include <libnautilus-extension/nautilus-menu-provider.h>
e3fc0f
+#include "nautilus-fileroller.h"
e3fc0f
+
e3fc0f
+
e3fc0f
+static GObjectClass *parent_class;
e3fc0f
+
e3fc0f
+
e3fc0f
+static void
e3fc0f
+extract_to_callback (NautilusMenuItem *item,
e3fc0f
+		     gpointer          user_data)
e3fc0f
+{
e3fc0f
+	GList            *files;
e3fc0f
+	NautilusFileInfo *file;
e3fc0f
+	char             *uri, *default_dir;
e3fc0f
+	GString          *cmd;
e3fc0f
+
e3fc0f
+	files = g_object_get_data (G_OBJECT (item), "files");
e3fc0f
+	file = files->data;
e3fc0f
+
e3fc0f
+	uri = nautilus_file_info_get_uri (file);
e3fc0f
+	default_dir = nautilus_file_info_get_parent_uri (file);
e3fc0f
+
e3fc0f
+	cmd = g_string_new ("file-roller");
e3fc0f
+	g_string_append_printf (cmd,
e3fc0f
+				" --default-dir=%s --extract %s",
e3fc0f
+				g_shell_quote (default_dir),
e3fc0f
+				g_shell_quote (uri));
e3fc0f
+
e3fc0f
+#ifdef DEBUG
e3fc0f
+	g_print ("EXEC: %s\n", cmd->str);
e3fc0f
+#endif
e3fc0f
+
e3fc0f
+	g_spawn_command_line_async (cmd->str, NULL);
e3fc0f
+
e3fc0f
+	g_string_free (cmd, TRUE);
e3fc0f
+	g_free (default_dir);
e3fc0f
+	g_free (uri);
e3fc0f
+}
e3fc0f
+
e3fc0f
+
e3fc0f
+static void
e3fc0f
+extract_here_callback (NautilusMenuItem *item,
e3fc0f
+		       gpointer          user_data)
e3fc0f
+{
e3fc0f
+	GList            *files, *scan;
e3fc0f
+	NautilusFileInfo *file;
e3fc0f
+	char             *dir;
e3fc0f
+	GString          *cmd;
e3fc0f
+
e3fc0f
+	files = g_object_get_data (G_OBJECT (item), "files");
e3fc0f
+	file = files->data;
e3fc0f
+
e3fc0f
+	dir = nautilus_file_info_get_parent_uri (file);
e3fc0f
+
e3fc0f
+	cmd = g_string_new ("file-roller");
e3fc0f
+	g_string_append_printf (cmd," --extract-here --notify");
e3fc0f
+
e3fc0f
+	g_free (dir);
e3fc0f
+
e3fc0f
+	for (scan = files; scan; scan = scan->next) {
e3fc0f
+		NautilusFileInfo *file = scan->data;
e3fc0f
+		char             *uri;
e3fc0f
+
e3fc0f
+		uri = nautilus_file_info_get_uri (file);
e3fc0f
+		g_string_append_printf (cmd, " %s", g_shell_quote (uri));
e3fc0f
+		g_free (uri);
e3fc0f
+	}
e3fc0f
+
e3fc0f
+	g_spawn_command_line_async (cmd->str, NULL);
e3fc0f
+
e3fc0f
+#ifdef DEBUG
e3fc0f
+	g_print ("EXEC: %s\n", cmd->str);
e3fc0f
+#endif
e3fc0f
+
e3fc0f
+	g_string_free (cmd, TRUE);
e3fc0f
+}
e3fc0f
+
e3fc0f
+
e3fc0f
+static void
e3fc0f
+add_callback (NautilusMenuItem *item,
e3fc0f
+	      gpointer          user_data)
e3fc0f
+{
e3fc0f
+	GList            *files, *scan;
e3fc0f
+	NautilusFileInfo *file;
e3fc0f
+	char             *uri, *dir;
e3fc0f
+	GString          *cmd;
e3fc0f
+
e3fc0f
+	files = g_object_get_data (G_OBJECT (item), "files");
e3fc0f
+	file = files->data;
e3fc0f
+
e3fc0f
+	uri = nautilus_file_info_get_uri (file);
e3fc0f
+	dir = g_path_get_dirname (uri);
e3fc0f
+
e3fc0f
+	cmd = g_string_new ("file-roller");
e3fc0f
+	g_string_append (cmd, " --notify");
e3fc0f
+	g_string_append_printf (cmd," --default-dir=%s", g_shell_quote (dir));
e3fc0f
+	g_string_append (cmd," --add");
e3fc0f
+
e3fc0f
+	g_free (dir);
e3fc0f
+	g_free (uri);
e3fc0f
+
e3fc0f
+	for (scan = files; scan; scan = scan->next) {
e3fc0f
+		NautilusFileInfo *file = scan->data;
e3fc0f
+
e3fc0f
+		uri = nautilus_file_info_get_uri (file);
e3fc0f
+		g_string_append_printf (cmd, " %s", g_shell_quote (uri));
e3fc0f
+		g_free (uri);
e3fc0f
+	}
e3fc0f
+
e3fc0f
+	g_spawn_command_line_async (cmd->str, NULL);
e3fc0f
+
e3fc0f
+	g_string_free (cmd, TRUE);
e3fc0f
+}
e3fc0f
+
e3fc0f
+
e3fc0f
+static struct {
e3fc0f
+	char     *mime_type;
e3fc0f
+	gboolean  is_compressed;
e3fc0f
+} archive_mime_types[] = {
e3fc0f
+		{ "application/x-7z-compressed", TRUE },
e3fc0f
+		{ "application/x-7z-compressed-tar", TRUE },
e3fc0f
+		{ "application/x-ace", TRUE },
e3fc0f
+		{ "application/x-alz", TRUE },
e3fc0f
+		{ "application/x-ar", TRUE },
e3fc0f
+		{ "application/x-arj", TRUE },
e3fc0f
+		{ "application/x-bzip", TRUE },
e3fc0f
+		{ "application/x-bzip-compressed-tar", TRUE },
e3fc0f
+		{ "application/x-bzip1", TRUE },
e3fc0f
+		{ "application/x-bzip1-compressed-tar", TRUE },
e3fc0f
+		{ "application/vnd.ms-cab-compressed", TRUE },
e3fc0f
+		{ "application/x-cbr", TRUE },
e3fc0f
+		{ "application/x-cbz", TRUE },
e3fc0f
+		{ "application/x-cd-image", FALSE },
e3fc0f
+		{ "application/x-compress", TRUE },
e3fc0f
+		{ "application/x-compressed-tar", TRUE },
e3fc0f
+		{ "application/x-cpio", TRUE },
e3fc0f
+		{ "application/x-deb", TRUE },
e3fc0f
+		{ "application/vnd.debian.binary-package", TRUE },
e3fc0f
+		{ "application/x-ear", TRUE },
e3fc0f
+		{ "application/x-ms-dos-executable", FALSE },
e3fc0f
+		{ "application/x-gtar", FALSE },
e3fc0f
+		{ "application/x-gzip", TRUE },
e3fc0f
+		{ "application/x-gzpostscript", TRUE },
e3fc0f
+		{ "application/x-java-archive", TRUE },
e3fc0f
+		{ "application/x-lha", TRUE },
e3fc0f
+		{ "application/x-lhz", TRUE },
e3fc0f
+		{ "application/x-lzip", TRUE },
e3fc0f
+		{ "application/x-lzip-compressed-tar", TRUE },
e3fc0f
+		{ "application/x-lzma", TRUE },
e3fc0f
+		{ "application/x-lzma-compressed-tar", TRUE },
e3fc0f
+		{ "application/x-lzop", TRUE },
e3fc0f
+		{ "application/x-lzop-compressed-tar", TRUE },
e3fc0f
+		{ "application/x-ms-wim", TRUE },
e3fc0f
+		{ "application/x-rar", TRUE },
e3fc0f
+		{ "application/x-rar-compressed", TRUE },
e3fc0f
+		{ "application/x-rpm", TRUE },
e3fc0f
+		{ "application/x-rzip", TRUE },
e3fc0f
+		{ "application/x-tar", FALSE },
e3fc0f
+		{ "application/x-tarz", TRUE },
e3fc0f
+		{ "application/x-stuffit", TRUE },
e3fc0f
+		{ "application/x-war", TRUE },
e3fc0f
+		{ "application/x-xz", TRUE },
e3fc0f
+		{ "application/x-xz-compressed-tar", TRUE },
e3fc0f
+		{ "application/x-zip", TRUE },
e3fc0f
+		{ "application/x-zip-compressed", TRUE },
e3fc0f
+		{ "application/x-zoo", TRUE },
e3fc0f
+		{ "application/zip", TRUE },
e3fc0f
+		{ "multipart/x-zip", TRUE },
e3fc0f
+		{ NULL, FALSE }
e3fc0f
+};
e3fc0f
+
e3fc0f
+
e3fc0f
+typedef struct {
e3fc0f
+      gboolean is_archive;
e3fc0f
+      gboolean is_derived_archive;
e3fc0f
+      gboolean is_compressed_archive;
e3fc0f
+} FileMimeInfo;
e3fc0f
+
e3fc0f
+
e3fc0f
+static FileMimeInfo
e3fc0f
+get_file_mime_info (NautilusFileInfo *file)
e3fc0f
+{
e3fc0f
+	FileMimeInfo file_mime_info;
e3fc0f
+	int          i;
e3fc0f
+
e3fc0f
+	file_mime_info.is_archive = FALSE;
e3fc0f
+	file_mime_info.is_derived_archive = FALSE;
e3fc0f
+	file_mime_info.is_compressed_archive = FALSE;
e3fc0f
+
e3fc0f
+	for (i = 0; archive_mime_types[i].mime_type != NULL; i++)
e3fc0f
+		if (nautilus_file_info_is_mime_type (file, archive_mime_types[i].mime_type)) {
e3fc0f
+			char *mime_type;
e3fc0f
+			char *content_type_mime_file;
e3fc0f
+			char *content_type_mime_compare;
e3fc0f
+
e3fc0f
+			mime_type = nautilus_file_info_get_mime_type (file);
e3fc0f
+
e3fc0f
+			content_type_mime_file = g_content_type_from_mime_type (mime_type);
e3fc0f
+			content_type_mime_compare = g_content_type_from_mime_type (archive_mime_types[i].mime_type);
e3fc0f
+
e3fc0f
+			file_mime_info.is_archive = TRUE;
e3fc0f
+			file_mime_info.is_compressed_archive = archive_mime_types[i].is_compressed;
e3fc0f
+			if ((content_type_mime_file != NULL) && (content_type_mime_compare != NULL))
e3fc0f
+				file_mime_info.is_derived_archive = ! g_content_type_equals (content_type_mime_file, content_type_mime_compare);
e3fc0f
+
e3fc0f
+			g_free (mime_type);
e3fc0f
+			g_free (content_type_mime_file);
e3fc0f
+			g_free (content_type_mime_compare);
e3fc0f
+
e3fc0f
+			return file_mime_info;
e3fc0f
+		}
e3fc0f
+
e3fc0f
+	return file_mime_info;
e3fc0f
+}
e3fc0f
+
e3fc0f
+
e3fc0f
+static gboolean
e3fc0f
+unsupported_scheme (NautilusFileInfo *file)
e3fc0f
+{
e3fc0f
+	gboolean  result = FALSE;
e3fc0f
+	GFile    *location;
e3fc0f
+	char     *scheme;
e3fc0f
+
e3fc0f
+	location = nautilus_file_info_get_location (file);
e3fc0f
+	scheme = g_file_get_uri_scheme (location);
e3fc0f
+
e3fc0f
+	if (scheme != NULL) {
e3fc0f
+		const char *unsupported[] = { "trash", "computer", "x-nautilus-desktop", NULL };
e3fc0f
+		int         i;
e3fc0f
+
e3fc0f
+		for (i = 0; unsupported[i] != NULL; i++)
e3fc0f
+			if (strcmp (scheme, unsupported[i]) == 0)
e3fc0f
+				result = TRUE;
e3fc0f
+	}
e3fc0f
+
e3fc0f
+	g_free (scheme);
e3fc0f
+	g_object_unref (location);
e3fc0f
+
e3fc0f
+	return result;
e3fc0f
+}
e3fc0f
+
e3fc0f
+
e3fc0f
+static GList *
e3fc0f
+nautilus_fr_get_file_items (NautilusMenuProvider *provider,
e3fc0f
+			    GtkWidget            *window,
e3fc0f
+			    GList                *files)
e3fc0f
+{
e3fc0f
+	GList    *items = NULL;
e3fc0f
+	GList    *scan;
e3fc0f
+	gboolean  can_write = TRUE;
e3fc0f
+	gboolean  one_item;
e3fc0f
+	gboolean  one_archive = FALSE;
e3fc0f
+	gboolean  one_derived_archive = FALSE;
e3fc0f
+	gboolean  one_compressed_archive = FALSE;
e3fc0f
+	gboolean  all_archives = TRUE;
e3fc0f
+	gboolean  all_archives_derived = TRUE;
e3fc0f
+	gboolean  all_archives_compressed = TRUE;
e3fc0f
+
e3fc0f
+	if (files == NULL)
e3fc0f
+		return NULL;
e3fc0f
+
e3fc0f
+	for (scan = files; scan; scan = scan->next) {
e3fc0f
+		NautilusFileInfo *file = scan->data;
e3fc0f
+		FileMimeInfo      file_mime_info;
e3fc0f
+
e3fc0f
+		if (unsupported_scheme (file))
e3fc0f
+			return NULL;
e3fc0f
+
e3fc0f
+		file_mime_info = get_file_mime_info (file);
e3fc0f
+
e3fc0f
+		if (all_archives && ! file_mime_info.is_archive)
e3fc0f
+			all_archives = FALSE;
e3fc0f
+
e3fc0f
+		if (all_archives_compressed && file_mime_info.is_archive && ! file_mime_info.is_compressed_archive)
e3fc0f
+			all_archives_compressed = FALSE;
e3fc0f
+
e3fc0f
+		if (all_archives_derived && file_mime_info.is_archive && ! file_mime_info.is_derived_archive)
e3fc0f
+			all_archives_derived = FALSE;
e3fc0f
+
e3fc0f
+		if (can_write) {
e3fc0f
+			NautilusFileInfo *parent;
e3fc0f
+
e3fc0f
+			parent = nautilus_file_info_get_parent_info (file);
e3fc0f
+ 			can_write = nautilus_file_info_can_write (parent);
e3fc0f
+			g_object_unref (parent);
e3fc0f
+		}
e3fc0f
+	}
e3fc0f
+
e3fc0f
+	/**/
e3fc0f
+
e3fc0f
+	one_item = (files != NULL) && (files->next == NULL);
e3fc0f
+	one_archive = one_item && all_archives;
e3fc0f
+	one_derived_archive = one_archive && all_archives_derived;
e3fc0f
+	one_compressed_archive = one_archive && all_archives_compressed;
e3fc0f
+
e3fc0f
+	if (all_archives && can_write) {
e3fc0f
+		NautilusMenuItem *item;
e3fc0f
+
e3fc0f
+		item = nautilus_menu_item_new ("NautilusFr::extract_here",
e3fc0f
+					       g_dgettext ("file-roller", "Extract Here"),
e3fc0f
+					       /* Translators: the current position is the current folder */
e3fc0f
+					       g_dgettext ("file-roller", "Extract the selected archive to the current position"),
e3fc0f
+					       "drive-harddisk");
e3fc0f
+		g_signal_connect (item,
e3fc0f
+				  "activate",
e3fc0f
+				  G_CALLBACK (extract_here_callback),
e3fc0f
+				  provider);
e3fc0f
+		g_object_set_data_full (G_OBJECT (item),
e3fc0f
+					"files",
e3fc0f
+					nautilus_file_info_list_copy (files),
e3fc0f
+					(GDestroyNotify) nautilus_file_info_list_free);
e3fc0f
+
e3fc0f
+		items = g_list_append (items, item);
e3fc0f
+	}
e3fc0f
+	else if (all_archives && ! can_write) {
e3fc0f
+		NautilusMenuItem *item;
e3fc0f
+
e3fc0f
+		item = nautilus_menu_item_new ("NautilusFr::extract_to",
e3fc0f
+					       g_dgettext ("file-roller", "Extract To..."),
e3fc0f
+					       g_dgettext ("file-roller", "Extract the selected archive"),
e3fc0f
+					       "drive-harddisk");
e3fc0f
+		g_signal_connect (item,
e3fc0f
+				  "activate",
e3fc0f
+				  G_CALLBACK (extract_to_callback),
e3fc0f
+				  provider);
e3fc0f
+		g_object_set_data_full (G_OBJECT (item),
e3fc0f
+					"files",
e3fc0f
+					nautilus_file_info_list_copy (files),
e3fc0f
+					(GDestroyNotify) nautilus_file_info_list_free);
e3fc0f
+
e3fc0f
+		items = g_list_append (items, item);
e3fc0f
+
e3fc0f
+	}
e3fc0f
+
e3fc0f
+	if (! one_compressed_archive || one_derived_archive) {
e3fc0f
+		NautilusMenuItem *item;
e3fc0f
+
e3fc0f
+		item = nautilus_menu_item_new ("NautilusFr::add",
e3fc0f
+					       g_dgettext ("file-roller", "Compress..."),
e3fc0f
+					       g_dgettext ("file-roller", "Create a compressed archive with the selected objects"),
e3fc0f
+					       "gnome-mime-application-x-archive");
e3fc0f
+		g_signal_connect (item,
e3fc0f
+				  "activate",
e3fc0f
+				  G_CALLBACK (add_callback),
e3fc0f
+				  provider);
e3fc0f
+		g_object_set_data_full (G_OBJECT (item),
e3fc0f
+					"files",
e3fc0f
+					nautilus_file_info_list_copy (files),
e3fc0f
+					(GDestroyNotify) nautilus_file_info_list_free);
e3fc0f
+
e3fc0f
+		items = g_list_append (items, item);
e3fc0f
+	}
e3fc0f
+
e3fc0f
+	return items;
e3fc0f
+}
e3fc0f
+
e3fc0f
+
e3fc0f
+static void
e3fc0f
+nautilus_fr_menu_provider_iface_init (NautilusMenuProviderIface *iface)
e3fc0f
+{
e3fc0f
+	iface->get_file_items = nautilus_fr_get_file_items;
e3fc0f
+}
e3fc0f
+
e3fc0f
+
e3fc0f
+static void
e3fc0f
+nautilus_fr_instance_init (NautilusFr *fr)
e3fc0f
+{
e3fc0f
+}
e3fc0f
+
e3fc0f
+
e3fc0f
+static void
e3fc0f
+nautilus_fr_class_init (NautilusFrClass *class)
e3fc0f
+{
e3fc0f
+	parent_class = g_type_class_peek_parent (class);
e3fc0f
+}
e3fc0f
+
e3fc0f
+
e3fc0f
+static GType fr_type = 0;
e3fc0f
+
e3fc0f
+
e3fc0f
+GType
e3fc0f
+nautilus_fr_get_type (void)
e3fc0f
+{
e3fc0f
+	return fr_type;
e3fc0f
+}
e3fc0f
+
e3fc0f
+
e3fc0f
+void
e3fc0f
+nautilus_fr_register_type (GTypeModule *module)
e3fc0f
+{
e3fc0f
+	static const GTypeInfo info = {
e3fc0f
+		sizeof (NautilusFrClass),
e3fc0f
+		(GBaseInitFunc) NULL,
e3fc0f
+		(GBaseFinalizeFunc) NULL,
e3fc0f
+		(GClassInitFunc) nautilus_fr_class_init,
e3fc0f
+		NULL,
e3fc0f
+		NULL,
e3fc0f
+		sizeof (NautilusFr),
e3fc0f
+		0,
e3fc0f
+		(GInstanceInitFunc) nautilus_fr_instance_init,
e3fc0f
+	};
e3fc0f
+
e3fc0f
+	static const GInterfaceInfo menu_provider_iface_info = {
e3fc0f
+		(GInterfaceInitFunc) nautilus_fr_menu_provider_iface_init,
e3fc0f
+		NULL,
e3fc0f
+		NULL
e3fc0f
+	};
e3fc0f
+
e3fc0f
+	fr_type = g_type_module_register_type (module,
e3fc0f
+					       G_TYPE_OBJECT,
e3fc0f
+					       "NautilusFileRoller",
e3fc0f
+					       &info, 0);
e3fc0f
+
e3fc0f
+	g_type_module_add_interface (module,
e3fc0f
+				     fr_type,
e3fc0f
+				     NAUTILUS_TYPE_MENU_PROVIDER,
e3fc0f
+				     &menu_provider_iface_info);
e3fc0f
+}
e3fc0f
diff --git a/nautilus/nautilus-fileroller.h b/nautilus/nautilus-fileroller.h
e3fc0f
new file mode 100644
e3fc0f
index 0000000..df2ccb5
e3fc0f
--- /dev/null
e3fc0f
+++ b/nautilus/nautilus-fileroller.h
e3fc0f
@@ -0,0 +1,51 @@
e3fc0f
+/*
e3fc0f
+ *  File-Roller
e3fc0f
+ * 
e3fc0f
+ *  Copyright (C) 2004 Free Software Foundation, Inc.
e3fc0f
+ *
e3fc0f
+ *  This library is free software; you can redistribute it and/or
e3fc0f
+ *  modify it under the terms of the GNU General Public
e3fc0f
+ *  License as published by the Free Software Foundation; either
e3fc0f
+ *  version 2 of the License, or (at your option) any later version.
e3fc0f
+ *
e3fc0f
+ *  This library is distributed in the hope that it will be useful,
e3fc0f
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
e3fc0f
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
e3fc0f
+ *  Library General Public License for more details.
e3fc0f
+ *
e3fc0f
+ *  You should have received a copy of the GNU General Public
e3fc0f
+ *  License along with this library; if not, write to the Free
e3fc0f
+ *  Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
e3fc0f
+ *
e3fc0f
+ *  Author: Paolo Bacchilega <paobac@cvs.gnome.org>
e3fc0f
+ * 
e3fc0f
+ */
e3fc0f
+
e3fc0f
+#ifndef NAUTILUS_FILEROLLER_H
e3fc0f
+#define NAUTILUS_FILEROLLER_H
e3fc0f
+
e3fc0f
+#include <glib-object.h>
e3fc0f
+
e3fc0f
+G_BEGIN_DECLS
e3fc0f
+
e3fc0f
+#define NAUTILUS_TYPE_FR  (nautilus_fr_get_type ())
e3fc0f
+#define NAUTILUS_FR(o)    (G_TYPE_CHECK_INSTANCE_CAST ((o), NAUTILUS_TYPE_FR, NautilusFr))
e3fc0f
+#define NAUTILUS_IS_FR(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), NAUTILUS_TYPE_FR))
e3fc0f
+
e3fc0f
+typedef struct _NautilusFr      NautilusFr;
e3fc0f
+typedef struct _NautilusFrClass NautilusFrClass;
e3fc0f
+
e3fc0f
+struct _NautilusFr {
e3fc0f
+	GObject __parent;
e3fc0f
+};
e3fc0f
+
e3fc0f
+struct _NautilusFrClass {
e3fc0f
+	GObjectClass __parent;
e3fc0f
+};
e3fc0f
+
e3fc0f
+GType nautilus_fr_get_type      (void);
e3fc0f
+void  nautilus_fr_register_type (GTypeModule *module);
e3fc0f
+
e3fc0f
+G_END_DECLS
e3fc0f
+
e3fc0f
+#endif /* NAUTILUS_FILEROLLER_H */
e3fc0f
diff --git a/po/POTFILES.in b/po/POTFILES.in
e3fc0f
index f09b6a8..03282a8 100644
e3fc0f
--- a/po/POTFILES.in
e3fc0f
+++ b/po/POTFILES.in
e3fc0f
@@ -7,6 +7,9 @@
e3fc0f
 data/org.gnome.FileRoller.appdata.xml.in
e3fc0f
 data/org.gnome.FileRoller.desktop.in.in
e3fc0f
 [type: gettext/gsettings]data/org.gnome.FileRoller.gschema.xml
e3fc0f
+nautilus/fileroller-module.c
e3fc0f
+nautilus/nautilus-fileroller.c
e3fc0f
+nautilus/nautilus-fileroller.h
e3fc0f
 src/commands/rpm2cpio.c
e3fc0f
 src/dlg-add.c
e3fc0f
 src/dlg-add.h
e3fc0f
-- 
e3fc0f
1.8.3.1
e3fc0f