mirror of
https://gitlab.gnome.org/GNOME/nautilus
synced 2024-08-24 18:25:50 +00:00
Add simple slot drop proxy API to libnautilus-private, centered around
2008-07-13 Christian Neumair <cneumair@gnome.org> * libnautilus-private/nautilus-dnd.c (nautilus_drag_uri_array_from_selection_list), (nautilus_drag_uri_list_from_selection_list), (nautilus_drag_uri_array_from_list), (nautilus_drag_uri_list_from_array), (slot_proxy_drag_motion), (drag_info_clear), (slot_proxy_drag_leave), (slot_proxy_drag_drop), (slot_proxy_handle_drop), (slot_proxy_drag_data_received), (nautilus_drag_slot_proxy_init): * libnautilus-private/nautilus-dnd.h: Add simple slot drop proxy API to libnautilus-private, centered around nautilus_drag_slot_proxy_init(). The notebook tab label drop targets will later be ported to this API. Add API for converting URI lists to URI arrays, and for constructing URI lists and arrays from selection lists. * src/nautilus-notebook.c (notebook_tab_drag_data_received): Use nautilus_drag_uri_array_from_selection_list(). * src/nautilus-pathbar.c (slider_timeout), (nautilus_path_bar_slider_drag_motion), (nautilus_path_bar_slider_drag_leave), (nautilus_path_bar_init), (nautilus_path_bar_finalize), (button_data_free), (button_drag_data_get_cb), (setup_button_drag_source), (make_directory_button): * src/nautilus-pathbar.h: Add path bar drop targets, use nautilus_drag_slot_proxy_init() for setup. Also offer GNOME icon lists as drag target. Reveal hidden paths when hovering over the up/down sliders for some time. Fixes #309842. svn path=/trunk/; revision=14356
This commit is contained in:
parent
88d90c73c4
commit
d4f08bc033
34
ChangeLog
34
ChangeLog
|
@ -1,3 +1,37 @@
|
|||
2008-07-13 Christian Neumair <cneumair@gnome.org>
|
||||
|
||||
* libnautilus-private/nautilus-dnd.c
|
||||
(nautilus_drag_uri_array_from_selection_list),
|
||||
(nautilus_drag_uri_list_from_selection_list),
|
||||
(nautilus_drag_uri_array_from_list),
|
||||
(nautilus_drag_uri_list_from_array), (slot_proxy_drag_motion),
|
||||
(drag_info_clear), (slot_proxy_drag_leave), (slot_proxy_drag_drop),
|
||||
(slot_proxy_handle_drop), (slot_proxy_drag_data_received),
|
||||
(nautilus_drag_slot_proxy_init):
|
||||
* libnautilus-private/nautilus-dnd.h:
|
||||
Add simple slot drop proxy API to libnautilus-private, centered
|
||||
around nautilus_drag_slot_proxy_init().
|
||||
The notebook tab label drop targets will later be ported to this API.
|
||||
|
||||
Add API for converting URI lists to URI arrays, and for constructing
|
||||
URI lists and arrays from selection lists.
|
||||
|
||||
* src/nautilus-notebook.c (notebook_tab_drag_data_received):
|
||||
Use nautilus_drag_uri_array_from_selection_list().
|
||||
|
||||
* src/nautilus-pathbar.c (slider_timeout),
|
||||
(nautilus_path_bar_slider_drag_motion),
|
||||
(nautilus_path_bar_slider_drag_leave), (nautilus_path_bar_init),
|
||||
(nautilus_path_bar_finalize), (button_data_free),
|
||||
(button_drag_data_get_cb), (setup_button_drag_source),
|
||||
(make_directory_button):
|
||||
* src/nautilus-pathbar.h:
|
||||
Add path bar drop targets, use nautilus_drag_slot_proxy_init() for
|
||||
setup.
|
||||
Also offer GNOME icon lists as drag target.
|
||||
Reveal hidden paths when hovering over the up/down sliders for some
|
||||
time. Fixes #309842.
|
||||
|
||||
2008-07-13 Christian Neumair <cneumair@gnome.org>
|
||||
|
||||
* libnautilus-private/nautilus-view.c
|
||||
|
|
|
@ -31,6 +31,9 @@
|
|||
|
||||
#include "nautilus-program-choosing.h"
|
||||
#include "nautilus-link.h"
|
||||
#include "nautilus-window-slot-info.h"
|
||||
#include "nautilus-window-info.h"
|
||||
#include "nautilus-view.h"
|
||||
#include <eel/eel-glib-extensions.h>
|
||||
#include <eel/eel-gtk-extensions.h>
|
||||
#include <eel/eel-string.h>
|
||||
|
@ -118,6 +121,76 @@ nautilus_drag_destroy_selection_list (GList *list)
|
|||
g_list_free (list);
|
||||
}
|
||||
|
||||
char **
|
||||
nautilus_drag_uri_array_from_selection_list (const GList *selection_list)
|
||||
{
|
||||
GList *uri_list;
|
||||
char **uris;
|
||||
|
||||
uri_list = nautilus_drag_uri_list_from_selection_list (selection_list);
|
||||
uris = nautilus_drag_uri_array_from_list (uri_list);
|
||||
eel_g_list_free_deep (uri_list);
|
||||
|
||||
return uris;
|
||||
}
|
||||
|
||||
GList *
|
||||
nautilus_drag_uri_list_from_selection_list (const GList *selection_list)
|
||||
{
|
||||
NautilusDragSelectionItem *selection_item;
|
||||
GList *uri_list;
|
||||
const GList *l;
|
||||
|
||||
uri_list = NULL;
|
||||
for (l = selection_list; l != NULL; l = l->next) {
|
||||
selection_item = (NautilusDragSelectionItem *) l->data;
|
||||
if (selection_item->uri != NULL) {
|
||||
uri_list = g_list_prepend (uri_list, g_strdup (selection_item->uri));
|
||||
}
|
||||
}
|
||||
|
||||
return g_list_reverse (uri_list);
|
||||
}
|
||||
|
||||
char **
|
||||
nautilus_drag_uri_array_from_list (const GList *uri_list)
|
||||
{
|
||||
const GList *l;
|
||||
char **uris;
|
||||
int i;
|
||||
|
||||
if (uri_list == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uris = g_new0 (char *, g_list_length ((GList *) uri_list));
|
||||
for (i = 0, l = uri_list; l != NULL; l = l->next) {
|
||||
uris[i++] = g_strdup ((char *) l->data);
|
||||
}
|
||||
uris[i] = NULL;
|
||||
|
||||
return uris;
|
||||
}
|
||||
|
||||
GList *
|
||||
nautilus_drag_uri_list_from_array (const char **uris)
|
||||
{
|
||||
GList *uri_list;
|
||||
int i;
|
||||
|
||||
if (uris == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uri_list = NULL;
|
||||
|
||||
for (i = 0; uris[i] != NULL; i++) {
|
||||
uri_list = g_list_prepend (uri_list, g_strdup (uris[i]));
|
||||
}
|
||||
|
||||
return g_list_reverse (uri_list);
|
||||
}
|
||||
|
||||
GList *
|
||||
nautilus_drag_build_selection_list (GtkSelectionData *data)
|
||||
{
|
||||
|
@ -921,3 +994,284 @@ nautilus_drag_selection_includes_special_link (GList *selection_list)
|
|||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
slot_proxy_drag_motion (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
int x,
|
||||
int y,
|
||||
unsigned int time,
|
||||
gpointer user_data)
|
||||
{
|
||||
GdkAtom target;
|
||||
int action;
|
||||
char *target_uri;
|
||||
NautilusDragSlotProxyInfo *drag_info;
|
||||
|
||||
drag_info = user_data;
|
||||
|
||||
action = 0;
|
||||
|
||||
if (gtk_drag_get_source_widget (context) == widget) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (!drag_info->have_data) {
|
||||
target = gtk_drag_dest_find_target (widget, context, NULL);
|
||||
gtk_drag_get_data (widget, context, target, time);
|
||||
}
|
||||
|
||||
target_uri = NULL;
|
||||
if (drag_info->target_location != NULL) {
|
||||
target_uri = g_file_get_uri (drag_info->target_location);
|
||||
}
|
||||
|
||||
if (drag_info->have_data &&
|
||||
drag_info->have_valid_data) {
|
||||
if (drag_info->info == NAUTILUS_ICON_DND_GNOME_ICON_LIST) {
|
||||
nautilus_drag_default_drop_action_for_icons (context, target_uri,
|
||||
drag_info->data.selection_list,
|
||||
&action);
|
||||
} else if (drag_info->info == NAUTILUS_ICON_DND_URI_LIST) {
|
||||
action = nautilus_drag_default_drop_action_for_uri_list (context, target_uri);
|
||||
} else if (drag_info->info == NAUTILUS_ICON_DND_NETSCAPE_URL) {
|
||||
action = nautilus_drag_default_drop_action_for_netscape_url (context);
|
||||
}
|
||||
}
|
||||
|
||||
g_free (target_uri);
|
||||
|
||||
out:
|
||||
if (action != 0) {
|
||||
gtk_drag_highlight (widget);
|
||||
} else {
|
||||
gtk_drag_unhighlight (widget);
|
||||
}
|
||||
|
||||
gdk_drag_status (context, action, time);
|
||||
}
|
||||
|
||||
static void
|
||||
drag_info_clear (NautilusDragSlotProxyInfo *drag_info)
|
||||
{
|
||||
if (!drag_info->have_data) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (drag_info->info == NAUTILUS_ICON_DND_GNOME_ICON_LIST) {
|
||||
nautilus_drag_destroy_selection_list (drag_info->data.selection_list);
|
||||
} else if (drag_info->info == NAUTILUS_ICON_DND_URI_LIST) {
|
||||
g_list_free (drag_info->data.uri_list);
|
||||
} else if (drag_info->info == NAUTILUS_ICON_DND_NETSCAPE_URL) {
|
||||
g_free (drag_info->data.netscape_url);
|
||||
}
|
||||
|
||||
out:
|
||||
drag_info->have_data = FALSE;
|
||||
drag_info->have_valid_data = FALSE;
|
||||
|
||||
drag_info->drop_occured = FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
slot_proxy_drag_leave (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
unsigned int time,
|
||||
gpointer user_data)
|
||||
{
|
||||
NautilusDragSlotProxyInfo *drag_info;
|
||||
|
||||
drag_info = user_data;
|
||||
|
||||
gtk_drag_unhighlight (widget);
|
||||
drag_info_clear (drag_info);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
slot_proxy_drag_drop (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
int x,
|
||||
int y,
|
||||
unsigned int time,
|
||||
gpointer user_data)
|
||||
{
|
||||
GdkAtom target;
|
||||
NautilusDragSlotProxyInfo *drag_info;
|
||||
|
||||
drag_info = user_data;
|
||||
g_assert (!drag_info->have_data);
|
||||
|
||||
drag_info->drop_occured = TRUE;
|
||||
|
||||
target = gtk_drag_dest_find_target (widget, context, NULL);
|
||||
gtk_drag_get_data (widget, context, target, time);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
slot_proxy_handle_drop (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
unsigned int time,
|
||||
NautilusDragSlotProxyInfo *drag_info)
|
||||
{
|
||||
GtkWidget *window;
|
||||
NautilusWindowSlotInfo *target_slot;
|
||||
NautilusView *target_view;
|
||||
char *target_uri;
|
||||
GList *uri_list;
|
||||
|
||||
if (!drag_info->have_data ||
|
||||
!drag_info->have_valid_data) {
|
||||
gtk_drag_finish (context, FALSE, FALSE, time);
|
||||
drag_info_clear (drag_info);
|
||||
return;
|
||||
}
|
||||
|
||||
window = gtk_widget_get_toplevel (widget);
|
||||
g_assert (NAUTILUS_IS_WINDOW_INFO (window));
|
||||
|
||||
if (drag_info->target_slot != NULL) {
|
||||
target_slot = drag_info->target_slot;
|
||||
} else {
|
||||
target_slot = nautilus_window_info_get_active_slot (NAUTILUS_WINDOW_INFO (window));
|
||||
}
|
||||
|
||||
target_uri = NULL;
|
||||
if (drag_info->target_location != NULL) {
|
||||
target_uri = g_file_get_uri (drag_info->target_location);
|
||||
} else if (target_slot != NULL) {
|
||||
target_uri = nautilus_window_slot_info_get_current_location (target_slot);
|
||||
}
|
||||
|
||||
target_view = NULL;
|
||||
if (target_slot != NULL) {
|
||||
target_view = nautilus_window_slot_info_get_current_view (target_slot);
|
||||
}
|
||||
|
||||
if (target_slot != NULL && target_view != NULL) {
|
||||
if (drag_info->info == NAUTILUS_ICON_DND_GNOME_ICON_LIST) {
|
||||
uri_list = nautilus_drag_uri_list_from_selection_list (drag_info->data.selection_list);
|
||||
g_assert (uri_list != NULL);
|
||||
|
||||
nautilus_view_drop_proxy_received_uris (target_view,
|
||||
uri_list,
|
||||
target_uri,
|
||||
context->action);
|
||||
eel_g_list_free_deep (uri_list);
|
||||
} else if (drag_info->info == NAUTILUS_ICON_DND_URI_LIST) {
|
||||
nautilus_view_drop_proxy_received_uris (target_view,
|
||||
drag_info->data.uri_list,
|
||||
target_uri,
|
||||
context->action);
|
||||
} if (drag_info->info == NAUTILUS_ICON_DND_NETSCAPE_URL) {
|
||||
nautilus_view_drop_proxy_received_netscape_url (target_view,
|
||||
drag_info->data.netscape_url,
|
||||
target_uri,
|
||||
context->action);
|
||||
}
|
||||
|
||||
|
||||
gtk_drag_finish (context, TRUE, FALSE, time);
|
||||
} else {
|
||||
gtk_drag_finish (context, FALSE, FALSE, time);
|
||||
}
|
||||
|
||||
if (target_view != NULL) {
|
||||
g_object_unref (target_view);
|
||||
}
|
||||
|
||||
g_free (target_uri);
|
||||
|
||||
drag_info_clear (drag_info);
|
||||
}
|
||||
|
||||
static void
|
||||
slot_proxy_drag_data_received (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
int x,
|
||||
int y,
|
||||
GtkSelectionData *data,
|
||||
unsigned int info,
|
||||
unsigned int time,
|
||||
gpointer user_data)
|
||||
{
|
||||
NautilusDragSlotProxyInfo *drag_info;
|
||||
char **uris;
|
||||
|
||||
drag_info = user_data;
|
||||
|
||||
g_assert (!drag_info->have_data);
|
||||
|
||||
drag_info->have_data = TRUE;
|
||||
drag_info->info = info;
|
||||
|
||||
if (data->length < 0) {
|
||||
drag_info->have_valid_data = FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
if (info == NAUTILUS_ICON_DND_GNOME_ICON_LIST) {
|
||||
drag_info->data.selection_list = nautilus_drag_build_selection_list (data);
|
||||
|
||||
drag_info->have_valid_data = drag_info->data.selection_list != NULL;
|
||||
} else if (info == NAUTILUS_ICON_DND_URI_LIST) {
|
||||
uris = gtk_selection_data_get_uris (data);
|
||||
drag_info->data.uri_list = nautilus_drag_uri_list_from_array ((const char **) uris);
|
||||
g_strfreev (uris);
|
||||
|
||||
drag_info->have_valid_data = drag_info->data.uri_list != NULL;
|
||||
} else if (info == NAUTILUS_ICON_DND_NETSCAPE_URL) {
|
||||
drag_info->data.netscape_url = g_strdup ((char *) data->data);
|
||||
|
||||
drag_info->have_valid_data = drag_info->data.netscape_url != NULL;
|
||||
}
|
||||
|
||||
if (drag_info->drop_occured) {
|
||||
slot_proxy_handle_drop (widget, context, time, drag_info);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nautilus_drag_slot_proxy_init (GtkWidget *widget,
|
||||
NautilusDragSlotProxyInfo *drag_info)
|
||||
{
|
||||
const GtkTargetEntry targets[] = {
|
||||
{ NAUTILUS_ICON_DND_GNOME_ICON_LIST_TYPE, 0, NAUTILUS_ICON_DND_GNOME_ICON_LIST },
|
||||
{ NAUTILUS_ICON_DND_NETSCAPE_URL_TYPE, 0, NAUTILUS_ICON_DND_NETSCAPE_URL }
|
||||
};
|
||||
GtkTargetList *target_list;
|
||||
|
||||
g_assert (GTK_IS_WIDGET (widget));
|
||||
g_assert (drag_info != NULL);
|
||||
|
||||
gtk_drag_dest_set (widget, 0,
|
||||
NULL, 0,
|
||||
GDK_ACTION_MOVE |
|
||||
GDK_ACTION_COPY |
|
||||
GDK_ACTION_LINK |
|
||||
GDK_ACTION_ASK);
|
||||
|
||||
gtk_drag_source_add_uri_targets (widget);
|
||||
|
||||
target_list = gtk_target_list_new (targets, G_N_ELEMENTS (targets));
|
||||
gtk_target_list_add_uri_targets (target_list, NAUTILUS_ICON_DND_URI_LIST);
|
||||
gtk_drag_dest_set_target_list (widget, target_list);
|
||||
gtk_target_list_unref (target_list);
|
||||
|
||||
g_signal_connect (widget, "drag-motion",
|
||||
G_CALLBACK (slot_proxy_drag_motion),
|
||||
drag_info);
|
||||
g_signal_connect (widget, "drag-drop",
|
||||
G_CALLBACK (slot_proxy_drag_drop),
|
||||
drag_info);
|
||||
g_signal_connect (widget, "drag-data-received",
|
||||
G_CALLBACK (slot_proxy_drag_data_received),
|
||||
drag_info);
|
||||
g_signal_connect (widget, "drag-leave",
|
||||
G_CALLBACK (slot_proxy_drag_leave),
|
||||
drag_info);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -21,23 +21,24 @@
|
|||
Boston, MA 02111-1307, USA.
|
||||
|
||||
Authors: Pavel Cisler <pavel@eazel.com>,
|
||||
Ettore Perazzoli <ettore@gnu.org>
|
||||
Ettore Perazzoli <ettore@gnu.org>
|
||||
*/
|
||||
|
||||
#ifndef NAUTILUS_DND_H
|
||||
#define NAUTILUS_DND_H
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <libnautilus-private/nautilus-window-slot-info.h>
|
||||
|
||||
/* Drag & Drop target names. */
|
||||
#define NAUTILUS_ICON_DND_GNOME_ICON_LIST_TYPE "x-special/gnome-icon-list"
|
||||
#define NAUTILUS_ICON_DND_URI_LIST_TYPE "text/uri-list"
|
||||
#define NAUTILUS_ICON_DND_GNOME_ICON_LIST_TYPE "x-special/gnome-icon-list"
|
||||
#define NAUTILUS_ICON_DND_URI_LIST_TYPE "text/uri-list"
|
||||
#define NAUTILUS_ICON_DND_NETSCAPE_URL_TYPE "_NETSCAPE_URL"
|
||||
#define NAUTILUS_ICON_DND_COLOR_TYPE "application/x-color"
|
||||
#define NAUTILUS_ICON_DND_BGIMAGE_TYPE "property/bgimage"
|
||||
#define NAUTILUS_ICON_DND_KEYWORD_TYPE "property/keyword"
|
||||
#define NAUTILUS_ICON_DND_COLOR_TYPE "application/x-color"
|
||||
#define NAUTILUS_ICON_DND_BGIMAGE_TYPE "property/bgimage"
|
||||
#define NAUTILUS_ICON_DND_KEYWORD_TYPE "property/keyword"
|
||||
#define NAUTILUS_ICON_DND_RESET_BACKGROUND_TYPE "x-special/gnome-reset-background"
|
||||
#define NAUTILUS_ICON_DND_ROOTWINDOW_DROP_TYPE "application/x-rootwindow-drop"
|
||||
#define NAUTILUS_ICON_DND_ROOTWINDOW_DROP_TYPE "application/x-rootwindow-drop"
|
||||
#define NAUTILUS_ICON_DND_XDNDDIRECTSAVE_TYPE "XdndDirectSave0" /* XDS Protocol Type */
|
||||
|
||||
/* Item of the drag selection list */
|
||||
|
@ -87,8 +88,8 @@ typedef struct {
|
|||
*/
|
||||
GList *selection_list;
|
||||
|
||||
/* has the drop occured ? */
|
||||
gboolean drop_occured;
|
||||
/* has the drop occured ? */
|
||||
gboolean drop_occured;
|
||||
|
||||
/* whether or not need to clean up the previous dnd data */
|
||||
gboolean need_to_destroy;
|
||||
|
@ -100,59 +101,92 @@ typedef struct {
|
|||
|
||||
} NautilusDragInfo;
|
||||
|
||||
typedef void (* NautilusDragEachSelectedItemDataGet) (const char *url,
|
||||
typedef struct {
|
||||
/* NB: the following elements are managed by us */
|
||||
gboolean have_data;
|
||||
gboolean have_valid_data;
|
||||
|
||||
gboolean drop_occured;
|
||||
|
||||
unsigned int info;
|
||||
union {
|
||||
GList *selection_list;
|
||||
GList *uri_list;
|
||||
char *netscape_url;
|
||||
} data;
|
||||
|
||||
/* NB: the following elements are managed by the caller of
|
||||
* nautilus_drag_slot_proxy_init() */
|
||||
|
||||
/* a fixed location, or NULL to use slot's location */
|
||||
GFile *target_location;
|
||||
/* a fixed slot, or NULL to use the window's active slot */
|
||||
NautilusWindowSlotInfo *target_slot;
|
||||
} NautilusDragSlotProxyInfo;
|
||||
|
||||
typedef void (* NautilusDragEachSelectedItemDataGet) (const char *url,
|
||||
int x, int y, int w, int h,
|
||||
gpointer data);
|
||||
typedef void (* NautilusDragEachSelectedItemIterator) (NautilusDragEachSelectedItemDataGet iteratee,
|
||||
typedef void (* NautilusDragEachSelectedItemIterator) (NautilusDragEachSelectedItemDataGet iteratee,
|
||||
gpointer iterator_context,
|
||||
gpointer data);
|
||||
|
||||
void nautilus_drag_init (NautilusDragInfo *drag_info,
|
||||
const GtkTargetEntry *drag_types,
|
||||
int drag_type_count,
|
||||
gboolean add_text_targets);
|
||||
void nautilus_drag_finalize (NautilusDragInfo *drag_info);
|
||||
NautilusDragSelectionItem *nautilus_drag_selection_item_new (void);
|
||||
void nautilus_drag_destroy_selection_list (GList *selection_list);
|
||||
GList *nautilus_drag_build_selection_list (GtkSelectionData *data);
|
||||
gboolean nautilus_drag_items_local (const char *target_uri,
|
||||
const GList *selection_list);
|
||||
gboolean nautilus_drag_uris_local (const char *target_uri,
|
||||
const GList *source_uri_list);
|
||||
gboolean nautilus_drag_items_in_trash (const GList *selection_list);
|
||||
gboolean nautilus_drag_items_on_desktop (const GList *selection_list);
|
||||
void nautilus_drag_default_drop_action_for_icons (GdkDragContext *context,
|
||||
const char *target_uri,
|
||||
const GList *items,
|
||||
int *action);
|
||||
GdkDragAction nautilus_drag_default_drop_action_for_netscape_url (GdkDragContext *context);
|
||||
GdkDragAction nautilus_drag_default_drop_action_for_uri_list (GdkDragContext *context,
|
||||
const char *target_uri_string);
|
||||
gboolean nautilus_drag_drag_data_get (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
GtkSelectionData *selection_data,
|
||||
guint info,
|
||||
guint32 time,
|
||||
gpointer container_context,
|
||||
void nautilus_drag_init (NautilusDragInfo *drag_info,
|
||||
const GtkTargetEntry *drag_types,
|
||||
int drag_type_count,
|
||||
gboolean add_text_targets);
|
||||
void nautilus_drag_finalize (NautilusDragInfo *drag_info);
|
||||
NautilusDragSelectionItem *nautilus_drag_selection_item_new (void);
|
||||
void nautilus_drag_destroy_selection_list (GList *selection_list);
|
||||
GList *nautilus_drag_build_selection_list (GtkSelectionData *data);
|
||||
|
||||
char ** nautilus_drag_uri_array_from_selection_list (const GList *selection_list);
|
||||
GList * nautilus_drag_uri_list_from_selection_list (const GList *selection_list);
|
||||
|
||||
char ** nautilus_drag_uri_array_from_list (const GList *uri_list);
|
||||
GList * nautilus_drag_uri_list_from_array (const char **uris);
|
||||
|
||||
gboolean nautilus_drag_items_local (const char *target_uri,
|
||||
const GList *selection_list);
|
||||
gboolean nautilus_drag_uris_local (const char *target_uri,
|
||||
const GList *source_uri_list);
|
||||
gboolean nautilus_drag_items_in_trash (const GList *selection_list);
|
||||
gboolean nautilus_drag_items_on_desktop (const GList *selection_list);
|
||||
void nautilus_drag_default_drop_action_for_icons (GdkDragContext *context,
|
||||
const char *target_uri,
|
||||
const GList *items,
|
||||
int *action);
|
||||
GdkDragAction nautilus_drag_default_drop_action_for_netscape_url (GdkDragContext *context);
|
||||
GdkDragAction nautilus_drag_default_drop_action_for_uri_list (GdkDragContext *context,
|
||||
const char *target_uri_string);
|
||||
gboolean nautilus_drag_drag_data_get (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
GtkSelectionData *selection_data,
|
||||
guint info,
|
||||
guint32 time,
|
||||
gpointer container_context,
|
||||
NautilusDragEachSelectedItemIterator each_selected_item_iterator);
|
||||
int nautilus_drag_modifier_based_action (int default_action,
|
||||
int non_default_action);
|
||||
int nautilus_drag_modifier_based_action (int default_action,
|
||||
int non_default_action);
|
||||
|
||||
GdkDragAction nautilus_drag_drop_action_ask (GtkWidget *widget,
|
||||
GdkDragAction possible_actions);
|
||||
GdkDragAction nautilus_drag_drop_background_ask (GtkWidget *widget,
|
||||
GdkDragAction possible_actions);
|
||||
GdkDragAction nautilus_drag_drop_action_ask (GtkWidget *widget,
|
||||
GdkDragAction possible_actions);
|
||||
GdkDragAction nautilus_drag_drop_background_ask (GtkWidget *widget,
|
||||
GdkDragAction possible_actions);
|
||||
|
||||
gboolean nautilus_drag_autoscroll_in_scroll_region (GtkWidget *widget);
|
||||
void nautilus_drag_autoscroll_calculate_delta (GtkWidget *widget,
|
||||
float *x_scroll_delta,
|
||||
float *y_scroll_delta);
|
||||
void nautilus_drag_autoscroll_start (NautilusDragInfo *drag_info,
|
||||
GtkWidget *widget,
|
||||
GtkFunction callback,
|
||||
gpointer user_data);
|
||||
void nautilus_drag_autoscroll_stop (NautilusDragInfo *drag_info);
|
||||
gboolean nautilus_drag_autoscroll_in_scroll_region (GtkWidget *widget);
|
||||
void nautilus_drag_autoscroll_calculate_delta (GtkWidget *widget,
|
||||
float *x_scroll_delta,
|
||||
float *y_scroll_delta);
|
||||
void nautilus_drag_autoscroll_start (NautilusDragInfo *drag_info,
|
||||
GtkWidget *widget,
|
||||
GtkFunction callback,
|
||||
gpointer user_data);
|
||||
void nautilus_drag_autoscroll_stop (NautilusDragInfo *drag_info);
|
||||
|
||||
gboolean nautilus_drag_selection_includes_special_link (GList *selection_list);
|
||||
gboolean nautilus_drag_selection_includes_special_link (GList *selection_list);
|
||||
|
||||
void nautilus_drag_slot_proxy_init (GtkWidget *widget,
|
||||
NautilusDragSlotProxyInfo *drag_info);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -255,8 +255,7 @@ notebook_tab_drag_data_received (GtkWidget *widget,
|
|||
NautilusWindow *window;
|
||||
NautilusNavigationWindow *navigation_window;
|
||||
GtkWidget *notebook;
|
||||
GList *uri_list, *selection_list, *l;
|
||||
NautilusDragSelectionItem *selection_item;
|
||||
GList *uri_list, *selection_list;
|
||||
char **uris;
|
||||
int i;
|
||||
|
||||
|
@ -285,18 +284,7 @@ notebook_tab_drag_data_received (GtkWidget *widget,
|
|||
return;
|
||||
}
|
||||
|
||||
i = 0;
|
||||
|
||||
uris = g_new0 (char *, g_list_length (selection_list));
|
||||
for (l = selection_list; l != NULL; l = l->next) {
|
||||
selection_item = (NautilusDragSelectionItem *) l->data;
|
||||
|
||||
uris[i] = g_strdup (selection_item->uri);
|
||||
if (uris[i] != NULL) {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
uris[i] = NULL;
|
||||
uris = nautilus_drag_uri_array_from_selection_list (selection_list);
|
||||
|
||||
nautilus_drag_destroy_selection_list (selection_list);
|
||||
} else {
|
||||
|
|
|
@ -32,7 +32,13 @@
|
|||
#include <libnautilus-private/nautilus-global-preferences.h>
|
||||
#include <libnautilus-private/nautilus-icon-names.h>
|
||||
#include <libnautilus-private/nautilus-trash-monitor.h>
|
||||
#include <libnautilus-private/nautilus-marshal.h>
|
||||
#include <libnautilus-private/nautilus-dnd.h>
|
||||
#include <libnautilus-private/nautilus-icon-dnd.h>
|
||||
#include "nautilus-pathbar.h"
|
||||
#include "nautilus-window.h"
|
||||
#include "nautilus-window-private.h"
|
||||
#include "nautilus-window-slot.h"
|
||||
|
||||
enum {
|
||||
PATH_CLICKED,
|
||||
|
@ -78,6 +84,8 @@ struct _ButtonData
|
|||
GtkWidget *label;
|
||||
guint ignore_changes : 1;
|
||||
guint file_is_hidden : 1;
|
||||
|
||||
NautilusDragSlotProxyInfo drag_info;
|
||||
};
|
||||
|
||||
/* This macro is used to check if a button can be used as a fake root.
|
||||
|
@ -217,6 +225,70 @@ trash_state_changed_cb (NautilusTrashMonitor *monitor,
|
|||
g_object_unref (file);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
slider_timeout (gpointer user_data)
|
||||
{
|
||||
NautilusPathBar *path_bar;
|
||||
|
||||
path_bar = NAUTILUS_PATH_BAR (user_data);
|
||||
|
||||
path_bar->drag_slider_timeout = 0;
|
||||
|
||||
if (GTK_WIDGET_VISIBLE (GTK_WIDGET (path_bar))) {
|
||||
if (path_bar->drag_slider_timeout_for_up_button) {
|
||||
nautilus_path_bar_scroll_up (path_bar->up_slider_button, path_bar);
|
||||
} else {
|
||||
nautilus_path_bar_scroll_down (path_bar->down_slider_button, path_bar);
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
nautilus_path_bar_slider_drag_motion (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
int x,
|
||||
int y,
|
||||
unsigned int time,
|
||||
gpointer user_data)
|
||||
{
|
||||
NautilusPathBar *path_bar;
|
||||
GtkSettings *settings;
|
||||
unsigned int timeout;
|
||||
|
||||
path_bar = NAUTILUS_PATH_BAR (user_data);
|
||||
|
||||
if (path_bar->drag_slider_timeout == 0) {
|
||||
settings = gtk_widget_get_settings (widget);
|
||||
|
||||
g_object_get (settings, "gtk-timeout-expand", &timeout, NULL);
|
||||
path_bar->drag_slider_timeout =
|
||||
g_timeout_add (timeout,
|
||||
slider_timeout,
|
||||
path_bar);
|
||||
|
||||
path_bar->drag_slider_timeout_for_up_button =
|
||||
widget == path_bar->up_slider_button;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
nautilus_path_bar_slider_drag_leave (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
unsigned int time,
|
||||
gpointer user_data)
|
||||
{
|
||||
NautilusPathBar *path_bar;
|
||||
|
||||
path_bar = NAUTILUS_PATH_BAR (user_data);
|
||||
|
||||
if (path_bar->drag_slider_timeout != 0) {
|
||||
g_source_remove (path_bar->drag_slider_timeout);
|
||||
path_bar->drag_slider_timeout = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
nautilus_path_bar_init (NautilusPathBar *path_bar)
|
||||
{
|
||||
|
@ -250,6 +322,30 @@ nautilus_path_bar_init (NautilusPathBar *path_bar)
|
|||
g_signal_connect (path_bar->down_slider_button, "button_press_event", G_CALLBACK (nautilus_path_bar_slider_button_press), path_bar);
|
||||
g_signal_connect (path_bar->down_slider_button, "button_release_event", G_CALLBACK (nautilus_path_bar_slider_button_release), path_bar);
|
||||
|
||||
gtk_drag_dest_set (GTK_WIDGET (path_bar->up_slider_button),
|
||||
0, NULL, 0, 0);
|
||||
gtk_drag_dest_set_track_motion (GTK_WIDGET (path_bar->up_slider_button), TRUE);
|
||||
g_signal_connect (path_bar->up_slider_button,
|
||||
"drag-motion",
|
||||
G_CALLBACK (nautilus_path_bar_slider_drag_motion),
|
||||
path_bar);
|
||||
g_signal_connect (path_bar->up_slider_button,
|
||||
"drag-leave",
|
||||
G_CALLBACK (nautilus_path_bar_slider_drag_leave),
|
||||
path_bar);
|
||||
|
||||
gtk_drag_dest_set (GTK_WIDGET (path_bar->down_slider_button),
|
||||
0, NULL, 0, 0);
|
||||
gtk_drag_dest_set_track_motion (GTK_WIDGET (path_bar->up_slider_button), TRUE);
|
||||
g_signal_connect (path_bar->down_slider_button,
|
||||
"drag-motion",
|
||||
G_CALLBACK (nautilus_path_bar_slider_drag_motion),
|
||||
path_bar);
|
||||
g_signal_connect (path_bar->down_slider_button,
|
||||
"drag-leave",
|
||||
G_CALLBACK (nautilus_path_bar_slider_drag_leave),
|
||||
path_bar);
|
||||
|
||||
g_signal_connect (nautilus_trash_monitor_get (),
|
||||
"trash_state_changed",
|
||||
G_CALLBACK (trash_state_changed_cb),
|
||||
|
@ -314,6 +410,11 @@ nautilus_path_bar_finalize (GObject *object)
|
|||
|
||||
nautilus_path_bar_stop_scrolling (path_bar);
|
||||
|
||||
if (path_bar->drag_slider_timeout != 0) {
|
||||
g_source_remove (path_bar->drag_slider_timeout);
|
||||
path_bar->drag_slider_timeout = 0;
|
||||
}
|
||||
|
||||
g_list_free (path_bar->button_list);
|
||||
if (path_bar->root_path) {
|
||||
g_object_unref (path_bar->root_path);
|
||||
|
@ -1121,6 +1222,9 @@ button_data_free (ButtonData *button_data)
|
|||
g_object_unref (button_data->custom_icon);
|
||||
}
|
||||
g_free (button_data);
|
||||
|
||||
g_object_unref (button_data->drag_info.target_location);
|
||||
button_data->drag_info.target_location = NULL;
|
||||
}
|
||||
|
||||
static const char *
|
||||
|
@ -1281,22 +1385,53 @@ button_drag_data_get_cb (GtkWidget *widget,
|
|||
GtkSelectionData *selection_data,
|
||||
guint info,
|
||||
guint time_,
|
||||
gpointer data)
|
||||
gpointer user_data)
|
||||
{
|
||||
ButtonData *button_data;
|
||||
char *uri_list;
|
||||
char *uri;
|
||||
char *uri_list[2];
|
||||
char *tmp;
|
||||
|
||||
button_data = data;
|
||||
uri = g_file_get_uri (button_data->path);
|
||||
uri_list = g_strconcat (uri, "\r\n", NULL);
|
||||
g_free (uri);
|
||||
gtk_selection_data_set (selection_data,
|
||||
selection_data->target,
|
||||
8,
|
||||
uri_list,
|
||||
strlen (uri_list));
|
||||
g_free (uri_list);
|
||||
button_data = user_data;
|
||||
|
||||
uri_list[0] = g_file_get_uri (button_data->path);
|
||||
uri_list[1] = NULL;
|
||||
|
||||
if (info == NAUTILUS_ICON_DND_GNOME_ICON_LIST) {
|
||||
tmp = g_strdup_printf ("%s\r\n", uri_list[0]);
|
||||
gtk_selection_data_set (selection_data, selection_data->target,
|
||||
8, tmp, strlen (tmp));
|
||||
g_free (tmp);
|
||||
} else if (info == NAUTILUS_ICON_DND_URI_LIST) {
|
||||
gtk_selection_data_set_uris (selection_data, uri_list);
|
||||
}
|
||||
|
||||
g_free (uri_list[0]);
|
||||
}
|
||||
|
||||
static void
|
||||
setup_button_drag_source (ButtonData *button_data)
|
||||
{
|
||||
GtkTargetList *target_list;
|
||||
const GtkTargetEntry targets[] = {
|
||||
{ NAUTILUS_ICON_DND_GNOME_ICON_LIST_TYPE, 0, NAUTILUS_ICON_DND_GNOME_ICON_LIST }
|
||||
};
|
||||
|
||||
gtk_drag_source_set (button_data->button,
|
||||
GDK_BUTTON1_MASK,
|
||||
NULL, 0,
|
||||
GDK_ACTION_MOVE |
|
||||
GDK_ACTION_COPY |
|
||||
GDK_ACTION_LINK |
|
||||
GDK_ACTION_ASK);
|
||||
|
||||
target_list = gtk_target_list_new (targets, G_N_ELEMENTS (targets));
|
||||
gtk_target_list_add_uri_targets (target_list, NAUTILUS_ICON_DND_URI_LIST);
|
||||
gtk_drag_source_set_target_list (button_data->button, target_list);
|
||||
gtk_target_list_unref (target_list);
|
||||
|
||||
g_signal_connect (button_data->button, "drag-data-get",
|
||||
G_CALLBACK (button_drag_data_get_cb),
|
||||
button_data);
|
||||
}
|
||||
|
||||
static ButtonData *
|
||||
|
@ -1307,10 +1442,6 @@ make_directory_button (NautilusPathBar *path_bar,
|
|||
gboolean base_dir,
|
||||
gboolean file_is_hidden)
|
||||
{
|
||||
const GtkTargetEntry targets[] = {
|
||||
{ "text/uri-list", 0, 0 }
|
||||
};
|
||||
|
||||
GtkWidget *child;
|
||||
GtkWidget *label_alignment;
|
||||
ButtonData *button_data;
|
||||
|
@ -1325,6 +1456,8 @@ make_directory_button (NautilusPathBar *path_bar,
|
|||
button_data->type = find_button_type (path_bar, path, button_data);
|
||||
button_data->button = gtk_toggle_button_new ();
|
||||
gtk_button_set_focus_on_click (GTK_BUTTON (button_data->button), FALSE);
|
||||
|
||||
button_data->drag_info.target_location = g_object_ref (path);
|
||||
|
||||
switch (button_data->type) {
|
||||
case ROOT_BUTTON:
|
||||
|
@ -1391,12 +1524,10 @@ make_directory_button (NautilusPathBar *path_bar,
|
|||
g_signal_connect (button_data->button, "clicked", G_CALLBACK (button_clicked_cb), button_data);
|
||||
g_object_weak_ref (G_OBJECT (button_data->button), (GWeakNotify) button_data_free, button_data);
|
||||
|
||||
gtk_drag_source_set (button_data->button,
|
||||
GDK_BUTTON1_MASK,
|
||||
targets,
|
||||
G_N_ELEMENTS (targets),
|
||||
GDK_ACTION_COPY);
|
||||
g_signal_connect (button_data->button, "drag-data-get",G_CALLBACK (button_drag_data_get_cb), button_data);
|
||||
setup_button_drag_source (button_data);
|
||||
|
||||
nautilus_drag_slot_proxy_init (button_data->button,
|
||||
&(button_data->drag_info));
|
||||
|
||||
return button_data;
|
||||
}
|
||||
|
|
|
@ -61,6 +61,9 @@ struct _NautilusPathBar
|
|||
guint slider_visible : 1;
|
||||
guint need_timer : 1;
|
||||
guint ignore_click : 1;
|
||||
|
||||
unsigned int drag_slider_timeout;
|
||||
gboolean drag_slider_timeout_for_up_button;
|
||||
};
|
||||
|
||||
struct _NautilusPathBarClass
|
||||
|
|
Loading…
Reference in a new issue