Exemplo n.º 1
0
JNIEXPORT jlong JNICALL
Java_org_gnome_gtk_GtkSelectionData_gtk_1selection_1data_1copy
(
	JNIEnv* env,
	jclass cls,
	jlong _self
)
{
	GtkSelectionData* result;
	jlong _result;
	GtkSelectionData* self;

	// convert parameter self
	self = (GtkSelectionData*) _self;

	// call function
	result = gtk_selection_data_copy(self);

	// cleanup parameter self

	// translate return value to JNI type
	_result = (jlong) result;

	// and finally
	return _result;
}
Exemplo n.º 2
0
static void
slot_proxy_drag_data_received (GtkWidget          *widget,
                               GdkDragContext     *context,
                               int                 x,
                               int                 y,
                               GtkSelectionData   *data,
                               unsigned int        info,
                               unsigned int        time,
                               gpointer            user_data)
{
    NautilusDragSlotProxyInfo *drag_info;
    char **uris;

    drag_info = user_data;

    g_assert (!drag_info->have_data);

    drag_info->have_data = TRUE;
    drag_info->info = info;

    if (gtk_selection_data_get_length (data) < 0) {
        drag_info->have_valid_data = FALSE;
        return;
    }

    if (info == NAUTILUS_ICON_DND_GNOME_ICON_LIST) {
        drag_info->data.selection_list = nautilus_drag_build_selection_list (data);

        drag_info->have_valid_data = drag_info->data.selection_list != NULL;
    } else if (info == NAUTILUS_ICON_DND_URI_LIST) {
        uris = gtk_selection_data_get_uris (data);
        drag_info->data.uri_list = nautilus_drag_uri_list_from_array ((const char **) uris);
        g_strfreev (uris);

        drag_info->have_valid_data = drag_info->data.uri_list != NULL;
    } else if (info == NAUTILUS_ICON_DND_NETSCAPE_URL) {
        drag_info->data.netscape_url = g_strdup ((char *) gtk_selection_data_get_data (data));

        drag_info->have_valid_data = drag_info->data.netscape_url != NULL;
    } else if (info == NAUTILUS_ICON_DND_TEXT ||
               info == NAUTILUS_ICON_DND_XDNDDIRECTSAVE ||
               info == NAUTILUS_ICON_DND_RAW) {
        drag_info->data.selection_data = gtk_selection_data_copy (data);
        drag_info->have_valid_data = drag_info->data.selection_data != NULL;
    }

    if (drag_info->drop_occured) {
        slot_proxy_handle_drop (widget, context, time, drag_info);
    }
}
Exemplo n.º 3
0
static void
clipboard_contents_received(GtkClipboard     *clipboard,
                            GtkSelectionData *selection_data,
                            gpointer          data)
{
    retrieval_context *context = static_cast<retrieval_context *>(data);
    if (context->timed_out) {
        delete context;
        return;
    }

    context->completed = PR_TRUE;

    if (selection_data->length >= 0)
        context->data = gtk_selection_data_copy(selection_data);
}
Exemplo n.º 4
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;
	}

}
Exemplo n.º 5
0
static void
drag_data_received_cb (GtkWidget *widget,
		       GdkDragContext *context,
		       int x,
		       int y,
		       GtkSelectionData *selection_data,
		       guint info,
		       guint32 time,
		       EphyNodeView *view)
{
	GtkTreeViewDropPosition pos;

	/* x and y here are valid only on drop ! */

	if ((gtk_selection_data_get_length (selection_data) <= 0) ||
	    (gtk_selection_data_get_data (selection_data) == NULL))
	{
		return;
	}	

	/* appease GtkTreeView by preventing its drag_data_receive
	* from being called */
	g_signal_stop_emission_by_name (view, "drag_data_received");

	if (!view->priv->have_drag_data)
	{
		view->priv->have_drag_data = TRUE;
		view->priv->drag_data = 
			gtk_selection_data_copy (selection_data);
	}

	if (view->priv->drop_occurred)
	{
		EphyNode *node;
		char **uris;
		gboolean success = FALSE;
		GtkTreePath *path;

		if (gtk_tree_view_get_dest_row_at_pos
			(GTK_TREE_VIEW (widget), x, y, &path, &pos) == FALSE)
		{
			return;
		}

		node = get_node_from_path (view, path);
		if (node == NULL) return;

		uris = gtk_selection_data_get_uris (selection_data);

		if (uris != NULL && ephy_node_get_is_drag_dest (node))
		{
			/* FIXME fill success */
			g_signal_emit (G_OBJECT (view),
				       ephy_node_view_signals[NODE_DROPPED], 0,
				       node, uris);
			g_strfreev (uris);

		}

		view->priv->drop_occurred = FALSE;
		free_drag_data (view);
		gtk_drag_finish (context, success, FALSE, time);

		if (path)
		{
			gtk_tree_path_free (path);
		}
	}
}
static gboolean
drag_data_received_callback (GtkWidget *widget,
                             GdkDragContext *context,
                             int x,
                             int y,
                             GtkSelectionData *selection_data,
                             guint info,
                             guint32 time,
                             gpointer data)
{
    NautilusTreeViewDragDest *dest;
    const gchar *tmp;
    int length;
    gboolean success, finished;

    dest = NAUTILUS_TREE_VIEW_DRAG_DEST (data);

    if (!dest->details->have_drag_data) {
        dest->details->have_drag_data = TRUE;
        dest->details->drag_type = info;
        dest->details->drag_data =
            gtk_selection_data_copy (selection_data);
        if (info == NAUTILUS_ICON_DND_GNOME_ICON_LIST) {
            dest->details->drag_list =
                nautilus_drag_build_selection_list (selection_data);
        }
    }

    if (dest->details->drop_occurred) {
        success = FALSE;
        finished = TRUE;
        switch (info) {
        case NAUTILUS_ICON_DND_GNOME_ICON_LIST :
            receive_dropped_icons (dest, context, x, y);
            success = TRUE;
            break;
        case NAUTILUS_ICON_DND_NETSCAPE_URL :
            receive_dropped_netscape_url (dest, context, x, y);
            success = TRUE;
            break;
        case NAUTILUS_ICON_DND_URI_LIST :
            receive_dropped_uri_list (dest, context, x, y);
            success = TRUE;
            break;
        case NAUTILUS_ICON_DND_TEXT:
            receive_dropped_text (dest, context, x, y);
            success = TRUE;
            break;
        case NAUTILUS_ICON_DND_RAW:
            length = gtk_selection_data_get_length (selection_data);
            tmp = (const gchar *) gtk_selection_data_get_data (selection_data);
            receive_dropped_raw (dest, tmp, length, context, x, y);
            success = TRUE;
            break;
        case NAUTILUS_ICON_DND_XDNDDIRECTSAVE:
            finished = receive_xds (dest, widget, time, context, x, y);
            success = TRUE;
            break;
        }

        if (finished) {
            dest->details->drop_occurred = FALSE;
            free_drag_data (dest);
            gtk_drag_finish (context, success, FALSE, time);
        }
    }

    /* appease GtkTreeView by preventing its drag_data_receive
     * from being called */
    g_signal_stop_emission_by_name (dest->details->tree_view,
                                    "drag-data-received");

    return TRUE;
}
Exemplo n.º 7
0
/* *** SelectionData *** */
EXTERNML GtkSelectionData* alloc_GtkSelectionData() {
    GtkSelectionData res;
    return gtk_selection_data_copy(&res);
}