Re: Drag'n drop of files on a launcher
- From: Frank Worsley <fworsley shaw ca>
- To: Dave Camp <dave ximian com>
- Cc: Anne et Bertrand <anneetbertrand wanadoo fr>, nautilus-list gnome org
- Subject: Re: Drag'n drop of files on a launcher
- Date: Fri, 26 Jul 2002 12:07:45 -0700
> Maybe this should only send APPEND_PATHS if all the uris have local
> paths?
Good call, updated patch attached. Ok to commit?
- Frank
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/nautilus/ChangeLog,v
retrieving revision 1.5460
diff -u -p -r1.5460 ChangeLog
--- ChangeLog 26 Jul 2002 00:45:58 -0000 1.5460
+++ ChangeLog 26 Jul 2002 19:08:35 -0000
@@ -1,3 +1,9 @@
+2002-07-26 Frank Worsley <fworsley shaw ca>
+
+ * libnautilus-private/nautilus-program-choosing.c:
+ (nautilus_launch_desktop_file): be smarter about
+ appending parameters as uris vs. paths
+
2002-07-25 Michael Meeks <michael ximian com>
* libnautilus-private/nautilus-icon-factory.c
Index: libnautilus-private/nautilus-program-choosing.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-program-choosing.c,v
retrieving revision 1.59
diff -u -p -r1.59 nautilus-program-choosing.c
--- libnautilus-private/nautilus-program-choosing.c 10 Jul 2002 18:54:07 -0000 1.59
+++ libnautilus-private/nautilus-program-choosing.c 26 Jul 2002 19:08:36 -0000
@@ -639,6 +639,7 @@ nautilus_launch_desktop_file (const char
{
GError *error;
GnomeDesktopItem *ditem;
+ GnomeDesktopItemLaunchFlags flags;
const char *command_string;
char *local_path, *message;
const GList *p;
@@ -681,23 +682,23 @@ nautilus_launch_desktop_file (const char
return;
}
+ /* count the number of uris with local paths */
+ count = 0;
+ total = g_list_length ((GList *) parameter_uris);
+ for (p = parameter_uris; p != NULL; p = p->next) {
+ local_path = gnome_vfs_get_local_path_from_uri ((const char *) p->data);
+ if (local_path != NULL) {
+ g_free (local_path);
+ count++;
+ }
+ }
+
/* check if this app only supports local files */
command_string = gnome_desktop_item_get_string (ditem, GNOME_DESKTOP_ITEM_EXEC);
if ((strstr (command_string, "%F") || strstr (command_string, "%f"))
&& !(strstr (command_string, "%U") || strstr (command_string, "%u"))
&& parameter_uris != NULL) {
- /* count the number of uris with local paths */
- count = 0;
- total = g_list_length ((GList *) parameter_uris);
- for (p = parameter_uris; p != NULL; p = p->next) {
- local_path = gnome_vfs_get_local_path_from_uri ((const char *) p->data);
- if (local_path != NULL) {
- g_free (local_path);
- count++;
- }
- }
-
if (count == 0) {
/* all files are non-local */
eel_show_error_dialog
@@ -721,9 +722,16 @@ nautilus_launch_desktop_file (const char
}
}
+ /* we append local paths only if all parameters are local */
+ if (count == total) {
+ flags = GNOME_DESKTOP_ITEM_LAUNCH_APPEND_PATHS;
+ } else {
+ flags = GNOME_DESKTOP_ITEM_LAUNCH_APPEND_URIS;
+ }
+
error = NULL;
gnome_desktop_item_launch (ditem, (GList *) parameter_uris,
- GNOME_DESKTOP_ITEM_LAUNCH_APPEND_URIS,
+ flags,
&error);
if (error != NULL) {
Index: libgnome-desktop/gnome-desktop-item.c
===================================================================
RCS file: /cvs/gnome/gnome-desktop/libgnome-desktop/gnome-desktop-item.c,v
retrieving revision 1.109
diff -u -p -r1.109 gnome-desktop-item.c
--- libgnome-desktop/gnome-desktop-item.c 12 Jul 2002 03:45:09 -0000 1.109
+++ libgnome-desktop/gnome-desktop-item.c 20 Jul 2002 02:45:05 -0000
@@ -1478,7 +1478,8 @@ ditem_execute (const GnomeDesktopItem *i
char **envp,
gboolean launch_only_one,
gboolean use_current_dir,
- gboolean append_uris,
+ gboolean append_uris,
+ gboolean append_paths,
GError **error)
{
char **real_argv;
@@ -1532,6 +1533,16 @@ ditem_execute (const GnomeDesktopItem *i
added_status = ADDED_ALL;
}
+ /* append_uris and append_paths are mutually exlusive */
+ if (launched == 0 && added_status == ADDED_NONE && append_paths) {
+ uris = stringify_files (args, FALSE, FALSE);
+ temp = g_strconcat (new_exec, " ", uris, NULL);
+ g_free (uris);
+ g_free (new_exec);
+ new_exec = temp;
+ added_status = ADDED_ALL;
+ }
+
if (launched > 0 && added_status == ADDED_NONE) {
g_free (new_exec);
break;
@@ -1649,7 +1660,7 @@ gnome_desktop_item_launch (const GnomeDe
}
/**
- * gnome_desktop_item_launch_wth_env:
+ * gnome_desktop_item_launch_with_env:
* @item: A desktop item
* @file_list: Files/URIs to launch this item with, can be %NULL
* @flags: FIXME
@@ -1736,6 +1747,7 @@ gnome_desktop_item_launch_with_env (cons
(flags & GNOME_DESKTOP_ITEM_LAUNCH_ONLY_ONE),
(flags & GNOME_DESKTOP_ITEM_LAUNCH_USE_CURRENT_DIR),
(flags & GNOME_DESKTOP_ITEM_LAUNCH_APPEND_URIS),
+ (flags & GNOME_DESKTOP_ITEM_LAUNCH_APPEND_PATHS),
error);
return ret;
Index: libgnome-desktop/gnome-desktop-item.h
===================================================================
RCS file: /cvs/gnome/gnome-desktop/libgnome-desktop/gnome-desktop-item.h,v
retrieving revision 1.45
diff -u -p -r1.45 gnome-desktop-item.h
--- libgnome-desktop/gnome-desktop-item.h 12 Jul 2002 03:45:09 -0000 1.45
+++ libgnome-desktop/gnome-desktop-item.h 20 Jul 2002 02:45:05 -0000
@@ -118,7 +118,9 @@ typedef enum {
/* Append the list of URIs to the command if no Exec
* parameter is specified, instead of launching the
* app without parameters. */
- GNOME_DESKTOP_ITEM_LAUNCH_APPEND_URIS = 1<<2
+ GNOME_DESKTOP_ITEM_LAUNCH_APPEND_URIS = 1<<2,
+ /* Same as above but instead append local paths */
+ GNOME_DESKTOP_ITEM_LAUNCH_APPEND_PATHS = 1<<3
} GnomeDesktopItemLaunchFlags;
typedef enum {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]