Re: [PATCH] Add DnD files onto archiver files with help of file-roller
- From: Nelson Benítez <gnel cenobioracing com>
- To: Nelson Benítez <gnel cenobioracing com>
- Cc: nautilus-list gnome org, Alexander Larsson <alexl redhat com>
- Subject: Re: [PATCH] Add DnD files onto archiver files with help of file-roller
- Date: Sat, 25 Nov 2006 23:15:06 +0000
Nelson Benítez escribió:
> Alexander Larsson escribió:
>> nautilus_is_archiver_file() is pretty weird, it looks for e.e.g "zip"
>> anywhere in a filename, not ".zip" at the end. Also we should probably
>> be using mimetypes, not extensions if possible.
>
> Now I added code so it looks for "zip" at the end of filename so now
> even 'photos.zip.backup' filename is not matched.
Sorry, now that should work as I stated. Patch attached.
Index: libnautilus-private/nautilus-dnd.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-dnd.c,v
retrieving revision 1.26
diff -p -u -r1.26 nautilus-dnd.c
--- libnautilus-private/nautilus-dnd.c 27 Jul 2006 21:58:41 -0000 1.26
+++ libnautilus-private/nautilus-dnd.c 25 Nov 2006 16:11:22 -0000
@@ -29,6 +29,7 @@
#include <config.h>
#include "nautilus-dnd.h"
+#include "nautilus-file-utilities.h"
#include "nautilus-program-choosing.h"
#include "nautilus-link.h"
#include <eel/eel-glib-extensions.h>
@@ -369,6 +370,9 @@ nautilus_drag_default_drop_action_for_ic
desktop_uri = nautilus_get_desktop_directory_uri ();
target_uri = gnome_vfs_uri_new (desktop_uri);
g_free (desktop_uri);
+ } else if (nautilus_is_archiver_file (target_uri_string)) {
+ *action = GDK_ACTION_COPY;
+ return;
} else {
target_uri = gnome_vfs_uri_new (target_uri_string);
}
Index: libnautilus-private/nautilus-file-dnd.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file-dnd.c,v
retrieving revision 1.9
diff -p -u -r1.9 nautilus-file-dnd.c
--- libnautilus-private/nautilus-file-dnd.c 27 Jul 2006 21:58:41 -0000 1.9
+++ libnautilus-private/nautilus-file-dnd.c 25 Nov 2006 16:11:22 -0000
@@ -25,6 +25,7 @@
#include <config.h>
#include "nautilus-file-dnd.h"
+#include "nautilus-file-utilities.h"
#include "nautilus-desktop-icon-file.h"
#include "nautilus-dnd.h"
@@ -36,6 +37,7 @@ static gboolean
nautilus_drag_can_accept_files (NautilusFile *drop_target_item)
{
NautilusDirectory *directory;
+ char *uri;
if (nautilus_file_is_directory (drop_target_item)) {
gboolean res;
@@ -61,6 +63,13 @@ nautilus_drag_can_accept_files (Nautilus
return TRUE;
}
+ uri = nautilus_file_get_uri (drop_target_item);
+
+ if (nautilus_is_archiver_file (uri)) {
+ g_free (uri);
+ return TRUE;
+ }
+ g_free (uri);
return FALSE;
}
Index: libnautilus-private/nautilus-file-utilities.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file-utilities.c,v
retrieving revision 1.135
diff -p -u -r1.135 nautilus-file-utilities.c
--- libnautilus-private/nautilus-file-utilities.c 19 Oct 2006 13:27:21 -0000 1.135
+++ libnautilus-private/nautilus-file-utilities.c 25 Nov 2006 16:11:22 -0000
@@ -49,6 +49,18 @@
#define LEGACY_DESKTOP_DIRECTORY_NAME ".gnome-desktop"
#define DEFAULT_DESKTOP_DIRECTORY_MODE (0755)
+#define FILE_ROLLER_SUPPORTED_ARCHIVERS "tar.gz",\
+ "tgz",\
+ "tar.bz2",\
+ "zip",\
+ "tar",\
+ "7z",\
+ "rar",\
+ "jar",\
+ "war",\
+ "ear",\
+ "arj"
+
char *
nautilus_compute_title_for_uri (const char *text_uri)
@@ -624,6 +636,29 @@ nautilus_get_uri_shortname_for_display (
}
return name;
+}
+
+gboolean
+nautilus_is_archiver_file (const char *uri)
+{
+ int i,tot;
+ char *p;
+ g_return_val_if_fail (uri != NULL, FALSE);
+
+ static const char* archivers [] = { FILE_ROLLER_SUPPORTED_ARCHIVERS };
+
+ tot = G_N_ELEMENTS (archivers);
+ for (i=0;i<tot;i++) {
+ p = g_strrstr (uri, archivers[i]);
+ if (p != NULL) {
+ if (strlen(p) == strlen(archivers[i])) {
+ //make sure the match is at the end, to not match e.g. 'photos.zip.backup'
+ return TRUE;
+ }
+ }
+ }
+
+ return FALSE;
}
#if !defined (NAUTILUS_OMIT_SELF_CHECK)
Index: libnautilus-private/nautilus-file-utilities.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-file-utilities.h,v
retrieving revision 1.61
diff -p -u -r1.61 nautilus-file-utilities.h
--- libnautilus-private/nautilus-file-utilities.h 8 Jul 2006 08:38:17 -0000 1.61
+++ libnautilus-private/nautilus-file-utilities.h 25 Nov 2006 16:11:22 -0000
@@ -46,6 +46,7 @@ gboolean nautilus_is_desktop_directory_f
gboolean nautilus_is_desktop_directory_escaped (char *escaped_dir);
gboolean nautilus_is_home_directory_file_escaped (char *escaped_dirname,
char *escaped_file);
+gboolean nautilus_is_archiver_file (const char *uri);
char * nautilus_get_gmc_desktop_directory (void);
char * nautilus_get_pixmap_directory (void);
Index: src/file-manager/fm-directory-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-directory-view.c,v
retrieving revision 1.753
diff -p -u -r1.753 fm-directory-view.c
--- src/file-manager/fm-directory-view.c 23 Nov 2006 13:57:01 -0000 1.753
+++ src/file-manager/fm-directory-view.c 25 Nov 2006 16:11:40 -0000
@@ -9569,6 +9496,31 @@ fm_directory_view_move_copy_items (const
if (eel_uri_is_trash (target_uri) && copy_action == GDK_ACTION_MOVE) {
trash_or_delete_files_common (view, item_uris, relative_item_points, FALSE);
+ } else if (copy_action == GDK_ACTION_COPY && nautilus_is_archiver_file (target_uri)) {
+ //file-roller only handles local files (no gnomevfs support yet)
+ if (g_str_has_prefix (target_uri,"file://") &&
+ g_str_has_prefix ((char *) item_uris->data,"file://")) {
+ GList *p;
+ char *command, *tmp, *tmp2, *tmp3;
+ tmp = gnome_vfs_get_local_path_from_uri (target_uri);
+ tmp2 = g_shell_quote (tmp);
+ command = g_strconcat ("file-roller -a ", tmp2, NULL);
+ g_free (tmp);
+ g_free (tmp2);
+ for (p = (GList *) item_uris; p != NULL; p = p->next) {
+ tmp = gnome_vfs_get_local_path_from_uri ((char *) p->data);
+ tmp2 = g_shell_quote (tmp);
+ tmp3 = g_strconcat (command, " ", tmp2, NULL);
+ g_free (command);
+ command = tmp3;
+ tmp3 = NULL;
+ g_free (tmp);
+ g_free (tmp2);
+ }
+ eel_gnome_shell_execute_on_screen (command,
+ gtk_widget_get_screen (GTK_WIDGET (view)));
+ g_free (command);
+ }
} else {
nautilus_file_operations_copy_move
(item_uris, relative_item_points,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]