[Nautilus-list] patch to fix .desktop dnd
- From: jacob berkman <jacob ximian com>
- To: Nautilus <nautilus-list lists eazel com>
- Subject: [Nautilus-list] patch to fix .desktop dnd
- Date: 15 Feb 2002 14:07:01 -0500
this patch fixes dnd of .desktop files to nautilus. you will want my
previous patch so that it doesn't seg fault when you try to drop an
item.
also included is a small patch to fix launching with the new
gnome-terminal (profterm). i don't know if that code path actually gets
hit though (this was on the way to eventually fixing the real bug which
was in libgnome).
nautilus should probably switch to using GnomeDesktopItem rather than
NautilusDesktopFile, but i'll leave that for a later day.
jacob
--
Index: configure.in
===================================================================
RCS file: /cvs/gnome/nautilus/configure.in,v
retrieving revision 1.411
diff -u -r1.411 configure.in
--- configure.in 2002/02/12 00:55:36 1.411
+++ configure.in 2002/02/15 18:49:15
@@ -10,6 +10,7 @@
ESOUND_REQUIRED=0.2.23
GLIB_REQUIRED=1.3.10
GNOME_CANVAS_REQUIRED=1.105
+GNOME_DESKTOP_REQUIRED=1.5.9
GNOME_REQUIRED=1.105
GNOME_UI_REQUIRED=1.110.1
GNOME_VFS_REQUIRED=1.1
@@ -53,6 +54,7 @@
bonobo-activation-2.0 >= $BONOBO_ACTIVATION_REQUIRED \
eel-2.0 >= $EEL_REQUIRED \
glib-2.0 >= $GLIB_REQUIRED \
+ gnome-desktop-2.0 >= $GNOME_DESKTOP_REQUIRED \
gnome-vfs-2.0 >= $GNOME_VFS_REQUIRED \
gtk+-2.0 >= $GTK_REQUIRED \
libart-2.0 >= $ART_REQUIRED \
@@ -273,7 +275,7 @@
AC_SUBST(LIBNAUTILUS_IDL_INCLUDES)
dnl core nautilus (must list bonobo-activation and libbonobo because idldir does not respect "requires")
-CORE_MODULES="eel-2.0 librsvg-2.0 bonobo-activation-2.0 libbonobo-2.0 libbonoboui-2.0 esound $EXTRA_CORE_MODULES"
+CORE_MODULES="eel-2.0 librsvg-2.0 bonobo-activation-2.0 libbonobo-2.0 libbonoboui-2.0 esound gnome-desktop-2.0 $EXTRA_CORE_MODULES"
CORE_CFLAGS="`$PKG_CONFIG --cflags $CORE_MODULES`"
AC_SUBST(CORE_CFLAGS)
CORE_LIBS="`$PKG_CONFIG --libs $CORE_MODULES` $CDDA_LIBS $FAM_LIBS $LIBJPEG"
Index: libnautilus-private/nautilus-link-desktop-file.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-link-desktop-file.c,v
retrieving revision 1.8
diff -u -r1.8 nautilus-link-desktop-file.c
--- libnautilus-private/nautilus-link-desktop-file.c 2002/02/12 00:56:00 1.8
+++ libnautilus-private/nautilus-link-desktop-file.c 2002/02/15 18:49:15
@@ -491,25 +491,26 @@
}
-#if GNOME2_CONVERSION_COMPLETE
-
void
-nautilus_link_desktop_file_local_create_from_gnome_entry (GnomeDesktopEntry *entry,
+nautilus_link_desktop_file_local_create_from_gnome_entry (GnomeDesktopItem *entry,
const char *dest_path,
const GdkPoint *position)
{
char *uri;
GList dummy_list;
NautilusFileChangesQueuePosition item;
- GnomeDesktopEntry *new_entry;
- char *file_name;
+ GnomeDesktopItem *new_entry;
+ char *file_name, *location;
+ const char *name;
- new_entry = gnome_desktop_entry_copy (entry);
- g_free (new_entry->location);
- file_name = g_strdup_printf ("%s.desktop", entry->name);
- new_entry->location = nautilus_make_path (dest_path, file_name);
+ name = gnome_desktop_item_get_string (entry, GNOME_DESKTOP_ITEM_NAME);
+ file_name = g_strdup_printf ("%s.desktop", name);
+ location = nautilus_make_path (dest_path, file_name);
g_free (file_name);
- gnome_desktop_entry_save (new_entry);
+
+ new_entry = gnome_desktop_item_copy (entry);
+ gnome_desktop_item_save (new_entry, location, TRUE, NULL);
+ g_free (location);
uri = gnome_vfs_get_uri_from_local_path (dest_path);
dummy_list.data = uri;
@@ -530,7 +531,5 @@
nautilus_directory_schedule_position_set (&dummy_list);
}
- gnome_desktop_entry_free (new_entry);
+ gnome_desktop_item_unref (new_entry);
}
-
-#endif
Index: libnautilus-private/nautilus-link-desktop-file.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-link-desktop-file.h,v
retrieving revision 1.4
diff -u -r1.4 nautilus-link-desktop-file.h
--- libnautilus-private/nautilus-link-desktop-file.h 2001/10/30 00:26:25 1.4
+++ libnautilus-private/nautilus-link-desktop-file.h 2002/02/15 18:49:15
@@ -27,8 +27,8 @@
#include "nautilus-file.h"
#include <gdk/gdk.h>
+#include <libgnome/gnome-desktop-item.h>
-
gboolean nautilus_link_desktop_file_local_create (const char *directory_path,
const char *name,
const char *image,
@@ -50,11 +50,9 @@
int link_file_size);
char * nautilus_link_desktop_file_get_link_icon_given_file_contents (const char *link_file_contents,
int link_file_size);
-#if GNOME2_CONVERSION_COMPLETE
-void nautilus_link_desktop_file_local_create_from_gnome_entry (GnomeDesktopEntry *entry,
+void nautilus_link_desktop_file_local_create_from_gnome_entry (GnomeDesktopItem *entry,
const char *dest_path,
const GdkPoint *position);
-#endif
#endif /* NAUTILUS_LINK_DESKTOP_FILE_H */
Index: libnautilus-private/nautilus-link-historical.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-link-historical.c,v
retrieving revision 1.6
diff -u -r1.6 nautilus-link-historical.c
--- libnautilus-private/nautilus-link-historical.c 2002/02/12 00:56:00 1.6
+++ libnautilus-private/nautilus-link-historical.c 2002/02/15 18:49:16
@@ -388,63 +388,52 @@
return nautilus_link_historical_local_get_link_type (path) == NAUTILUS_LINK_TRASH;
}
-#if GNOME2_CONVERSION_COMPLETE
-
void
-nautilus_link_historical_local_create_from_gnome_entry (GnomeDesktopEntry *entry, const char *dest_path, const GdkPoint *position)
+nautilus_link_historical_local_create_from_gnome_entry (GnomeDesktopItem *entry, const char *dest_path, const GdkPoint *position)
{
- char *icon_name;
+ char *icon_name, *icon;
char *launch_string, *terminal_command;
- char *quoted, *arguments, *temp_str;
- int i;
+ const char *name, *arguments;
if (entry == NULL || dest_path == NULL) {
return;
}
- /* Extract arguments from exec array */
- arguments = NULL;
- for (i = 0; i < entry->exec_length; ++i) {
- quoted = eel_shell_quote (entry->exec[i]);
- if (arguments == NULL) {
- arguments = quoted;
- } else {
- temp_str = arguments;
- arguments = g_strconcat (arguments, " ", quoted, NULL);
- g_free (temp_str);
- g_free (quoted);
- }
- }
+ name = gnome_desktop_item_get_string (entry, GNOME_DESKTOP_ITEM_NAME);
+ arguments = gnome_desktop_item_get_string (entry, GNOME_DESKTOP_ITEM_EXEC);
- if (strcmp (entry->type, "Application") == 0) {
- if (entry->terminal) {
+ switch (gnome_desktop_item_get_entry_type (entry)) {
+ case GNOME_DESKTOP_ITEM_TYPE_APPLICATION:
+ if (gnome_desktop_item_get_boolean (entry, GNOME_DESKTOP_ITEM_TERMINAL)) {
terminal_command = eel_gnome_make_terminal_command (arguments);
launch_string = g_strconcat ("command:", terminal_command, NULL);
g_free (terminal_command);
} else {
launch_string = g_strconcat ("command:", arguments, NULL);
- }
- } else if (strcmp (entry->type, "URL") == 0) {
+ }
+ break;
+ case GNOME_DESKTOP_ITEM_TYPE_LINK:
launch_string = g_strdup (arguments);
- } else {
+ break;
+ default:
/* Unknown .desktop file type */
launch_string = NULL;
}
- if (entry->icon != NULL) {
- icon_name = eel_make_uri_from_half_baked_uri (entry->icon);
+
+ icon = gnome_desktop_item_get_icon (entry);
+ if (icon != NULL) {
+ icon_name = eel_make_uri_from_half_baked_uri (icon);
+ g_free (icon);
} else {
icon_name = g_strdup ("gnome-unknown.png");
}
if (launch_string != NULL) {
- nautilus_link_historical_local_create (dest_path, entry->name, icon_name,
+ nautilus_link_historical_local_create (dest_path, name, icon_name,
launch_string, position, NAUTILUS_LINK_GENERIC);
}
g_free (icon_name);
g_free (launch_string);
- g_free (arguments);
}
-
-#endif
Index: libnautilus-private/nautilus-link-historical.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-link-historical.h,v
retrieving revision 1.4
diff -u -r1.4 nautilus-link-historical.h
--- libnautilus-private/nautilus-link-historical.h 2001/10/30 00:26:25 1.4
+++ libnautilus-private/nautilus-link-historical.h 2002/02/15 18:49:16
@@ -28,6 +28,7 @@
#include "nautilus-file.h"
#include <gdk/gdk.h>
+#include <libgnome/gnome-desktop-item.h>
gboolean nautilus_link_historical_local_create (const char *directory_path,
const char *name,
@@ -52,10 +53,8 @@
char * nautilus_link_historical_get_link_icon_given_file_contents (const char *link_file_contents,
int link_file_size);
-#if GNOME2_CONVERSION_COMPLETE
-void nautilus_link_historical_local_create_from_gnome_entry (GnomeDesktopEntry *entry,
+void nautilus_link_historical_local_create_from_gnome_entry (GnomeDesktopItem *entry,
const char *dest_path,
const GdkPoint *position);
-#endif
#endif /* NAUTILUS_LINK_HISTORICAL_H */
Index: libnautilus-private/nautilus-link.c
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-link.c,v
retrieving revision 1.68
diff -u -r1.68 nautilus-link.c
--- libnautilus-private/nautilus-link.c 2002/02/12 00:56:00 1.68
+++ libnautilus-private/nautilus-link.c 2002/02/15 18:49:16
@@ -310,14 +310,10 @@
}
}
-#if GNOME2_CONVERSION_COMPLETE
-
void
-nautilus_link_local_create_from_gnome_entry (GnomeDesktopEntry *entry,
+nautilus_link_local_create_from_gnome_entry (GnomeDesktopItem *item,
const char *dest_path,
const GdkPoint *position)
{
- nautilus_link_desktop_file_local_create_from_gnome_entry (entry, dest_path, position);
+ nautilus_link_desktop_file_local_create_from_gnome_entry (item, dest_path, position);
}
-
-#endif
Index: libnautilus-private/nautilus-link.h
===================================================================
RCS file: /cvs/gnome/nautilus/libnautilus-private/nautilus-link.h,v
retrieving revision 1.21
diff -u -r1.21 nautilus-link.h
--- libnautilus-private/nautilus-link.h 2001/10/28 20:21:46 1.21
+++ libnautilus-private/nautilus-link.h 2002/02/15 18:49:16
@@ -28,6 +28,7 @@
#include "nautilus-file.h"
#include <gdk/gdk.h>
+#include <libgnome/gnome-desktop-item.h>
/* Link types */
typedef enum {
@@ -111,10 +112,8 @@
char * nautilus_link_get_link_icon_given_file_contents (const char *file_contents,
int link_file_size);
-#ifdef GNOME2_CONVERSION_COMPLETE
-void nautilus_link_local_create_from_gnome_entry (GnomeDesktopEntry *entry,
+void nautilus_link_local_create_from_gnome_entry (GnomeDesktopItem *item,
const char *dest_path,
const GdkPoint *position);
-#endif
#endif /* NAUTILUS_LINK_H */
Index: src/file-manager/fm-icon-view.c
===================================================================
RCS file: /cvs/gnome/nautilus/src/file-manager/fm-icon-view.c,v
retrieving revision 1.242
diff -u -r1.242 fm-icon-view.c
--- src/file-manager/fm-icon-view.c 2002/02/14 23:22:00 1.242
+++ src/file-manager/fm-icon-view.c 2002/02/15 18:49:16
@@ -45,6 +45,7 @@
#include <gtk/gtkwindow.h>
#include <libgnome/gnome-i18n.h>
#include <libgnome/gnome-config.h>
+#include <libgnome/gnome-desktop-item.h>
#include <libgnomevfs/gnome-vfs-ops.h>
#include <libgnomevfs/gnome-vfs-async-ops.h>
#include <libgnomevfs/gnome-vfs-uri.h>
@@ -2523,19 +2524,86 @@
gtk_widget_show (GTK_WIDGET (icon_container));
}
+/**
+ * stolen from gnome-vfs-uri.c.
+ *
+ * implements the gnome 1.x gnome_vfs_uri_list_extract_uris(), which
+ * returns a GList of char *uris.
+ **/
+static GList *
+vfs_uri_list_parse (const gchar* uri_list)
+{
+ /* Note that this is mostly very stolen from old libgnome/gnome-mime.c */
+
+ const gchar *p, *q;
+ gchar *retval;
+ GList *result = NULL;
+
+ g_return_val_if_fail (uri_list != NULL, NULL);
+
+ p = uri_list;
+
+ /* We don't actually try to validate the URI according to RFC
+ * 2396, or even check for allowed characters - we just ignore
+ * comments and trim whitespace off the ends. We also
+ * allow LF delimination as well as the specified CRLF.
+ */
+ while (p != NULL) {
+ if (*p != '#') {
+ while (g_ascii_isspace (*p))
+ p++;
+
+ q = p;
+ while ((*q != '\0')
+ && (*q != '\n')
+ && (*q != '\r'))
+ q++;
+
+ if (q > p) {
+ q--;
+ while (q > p
+ && g_ascii_isspace (*q))
+ q--;
+
+ retval = g_malloc (q - p + 2);
+ strncpy (retval, p, q - p + 1);
+ retval[q - p + 1] = '\0';
+
+ result = g_list_prepend (result, retval);
+ }
+ }
+ p = strchr (p, '\n');
+ if (p != NULL)
+ p++;
+ }
+
+ return g_list_reverse (result);
+}
+
+/**
+ * gnome_uri_list_free_strings:
+ * @list: A GList returned by gnome_uri_list_extract_uris() or gnome_uri_list_extract_filenames()
+ *
+ * Releases all of the resources allocated by @list.
+ *
+ * stolen from gnome-mime.c
+ */
static void
+uri_list_free_strings (GList *list)
+{
+ g_list_foreach (list, (GFunc)g_free, NULL);
+ g_list_free (list);
+}
+
+static void
icon_view_handle_uri_list (NautilusIconContainer *container, const char *item_uris,
GdkDragAction action, int x, int y, FMIconView *view)
{
-#if GNOME2_CONVERSION_COMPLETE
GList *uri_list;
-#endif
GList *node, *real_uri_list = NULL;
GnomeVFSURI *container_uri;
-#if GNOME2_CONVERSION_COMPLETE
- GnomeDesktopEntry *entry;
-#endif
+ GnomeDesktopItem *entry;
GdkPoint point;
char *uri;
char *local_path;
@@ -2593,8 +2661,7 @@
*/
all_local = TRUE;
n_uris = 0;
-#if GNOME2_CONVERSION_COMPLETE
- uri_list = gnome_vfs_uri_list_extract_uris (item_uris);
+ uri_list = vfs_uri_list_parse (item_uris);
for (node = uri_list; node != NULL; node = node->next) {
gchar *sanitized_uri;
@@ -2606,8 +2673,7 @@
all_local = FALSE;
n_uris++;
}
- gnome_vfs_uri_list_free_strings (uri_list);
-#endif
+ uri_list_free_strings (uri_list);
if (all_local == TRUE &&
(action == GDK_ACTION_COPY ||
@@ -2635,18 +2701,17 @@
uri = node->data;
local_path = gnome_vfs_get_local_path_from_uri (uri);
if (local_path != NULL) {
-#if GNOME2_CONVERSION_COMPLETE
- entry = gnome_desktop_entry_load (local_path);
+ entry = gnome_desktop_item_new_from_file (local_path, 0, NULL);
if (entry != NULL) {
/* FIXME: Handle name conflicts? */
nautilus_link_local_create_from_gnome_entry (entry, container_path, &point);
- gnome_desktop_entry_free (entry);
+ gnome_desktop_item_unref (entry);
}
g_free (local_path);
if (entry != NULL) {
continue;
+
}
-#endif
}
/* Make a link from the URI alone. Generate the file
@@ -2673,9 +2738,8 @@
g_free (container_path);
}
-#if GNOME2_CONVERSION_COMPLETE
- gnome_vfs_uri_list_free_strings (real_uri_list);
-#endif
+ uri_list_free_strings (real_uri_list);
+
gnome_vfs_uri_unref (container_uri);
g_free (container_uri_string);
Index: eel/eel-gnome-extensions.c
===================================================================
RCS file: /cvs/gnome/eel/eel/eel-gnome-extensions.c,v
retrieving revision 1.24
diff -u -r1.24 eel-gnome-extensions.c
--- eel/eel-gnome-extensions.c 2002/02/07 00:26:18 1.24
+++ eel/eel-gnome-extensions.c 2002/02/15 18:56:30
@@ -592,7 +592,7 @@
char *command;
guint i;
static const char *const commands[][3] = {
- { "gnome-terminal", "--start-factory-server --use-factory -x", "--login" },
+ { "gnome-terminal", "-e", "" },
{ "dtterm", "-e", "-ls" },
{ "nxterm", "-e", "-ls" },
{ "color-xterm", "-e", "-ls" },
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]