Commit ce097b2d authored by Gene Z. Ragan's avatar Gene Z. Ragan Committed by Gene Ragan
Browse files

Fixed bug 2212, Not able to drag icons from the panel.

2000-10-06  Gene Z. Ragan  <gzr@eazel.com>

	Fixed bug 2212, Not able to drag icons from the panel.

	* libnautilus-extensions/nautilus-icon-container.c:
	* libnautilus-extensions/nautilus-icon-container.h:
	(button_release_event), (nautilus_icon_container_initialize_class):
	Add a new signal to create symbolic links

	* libnautilus-extensions/nautilus-icon-dnd.c:
	(drag_data_received_callback), (receive_dropped_uri_list),
	(nautilus_icon_container_get_drop_action), (drag_motion_callback):
	Handle URI drags.

	* src/file-manager/fm-desktop-icon-view.c:
	(fm_desktop_icon_view_initialize), (create_link_callback),
	(icon_view_create_nautilus_links):
	Callbacks to handle the create_nautilus_links signal.  Create
	links from the data passed in the list using gnome-vfs async
	callback.

	* libnautilus-extensions/nautilus-program-choosing.c:
	(nautilus_launch_application_from_command):
	Quoted the command string in addition to the parameter.
parent 961728af
2000-10-06 Gene Z. Ragan <gzr@eazel.com>
Fixed bug 2212, Not able to drag icons from the panel.
* libnautilus-extensions/nautilus-icon-container.c:
* libnautilus-extensions/nautilus-icon-container.h:
(button_release_event), (nautilus_icon_container_initialize_class):
Add a new signal to create symbolic links
* libnautilus-extensions/nautilus-icon-dnd.c:
(drag_data_received_callback), (receive_dropped_uri_list),
(nautilus_icon_container_get_drop_action), (drag_motion_callback):
Handle URI drags.
* src/file-manager/fm-desktop-icon-view.c:
(fm_desktop_icon_view_initialize), (create_link_callback),
(icon_view_create_nautilus_links):
Callbacks to handle the create_nautilus_links signal. Create
links from the data passed in the list using gnome-vfs async
callback.
* libnautilus-extensions/nautilus-program-choosing.c:
(nautilus_launch_application_from_command):
Quoted the command string in addition to the parameter.
2000-10-05 Mike Fleming <mfleming@eazel.com>
* components/services/summary/nautilus-view/nautilus-summary-view.c
......
......@@ -154,6 +154,7 @@ enum {
ICON_TEXT_CHANGED,
LAYOUT_CHANGED,
MOVE_COPY_ITEMS,
CREATE_NAUTILUS_LINKS,
PREVIEW,
SELECTION_CHANGED,
LAST_SIGNAL
......@@ -2400,7 +2401,7 @@ button_release_event (GtkWidget *widget,
stop_rubberbanding (container, event);
return TRUE;
}
if (event->button == details->drag_button) {
details->drag_button = 0;
......@@ -2842,6 +2843,18 @@ nautilus_icon_container_initialize_class (NautilusIconContainerClass *class)
GTK_TYPE_INT,
GTK_TYPE_INT,
GTK_TYPE_INT);
signals[CREATE_NAUTILUS_LINKS]
= gtk_signal_new ("create_nautilus_links",
GTK_RUN_LAST,
object_class->type,
GTK_SIGNAL_OFFSET (NautilusIconContainerClass,
create_nautilus_links),
gtk_marshal_NONE__POINTER_INT_INT,
GTK_TYPE_NONE, 3,
GTK_TYPE_POINTER,
GTK_TYPE_INT,
GTK_TYPE_INT);
signals[GET_CONTAINER_URI]
= gtk_signal_new ("get_container_uri",
GTK_RUN_LAST,
......
......@@ -86,6 +86,10 @@ typedef struct {
int copy_action,
int x,
int y);
void (* create_nautilus_links) (NautilusIconContainer *container,
GList *item_uris,
int x,
int y);
/* Queries on the container for subclass/client.
* These must be implemented. The default "do nothing" is not good enough.
......
......@@ -47,6 +47,7 @@
#include <gtk/gtkmain.h>
#include <gtk/gtksignal.h>
#include <libgnome/gnome-i18n.h>
#include <libgnome/gnome-mime.h>
#include <libgnomeui/gnome-canvas-rect-ellipse.h>
#include <libgnomeui/gnome-stock.h>
#include <libgnomeui/gnome-uidefs.h>
......@@ -81,6 +82,10 @@ static void receive_dropped_keyword (NautilusIconCo
char* keyword,
int x,
int y);
static void receive_dropped_uri_list (NautilusIconContainer *container,
char* keyword,
int x,
int y);
static void nautilus_icon_container_free_drag_data (NautilusIconContainer *container);
static void set_drop_target (NautilusIconContainer *container,
NautilusIcon *icon);
......@@ -395,6 +400,7 @@ drag_data_received_callback (GtkWidget *widget,
case NAUTILUS_ICON_DND_COLOR:
case NAUTILUS_ICON_DND_BGIMAGE:
case NAUTILUS_ICON_DND_KEYWORD:
case NAUTILUS_ICON_DND_URI_LIST:
/* Save the data so we can do the actual work on drop. */
g_assert (drag_info->selection_data == NULL);
drag_info->selection_data = nautilus_gtk_selection_data_copy_deep (data);
......@@ -434,6 +440,13 @@ drag_data_received_callback (GtkWidget *widget,
(char*) data->data, x, y);
gtk_drag_finish (context, FALSE, FALSE, time);
break;
case NAUTILUS_ICON_DND_URI_LIST:
receive_dropped_uri_list
(NAUTILUS_ICON_CONTAINER (widget),
(char*) data->data, x, y);
gtk_drag_finish (context, FALSE, FALSE, time);
break;
default:
gtk_drag_finish (context, FALSE, FALSE, time);
}
......@@ -582,6 +595,35 @@ receive_dropped_keyword (NautilusIconContainer *container, char* keyword, int x,
nautilus_icon_container_update_icon (container, drop_target_icon);
}
/* handle dropped uri list */
static void
receive_dropped_uri_list (NautilusIconContainer *container, char *uri_list, int x, int y)
{
GList *li, *files;
int argc;
char **argv;
int i;
g_assert (uri_list != NULL);
files = gnome_uri_list_extract_filenames (uri_list);
argc = g_list_length (files);
argv = g_new (char *, argc + 1);
argv[argc] = NULL;
for (i=0, li = files; li; i++, li = g_list_next (li)) {
argv[i] = li->data;
}
/* Extract .desktop info and create link/links */
gtk_signal_emit_by_name (GTK_OBJECT (container), "create_nautilus_links",
files,
x, y);
gnome_uri_list_free_strings (files);
g_free(argv);
}
static int
auto_scroll_timeout_callback (gpointer data)
{
......@@ -966,10 +1008,11 @@ nautilus_icon_container_get_drop_action (NautilusIconContainer *container,
case NAUTILUS_ICON_DND_COLOR:
case NAUTILUS_ICON_DND_BGIMAGE:
case NAUTILUS_ICON_DND_KEYWORD:
case NAUTILUS_ICON_DND_URI_LIST:
*default_action = context->suggested_action;
*non_default_action = context->suggested_action;
break;
default:
}
......@@ -1202,7 +1245,7 @@ drag_motion_callback (GtkWidget *widget,
{
int default_action, non_default_action;
int resulting_action;
nautilus_icon_container_ensure_drag_data (NAUTILUS_ICON_CONTAINER (widget), context, time);
nautilus_icon_container_position_shadow (NAUTILUS_ICON_CONTAINER (widget), x, y);
nautilus_icon_dnd_update_drop_target (NAUTILUS_ICON_CONTAINER (widget), context, x, y);
......
......@@ -306,14 +306,18 @@ nautilus_launch_application (GnomeVFSMimeApplication *application, const char *u
void
nautilus_launch_application_from_command (const char *command_string, const char *parameter)
{
char *full_command, *quoted_parameter;
char *full_command, *quoted_parameter, *quoted_command;
if (parameter != NULL) {
quoted_parameter = nautilus_shell_quote (parameter);
full_command = g_strconcat (command_string, " ", quoted_parameter, " &", NULL);
quoted_command = nautilus_shell_quote (command_string);
full_command = g_strconcat (quoted_command, " ", quoted_parameter, " &", NULL);
g_free (quoted_command);
g_free (quoted_parameter);
} else {
full_command = g_strconcat (command_string, " &", NULL);
quoted_command = nautilus_shell_quote (command_string);
full_command = g_strconcat (quoted_command, " &", NULL);
g_free (quoted_command);
}
system (full_command);
......
......@@ -154,6 +154,7 @@ enum {
ICON_TEXT_CHANGED,
LAYOUT_CHANGED,
MOVE_COPY_ITEMS,
CREATE_NAUTILUS_LINKS,
PREVIEW,
SELECTION_CHANGED,
LAST_SIGNAL
......@@ -2400,7 +2401,7 @@ button_release_event (GtkWidget *widget,
stop_rubberbanding (container, event);
return TRUE;
}
if (event->button == details->drag_button) {
details->drag_button = 0;
......@@ -2842,6 +2843,18 @@ nautilus_icon_container_initialize_class (NautilusIconContainerClass *class)
GTK_TYPE_INT,
GTK_TYPE_INT,
GTK_TYPE_INT);
signals[CREATE_NAUTILUS_LINKS]
= gtk_signal_new ("create_nautilus_links",
GTK_RUN_LAST,
object_class->type,
GTK_SIGNAL_OFFSET (NautilusIconContainerClass,
create_nautilus_links),
gtk_marshal_NONE__POINTER_INT_INT,
GTK_TYPE_NONE, 3,
GTK_TYPE_POINTER,
GTK_TYPE_INT,
GTK_TYPE_INT);
signals[GET_CONTAINER_URI]
= gtk_signal_new ("get_container_uri",
GTK_RUN_LAST,
......
......@@ -86,6 +86,10 @@ typedef struct {
int copy_action,
int x,
int y);
void (* create_nautilus_links) (NautilusIconContainer *container,
GList *item_uris,
int x,
int y);
/* Queries on the container for subclass/client.
* These must be implemented. The default "do nothing" is not good enough.
......
......@@ -47,6 +47,7 @@
#include <gtk/gtkmain.h>
#include <gtk/gtksignal.h>
#include <libgnome/gnome-i18n.h>
#include <libgnome/gnome-mime.h>
#include <libgnomeui/gnome-canvas-rect-ellipse.h>
#include <libgnomeui/gnome-stock.h>
#include <libgnomeui/gnome-uidefs.h>
......@@ -81,6 +82,10 @@ static void receive_dropped_keyword (NautilusIconCo
char* keyword,
int x,
int y);
static void receive_dropped_uri_list (NautilusIconContainer *container,
char* keyword,
int x,
int y);
static void nautilus_icon_container_free_drag_data (NautilusIconContainer *container);
static void set_drop_target (NautilusIconContainer *container,
NautilusIcon *icon);
......@@ -395,6 +400,7 @@ drag_data_received_callback (GtkWidget *widget,
case NAUTILUS_ICON_DND_COLOR:
case NAUTILUS_ICON_DND_BGIMAGE:
case NAUTILUS_ICON_DND_KEYWORD:
case NAUTILUS_ICON_DND_URI_LIST:
/* Save the data so we can do the actual work on drop. */
g_assert (drag_info->selection_data == NULL);
drag_info->selection_data = nautilus_gtk_selection_data_copy_deep (data);
......@@ -434,6 +440,13 @@ drag_data_received_callback (GtkWidget *widget,
(char*) data->data, x, y);
gtk_drag_finish (context, FALSE, FALSE, time);
break;
case NAUTILUS_ICON_DND_URI_LIST:
receive_dropped_uri_list
(NAUTILUS_ICON_CONTAINER (widget),
(char*) data->data, x, y);
gtk_drag_finish (context, FALSE, FALSE, time);
break;
default:
gtk_drag_finish (context, FALSE, FALSE, time);
}
......@@ -582,6 +595,35 @@ receive_dropped_keyword (NautilusIconContainer *container, char* keyword, int x,
nautilus_icon_container_update_icon (container, drop_target_icon);
}
/* handle dropped uri list */
static void
receive_dropped_uri_list (NautilusIconContainer *container, char *uri_list, int x, int y)
{
GList *li, *files;
int argc;
char **argv;
int i;
g_assert (uri_list != NULL);
files = gnome_uri_list_extract_filenames (uri_list);
argc = g_list_length (files);
argv = g_new (char *, argc + 1);
argv[argc] = NULL;
for (i=0, li = files; li; i++, li = g_list_next (li)) {
argv[i] = li->data;
}
/* Extract .desktop info and create link/links */
gtk_signal_emit_by_name (GTK_OBJECT (container), "create_nautilus_links",
files,
x, y);
gnome_uri_list_free_strings (files);
g_free(argv);
}
static int
auto_scroll_timeout_callback (gpointer data)
{
......@@ -966,10 +1008,11 @@ nautilus_icon_container_get_drop_action (NautilusIconContainer *container,
case NAUTILUS_ICON_DND_COLOR:
case NAUTILUS_ICON_DND_BGIMAGE:
case NAUTILUS_ICON_DND_KEYWORD:
case NAUTILUS_ICON_DND_URI_LIST:
*default_action = context->suggested_action;
*non_default_action = context->suggested_action;
break;
default:
}
......@@ -1202,7 +1245,7 @@ drag_motion_callback (GtkWidget *widget,
{
int default_action, non_default_action;
int resulting_action;
nautilus_icon_container_ensure_drag_data (NAUTILUS_ICON_CONTAINER (widget), context, time);
nautilus_icon_container_position_shadow (NAUTILUS_ICON_CONTAINER (widget), x, y);
nautilus_icon_dnd_update_drop_target (NAUTILUS_ICON_CONTAINER (widget), context, x, y);
......
......@@ -306,14 +306,18 @@ nautilus_launch_application (GnomeVFSMimeApplication *application, const char *u
void
nautilus_launch_application_from_command (const char *command_string, const char *parameter)
{
char *full_command, *quoted_parameter;
char *full_command, *quoted_parameter, *quoted_command;
if (parameter != NULL) {
quoted_parameter = nautilus_shell_quote (parameter);
full_command = g_strconcat (command_string, " ", quoted_parameter, " &", NULL);
quoted_command = nautilus_shell_quote (command_string);
full_command = g_strconcat (quoted_command, " ", quoted_parameter, " &", NULL);
g_free (quoted_command);
g_free (quoted_parameter);
} else {
full_command = g_strconcat (command_string, " &", NULL);
quoted_command = nautilus_shell_quote (command_string);
full_command = g_strconcat (quoted_command, " &", NULL);
g_free (quoted_command);
}
system (full_command);
......
......@@ -38,6 +38,8 @@
#include <libgnomevfs/gnome-vfs.h>
#include <libnautilus-extensions/nautilus-directory-notify.h>
#include <libnautilus-extensions/nautilus-directory-background.h>
#include <libnautilus-extensions/nautilus-file-changes-queue.h>
#include <libnautilus-extensions/nautilus-metadata.h>
#include <libnautilus-extensions/nautilus-program-choosing.h>
#include <libnautilus-extensions/nautilus-file-operations.h>
#include <libnautilus-extensions/nautilus-file-utilities.h>
......@@ -59,6 +61,15 @@
#define TRASH_LINK_NAME _("Trash")
typedef struct {
GnomeVFSResult expected_result;
char *uri;
char *target_uri;
GdkPoint point;
GnomeDesktopEntry *entry;
} CallbackData;
static void fm_desktop_icon_view_initialize (FMDesktopIconView *desktop_icon_view);
static void fm_desktop_icon_view_initialize_class (FMDesktopIconViewClass *klass);
static void fm_desktop_icon_view_create_background_context_menu_items (FMDirectoryView *view,
......@@ -75,6 +86,11 @@ static void volume_mounted_callback (NautilusVolumeMonitor *mo
static void volume_unmounted_callback (NautilusVolumeMonitor *monitor,
NautilusVolume *volume,
FMDesktopIconView *icon_view);
static void icon_view_create_nautilus_links (NautilusIconContainer *container,
const GList *item_uris,
int x,
int y,
FMDirectoryView *view);
static void mount_unmount_removable (GtkCheckMenuItem *item,
FMDesktopIconView *icon_view);
static void place_home_directory (FMDesktopIconView *icon_view);
......@@ -313,6 +329,11 @@ fm_desktop_icon_view_initialize (FMDesktopIconView *desktop_icon_view)
"volume_unmounted",
volume_unmounted_callback,
desktop_icon_view);
gtk_signal_connect (GTK_OBJECT (icon_container),
"create_nautilus_links",
GTK_SIGNAL_FUNC (icon_view_create_nautilus_links),
desktop_icon_view);
nautilus_preferences_add_callback (NAUTILUS_PREFERENCES_HOME_URI, home_uri_changed,
desktop_icon_view);
......@@ -562,6 +583,104 @@ volume_unmounted_callback (NautilusVolumeMonitor *monitor,
g_free (volume_name);
}
static void
create_link_callback (GnomeVFSAsyncHandle *handle,
GnomeVFSResult result,
gpointer callback_data)
{
char *uri, *target_uri, *position;
GnomeVFSResult expected_result;
CallbackData *info;
GList dummy_list;
NautilusFile *file;
info = (CallbackData*) callback_data;
uri = info->uri;
target_uri = info->target_uri;
expected_result = info->expected_result;
/* Set metadata attributes */
file = nautilus_file_get (uri);
position = g_strdup_printf ("%d,%d", info->point.x, info->point.y);
nautilus_file_set_metadata (file, NAUTILUS_METADATA_KEY_ICON_POSITION, "0,0", position);
nautilus_file_set_metadata (file, NAUTILUS_METADATA_KEY_CUSTOM_ICON, "icon", info->entry->icon);
/* Notify directory that this new file has been created. */
dummy_list.data = uri;
dummy_list.next = NULL;
dummy_list.prev = NULL;
nautilus_directory_notify_files_added (&dummy_list);
g_free (uri);
g_free (position);
g_free (target_uri);
gnome_desktop_entry_free (info->entry);
g_free (callback_data);
}
static void
icon_view_create_nautilus_links (NautilusIconContainer *container, const GList *item_uris,
int x, int y, FMDirectoryView *view)
{
const GList *element;
char *desktop_path, *target_uri, *link_path, *link_uri, *program_path;
GnomeVFSURI *uri;
GnomeDesktopEntry *entry;
CallbackData *info;
GnomeVFSAsyncHandle *handle;
int index;
if (item_uris == NULL) {
return;
}
program_path = NULL;
desktop_path = nautilus_get_desktop_directory ();
for (element = item_uris, index = 0; element != NULL; element = element->next, index++) {
entry = gnome_desktop_entry_load ((char *)element->data);
if (entry != NULL) {
link_path = g_strdup_printf ("%s/%s", desktop_path, entry->name);
link_uri = gnome_vfs_get_uri_from_local_path (link_path);
/* Verify that have an actual path */
if (entry->exec[index][0] != '/') {
program_path = gnome_is_program_in_path(entry->exec[index]);
target_uri = gnome_vfs_get_uri_from_local_path (program_path);
g_free (program_path);
program_path = NULL;
} else {
target_uri = gnome_vfs_get_uri_from_local_path (entry->exec[index]);
}
uri = gnome_vfs_uri_new (target_uri);
/* Create symbolic link */
info = g_malloc (sizeof (CallbackData));
info->uri = link_uri;
info->target_uri = target_uri;
info->expected_result = GNOME_VFS_OK;
info->point.x = x;
info->point.y = y;
info->entry = entry;
gnome_vfs_async_create_symbolic_link (&handle, gnome_vfs_uri_new (link_path),
target_uri, create_link_callback, info);
g_free (link_path);
gnome_vfs_uri_unref (uri);
}
}
g_free (desktop_path);
}
static void
mount_unmount_removable (GtkCheckMenuItem *item, FMDesktopIconView *icon_view)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment