Beispiel #1
0
static void
gimp_color_area_drag_data_received (GtkWidget        *widget,
                                    GdkDragContext   *context,
                                    gint              x,
                                    gint              y,
                                    GtkSelectionData *selection_data,
                                    guint             info,
                                    guint             time)
{
  GimpColorArea *area = GIMP_COLOR_AREA (widget);
  const guint16 *vals;
  GimpRGB        color;

  if (gtk_selection_data_get_length (selection_data) != 8 ||
      gtk_selection_data_get_format (selection_data) != 16)
    {
      g_warning ("%s: received invalid color data", G_STRFUNC);
      return;
    }

  vals = (const guint16 *) gtk_selection_data_get_data (selection_data);

  gimp_rgba_set (&color,
                 (gdouble) vals[0] / 0xffff,
                 (gdouble) vals[1] / 0xffff,
                 (gdouble) vals[2] / 0xffff,
                 (gdouble) vals[3] / 0xffff);

  gimp_color_area_set_color (area, &color);
}
Beispiel #2
0
static void
handle_drop(GtkWidget *widget, GdkDragContext *context, gint x, gint y,
            GtkSelectionData *data, guint info, guint time)
{
  gboolean success = FALSE;

  if (gtk_selection_data_get_length (data) >= 0 &&
      gtk_selection_data_get_format (data) == 8)
    {
      ObjectList_t *list = get_shapes();
      Object_t *obj;

      x = get_real_coord(x);
      y = get_real_coord(y);
      obj = object_list_find(list, x, y);
      if (obj && !obj->locked)
        {
          command_list_add(edit_object_command_new(obj));
          object_set_url(obj, (const gchar *) gtk_selection_data_get_data (data));
          object_emit_update_signal(obj);
          success = TRUE;
        }
    }
  gtk_drag_finish(context, success, FALSE, time);
}
Beispiel #3
0
static void
display_data_received_callback (GtkWidget *widget, 
				GdkDragContext *context,
				gint x, 
				gint y, 
				GtkSelectionData *data,
				guint info, 
				guint time, 
				DDisplay *ddisp)
{
  if (gtk_selection_data_get_format(data) == 8 &&
      gtk_selection_data_get_length(data) == sizeof(ToolButtonData *) &&
      gtk_drag_get_source_widget(context) != NULL) {
    ToolButtonData *tooldata = *(ToolButtonData **)gtk_selection_data_get_data(data);
    /* g_message("Tool drop %s at (%d, %d)", (gchar *)tooldata->extra_data, x, y);*/
    ddisplay_drop_object(ddisp, x, y,
			 object_get_type((gchar *)tooldata->extra_data),
			 tooldata->user_data);

    gtk_drag_finish (context, TRUE, FALSE, time);
  } else {
    dia_dnd_file_drag_data_received (widget, context, x, y, data, info, time, ddisp);
  }
  /* ensure the right window has the focus for text editing */
  gtk_window_present(GTK_WINDOW(ddisp->shell));
}
Beispiel #4
0
/* methods to receive URLs which were dropped anywhere in the main window */
static void
liferea_shell_URL_received (GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *data, guint info, guint time_received)
{
	gchar		*tmp1, *tmp2, *freeme;
	GtkWidget	*mainwindow;
	GtkAllocation	alloc;
	GtkTreeView	*treeview;
	GtkTreeModel	*model;
	GtkTreePath	*path;
	GtkTreeIter	iter;
	nodePtr		node;
	gint		tx, ty;
	
	g_return_if_fail (gtk_selection_data_get_data (data) != NULL);
		
	mainwindow = GTK_WIDGET (shell->priv->window);
	treeview = GTK_TREE_VIEW (shell->priv->feedlistView);
	model = gtk_tree_view_get_model (treeview);

	/* x and y are relative to the main window, make them relative to the treeview */
	gtk_widget_translate_coordinates (mainwindow, GTK_WIDGET (treeview), x, y, &tx, &ty);

	/* Allow link drops only over feed list widget. This is to avoid
	   the frequent accidental text drops in the HTML view. */

	gtk_widget_get_allocation(GTK_WIDGET(treeview), &alloc);

	if((x > alloc.x+alloc.width) || (x < alloc.x) ||
	   (y > alloc.y+alloc.height) || (y < alloc.y)) {
		gtk_drag_finish (context, FALSE, FALSE, time_received);
		return;
	}		

	if ((gtk_selection_data_get_length (data) >= 0) && (gtk_selection_data_get_format (data) == 8)) {
		/* extra handling to accept multiple drops */
		freeme = tmp1 = g_strdup (gtk_selection_data_get_data (data));
		while ((tmp2 = strsep (&tmp1, "\n\r"))) {
			if (strlen (tmp2)) {
				/* if the drop is over a node, select it so that feedlist_add_subscription()
				 * adds it in the correct folder */
				if (gtk_tree_view_get_dest_row_at_pos (treeview, tx, ty, &path, NULL)) {
					if (gtk_tree_model_get_iter (model, &iter, path)) {
						gtk_tree_model_get (model, &iter, FS_PTR, &node, -1);
						/* if node is NULL, feed_list_view_select() will unselect the tv */
						feed_list_view_select (node);
					}
					gtk_tree_path_free (path);
				}
				feedlist_add_subscription (g_strdup (tmp2), NULL, NULL,
				                           FEED_REQ_PRIORITY_HIGH);
			}
		}
		g_free (freeme);
		gtk_drag_finish (context, TRUE, FALSE, time_received);
	} else {
		gtk_drag_finish (context, FALSE, FALSE, time_received);
	}
}
Beispiel #5
0
static void
entry_drag_data_received (GtkEditable      *entry,
			  GdkDragContext   *context,
			  gint              x,
			  gint              y,
			  GtkSelectionData *selection_data,
			  guint             info,
			  guint32           time,
			  PanelRunDialog   *dialog)
{
	char **uris;
	char  *file;
	int    i;

        if (gtk_selection_data_get_format (selection_data) != 8 || gtk_selection_data_get_length (selection_data) == 0) {
        	g_warning (_("URI list dropped on run dialog had wrong format (%d) or length (%d)\n"),
			   gtk_selection_data_get_format (selection_data),
			   gtk_selection_data_get_length (selection_data));
		return;
        }

	uris = g_uri_list_extract_uris ((const char *)gtk_selection_data_get_data (selection_data));

	if (!uris) {
		gtk_drag_finish (context, FALSE, FALSE, time);
		return;
	}

	for (i = 0; uris [i]; i++) {
		if (!uris [i] || !uris [i][0])
			continue;

		file = g_filename_from_uri (uris [i], NULL, NULL);

		/* FIXME: I assume the file is in utf8 encoding if coming from a URI? */
		if (file) {
			panel_run_dialog_append_file_utf8 (dialog, file);
			g_free (file);
		} else
			panel_run_dialog_append_file_utf8 (dialog, uris [i]);
	}

	g_strfreev (uris);
	gtk_drag_finish (context, TRUE, FALSE, time);
}
Beispiel #6
0
static void _lib_keywords_drag_data_received_callback(GtkWidget *w,
        GdkDragContext *dctx,
        guint x,
        guint y,
        GtkSelectionData *data,
        guint info,
        guint time,
        gpointer user_data)
{
    dt_lib_module_t *self = (dt_lib_module_t *)user_data;
    dt_lib_keywords_t *d = (dt_lib_keywords_t*)self->data;

    GtkTreePath *dpath;
    GtkTreeViewDropPosition dpos;
    GtkTreeModel *model = gtk_tree_view_get_model(d->view);

    if (gtk_selection_data_get_format(data) == 8)
    {
        if (gtk_tree_view_get_dest_row_at_pos(d->view, x, y, &dpath, &dpos))
        {
            /* fetch tree iter of source and dest dnd operation */
            GtkTreePath *spath = gtk_tree_path_new_from_string((char *)gtk_selection_data_get_data(data));

            char dtag[1024];
            char stag[1024];

            _lib_keywords_string_from_path(dtag, 1024, model, dpath);
            _lib_keywords_string_from_path(stag, 1024, model, spath);

            /* reject drop onto ourself */
            if (strcmp(dtag,stag) == 0)
                goto reject_drop;

            /* updated tags in database */
            dt_tag_reorganize(stag,dtag);

            /* lets move the source iter into dest iter */
            GtkTreeIter sit,dit;
            gtk_tree_model_get_iter(model, &sit, spath);
            gtk_tree_model_get_iter(model, &dit, dpath);

            _gtk_tree_move_iter(GTK_TREE_STORE(model), &sit, &dit);

            /* accept drop */
            gtk_drag_finish(dctx, TRUE, FALSE, time);


        }

    }

    /* reject drop */
reject_drop:
    gtk_drag_finish (dctx, FALSE, FALSE, time);
}
Beispiel #7
0
static void target_drag_data_received( GtkWidget *WXUNUSED(widget),
                                       GdkDragContext *context,
                                       gint x,
                                       gint y,
                                       GtkSelectionData *data,
                                       guint WXUNUSED(info),
                                       guint time,
                                       wxDropTarget *drop_target )
{
    /* Owen Taylor: "call gtk_drag_finish() with
       success == TRUE" */

    if (gtk_selection_data_get_length(data) <= 0 || gtk_selection_data_get_format(data) != 8)
    {
        /* negative data length and non 8-bit data format
           qualifies for junk */
        gtk_drag_finish (context, FALSE, FALSE, time);

        return;
    }

    wxLogTrace(TRACE_DND, wxT( "Drop target: data received event") );

    /* inform the wxDropTarget about the current GtkSelectionData.
       this is only valid for the duration of this call */
    drop_target->GTKSetDragData( data );

    wxDragResult result = ConvertFromGTK(gdk_drag_context_get_selected_action(context));

    if ( wxIsDragResultOk( drop_target->OnData( x, y, result ) ) )
    {
        wxLogTrace(TRACE_DND, wxT( "Drop target: OnData returned true") );

        /* tell GTK that data transfer was successful */
        gtk_drag_finish( context, TRUE, FALSE, time );
    }
    else
    {
        wxLogTrace(TRACE_DND, wxT( "Drop target: OnData returned FALSE") );

        /* tell GTK that data transfer was not successful */
        gtk_drag_finish( context, FALSE, FALSE, time );
    }

    /* after this, invalidate the drop_target's drag data */
    drop_target->GTKSetDragData( NULL );
}
Beispiel #8
0
Datei: testdnd.c Projekt: BYC/gtk
void  
label_drag_data_received  (GtkWidget          *widget,
			    GdkDragContext     *context,
			    gint                x,
			    gint                y,
			    GtkSelectionData   *selection_data,
			    guint               info,
			    guint               time)
{
  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 *) gtk_selection_data_get_data (selection_data));
      gtk_drag_finish (context, TRUE, FALSE, time);
      return;
    }
  
  gtk_drag_finish (context, FALSE, FALSE, time);
}
Beispiel #9
0
static void vte_drag_data_received(GtkWidget *widget, GdkDragContext *drag_context,
								   gint x, gint y, GtkSelectionData *data, guint info, guint ltime)
{
	if (info == TARGET_TEXT_PLAIN)
	{
		if (gtk_selection_data_get_format(data) == 8 && gtk_selection_data_get_length(data) > 0)
			vf->vte_terminal_feed_child(VTE_TERMINAL(widget),
				(const gchar*) gtk_selection_data_get_data(data),
				gtk_selection_data_get_length(data));
	}
	else
	{
		gchar *text = (gchar*) gtk_selection_data_get_text(data);
		if (!EMPTY(text))
			vf->vte_terminal_feed_child(VTE_TERMINAL(widget), text, strlen(text));
		g_free(text);
	}
	gtk_drag_finish(drag_context, TRUE, FALSE, ltime);
}
Beispiel #10
0
static void gtkDragDataReceived(GtkWidget *widget, GdkDragContext *drag_context, gint x, gint y,
                            GtkSelectionData *seldata, guint info, guint time, Ihandle *ih)
{
  IFnsCiii cbDrop = (IFnsCiii)IupGetCallback(ih, "DROPDATA_CB");
  void* targetData = NULL;
  char* type;
  int size, format, res;
  GdkDragAction action;

#if GTK_CHECK_VERSION(2, 22, 0)
  action = gdk_drag_context_get_selected_action(drag_context);
#else
  action = drag_context->action;
#endif

#if GTK_CHECK_VERSION(2, 14, 0)
  type = gdk_atom_name(gtk_selection_data_get_target(seldata));
  targetData = (void*)gtk_selection_data_get_data(seldata);
  size = gtk_selection_data_get_length(seldata);
  format = gtk_selection_data_get_format(seldata);
#else
  type = gdk_atom_name(seldata->type);
  targetData = (void*)seldata->data;
  size = seldata->length;
  format = seldata->format;
#endif

  if(size <= 0 || format != 8 ||
    (action != GDK_ACTION_MOVE && action != GDK_ACTION_COPY))
  {
    gtk_drag_finish(drag_context, FALSE, FALSE, time);
    return;
  }

  if(cbDrop)
    res = cbDrop(ih, type, targetData, size, x, y);

  gtk_drag_finish(drag_context, TRUE, FALSE, time);

  (void)info;
  (void)widget;
  (void)time;
}
Beispiel #11
0
static void
handle_drop(GtkWidget *widget, GdkDragContext *context, gint x, gint y,
            GtkSelectionData *data, guint info, guint time)
{
   gboolean success = FALSE;

   if (gtk_selection_data_get_length (data) >= 0 &&
       gtk_selection_data_get_format (data) == 8)
     {
       const gchar *text = (const gchar *) gtk_selection_data_get_data (data);

       if (g_utf8_validate (text, -1, NULL))
         {
           gtk_entry_set_text (GTK_ENTRY (widget), text);
           success = TRUE;
         }
     }

   gtk_drag_finish(context, success, FALSE, time);
}
static gboolean
receive_xds (NautilusTreeViewDragDest *dest,
             GtkWidget *widget,
             guint32 time,
             GdkDragContext *context,
             int x, int y)
{
    GFile *location;
    const guchar *selection_data;
    gint selection_format;
    gint selection_length;

    selection_data = gtk_selection_data_get_data (dest->details->drag_data);
    selection_format = gtk_selection_data_get_format (dest->details->drag_data);
    selection_length = gtk_selection_data_get_length (dest->details->drag_data);

    if (selection_format == 8
            && selection_length == 1
            && selection_data[0] == 'F') {
        gtk_drag_get_data (widget, context,
                           gdk_atom_intern (NAUTILUS_ICON_DND_RAW_TYPE,
                                            FALSE),
                           time);
        return FALSE;
    } else if (selection_format == 8
               && selection_length == 1
               && selection_data[0] == 'S') {
        g_assert (dest->details->direct_save_uri != NULL);
        location = g_file_new_for_uri (dest->details->direct_save_uri);

        nautilus_file_changes_queue_file_added (location);
        nautilus_file_changes_consume_changes (TRUE);

        g_object_unref (location);
    }
    return TRUE;
}
Beispiel #13
0
static void
drag_data_received_callback (GtkWidget *widget,
			     GdkDragContext *context,
			     int x,
			     int y,
			     GtkSelectionData *data,
			     guint info,
			     guint32 time,
			     gpointer user_data)
{
    	NemoDragInfo *drag_info;
	char *tmp;
	const char *tmp_raw;
	int length;
	gboolean success;

	drag_info = &(NEMO_ICON_CONTAINER (widget)->details->dnd_info->drag_info);

	drag_info->got_drop_data_type = TRUE;
	drag_info->data_type = info;

	switch (info) {
	case NEMO_ICON_DND_GNOME_ICON_LIST:
		nemo_icon_container_dropped_icon_feedback (widget, data, x, y);
		break;
	case NEMO_ICON_DND_URI_LIST:
	case NEMO_ICON_DND_TEXT:
	case NEMO_ICON_DND_XDNDDIRECTSAVE:
	case NEMO_ICON_DND_RAW:
		/* Save the data so we can do the actual work on drop. */
		if (drag_info->selection_data != NULL) {
			gtk_selection_data_free (drag_info->selection_data);
		}
		drag_info->selection_data = gtk_selection_data_copy (data);
		break;

	/* Netscape keeps sending us the data, even though we accept the first drag */
	case NEMO_ICON_DND_NETSCAPE_URL:
		if (drag_info->selection_data != NULL) {
			gtk_selection_data_free (drag_info->selection_data);
			drag_info->selection_data = gtk_selection_data_copy (data);
		}
		break;
	case NEMO_ICON_DND_ROOTWINDOW_DROP:
		/* Do nothing, this won't even happen, since we don't want to call get_data twice */
		break;
	}

	/* this is the second use case of this callback.
	 * we have to do the actual work for the drop.
	 */
	if (drag_info->drop_occured) {

		success = FALSE;
		switch (info) {
		case NEMO_ICON_DND_GNOME_ICON_LIST:
			nemo_icon_container_receive_dropped_icons
				(NEMO_ICON_CONTAINER (widget),
				 context, x, y);
			break;
		case NEMO_ICON_DND_NETSCAPE_URL:
			receive_dropped_netscape_url
				(NEMO_ICON_CONTAINER (widget),
				 (char *) gtk_selection_data_get_data (data), context, x, y);
			success = TRUE;
			break;
		case NEMO_ICON_DND_URI_LIST:
			receive_dropped_uri_list
				(NEMO_ICON_CONTAINER (widget),
				 (char *) gtk_selection_data_get_data (data), context, x, y);
			success = TRUE;
			break;
		case NEMO_ICON_DND_TEXT:
			tmp = gtk_selection_data_get_text (data);
			receive_dropped_text
				(NEMO_ICON_CONTAINER (widget),
				 (char *) tmp, context, x, y);
			success = TRUE;
			g_free (tmp);
			break;
		case NEMO_ICON_DND_RAW:
			length = gtk_selection_data_get_length (data);
			tmp_raw = gtk_selection_data_get_data (data);
			receive_dropped_raw
				(NEMO_ICON_CONTAINER (widget),
				 tmp_raw, length, drag_info->direct_save_uri,
				 context, x, y);
			success = TRUE;
			break;
		case NEMO_ICON_DND_ROOTWINDOW_DROP:
			/* Do nothing, everything is done by the sender */
			break;
		case NEMO_ICON_DND_XDNDDIRECTSAVE:
		{
			const guchar *selection_data;
			gint selection_length;
			gint selection_format;

			selection_data = gtk_selection_data_get_data (drag_info->selection_data);
			selection_length = gtk_selection_data_get_length (drag_info->selection_data);
			selection_format = gtk_selection_data_get_format (drag_info->selection_data);

			if (selection_format == 8 &&
			    selection_length == 1 &&
			    selection_data[0] == 'F') {
				gtk_drag_get_data (widget, context,
				                  gdk_atom_intern (NEMO_ICON_DND_RAW_TYPE,
				                                   FALSE),
				                  time);
				return;
			} else if (selection_format == 8 &&
				   selection_length == 1 &&
				   selection_data[0] == 'F' &&
			           drag_info->direct_save_uri != NULL) {
				GdkPoint p;
				GFile *location;

				location = g_file_new_for_uri (drag_info->direct_save_uri);

				nemo_file_changes_queue_file_added (location);
				p.x = x; p.y = y;
				nemo_file_changes_queue_schedule_position_set (
				                 location,
				                 p,
				                 gdk_screen_get_number (
				                             gtk_widget_get_screen (widget)));
				g_object_unref (location);
				nemo_file_changes_consume_changes (TRUE);
				success = TRUE;
			}
			break;
		} /* NEMO_ICON_DND_XDNDDIRECTSAVE */
		}
		gtk_drag_finish (context, success, FALSE, time);
		
		nemo_icon_container_free_drag_data (NEMO_ICON_CONTAINER (widget));
		
		set_drop_target (NEMO_ICON_CONTAINER (widget), NULL);

		/* reinitialise it for the next dnd */
		drag_info->drop_occured = FALSE;
	}

}
Beispiel #14
0
static void
gth_file_list_drag_data_received (GtkWidget        *file_view,
				  GdkDragContext   *context,
				  int               x,
				  int               y,
				  GtkSelectionData *selection_data,
				  guint             info,
				  guint             time,
				  gpointer          user_data)
{
	GthBrowser     *browser = user_data;
	gboolean        success = FALSE;
	char          **uris;
	GList          *selected_files;
	GdkDragAction   action;

	g_signal_stop_emission_by_name (file_view, "drag-data-received");

	action = gdk_drag_context_get_suggested_action (context);
	if (action == GDK_ACTION_COPY || action == GDK_ACTION_MOVE) {
		success = TRUE;
	}

	if (action == GDK_ACTION_ASK) {
		GdkDragAction actions =
			_gtk_menu_ask_drag_drop_action (file_view,
							gdk_drag_context_get_actions (context),
							time);
		gdk_drag_status (context, actions, time);
		success = gdk_drag_context_get_selected_action (context) != 0;
	}

	if (gtk_selection_data_get_data_type (selection_data) == XDND_ACTION_DIRECT_SAVE_ATOM) {
		const guchar *data;
		int           format;
		int           length;

		data = gtk_selection_data_get_data (selection_data);
		format = gtk_selection_data_get_format (selection_data);
		length = gtk_selection_data_get_length (selection_data);

		if ((format == 8) && (length == 1) && (data[0] == 'S')) {
			success = TRUE;
		}
		else {
			gdk_property_change (gdk_drag_context_get_dest_window (context),
					     XDND_ACTION_DIRECT_SAVE_ATOM,
					     TEXT_PLAIN_ATOM,
					     8,
					     GDK_PROP_MODE_REPLACE,
					     (const guchar *) "",
					     0);
			success = FALSE;
		}

		gtk_drag_finish (context, success, FALSE, time);
		return;
	}

	gtk_drag_finish (context, success, FALSE, time);
	if (! success)
		return;

	uris = gtk_selection_data_get_uris (selection_data);
	selected_files = _g_file_list_new_from_uriv (uris);
	if (selected_files != NULL) {
		if (gtk_drag_get_source_widget (context) == file_view) {
			GList       *file_data_list;
			GList       *visible_files;
			BrowserData *data;
			GthTask     *task;

			file_data_list = gth_file_store_get_visibles (gth_browser_get_file_store (browser));
			visible_files = gth_file_data_list_to_file_list (file_data_list);

			data = g_object_get_data (G_OBJECT (browser), BROWSER_DATA_KEY);
			task = gth_reorder_task_new (gth_browser_get_location_source (browser),
						     gth_browser_get_location_data (browser),
						     visible_files,
						     selected_files,
						     data->drop_pos);
			gth_browser_exec_task (browser, task, FALSE);

			g_object_unref (task);
			_g_object_list_unref (visible_files);
			_g_object_list_unref (file_data_list);
		}
		else {
			GthFileSource *file_source;
			gboolean       cancel = FALSE;
			gboolean       move;

			file_source = gth_browser_get_location_source (browser);
			move = gdk_drag_context_get_selected_action (context) == GDK_ACTION_MOVE;
			if (move && ! gth_file_source_can_cut (file_source, (GFile *) selected_files->data)) {
				GtkWidget *dialog;
				int        response;

				dialog = _gtk_message_dialog_new (GTK_WINDOW (browser),
								  GTK_DIALOG_MODAL,
								  GTK_STOCK_DIALOG_QUESTION,
								  _("Could not move the files"),
								  _("Files cannot be moved to the current location, as alternative you can choose to copy them."),
								  GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
								  GTK_STOCK_COPY, GTK_RESPONSE_OK,
								  NULL);
				response = gtk_dialog_run (GTK_DIALOG (dialog));
				gtk_widget_destroy (dialog);

				if (response == GTK_RESPONSE_CANCEL)
					cancel = TRUE;

				move = FALSE;
			}

			if (! cancel) {
				GthFileSource *location_source;
				BrowserData   *data;
				GthTask       *task;

				location_source = gth_main_get_file_source (gth_browser_get_location (browser));
				data = g_object_get_data (G_OBJECT (browser), BROWSER_DATA_KEY);
				task = gth_copy_task_new (location_source,
							  gth_browser_get_location_data (browser),
							  move,
							  selected_files,
							  data->drop_pos);
				gth_browser_exec_task (browser, task, FALSE);

				g_object_unref (task);
				g_object_unref (location_source);
			}
		}
	}

	_g_object_list_unref (selected_files);
	g_strfreev (uris);
}
static void
caja_emblem_sidebar_drag_received_cb (GtkWidget *widget,
                                      GdkDragContext *drag_context,
                                      gint x,
                                      gint y,
                                      GtkSelectionData *data,
                                      guint info,
                                      guint time,
                                      CajaEmblemSidebar *emblem_sidebar)
{
    GSList *emblems;
    Emblem *emblem;
    GdkPixbuf *pixbuf;
    char *uri, *error, *uri_utf8;
    char **uris;
    GFile *f;
    int i;
    gboolean had_failure;
    gint data_format, data_length;
    const guchar *data_data;

    had_failure = FALSE;
    emblems = NULL;
    data_format = gtk_selection_data_get_format (data);
    data_length = gtk_selection_data_get_length (data);
    data_data = gtk_selection_data_get_data (data);

    switch (info)
    {
    case TARGET_URI_LIST:
        if (data_format != 8 ||
                data_length == 0)
        {
            g_message ("URI list had wrong format (%d) or length (%d)\n",
                       data_format, data_length);
            return;
        }

        uris = g_uri_list_extract_uris (data_data);
        if (uris == NULL)
        {
            break;
        }

        for (i = 0; uris[i] != NULL; ++i)
        {
            f = g_file_new_for_uri (uris[i]);
            pixbuf = caja_emblem_load_pixbuf_for_emblem (f);

            if (pixbuf == NULL)
            {
                /* this one apparently isn't an image, or
                 * at least not one that we know how to read
                 */
                had_failure = TRUE;
                g_object_unref (f);
                continue;
            }

            emblem = g_new (Emblem, 1);
            emblem->uri = g_file_get_uri (f);
            emblem->name = NULL; /* created later on by the user */
            emblem->keyword = NULL;
            emblem->pixbuf = pixbuf;

            g_object_unref (f);

            emblems = g_slist_prepend (emblems, emblem);
        }

        g_strfreev (uris);

        if (had_failure && emblems != NULL)
        {
            eel_show_error_dialog (_("Some of the files could not be added as emblems."), _("The emblems do not appear to be valid images."), NULL);
        }
        else if (had_failure && emblems == NULL)
        {
            eel_show_error_dialog (_("None of the files could be added as emblems."), _("The emblems do not appear to be valid images."), NULL);

        }

        if (emblems != NULL)
        {
            show_add_emblems_dialog (emblem_sidebar, emblems);
        }

        break;

    case TARGET_URI:
        if (data_format != 8 ||
                data_length == 0)
        {
            g_warning ("URI had wrong format (%d) or length (%d)\n",
                       data_format, data_length);
            return;
        }

        uri = g_strndup (data_data, data_length);

        f = g_file_new_for_uri (uri);
        pixbuf = caja_emblem_load_pixbuf_for_emblem (f);

        if (pixbuf != NULL)
        {
            emblem = g_new (Emblem, 1);
            emblem->uri = uri;
            emblem->name = NULL;
            emblem->keyword = NULL;
            emblem->pixbuf = pixbuf;

            emblems = g_slist_prepend (NULL, emblem);

            show_add_emblems_dialog (emblem_sidebar, emblems);
        }
        else
        {
            uri_utf8 = g_file_get_parse_name (f);

            if (uri_utf8)
            {
                error = g_strdup_printf (_("The file '%s' does not appear to be a valid image."), uri_utf8);
                g_free (uri_utf8);
            }
            else
            {
                error = g_strdup (_("The dragged file does not appear to be a valid image."));
            }
            eel_show_error_dialog (_("The emblem cannot be added."), error, NULL);
            g_free (error);
            g_free (uri_utf8);
        }

        g_object_unref (f);
        g_free (uri);

        break;

    case TARGET_NETSCAPE_URL:
        if (data_format != 8 ||
                data_length == 0)
        {
            g_message ("URI had wrong format (%d) or length (%d)\n",
                       data_format, data_length);
            return;
        }

        /* apparently, this is a URI/title pair?  or just a pair
         * of identical URIs?  Regardless, this seems to work...
         */

        uris = g_uri_list_extract_uris (data_data);
        if (uris == NULL)
        {
            break;
        }

        uri = uris[0];
        if (uri == NULL)
        {
            g_strfreev (uris);
            break;
        }

        f = g_file_new_for_uri (uri);
        pixbuf = caja_emblem_load_pixbuf_for_emblem (f);
        g_object_unref (f);

        if (pixbuf != NULL)
        {
            emblem = g_new (Emblem, 1);
            emblem->uri = g_strdup (uri);
            emblem->name = NULL;
            emblem->keyword = NULL;
            emblem->pixbuf = pixbuf;

            emblems = g_slist_prepend (NULL, emblem);

            show_add_emblems_dialog (emblem_sidebar, emblems);
        }
        else
        {
            g_warning ("Tried to load '%s', but failed.\n",
                       uri);
            error = g_strdup_printf (_("The file '%s' does not appear to be a valid image."), uri);
            eel_show_error_dialog (_("The emblem cannot be added."), error, NULL);
            g_free (error);
        }

        g_strfreev (uris);

        break;
    }
}
void on_dir_tree_view_drag_data_received ( GtkWidget *widget,
                                         GdkDragContext *drag_context,
                                         gint x,
                                         gint y,
                                         GtkSelectionData *sel_data,
                                         guint info,
                                         guint time,
                                         gpointer user_data )  //MOD added
{
    gchar **list, **puri;
    GList* files = NULL;
    PtkFileTask* task;
    VFSFileTaskType file_action = VFS_FILE_TASK_MOVE;
    PtkFileBrowser* file_browser = ( PtkFileBrowser* ) user_data;
    char* dest_dir;
    char* file_path;
    GtkWidget* parent_win;

    /*  Don't call the default handler  */
    g_signal_stop_emission_by_name( widget, "drag-data-received" );

    if ( ( gtk_selection_data_get_length( sel_data ) >= 0 ) && ( gtk_selection_data_get_format( sel_data ) == 8 ) )
    {
        dest_dir = dir_tree_view_get_drop_dir( widget, x, y );
        if ( dest_dir )
        {
            puri = list = gtk_selection_data_get_uris( sel_data );
            if( file_browser->pending_drag_status_tree )
            {
                // We only want to update drag status, not really want to drop
                dev_t dest_dev;
                struct stat statbuf;    // skip stat64
                if( stat( dest_dir, &statbuf ) == 0 )
                {
                    dest_dev = statbuf.st_dev;
                    if( 0 == file_browser->drag_source_dev_tree )
                    {
                        file_browser->drag_source_dev_tree = dest_dev;
                        for( ; *puri; ++puri )
                        {
                            file_path = g_filename_from_uri( *puri, NULL, NULL );
                            if( stat( file_path, &statbuf ) == 0 && statbuf.st_dev != dest_dev )
                            {
                                file_browser->drag_source_dev_tree = statbuf.st_dev;
                                g_free( file_path );
                                break;
                            }
                            g_free( file_path );
                        }
                    }
                    if( file_browser->drag_source_dev_tree != dest_dev )
                        // src and dest are on different devices */
                        gdk_drag_status( drag_context, GDK_ACTION_COPY, time);
                    else
                        gdk_drag_status( drag_context, GDK_ACTION_MOVE, time);
                }
                else
                    // stat failed
                    gdk_drag_status( drag_context, GDK_ACTION_COPY, time);

                g_free( dest_dir );
                g_strfreev( list );
                file_browser->pending_drag_status_tree = 0;
                return;
            }

            if ( puri )
            {
                if ( 0 == ( gdk_drag_context_get_selected_action ( drag_context ) &
                            ( GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK ) ) )
                {
                    gdk_drag_status( drag_context, GDK_ACTION_MOVE, time);
                }
                gtk_drag_finish ( drag_context, TRUE, FALSE, time );

                while ( *puri )
                {
                    if ( **puri == '/' )
                        file_path = g_strdup( *puri );
                    else
                        file_path = g_filename_from_uri( *puri, NULL, NULL );

                    if ( file_path )
                        files = g_list_prepend( files, file_path );
                    ++puri;
                }
                g_strfreev( list );

                switch ( gdk_drag_context_get_selected_action ( drag_context ) )
                {
                case GDK_ACTION_COPY:
                    file_action = VFS_FILE_TASK_COPY;
                    break;
                case GDK_ACTION_LINK:
                    file_action = VFS_FILE_TASK_LINK;
                    break;
                    /* FIXME:
                      GDK_ACTION_DEFAULT, GDK_ACTION_PRIVATE, and GDK_ACTION_ASK are not handled */
                default:
                    break;
                }
                if ( files )
                {
                    /* Accept the drop and perform file actions */
                    {
                        parent_win = gtk_widget_get_toplevel( GTK_WIDGET( file_browser ) );
                        task = ptk_file_task_new( file_action,
                                                  files,
                                                  dest_dir,
                                                  GTK_WINDOW( parent_win ),
                                                  file_browser->task_view );
                        ptk_file_task_run( task );
                    }
                }
                g_free( dest_dir );
                gtk_drag_finish ( drag_context, TRUE, FALSE, time );
                return ;
            }
            g_free( dest_dir );
        }
        //else
        //    g_warning ("bad dest_dir in on_dir_tree_view_drag_data_received");
    }
    /* If we are only getting drag status, not finished. */
    if( file_browser->pending_drag_status_tree )
    {
        gdk_drag_status ( drag_context, GDK_ACTION_COPY, time );
        file_browser->pending_drag_status_tree = 0;
        return;
    }
    gtk_drag_finish ( drag_context, FALSE, FALSE, time );
}