void
_gd_main_view_generic_dnd_common (GtkTreeModel *model,
                                  gboolean selection_mode,
                                  GtkTreePath *path,
                                  GtkSelectionData *data)
{
  gchar **uris;

  if (selection_mode)
    {
      uris = model_get_selection_uris (model);
    }
  else
    {
      GtkTreeIter iter;
      gboolean res;
      gchar *uri = NULL;

      if (path != NULL)
        {
          res = gtk_tree_model_get_iter (model, &iter, path);
          if (res)
            gtk_tree_model_get (model, &iter,
                                GD_MAIN_COLUMN_URI, &uri,
                                -1);
        }

      uris = g_new0 (gchar *, 2);
      uris[0] = uri;
      uris[1] = NULL;
    }

  gtk_selection_data_set_uris (data, uris);
  g_strfreev (uris);
}
static void
icon_drag_data_get (GtkWidget            *event_box,
                    GdkDragContext       *context,
                    GtkSelectionData     *selection_data,
                    guint                 info,
                    guint                 time_,
                    GbWorkspacePaneGroup *group)
{
   GbWorkspacePaneGroupPrivate *priv;
   GbWorkspacePane *pane;
   const gchar *uri;
   gchar **uris;

   g_return_if_fail(GTK_IS_EVENT_BOX(event_box));
   g_return_if_fail(GB_IS_WORKSPACE_PANE_GROUP(group));

   priv = group->priv;

   if ((pane = gb_workspace_pane_group_get_current_pane(group))) {
      if ((uri = gb_workspace_pane_get_uri(pane))) {
         gtk_selection_data_set_text(selection_data, uri, -1);
         uris = g_new0(gchar*, 2);
         uris[0] = g_strdup(uri);
         uris[1] = NULL;
         gtk_selection_data_set_uris(selection_data, uris);
         g_strfreev(uris);
      }
   }
Beispiel #3
0
static gboolean
gth_file_store_drag_data_get (GtkTreeDragSource *drag_source,
                              GtkTreePath       *path,
                              GtkSelectionData  *selection_data)
{
	gboolean      retval = FALSE;
	GthFileStore *file_store;
	int          *indices, n;
	GthFileRow   *row;

	g_return_val_if_fail (path != NULL, FALSE);

	file_store = (GthFileStore *) drag_source;

	indices = gtk_tree_path_get_indices (path);
	n = indices[0];
	if ((n < 0) || (n >= file_store->priv->num_rows))
		return FALSE;

	row = file_store->priv->rows[n];
	g_return_val_if_fail (row != NULL, FALSE);
	g_return_val_if_fail (row->pos == n, FALSE);

	if (gtk_selection_data_targets_include_uri (selection_data)) {
		char **uris;

		uris = g_new (char *, 2);
		uris[0] = g_file_get_uri (row->file_data->file);
		uris[1] = NULL;
		gtk_selection_data_set_uris (selection_data, uris);
		retval = TRUE;

		g_strfreev (uris);
	}
	else if (gtk_selection_data_targets_include_text (selection_data)) {
Beispiel #4
0
static void dest_dnd_set_data(GtkWidget *view,
			      GdkDragContext *context, GtkSelectionData *selection_data,
			      guint info, guint time, gpointer data)
{
	gchar *path = NULL;
	GList *list = NULL;
	GtkTreeModel *model;
	GtkTreeSelection *selection;
	GtkTreeIter iter;

	selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
	if (!gtk_tree_selection_get_selected(selection, &model, &iter)) return;

	gtk_tree_model_get(model, &iter, 1, &path, -1);
	if (!path) return;

	list = g_list_append(list, path);

	gchar **uris = uris_from_pathlist(list);
	gboolean ret = gtk_selection_data_set_uris(selection_data, uris);
	if (!ret)
		{
		char *str = g_strjoinv("\r\n", uris);
		ret = gtk_selection_data_set_text(selection_data, str, -1);
		g_free(str);
		}

	string_list_free(list);
}
Beispiel #5
0
static void  
drag_data_get_cb (GtkWidget        *widget,
		  GdkDragContext   *context,
		  GtkSelectionData *selection_data,
		  guint             info,
		  guint             time,
		  Launcher         *launcher)
{
	char *location;
	
	g_return_if_fail (launcher != NULL);

	location = launcher->location;

	if (info == TARGET_URI_LIST) {
		char *uri[2];

		uri[0] = panel_launcher_get_uri (location);
		uri[1] = NULL;

		gtk_selection_data_set_uris (selection_data, uri);

		g_free (uri[0]);
	} else if (info == TARGET_ICON_INTERNAL)
		gtk_selection_data_set (selection_data,
					gtk_selection_data_get_target (selection_data), 8,
					(unsigned char *) location,
					strlen (location));

}
Beispiel #6
0
static void
clipboard_get_cb (GtkClipboard     *clipboard,
		  GtkSelectionData *selection_data,
		  guint             info,
		  gpointer          user_data_or_owner)
{
	ClipboardData *clipboard_data = user_data_or_owner;
	GdkAtom        targets[1];
	int            n_targets;

	targets[0] = gtk_selection_data_get_target (selection_data);
	n_targets = 1;

	if (gtk_targets_include_uri (targets, n_targets)) {
		gtk_selection_data_set_uris (selection_data, clipboard_data->uris);
	}
	else if (gtk_targets_include_text (targets, n_targets)) {
		char  *str;
		gsize  len;

		str = clipboard_data_convert_to_text (clipboard_data, FALSE, &len);
		gtk_selection_data_set_text (selection_data, str, len);
		g_free (str);
	}
	else if (gtk_selection_data_get_target (selection_data) == GNOME_COPIED_FILES) {
		char  *str;
		gsize  len;

		str = clipboard_data_convert_to_text (clipboard_data, TRUE, &len);
		gtk_selection_data_set (selection_data, GNOME_COPIED_FILES, 8, (guchar *) str, len);
		g_free (str);
	}
}
Beispiel #7
0
static void
_get_data (GtkWidget *widget,GdkDragContext   *drag_context,
           GtkSelectionData *data,guint info,guint time,gpointer null)
{
  CairoMenuItemPrivate * priv = GET_PRIVATE(widget);
  gchar *uris[] = {priv->drag_source_data, NULL};
  gtk_selection_data_set_uris (data,uris);
}
Beispiel #8
0
void
gnac_profiles_mgr_on_drag_data_get(GtkWidget        *widget,
                                   GdkDragContext   *drag_context,
                                   GtkSelectionData *data,
                                   guint             info,
                                   guint             time,
                                   gpointer          user_data)
{
  gchar **uris = gnac_profiles_mgr_get_selected_uris();
  gtk_selection_data_set_uris(data, uris);
}
void
caja_get_clipboard_callback (GtkClipboard     *clipboard,
                             GtkSelectionData *selection_data,
                             guint             info,
                             gpointer          user_data)
{
    char **uris;
    GList *l;
    int i;
    CajaClipboardInfo *clipboard_info;
    GdkAtom target;

    clipboard_info =
        caja_clipboard_monitor_get_clipboard_info (caja_clipboard_monitor_get ());

    target = gtk_selection_data_get_target (selection_data);

    if (gtk_targets_include_uri (&target, 1))
    {
        uris = g_malloc ((g_list_length (clipboard_info->files) + 1) * sizeof (char *));
        i = 0;

        for (l = clipboard_info->files; l != NULL; l = l->next)
        {
            uris[i] = caja_file_get_uri (l->data);
            i++;
        }

        uris[i] = NULL;

        gtk_selection_data_set_uris (selection_data, uris);

        g_strfreev (uris);
    }
    else if (gtk_targets_include_text (&target, 1))
    {
        char *str;
        gsize len;

        str = convert_file_list_to_string (clipboard_info, TRUE, &len);
        gtk_selection_data_set_text (selection_data, str, len);
        g_free (str);
    }
    else if (target == copied_files_atom)
    {
        char *str;
        gsize len;

        str = convert_file_list_to_string (clipboard_info, FALSE, &len);
        gtk_selection_data_set (selection_data, copied_files_atom, 8, str, len);
        g_free (str);
    }
}
Beispiel #10
0
gboolean uri_selection_data_set_uris_from_filelist(GtkSelectionData *selection_data, GList *list)
{
	gchar **uris = uris_from_filelist(list);
	gboolean ret = gtk_selection_data_set_uris(selection_data, uris);
	if (!ret)
		{
		char *str = g_strjoinv("\r\n", uris);
		ret = gtk_selection_data_set_text(selection_data, str, -1);
		g_free(str);
		}

	g_strfreev(uris);
	return ret;
}
static void
tile_drag_data_get (GtkWidget * widget, GdkDragContext * context, GtkSelectionData * data,
	guint info, guint time)
{
	gchar *uris[2];

	if (TILE (widget)->uri)
	{
		uris[0] = TILE (widget)->uri;
		uris[1] = NULL;

		gtk_selection_data_set_uris (data, uris);
	}
}
Beispiel #12
0
static void
_get_clipboard_callback	(GtkClipboard*		clipboard,
			 GtkSelectionData*	selection_data,
			 guint			info,
			 gpointer               user_data)
{
    g_debug ("_get_clipboard_callback: begin");
    GdkAtom target;
    target = gtk_selection_data_get_target (selection_data);

    // set to a URI string
    if (gtk_targets_include_uri (&target, 1))
    {
	char **uris;
	uris = g_malloc ((clipboard_info.num + 1) * sizeof (char *));

	int i = 0;
	for (i = 0; i < clipboard_info.num; i++)
	{
	    uris[i] = g_file_get_uri (clipboard_info.file_list[i]);
	    i++;
	}
	uris[i] = NULL;

	gtk_selection_data_set_uris (selection_data, uris);
	g_strfreev (uris);
    }
    // set to a UTF-8 encoded string
    else if (gtk_targets_include_text (&target, 1))
    {
	char *str;
       	gsize len;
	str = __convert_file_list_to_string (&clipboard_info, TRUE, &len);

	gtk_selection_data_set_text (selection_data, str, len);
	g_free (str);
    }
    //NOTE: cut or copy
    else if (target == copied_files_atom)
    {
	char *str;
	gsize len;
	str = __convert_file_list_to_string (&clipboard_info, FALSE, &len);

	gtk_selection_data_set (selection_data, copied_files_atom, 8, (const guchar*)str, len);
        g_free (str);
    }
    g_debug ("_get_clipboard_callback: end");
}
Beispiel #13
0
static void
file_view_drag_data_get (GtkWidget* widget,
                         GdkDragContext *drag_context,
                         GtkSelectionData *data,
                         guint info,
                         guint time)
{
	AnjutaFileView* view = ANJUTA_FILE_VIEW(widget);
	GFile* selected = file_view_get_selected (view);

	if (selected)
	{
		gchar* uris[2];
		uris[0] = g_file_get_uri (selected);
		uris[1] = NULL;
		gtk_selection_data_set_uris (data, uris);
		g_free(uris[0]);
	}
}
Beispiel #14
0
static void
drag_data_get (GtkWidget          *widget,
	       GdkDragContext     *context,
	       GtkSelectionData   *selection_data,
	       guint               info,
	       guint               time,
	       ScreenshotDialog   *dialog)
{
  if (info == TYPE_TEXT_URI_LIST)
    {
      gchar **uris;

      uris = g_new (gchar *, 2);
      uris[0] = g_strconcat ("file://",
                             screenshot_save_get_filename (),
                             NULL);
      uris[1] = NULL;
      
      gtk_selection_data_set_uris (selection_data, uris);
    }
static void
wp_drag_get_data (GtkWidget *widget,
		  GdkDragContext *context,
		  GtkSelectionData *selection_data,
		  guint type, guint time,
		  AppearanceData *data)
{
  if (type == TARGET_URI_LIST) {
    MateWPItem *item = get_selected_item (data, NULL);

    if (item != NULL) {
      char *uris[2];

      uris[0] = g_filename_to_uri (item->filename, NULL, NULL);
      uris[1] = NULL;

      gtk_selection_data_set_uris (selection_data, uris);

      g_free (uris[0]);
    }
  }
}
JNIEXPORT jboolean JNICALL
Java_org_gnome_gtk_GtkSelectionData_gtk_1selection_1data_1set_1uris
(
	JNIEnv* env,
	jclass cls,
	jlong _self,
	jobjectArray _uris
)
{
	gboolean result;
	jboolean _result;
	GtkSelectionData* self;
	gchar** uris;

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

	// convert parameter uris
	uris = (gchar**) bindings_java_convert_strarray_to_gchararray(env, _uris);
	if (uris == NULL) {
		return  JNI_FALSE; // Java Exception already thrown
	}

	// call function
	result = gtk_selection_data_set_uris(self, uris);

	// cleanup parameter self

	// cleanup parameter uris
	bindings_java_convert_gchararray_to_strarray(env, (gchar**)uris, _uris);

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

	// and finally
	return _result;
}
Beispiel #17
0
static void
on_drag_data_get (GtkWidget *widget, GdkDragContext *drag_context,
		  GtkSelectionData *sel_data, guint info, guint time,
		  TTXWindow *self)
{
	char	*uris[2] = { NULL, NULL };
	GError	*err;

	if (!self->priv->img_file)
		return;

	err = NULL;
	uris[0] = g_filename_to_uri (self->priv->img_file, NULL, &err);
	if (!uris[0]) {
		g_warning ("fail to get an uri for %s: %s",
			   self->priv->img_file,
			   err ? err->message : "something went wrong");
		g_clear_error (&err);
		return;
	}

	gtk_selection_data_set_uris (sel_data, uris);
	g_free (uris[0]);
}
static void set_uri_data(GtkSelectionData *selection_data, jobject data) {
    const gchar* url = NULL;
    jstring jurl = NULL;

    jobjectArray files_array = NULL;
    gsize files_cnt = 0;
    
    jstring typeString;

    typeString = mainEnv->NewStringUTF("text/uri-list");
    if (mainEnv->CallBooleanMethod(data, jMapContainsKey, typeString, NULL)) {
        jurl = (jstring) mainEnv->CallObjectMethod(data, jMapGet, typeString, NULL);
        CHECK_JNI_EXCEPTION(mainEnv);
        url = mainEnv->GetStringUTFChars(jurl, NULL);
    }
    
    typeString = mainEnv->NewStringUTF("application/x-java-file-list");
    if (mainEnv->CallBooleanMethod(data, jMapContainsKey, typeString, NULL)) {
        files_array = (jobjectArray) mainEnv->CallObjectMethod(data, jMapGet, typeString, NULL);
        CHECK_JNI_EXCEPTION(mainEnv);
        if (files_array) {
            files_cnt = mainEnv->GetArrayLength(files_array);
        }
    }

    if (!url && !files_cnt) {
        return;
    }

    gsize uri_cnt = files_cnt + (url ? 1 : 0);

    gchar **uris = 
            (gchar**) glass_try_malloc0_n(uri_cnt + 1, // uris must be a NULL-terminated array of strings
                                            sizeof(gchar*));
    if (!uris) {
        if (url) {
            mainEnv->ReleaseStringUTFChars(jurl, url);
        }
        glass_throw_oom(mainEnv, "Failed to allocate uri data");
        return;
    }

    gsize i = 0;
    if (files_cnt > 0) {
        for (; i < files_cnt; ++i) {
            jstring string = (jstring) mainEnv->GetObjectArrayElement(files_array, i);
            const gchar* file = mainEnv->GetStringUTFChars(string, NULL);
            uris[i] = g_filename_to_uri(file, NULL, NULL);
            mainEnv->ReleaseStringUTFChars(string, file);
        }
    }

    if (url) {
        uris[i] = (gchar*) url;
    }
    //http://www.ietf.org/rfc/rfc2483.txt
    gtk_selection_data_set_uris(selection_data, uris);

    for (i = 0; i < uri_cnt; ++i) {
        if (uris[i] != url) {
            g_free(uris[i]);
        }
    }

    if (url) {
        mainEnv->ReleaseStringUTFChars(jurl, url);
    }
    g_free(uris);
}