Compare commits
3 Commits
wip/matthi
...
dnd-test
Author | SHA1 | Date | |
---|---|---|---|
|
cb7202ac6f | ||
|
ef632da8b6 | ||
|
0967f6f3fc |
@@ -355,7 +355,7 @@ gtk_color_button_drag_data_get (GtkWidget *widget,
|
||||
|
||||
gtk_selection_data_set (selection_data,
|
||||
gtk_selection_data_get_target (selection_data),
|
||||
16, (guchar *)dropped, 8);
|
||||
(guchar *)dropped, 8);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -202,7 +202,7 @@ swatch_drag_data_get (GtkWidget *widget,
|
||||
|
||||
gtk_selection_data_set (selection_data,
|
||||
g_intern_static_string ("application/x-color"),
|
||||
16, (guchar *)vals, 8);
|
||||
(guchar *)vals, 8);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -166,7 +166,6 @@ gtk_drag_get_data_finish (GtkDragGetData *data,
|
||||
|
||||
sdata.target = data->mime_type;
|
||||
sdata.type = data->mime_type;
|
||||
sdata.format = 8;
|
||||
sdata.length = size;
|
||||
sdata.data = bytes;
|
||||
sdata.display = gtk_widget_get_display (data->widget);
|
||||
|
@@ -444,7 +444,6 @@ gtk_link_button_drag_data_get_cb (GtkWidget *widget,
|
||||
uri = g_strdup_printf ("%s\r\n", priv->uri);
|
||||
gtk_selection_data_set (selection,
|
||||
gtk_selection_data_get_target (selection),
|
||||
8,
|
||||
(guchar *) uri,
|
||||
strlen (uri));
|
||||
|
||||
|
@@ -3212,14 +3212,13 @@ gtk_notebook_drag_data_get (GtkWidget *widget,
|
||||
{
|
||||
gtk_selection_data_set (data,
|
||||
target,
|
||||
8,
|
||||
(void*) &priv->detached_tab->child,
|
||||
sizeof (gpointer));
|
||||
priv->rootwindow_drop = FALSE;
|
||||
}
|
||||
else if (target == g_intern_static_string ("application/x-rootwindow-drop"))
|
||||
{
|
||||
gtk_selection_data_set (data, target, 8, NULL, 0);
|
||||
gtk_selection_data_set (data, target, NULL, 0);
|
||||
priv->rootwindow_drop = TRUE;
|
||||
}
|
||||
}
|
||||
|
@@ -1964,7 +1964,6 @@ drag_data_get_callback (GtkWidget *widget,
|
||||
{
|
||||
gtk_selection_data_set (data,
|
||||
target,
|
||||
8,
|
||||
(void*)&sidebar->drag_row,
|
||||
sizeof (gpointer));
|
||||
}
|
||||
|
@@ -193,7 +193,7 @@ _gtk_quartz_get_selection_data_from_pasteboard (NSPasteboard *pasteboard,
|
||||
const char *utf8_string = [s UTF8String];
|
||||
|
||||
gtk_selection_data_set (selection_data,
|
||||
target, 8,
|
||||
target,
|
||||
(guchar *)utf8_string, strlen (utf8_string));
|
||||
}
|
||||
}
|
||||
@@ -211,7 +211,7 @@ _gtk_quartz_get_selection_data_from_pasteboard (NSPasteboard *pasteboard,
|
||||
color[2] = 0xffff * [nscolor blueComponent];
|
||||
color[3] = 0xffff * [nscolor alphaComponent];
|
||||
|
||||
gtk_selection_data_set (selection_data, target, 16, (guchar *)color, 8);
|
||||
gtk_selection_data_set (selection_data, target, (guchar *)color, 8);
|
||||
}
|
||||
else if (target == g_intern_static_string ("text/uri-list"))
|
||||
{
|
||||
@@ -265,7 +265,7 @@ _gtk_quartz_get_selection_data_from_pasteboard (NSPasteboard *pasteboard,
|
||||
if (data)
|
||||
{
|
||||
gtk_selection_data_set (selection_data,
|
||||
target, 8,
|
||||
target,
|
||||
[data bytes], [data length]);
|
||||
}
|
||||
}
|
||||
@@ -279,12 +279,10 @@ _gtk_quartz_set_selection_data_for_pasteboard (NSPasteboard *pasteboard,
|
||||
{
|
||||
NSString *type;
|
||||
GdkDisplay *display;
|
||||
gint format;
|
||||
const guchar *data;
|
||||
NSUInteger length;
|
||||
|
||||
display = gtk_selection_data_get_display (selection_data);
|
||||
format = gtk_selection_data_get_format (selection_data);
|
||||
data = gtk_selection_data_get_data (selection_data);
|
||||
length = gtk_selection_data_get_length (selection_data);
|
||||
|
||||
|
@@ -299,22 +299,6 @@ gtk_selection_data_get_data_type (const GtkSelectionData *selection_data)
|
||||
return selection_data->type;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_selection_data_get_format:
|
||||
* @selection_data: a pointer to a #GtkSelectionData-struct.
|
||||
*
|
||||
* Retrieves the format of the selection.
|
||||
*
|
||||
* Returns: the format of the selection.
|
||||
**/
|
||||
gint
|
||||
gtk_selection_data_get_format (const GtkSelectionData *selection_data)
|
||||
{
|
||||
g_return_val_if_fail (selection_data != NULL, 0);
|
||||
|
||||
return selection_data->format;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_selection_data_get_data: (skip)
|
||||
* @selection_data: a pointer to a
|
||||
@@ -388,7 +372,6 @@ gtk_selection_data_get_display (const GtkSelectionData *selection_data)
|
||||
* gtk_selection_data_set:
|
||||
* @selection_data: a pointer to a #GtkSelectionData-struct.
|
||||
* @type: the type of selection data
|
||||
* @format: format (number of bits in a unit)
|
||||
* @data: (array length=length): pointer to the data (will be copied)
|
||||
* @length: length of the data
|
||||
*
|
||||
@@ -399,7 +382,6 @@ gtk_selection_data_get_display (const GtkSelectionData *selection_data)
|
||||
void
|
||||
gtk_selection_data_set (GtkSelectionData *selection_data,
|
||||
GdkAtom type,
|
||||
gint format,
|
||||
const guchar *data,
|
||||
gint length)
|
||||
{
|
||||
@@ -408,7 +390,6 @@ gtk_selection_data_set (GtkSelectionData *selection_data,
|
||||
g_free (selection_data->data);
|
||||
|
||||
selection_data->type = type;
|
||||
selection_data->format = format;
|
||||
|
||||
if (data)
|
||||
{
|
||||
@@ -442,7 +423,7 @@ selection_set_string (GtkSelectionData *selection_data,
|
||||
{
|
||||
gtk_selection_data_set (selection_data,
|
||||
g_intern_static_string ("STRING"),
|
||||
8, (guchar *) latin1, strlen (latin1));
|
||||
(guchar *) latin1, strlen (latin1));
|
||||
g_free (latin1);
|
||||
|
||||
return TRUE;
|
||||
@@ -462,16 +443,15 @@ selection_set_compound_text (GtkSelectionData *selection_data,
|
||||
gchar *tmp;
|
||||
guchar *text;
|
||||
GdkAtom encoding;
|
||||
gint format;
|
||||
gint new_length;
|
||||
|
||||
if (GDK_IS_X11_DISPLAY (selection_data->display))
|
||||
{
|
||||
tmp = g_strndup (str, len);
|
||||
if (gdk_x11_display_utf8_to_compound_text (selection_data->display, tmp,
|
||||
&encoding, &format, &text, &new_length))
|
||||
&encoding, NULL, &text, &new_length))
|
||||
{
|
||||
gtk_selection_data_set (selection_data, encoding, format, text, new_length);
|
||||
gtk_selection_data_set (selection_data, encoding, text, new_length);
|
||||
gdk_x11_free_compound_text (text);
|
||||
|
||||
result = TRUE;
|
||||
@@ -578,7 +558,7 @@ selection_set_text_plain (GtkSelectionData *selection_data,
|
||||
|
||||
gtk_selection_data_set (selection_data,
|
||||
selection_data->target,
|
||||
8, (guchar *) result, strlen (result));
|
||||
(guchar *) result, strlen (result));
|
||||
g_free (result);
|
||||
|
||||
return TRUE;
|
||||
@@ -661,7 +641,7 @@ gtk_selection_data_set_text (GtkSelectionData *selection_data,
|
||||
{
|
||||
gtk_selection_data_set (selection_data,
|
||||
utf8_atom,
|
||||
8, (guchar *)str, len);
|
||||
(guchar *)str, len);
|
||||
return TRUE;
|
||||
}
|
||||
else if (selection_data->target == g_intern_static_string ("STRING"))
|
||||
@@ -715,7 +695,7 @@ gtk_selection_data_get_text (const GtkSelectionData *selection_data)
|
||||
gint i;
|
||||
gint count = gdk_text_property_to_utf8_list_for_display (selection_data->display,
|
||||
selection_data->type,
|
||||
selection_data->format,
|
||||
8,
|
||||
selection_data->data,
|
||||
selection_data->length,
|
||||
&list);
|
||||
@@ -784,7 +764,7 @@ gtk_selection_data_set_pixbuf (GtkSelectionData *selection_data,
|
||||
NULL);
|
||||
if (result)
|
||||
gtk_selection_data_set (selection_data,
|
||||
atom, 8, (guchar *)str, len);
|
||||
atom, (guchar *)str, len);
|
||||
g_free (type);
|
||||
g_free (str);
|
||||
g_strfreev (mimes);
|
||||
@@ -963,7 +943,7 @@ gtk_selection_data_set_uris (GtkSelectionData *selection_data,
|
||||
{
|
||||
gtk_selection_data_set (selection_data,
|
||||
text_uri_list_atom,
|
||||
8, (guchar *)result, length);
|
||||
(guchar *)result, length);
|
||||
|
||||
g_free (result);
|
||||
|
||||
@@ -1001,7 +981,7 @@ gtk_selection_data_get_uris (const GtkSelectionData *selection_data)
|
||||
gchar **list;
|
||||
gint count = gdk_text_property_to_utf8_list_for_display (selection_data->display,
|
||||
utf8_atom,
|
||||
selection_data->format,
|
||||
8,
|
||||
selection_data->data,
|
||||
selection_data->length,
|
||||
&list);
|
||||
@@ -1014,52 +994,6 @@ gtk_selection_data_get_uris (const GtkSelectionData *selection_data)
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* gtk_selection_data_get_targets:
|
||||
* @selection_data: a #GtkSelectionData object
|
||||
* @targets: (out) (array length=n_atoms) (transfer container):
|
||||
* location to store an array of targets. The result stored
|
||||
* here must be freed with g_free().
|
||||
* @n_atoms: location to store number of items in @targets.
|
||||
*
|
||||
* Gets the contents of @selection_data as an array of targets.
|
||||
* This can be used to interpret the results of getting
|
||||
* the standard TARGETS target that is always supplied for
|
||||
* any selection.
|
||||
*
|
||||
* Returns: %TRUE if @selection_data contains a valid
|
||||
* array of targets, otherwise %FALSE.
|
||||
**/
|
||||
gboolean
|
||||
gtk_selection_data_get_targets (const GtkSelectionData *selection_data,
|
||||
GdkAtom **targets,
|
||||
gint *n_atoms)
|
||||
{
|
||||
g_return_val_if_fail (selection_data != NULL, FALSE);
|
||||
|
||||
if (selection_data->length >= 0 &&
|
||||
selection_data->format == 32 &&
|
||||
selection_data->type == g_intern_static_string ("ATOM"))
|
||||
{
|
||||
if (targets)
|
||||
*targets = g_memdup (selection_data->data, selection_data->length);
|
||||
if (n_atoms)
|
||||
*n_atoms = selection_data->length / sizeof (GdkAtom);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (targets)
|
||||
*targets = NULL;
|
||||
if (n_atoms)
|
||||
*n_atoms = -1;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_targets_include_text:
|
||||
* @targets: (array length=n_targets): an array of #GdkAtoms
|
||||
@@ -1117,21 +1051,15 @@ gtk_targets_include_text (GdkAtom *targets,
|
||||
gboolean
|
||||
gtk_selection_data_targets_include_text (const GtkSelectionData *selection_data)
|
||||
{
|
||||
GdkAtom *targets;
|
||||
gint n_targets;
|
||||
gboolean result = FALSE;
|
||||
GdkAtom target;
|
||||
|
||||
g_return_val_if_fail (selection_data != NULL, FALSE);
|
||||
|
||||
init_atoms ();
|
||||
|
||||
if (gtk_selection_data_get_targets (selection_data, &targets, &n_targets))
|
||||
{
|
||||
result = gtk_targets_include_text (targets, n_targets);
|
||||
g_free (targets);
|
||||
}
|
||||
target = gtk_selection_data_get_target (selection_data);
|
||||
|
||||
return result;
|
||||
return gtk_targets_include_text (&target, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1190,21 +1118,15 @@ gboolean
|
||||
gtk_selection_data_targets_include_image (const GtkSelectionData *selection_data,
|
||||
gboolean writable)
|
||||
{
|
||||
GdkAtom *targets;
|
||||
gint n_targets;
|
||||
gboolean result = FALSE;
|
||||
GdkAtom target;
|
||||
|
||||
g_return_val_if_fail (selection_data != NULL, FALSE);
|
||||
|
||||
init_atoms ();
|
||||
|
||||
if (gtk_selection_data_get_targets (selection_data, &targets, &n_targets))
|
||||
{
|
||||
result = gtk_targets_include_image (targets, n_targets, writable);
|
||||
g_free (targets);
|
||||
}
|
||||
target = gtk_selection_data_get_target (selection_data);
|
||||
|
||||
return result;
|
||||
return gtk_targets_include_image (&target, 1, writable);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1258,21 +1180,15 @@ gtk_targets_include_uri (GdkAtom *targets,
|
||||
gboolean
|
||||
gtk_selection_data_targets_include_uri (const GtkSelectionData *selection_data)
|
||||
{
|
||||
GdkAtom *targets;
|
||||
gint n_targets;
|
||||
gboolean result = FALSE;
|
||||
GdkAtom target;
|
||||
|
||||
g_return_val_if_fail (selection_data != NULL, FALSE);
|
||||
|
||||
init_atoms ();
|
||||
|
||||
if (gtk_selection_data_get_targets (selection_data, &targets, &n_targets))
|
||||
{
|
||||
result = gtk_targets_include_uri (targets, n_targets);
|
||||
g_free (targets);
|
||||
}
|
||||
target = gtk_selection_data_get_target (selection_data);
|
||||
|
||||
return result;
|
||||
return gtk_targets_include_uri (&target, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -49,8 +49,6 @@ GdkAtom gtk_selection_data_get_target (const GtkSelectionData *selectio
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GdkAtom gtk_selection_data_get_data_type (const GtkSelectionData *selection_data);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gint gtk_selection_data_get_format (const GtkSelectionData *selection_data);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
const guchar *gtk_selection_data_get_data (const GtkSelectionData *selection_data);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gint gtk_selection_data_get_length (const GtkSelectionData *selection_data);
|
||||
@@ -65,7 +63,6 @@ GdkDisplay *gtk_selection_data_get_display (const GtkSelectionData *selectio
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_selection_data_set (GtkSelectionData *selection_data,
|
||||
GdkAtom type,
|
||||
gint format,
|
||||
const guchar *data,
|
||||
gint length);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
@@ -90,10 +87,6 @@ gboolean gtk_selection_data_set_uris (GtkSelectionData *selection_data,
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gchar **gtk_selection_data_get_uris (const GtkSelectionData *selection_data);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_selection_data_get_targets (const GtkSelectionData *selection_data,
|
||||
GdkAtom **targets,
|
||||
gint *n_atoms);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gtk_selection_data_targets_include_text (const GtkSelectionData *selection_data);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
|
@@ -40,7 +40,6 @@ struct _GtkSelectionData
|
||||
/*< private >*/
|
||||
GdkAtom target;
|
||||
GdkAtom type;
|
||||
gint format;
|
||||
guchar *data;
|
||||
gint length;
|
||||
GdkDisplay *display;
|
||||
|
@@ -7653,7 +7653,6 @@ gtk_text_view_drag_data_get (GtkWidget *widget,
|
||||
{
|
||||
gtk_selection_data_set (selection_data,
|
||||
g_intern_static_string ("GTK_TEXT_BUFFER_CONTENTS"),
|
||||
8, /* bytes */
|
||||
(void*)&buffer,
|
||||
sizeof (buffer));
|
||||
}
|
||||
|
@@ -293,7 +293,6 @@ gtk_tree_set_row_drag_data (GtkSelectionData *selection_data,
|
||||
|
||||
gtk_selection_data_set (selection_data,
|
||||
g_intern_static_string ("GTK_TREE_MODEL_ROW"),
|
||||
8, /* bytes */
|
||||
(void*)trd,
|
||||
struct_size);
|
||||
|
||||
|
@@ -295,8 +295,6 @@ static const char *target_table[] = {
|
||||
"application/x-rootwindow-drop"
|
||||
};
|
||||
|
||||
static guint n_targets = sizeof(target_table) / sizeof(target_table[0]);
|
||||
|
||||
void
|
||||
target_drag_leave (GtkWidget *widget,
|
||||
GdkDrop *drop,
|
||||
@@ -386,8 +384,7 @@ target_drag_data_received (GtkWidget *widget,
|
||||
GdkDrop *drop,
|
||||
GtkSelectionData *selection_data)
|
||||
{
|
||||
if (gtk_selection_data_get_length (selection_data) >= 0 &&
|
||||
gtk_selection_data_get_format (selection_data) == 8)
|
||||
if (gtk_selection_data_get_length (selection_data) >= 0)
|
||||
{
|
||||
GdkDragAction action = gdk_drop_get_actions (drop);
|
||||
g_print ("Received \"%s\" in trashcan\n", (gchar *) gtk_selection_data_get_data (selection_data));
|
||||
@@ -404,8 +401,7 @@ label_drag_data_received (GtkWidget *widget,
|
||||
GdkDrop *drop,
|
||||
GtkSelectionData *selection_data)
|
||||
{
|
||||
if (gtk_selection_data_get_length (selection_data) >= 0 &&
|
||||
gtk_selection_data_get_format (selection_data) == 8)
|
||||
if (gtk_selection_data_get_length (selection_data) >= 0)
|
||||
{
|
||||
GdkDragAction action = action_make_unique (gdk_drop_get_actions (drop));
|
||||
g_print ("Received \"%s\" in label\n", (gchar *) gtk_selection_data_get_data (selection_data));
|
||||
@@ -426,8 +422,8 @@ source_drag_data_get (GtkWidget *widget,
|
||||
g_print ("I was dropped on the rootwin\n");
|
||||
else
|
||||
gtk_selection_data_set (selection_data,
|
||||
gtk_selection_data_get_target (selection_data),
|
||||
8, (guchar *) "I'm Data!", 9);
|
||||
gtk_selection_data_get_target (selection_data),
|
||||
(guchar *) "I'm Data!", 9);
|
||||
}
|
||||
|
||||
/* The following is a rather elaborate example demonstrating/testing
|
||||
@@ -503,7 +499,8 @@ popup_cb (gpointer data)
|
||||
gtk_window_set_position (GTK_WINDOW (popup_window), GTK_WIN_POS_MOUSE);
|
||||
|
||||
grid = gtk_grid_new ();
|
||||
targets = gdk_content_formats_new (target_table, n_targets - 1); /* no rootwin */
|
||||
/* no rootwin */
|
||||
targets = gdk_content_formats_new (target_table, G_N_ELEMENTS (target_table) - 1);
|
||||
|
||||
for (i=0; i<3; i++)
|
||||
for (j=0; j<3; j++)
|
||||
@@ -610,7 +607,8 @@ main (int argc, char **argv)
|
||||
|
||||
label = gtk_label_new ("Drop Here\n");
|
||||
|
||||
targets = gdk_content_formats_new (target_table, n_targets - 1); /* no rootwin */
|
||||
/* no rootwin */
|
||||
targets = gdk_content_formats_new (target_table, G_N_ELEMENTS (target_table) - 1);
|
||||
gtk_drag_dest_set (label,
|
||||
GTK_DEST_DEFAULT_ALL,
|
||||
targets,
|
||||
@@ -662,7 +660,7 @@ main (int argc, char **argv)
|
||||
|
||||
button = gtk_button_new_with_label ("Drag Here\n");
|
||||
|
||||
targets = gdk_content_formats_new (target_table, n_targets);
|
||||
targets = gdk_content_formats_new (target_table, G_N_ELEMENTS (target_table));
|
||||
gtk_drag_source_set (button, GDK_BUTTON1_MASK | GDK_BUTTON3_MASK,
|
||||
targets,
|
||||
GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||
|
@@ -33,7 +33,6 @@ drag_data_get (GtkWidget *widget,
|
||||
{
|
||||
gtk_selection_data_set (selection_data,
|
||||
g_intern_static_string ("GTK_LIST_BOX_ROW"),
|
||||
32,
|
||||
(const guchar *)&widget,
|
||||
sizeof (gpointer));
|
||||
}
|
||||
|
Reference in New Issue
Block a user