Re: [gtk-osx-users] Pasting images from clipboard
- From: John Ralls <jralls ceridwen us>
- To: Miroslav Rajcic <mrajcic hotmail com>
- Cc: "gtk-osx-users-list gnome org" <gtk-osx-users-list gnome org>
- Subject: Re: [gtk-osx-users] Pasting images from clipboard
- Date: Tue, 9 Feb 2016 07:09:38 -0800
On Feb 9, 2016, at 2:27 AM, Miroslav Rajcic <mrajcic hotmail com> wrote:
Is pasting images from the clipboard supported in GTK 2.x for OS X?
In my app, the same code doesn't work on OS X but works OK on all other platforms (Windows, Linux, BSD,
...).
Actual code goes like this:
- paste is initialized by call to:
GtkClipboard *clipboard = gtk_widget_get_clipboard (g_text.m_pWidget, GDK_SELECTION_CLIPBOARD);
gtk_clipboard_request_targets(clipboard, OnPasteClipboardTargetsReceivedFunc, NULL);
- inside OnPasteClipboardTargetsReceivedFunc callback, I do actual pasting with:
if(gtk_targets_include_image(atoms, n_atoms, FALSE)){
GtkPixbuf *pixbuf = gtk_clipboard_wait_for_image(clipboard);
if(!pixbuf){
gtkMessageBox(_("Failed to open image from the clipboard!"));
}
}
This GTK API call fails consistently all the time (returning NULL) on OS X (triggering error message box
below).
Is this a known issue?
Note that pasting works OK for other types of content (text, RTF), but naturally I use different calls to
fetch those.
The app is bundled with all image loaders, inserting image from file works OK, only clipboard operation is
problematic.
How are you putting the image into the clipboard and what kind of image is it? The quartz clipboard functions
are implemented separately from the other platforms in gtkclipboard-quartz.c:
gtk_clipboard_wait_for_image (GtkClipboard *clipboard)
{
const gchar *priority[] = { "image/png", "image/tiff", "image/jpeg", "image/gif", "image/bmp" };
int i;
GtkSelectionData *data;
for (i = 0; i < G_N_ELEMENTS (priority); i++)
{
data = gtk_clipboard_wait_for_contents (clipboard, gdk_atom_intern_static_string (priority[i]));
if (data)
{
GdkPixbuf *pixbuf = gtk_selection_data_get_pixbuf (data);
gtk_selection_data_free (data);
return pixbuf;
}
}
return NULL;
}
Note that it will only handle the 5 image types in the "priority" array.
Regards,
John Ralls
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]