Re: [gtk-osx-users] Pasting images from clipboard



I can confirm that this patch works OK. I actually modified sample to use this function (instead of patching 
GTK+ itself):

GdkPixbuf *gtk_clipboard_wait_for_image1 (GtkClipboard *clipboard)
{
        GdkAtom target = gdk_atom_intern_static_string("image/tiff");
        GtkSelectionData *data = gtk_clipboard_wait_for_contents (clipboard, target);
        if (data && data->data){
                GdkPixbuf *pixbuf = gtk_selection_data_get_pixbuf (data);
                gtk_selection_data_free (data);
                return pixbuf;
        }
        return NULL;
}

And it reported success.
I suppose this is a temporary code, because it only looks for tiff format?

Regards,
  Miroslav

________________________________________
From: John Ralls <jralls ceridwen us>
Sent: Monday, February 15, 2016 10:07 PM
To: Miroslav Rajcic
Cc: gtk-osx-users-list gnome org
Subject: Re: [gtk-osx-users] Pasting images from clipboard

On Feb 15, 2016, at 11:12 AM, Miroslav Rajcic <mrajcic hotmail com> wrote:

The test is exactly the same, I just forgot to remove Windows-specific files (Visual Studio project) when 
re-uploading the code.
I use modulesets-stable version of GTK+.


I haven't yet made a patch for gtk-osx, I expected you to go test with a git clone. The change is below: 
Apply it and try again.

Regards,
John Ralls


diff --git a/gtk/gtkclipboard-quartz.c b/gtk/gtkclipboard-quartz.c
index 29c7b11..79a3fd5 100644
--- a/gtk/gtkclipboard-quartz.c
+++ b/gtk/gtkclipboard-quartz.c
@@ -754,23 +754,18 @@ gtk_clipboard_wait_for_text (GtkClipboard *clipboard)
GdkPixbuf *
gtk_clipboard_wait_for_image (GtkClipboard *clipboard)
{
- const gchar *priority[] = { "image/png", "image/tiff", "image/jpeg", "image/gif", "image/bmp" };
+ GdkAtom target = gdk_atom_intern_static_string("image/tiff")
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);
+ data = gtk_clipboard_wait_for_contents (clipboard, target);
-       return pixbuf;
-       }
- }
+ if (data && data->data)
+ {
+ GdkPixbuf *pixbuf = gtk_selection_data_get_pixbuf (data);
+ gtk_selection_data_free (data);
+ return pixbuf;
+ }
return NULL;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]