Skip to content

Commit

Permalink
Some drag structs should use functions to access members now
Browse files Browse the repository at this point in the history
  • Loading branch information
gusnan committed Oct 25, 2022
1 parent 06fb6ab commit bf202cf
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 15 deletions.
28 changes: 17 additions & 11 deletions src/dndtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,34 +73,36 @@ drag_data_received_handl


/* Deal with what we are given from source */
if((selection_data != NULL) && (selection_data-> length >= 0))
if((selection_data != NULL) && (gtk_selection_data_get_length(selection_data) >= 0))
{
if (context-> action == GDK_ACTION_ASK)
GdkDragAction drag_action = gdk_drag_context_get_suggested_action(context);

if (drag_action == GDK_ACTION_ASK)
{
/* Ask the user to move or copy, then set the context action. */
}

if (context-> action == GDK_ACTION_MOVE)
if (drag_action == GDK_ACTION_MOVE)
delete_selection_data = TRUE;

/* Check that we got the format we can use */
g_print (" Receiving ");
switch (target_type)
{
case TARGET_INT32:
_idata = (glong*)selection_data-> data;
_idata = (glong*)gtk_selection_data_get_data(selection_data);
g_print ("integer: %ld", *_idata);
dnd_success = TRUE;
break;

case TARGET_STRING:
_sdata = (gchar*)selection_data-> data;
_sdata = (gchar*)gtk_selection_data_get_data(selection_data);
g_print ("string: %s", _sdata);
dnd_success = TRUE;
break;

case TARGET_URIS:
_sdata = (gchar*)selection_data-> data;
_sdata = (gchar*)gtk_selection_data_get_data(selection_data);
g_print ("uris: %s", _sdata);
dnd_success = TRUE;
break;
Expand Down Expand Up @@ -160,12 +162,14 @@ drag_drop_handl
/* Check to see if (x,y) is a valid drop site within widget */
is_valid_drop_site = TRUE;

GList *targets = gdk_drag_context_list_targets(context);

/* If the source offers a target */
if (context-> targets)
if (targets)
{
/* Choose the best target type */
target_type = GDK_POINTER_TO_ATOM
(g_list_nth_data (context-> targets, TARGET_INT32));
(g_list_nth_data (targets, TARGET_INT32));

/* Request the data from the source. */
gtk_drag_get_data
Expand Down Expand Up @@ -222,6 +226,8 @@ drag_data_get_handl
g_print ("%s: drag_data_get_handl\n", name);
g_assert (selection_data != NULL);

GdkAtom target = gtk_selection_data_get_target(selection_data);

g_print (" Sending ");
switch (target_type)
{
Expand All @@ -235,7 +241,7 @@ drag_data_get_handl
gtk_selection_data_set
(
selection_data, /* Allocated GdkSelectionData object */
selection_data-> target,/* target type */
target,/* target type */
_DWORD, /* number of bits per 'unit' */
(guchar*) &integer_data,/* pointer to data to be sent */
sizeof (integer_data) /* length of data in units */
Expand All @@ -247,7 +253,7 @@ drag_data_get_handl
gtk_selection_data_set
(
selection_data,
selection_data-> target,
target,
_BYTE,
(guchar*) string_data,
strlen (string_data)
Expand All @@ -259,7 +265,7 @@ drag_data_get_handl
gtk_selection_data_set
(
selection_data,
selection_data-> target,
target,
_BYTE,
(guchar*) string_data,
strlen (string_data)
Expand Down
15 changes: 11 additions & 4 deletions src/fileman.c
Original file line number Diff line number Diff line change
Expand Up @@ -673,8 +673,10 @@ dnd_drop_handler (GtkWidget *widget, GdkDragContext *context,
{
GdkAtom target_type = gdk_atom_intern ("text/uri-list", FALSE);

GList *targets = gdk_drag_context_list_targets(context);

/* If the source offers a target we request the data from her. */
if (context->targets && g_list_find (context->targets,
if (targets && g_list_find (targets,
GDK_ATOM_TO_POINTER (target_type)))
{
gtk_drag_get_data (widget, context, target_type, tim);
Expand All @@ -697,16 +699,21 @@ dnd_data_received_handler (GtkWidget *widget, GdkDragContext *context,
gboolean dnd_success = FALSE;
gboolean delete_selection_data = FALSE;

// const guchar *our_selection_data = gtk_selection_data_get_data(selection_data);

/* Is that usable by us? */
if (selection_data && selection_data->length >= 0 )
if (selection_data && gtk_selection_data_get_length(selection_data) >= 0 )
{
if (context->action == GDK_ACTION_MOVE)
GdkDragAction drag_action = gdk_drag_context_get_suggested_action(context);

if (drag_action == GDK_ACTION_MOVE)
delete_selection_data = TRUE;

/* Check that we got a format we can use. */
if (target_type == DND_TARGET_URI_LIST)
{
char *p = (char *) selection_data->data;
//char *p = (char *) selection_data->data;
char *p = (char *)gtk_selection_data_get_data(selection_data);
char **list;
int i;

Expand Down

0 comments on commit bf202cf

Please sign in to comment.