[PATCH] Add DnD files onto archiver files with help of file-roller
- From: Nelson Benítez <gnel cenobioracing com>
- To: nautilus-list gnome org
- Subject: [PATCH] Add DnD files onto archiver files with help of file-roller
- Date: Sun, 19 Nov 2006 22:53:14 +0000
Hi, please see http://bugs.gnome.org/377157 for details and also a
screencast of the feature. I also attach patch here.
Index: libnautilus-private/nautilus-dnd.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-dnd.c,v
retrieving revision 1.22
diff -p -u -r1.22 nautilus-dnd.c
--- libnautilus-private/nautilus-dnd.c 28 Jul 2005 12:26:17 -0000 1.22
+++ libnautilus-private/nautilus-dnd.c 6 Aug 2006 23:22:10 -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>
@@ -368,6 +369,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_LINK;
+ 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.7
diff -p -u -r1.7 nautilus-file-dnd.c
--- libnautilus-private/nautilus-file-dnd.c 12 Dec 2005 16:59:10 -0000 1.7
+++ libnautilus-private/nautilus-file-dnd.c 6 Aug 2006 23:22:10 -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"
@@ -37,6 +38,7 @@ nautilus_drag_can_accept_item (NautilusF
nautilus_drag_can_accept_files (NautilusFile *drop_target_item)
{
NautilusDirectory *directory;
+ char *uri;
if (nautilus_file_is_directory (drop_target_item)) {
gboolean res;
@@ -66,6 +68,13 @@ nautilus_drag_can_accept_item (NautilusF
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.128
diff -p -u -r1.128 nautilus-file-utilities.c
--- libnautilus-private/nautilus-file-utilities.c 12 Dec 2005 16:59:10 -0000 1.128
+++ libnautilus-private/nautilus-file-utilities.c 6 Aug 2006 23:22:11 -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)
@@ -581,6 +593,24 @@ nautilus_get_uri_shortname_for_display (
}
return name;
+}
+
+gboolean
+nautilus_is_archiver_file (const char *uri)
+{
+ int i,tot;
+ 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++) {
+ if (g_strrstr (uri, archivers[i]) != NULL) {
+ 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.58
diff -p -u -r1.58 nautilus-file-utilities.h
--- libnautilus-private/nautilus-file-utilities.h 12 Dec 2005 16:59:10 -0000 1.58
+++ libnautilus-private/nautilus-file-utilities.h 6 Aug 2006 23:22:11 -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: libnautilus-private/nautilus-icon-dnd.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-icon-dnd.c,v
retrieving revision 1.150
diff -p -u -r1.150 nautilus-icon-dnd.c
--- libnautilus-private/nautilus-icon-dnd.c 19 Sep 2005 09:59:50 -0000 1.150
+++ libnautilus-private/nautilus-icon-dnd.c 6 Aug 2006 23:22:20 -0000
@@ -1072,6 +1072,33 @@ nautilus_icon_container_receive_dropped_
if (local_move_only) {
handle_local_move (container, world_x, world_y);
+ } else if (context->action == GDK_ACTION_LINK && nautilus_is_archiver_file (drop_target)) {
+ //file-roller only handles local files (no gnomevfs support yet)
+ if (g_str_has_prefix (drop_target,"file://") &&
+ g_str_has_prefix (((NautilusDragSelectionItem *)
+ container->details->dnd_info->drag_info.selection_list->data)->uri,"file://")) {
+ GList *p;
+ char *command, *tmp, *tmp2, *tmp3;
+ tmp = gnome_vfs_get_local_path_from_uri (drop_target);
+ tmp2 = g_shell_quote (tmp);
+ command = g_strconcat ("file-roller -a ", tmp2, NULL);
+ g_free (tmp);
+ g_free (tmp2);
+ for (p = container->details->dnd_info->drag_info.selection_list; p;p = p->next) {
+ tmp = gnome_vfs_get_local_path_from_uri (
+ ((NautilusDragSelectionItem *) p->data)->uri);
+ 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 (container)));
+ g_free (command);
+ }
} else {
handle_nonlocal_move (container, context, world_x, world_y, drop_target, icon_hit);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]