mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-13 14:00:09 +00:00
Handle NSFilenamesPboardType in addition to NSURLPboardType to support dnd
2007-10-23 Richard Hult <richard@imendio.com> * gtk/gtkquartz.c: (_gtk_quartz_get_selection_data_from_pasteboard): Handle NSFilenamesPboardType in addition to NSURLPboardType to support dnd with multiple files from Finder, based on patch from Paul Davis (bug #467490). svn path=/trunk/; revision=18941
This commit is contained in:
parent
c42c7be050
commit
e4849ff2b7
@ -1,3 +1,11 @@
|
|||||||
|
2007-10-23 Richard Hult <richard@imendio.com>
|
||||||
|
|
||||||
|
* gtk/gtkquartz.c:
|
||||||
|
(_gtk_quartz_get_selection_data_from_pasteboard): Handle
|
||||||
|
NSFilenamesPboardType in addition to NSURLPboardType to support
|
||||||
|
dnd with multiple files from Finder, based on patch from Paul
|
||||||
|
Davis (bug #467490).
|
||||||
|
|
||||||
2007-10-23 Richard Hult <richard@imendio.com>
|
2007-10-23 Richard Hult <richard@imendio.com>
|
||||||
|
|
||||||
* gdk/quartz/gdkwindow-quartz.c:
|
* gdk/quartz/gdkwindow-quartz.c:
|
||||||
|
@ -100,7 +100,6 @@ _gtk_quartz_target_list_to_pasteboard_types (GtkTargetList *target_list)
|
|||||||
return [set allObjects];
|
return [set allObjects];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NSArray *
|
NSArray *
|
||||||
_gtk_quartz_target_entries_to_pasteboard_types (const GtkTargetEntry *targets,
|
_gtk_quartz_target_entries_to_pasteboard_types (const GtkTargetEntry *targets,
|
||||||
guint n_targets)
|
guint n_targets)
|
||||||
@ -164,10 +163,11 @@ _gtk_quartz_get_selection_data_from_pasteboard (NSPasteboard *pasteboard,
|
|||||||
if (target == gdk_atom_intern_static_string ("UTF8_STRING"))
|
if (target == gdk_atom_intern_static_string ("UTF8_STRING"))
|
||||||
{
|
{
|
||||||
NSString *s = [pasteboard stringForType:NSStringPboardType];
|
NSString *s = [pasteboard stringForType:NSStringPboardType];
|
||||||
int len = [s length];
|
|
||||||
|
|
||||||
if (s)
|
if (s)
|
||||||
{
|
{
|
||||||
|
int len = [s length];
|
||||||
|
|
||||||
selection_data->type = target;
|
selection_data->type = target;
|
||||||
selection_data->format = 8;
|
selection_data->format = 8;
|
||||||
selection_data->length = len;
|
selection_data->length = len;
|
||||||
@ -176,7 +176,8 @@ _gtk_quartz_get_selection_data_from_pasteboard (NSPasteboard *pasteboard,
|
|||||||
}
|
}
|
||||||
else if (target == gdk_atom_intern_static_string ("application/x-color"))
|
else if (target == gdk_atom_intern_static_string ("application/x-color"))
|
||||||
{
|
{
|
||||||
NSColor *nscolor = [[NSColor colorFromPasteboard:pasteboard] colorUsingColorSpaceName:NSDeviceRGBColorSpace];
|
NSColor *nscolor = [[NSColor colorFromPasteboard:pasteboard]
|
||||||
|
colorUsingColorSpaceName:NSDeviceRGBColorSpace];
|
||||||
|
|
||||||
guint16 color[4];
|
guint16 color[4];
|
||||||
|
|
||||||
@ -190,16 +191,41 @@ _gtk_quartz_get_selection_data_from_pasteboard (NSPasteboard *pasteboard,
|
|||||||
gtk_selection_data_set (selection_data, target, 16, (guchar *)color, 8);
|
gtk_selection_data_set (selection_data, target, 16, (guchar *)color, 8);
|
||||||
}
|
}
|
||||||
else if (target == gdk_atom_intern_static_string ("text/uri-list"))
|
else if (target == gdk_atom_intern_static_string ("text/uri-list"))
|
||||||
|
{
|
||||||
|
if ([[pasteboard types] containsObject:NSFilenamesPboardType])
|
||||||
|
{
|
||||||
|
gchar **uris;
|
||||||
|
NSArray *files = [pasteboard propertyListForType:NSFilenamesPboardType];
|
||||||
|
int n_files = [files count];
|
||||||
|
int i;
|
||||||
|
|
||||||
|
selection_data->target = gdk_atom_intern_static_string ("text/uri-list");
|
||||||
|
|
||||||
|
uris = (gchar **) g_malloc (sizeof (gchar*) * (n_files + 1));
|
||||||
|
for (i = 0; i < n_files; ++i)
|
||||||
|
{
|
||||||
|
NSString* uriString = [files objectAtIndex:i];
|
||||||
|
uriString = [@"file://" stringByAppendingString:uriString];
|
||||||
|
uriString = [uriString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
|
||||||
|
uris[i] = (gchar *) [uriString cStringUsingEncoding:NSUTF8StringEncoding];
|
||||||
|
}
|
||||||
|
uris[i] = NULL;
|
||||||
|
|
||||||
|
gtk_selection_data_set_uris (selection_data, uris);
|
||||||
|
g_free (uris);
|
||||||
|
}
|
||||||
|
else if ([[pasteboard types] containsObject:NSURLPboardType])
|
||||||
{
|
{
|
||||||
gchar *uris[2];
|
gchar *uris[2];
|
||||||
NSURL *url = [NSURL URLFromPasteboard:pasteboard];
|
NSURL *url = [NSURL URLFromPasteboard:pasteboard];
|
||||||
|
|
||||||
selection_data->target = gdk_atom_intern_static_string ("text/uri-list");
|
selection_data->target = gdk_atom_intern_static_string ("text/uri-list");
|
||||||
|
|
||||||
uris[0] = [[url description] UTF8String];
|
uris[0] = (gchar *) [[url description] UTF8String];
|
||||||
uris[1] = NULL;
|
uris[1] = NULL;
|
||||||
gtk_selection_data_set_uris (selection_data, uris);
|
gtk_selection_data_set_uris (selection_data, uris);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NSData *data;
|
NSData *data;
|
||||||
@ -233,7 +259,6 @@ _gtk_quartz_set_selection_data_for_pasteboard (NSPasteboard *pasteboard,
|
|||||||
GtkSelectionData *selection_data)
|
GtkSelectionData *selection_data)
|
||||||
{
|
{
|
||||||
NSString *type;
|
NSString *type;
|
||||||
NSData *data;
|
|
||||||
gchar *target = gdk_atom_name (selection_data->target);
|
gchar *target = gdk_atom_name (selection_data->target);
|
||||||
|
|
||||||
type = target_to_pasteboard_type (target);
|
type = target_to_pasteboard_type (target);
|
||||||
|
Loading…
Reference in New Issue
Block a user