forked from AuroraMiddleware/gtk
tests: Use accessor functions to access GtkSelectionData
This commit is contained in:
parent
67f6a43702
commit
7105e8e907
@ -377,13 +377,14 @@ target_drag_data_received (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
gint x,
|
||||
gint y,
|
||||
GtkSelectionData *data,
|
||||
GtkSelectionData *selection_data,
|
||||
guint info,
|
||||
guint time)
|
||||
{
|
||||
if ((data->length >= 0) && (data->format == 8))
|
||||
if (gtk_selection_data_get_length (selection_data) >= 0 &&
|
||||
gtk_selection_data_get_format (selection_data) == 8)
|
||||
{
|
||||
g_print ("Received \"%s\" in trashcan\n", (gchar *)data->data);
|
||||
g_print ("Received \"%s\" in trashcan\n", (gchar *) gtk_selection_data_get_data (selection_data));
|
||||
gtk_drag_finish (context, TRUE, FALSE, time);
|
||||
return;
|
||||
}
|
||||
@ -396,13 +397,14 @@ label_drag_data_received (GtkWidget *widget,
|
||||
GdkDragContext *context,
|
||||
gint x,
|
||||
gint y,
|
||||
GtkSelectionData *data,
|
||||
GtkSelectionData *selection_data,
|
||||
guint info,
|
||||
guint time)
|
||||
{
|
||||
if ((data->length >= 0) && (data->format == 8))
|
||||
if (gtk_selection_data_get_length (selection_data) >= 0 &&
|
||||
gtk_selection_data_get_format (selection_data) == 8)
|
||||
{
|
||||
g_print ("Received \"%s\" in label\n", (gchar *)data->data);
|
||||
g_print ("Received \"%s\" in label\n", (gchar *) gtk_selection_data_get_data (selection_data));
|
||||
gtk_drag_finish (context, TRUE, FALSE, time);
|
||||
return;
|
||||
}
|
||||
@ -422,7 +424,7 @@ source_drag_data_get (GtkWidget *widget,
|
||||
g_print ("I was dropped on the rootwin\n");
|
||||
else
|
||||
gtk_selection_data_set (selection_data,
|
||||
selection_data->target,
|
||||
gtk_selection_data_get_target (selection_data),
|
||||
8, (guchar *) "I'm Data!", 9);
|
||||
}
|
||||
|
||||
|
@ -8917,19 +8917,19 @@ create_snapshot (GtkWidget *widget)
|
||||
|
||||
void
|
||||
selection_test_received (GtkWidget *tree_view,
|
||||
GtkSelectionData *data)
|
||||
GtkSelectionData *selection_data)
|
||||
{
|
||||
GtkTreeModel *model;
|
||||
GtkListStore *store;
|
||||
GdkAtom *atoms;
|
||||
int i, l;
|
||||
|
||||
if (data->length < 0)
|
||||
if (gtk_selection_data_get_length (selection_data) < 0)
|
||||
{
|
||||
g_print ("Selection retrieval failed\n");
|
||||
return;
|
||||
}
|
||||
if (data->type != GDK_SELECTION_TYPE_ATOM)
|
||||
if (gtk_selection_data_get_data_type (selection_data) != GDK_SELECTION_TYPE_ATOM)
|
||||
{
|
||||
g_print ("Selection \"TARGETS\" was not returned as atoms!\n");
|
||||
return;
|
||||
@ -8943,9 +8943,9 @@ selection_test_received (GtkWidget *tree_view,
|
||||
|
||||
/* Add new items to list */
|
||||
|
||||
atoms = (GdkAtom *)data->data;
|
||||
gtk_selection_data_get_targets (selection_data,
|
||||
&atoms, &l);
|
||||
|
||||
l = data->length / sizeof (GdkAtom);
|
||||
for (i = 0; i < l; i++)
|
||||
{
|
||||
char *name;
|
||||
|
@ -61,7 +61,7 @@ drag_data_received (GtkWidget *widget,
|
||||
|
||||
GdkPixbuf *pixbuf;
|
||||
|
||||
if (selection_data->length < 0)
|
||||
if (gtk_selection_data_get_length (selection_data) < 0)
|
||||
return;
|
||||
|
||||
pixbuf = gtk_selection_data_get_pixbuf (selection_data);
|
||||
|
@ -134,7 +134,7 @@ on_button_drag_data_received (GtkWidget *widget,
|
||||
GtkWidget **child;
|
||||
|
||||
source = gtk_drag_get_source_widget (context);
|
||||
child = (void*) data->data;
|
||||
child = (void*) gtk_selection_data_get_data (data);
|
||||
|
||||
tab_label = gtk_notebook_get_tab_label (GTK_NOTEBOOK (source), *child);
|
||||
g_print ("Removing tab: %s\n", gtk_label_get_text (GTK_LABEL (tab_label)));
|
||||
|
@ -265,24 +265,28 @@ stringify_span (guchar *data, gint *position)
|
||||
}
|
||||
|
||||
void
|
||||
selection_received (GtkWidget *widget, GtkSelectionData *data)
|
||||
selection_received (GtkWidget *widget, GtkSelectionData *selection_data)
|
||||
{
|
||||
int position;
|
||||
int i;
|
||||
SelType seltype;
|
||||
char *str;
|
||||
guchar *data;
|
||||
GtkTextBuffer *buffer;
|
||||
GdkAtom type;
|
||||
|
||||
if (data->length < 0)
|
||||
if (gtk_selection_data_get_length (selection_data) < 0)
|
||||
{
|
||||
g_print("Error retrieving selection\n");
|
||||
return;
|
||||
}
|
||||
|
||||
type = gtk_selection_data_get_data_type (selection_data);
|
||||
|
||||
seltype = SEL_TYPE_NONE;
|
||||
for (i=0; i<LAST_SEL_TYPE; i++)
|
||||
{
|
||||
if (seltypes[i] == data->type)
|
||||
if (seltypes[i] == type)
|
||||
{
|
||||
seltype = i;
|
||||
break;
|
||||
@ -291,7 +295,7 @@ selection_received (GtkWidget *widget, GtkSelectionData *data)
|
||||
|
||||
if (seltype == SEL_TYPE_NONE)
|
||||
{
|
||||
char *name = gdk_atom_name (data->type);
|
||||
char *name = gdk_atom_name (type);
|
||||
g_print("Don't know how to handle type: %s\n",
|
||||
name?name:"<unknown>");
|
||||
return;
|
||||
@ -306,38 +310,39 @@ selection_received (GtkWidget *widget, GtkSelectionData *data)
|
||||
gtk_text_buffer_set_text (buffer, "", -1);
|
||||
|
||||
position = 0;
|
||||
while (position < data->length)
|
||||
while (position < gtk_selection_data_get_length (selection_data))
|
||||
{
|
||||
data = (guchar *) gtk_selection_data_get_data (selection_data);
|
||||
switch (seltype)
|
||||
{
|
||||
case ATOM:
|
||||
str = stringify_atom (data->data, &position);
|
||||
str = stringify_atom (data, &position);
|
||||
break;
|
||||
case COMPOUND_TEXT:
|
||||
case STRING:
|
||||
case TEXT:
|
||||
str = stringify_text (data->data, &position);
|
||||
str = stringify_text (data, &position);
|
||||
break;
|
||||
case BITMAP:
|
||||
case DRAWABLE:
|
||||
case PIXMAP:
|
||||
case WINDOW:
|
||||
case COLORMAP:
|
||||
str = stringify_xid (data->data, &position);
|
||||
str = stringify_xid (data, &position);
|
||||
break;
|
||||
case INTEGER:
|
||||
case PIXEL:
|
||||
str = stringify_integer (data->data, &position);
|
||||
str = stringify_integer (data, &position);
|
||||
break;
|
||||
case SPAN:
|
||||
str = stringify_span (data->data, &position);
|
||||
str = stringify_span (data, &position);
|
||||
break;
|
||||
default:
|
||||
{
|
||||
char *name = gdk_atom_name (data->type);
|
||||
char *name = gdk_atom_name (gtk_selection_data_get_data_type (selection_data));
|
||||
g_print("Can't convert type %s to string\n",
|
||||
name?name:"<unknown>");
|
||||
position = data->length;
|
||||
position = gtk_selection_data_get_length (selection_data);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user