]> Pileus Git - ~andy/gtk/commitdiff
take targets into account again to allow dnd of other things than text
authorHans Breuer <hans@breuer.org>
Sun, 8 Aug 2004 22:31:12 +0000 (22:31 +0000)
committerHans Breuer <hans@src.gnome.org>
Sun, 8 Aug 2004 22:31:12 +0000 (22:31 +0000)
2004-08-07  Hans Breuer  <hans@breuer.org>

* gtk/gtkdnd.c (gtk_drag_dest_set) : take targets into
account again to allow dnd of other things than text

* gdk/win32/gdkselection-win32.c : offer windows bitmap to
be pasted from clipboard (makes The GIMP 2.1's
"File/Acquire/Paste as New" work, only using gtk+ API)

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gdk/win32/gdkselection-win32.c
gtk/gtkdnd.c

index 1c7164852f4b39b0ead18990626ebde39ce4ec30..078e83cd5f411a29609475fc9ab34d28015e0cff 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2004-08-08  Hans Breuer  <hans@breuer.org>
+
+       * gtk/gtkdnd.c (gtk_drag_dest_set) : take targets into
+       account again to allow dnd of other things than text
+
+       * gdk/win32/gdkselection-win32.c : offer windows bitmap to
+       be pasted from clipboard (makes The GIMP 2.1's 
+       "File/Acquire/Paste as New" work, only using gtk+ API) 
+
 Sun Aug  8 01:32:36 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtk.def: Add gtk_cell_renderer_progress_get_type.
index 1c7164852f4b39b0ead18990626ebde39ce4ec30..078e83cd5f411a29609475fc9ab34d28015e0cff 100644 (file)
@@ -1,3 +1,12 @@
+2004-08-08  Hans Breuer  <hans@breuer.org>
+
+       * gtk/gtkdnd.c (gtk_drag_dest_set) : take targets into
+       account again to allow dnd of other things than text
+
+       * gdk/win32/gdkselection-win32.c : offer windows bitmap to
+       be pasted from clipboard (makes The GIMP 2.1's 
+       "File/Acquire/Paste as New" work, only using gtk+ API) 
+
 Sun Aug  8 01:32:36 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtk.def: Add gtk_cell_renderer_progress_get_type.
index 1c7164852f4b39b0ead18990626ebde39ce4ec30..078e83cd5f411a29609475fc9ab34d28015e0cff 100644 (file)
@@ -1,3 +1,12 @@
+2004-08-08  Hans Breuer  <hans@breuer.org>
+
+       * gtk/gtkdnd.c (gtk_drag_dest_set) : take targets into
+       account again to allow dnd of other things than text
+
+       * gdk/win32/gdkselection-win32.c : offer windows bitmap to
+       be pasted from clipboard (makes The GIMP 2.1's 
+       "File/Acquire/Paste as New" work, only using gtk+ API) 
+
 Sun Aug  8 01:32:36 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtk.def: Add gtk_cell_renderer_progress_get_type.
index 1c7164852f4b39b0ead18990626ebde39ce4ec30..078e83cd5f411a29609475fc9ab34d28015e0cff 100644 (file)
@@ -1,3 +1,12 @@
+2004-08-08  Hans Breuer  <hans@breuer.org>
+
+       * gtk/gtkdnd.c (gtk_drag_dest_set) : take targets into
+       account again to allow dnd of other things than text
+
+       * gdk/win32/gdkselection-win32.c : offer windows bitmap to
+       be pasted from clipboard (makes The GIMP 2.1's 
+       "File/Acquire/Paste as New" work, only using gtk+ API) 
+
 Sun Aug  8 01:32:36 2004  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtk.def: Add gtk_cell_renderer_progress_get_type.
index 5c9e81ca238b705b7cfa598b8dc18afe7fbc3ada..63fff2f685f179fff6cd5fcffcbce701bc02674b 100644 (file)
@@ -369,7 +369,38 @@ gdk_selection_convert (GdkWindow *requestor,
          _gdk_selection_property_store (requestor, GDK_SELECTION_TYPE_ATOM,
                                         32, (guchar *) data, 1 * sizeof (GdkAtom));
        }
-      else
+      else if (IsClipboardFormatAvailable (CF_BITMAP) ||
+               IsClipboardFormatAvailable (CF_DIB))
+       {
+         GdkAtom *data = g_new (GdkAtom, 1);
+         GdkAtom atom = gdk_atom_intern ("image/bmp", FALSE);
+          *data = atom;
+         _gdk_selection_property_store (requestor, GDK_SELECTION_TYPE_ATOM,
+                                        32, (guchar *) data, 1 * sizeof (GdkAtom));
+       }
+      else if (CountClipboardFormats() > 0)
+        {
+          /* if there is anything else in the clipboard, enum it all although we don't 
+           * offer special conversion services 
+           */
+          int fmt = 0, i = 0;
+         GdkAtom *data = g_new (GdkAtom, CountClipboardFormats());
+
+          for ( ; 0 != (fmt = EnumClipboardFormats (fmt)); )
+            {
+              char sFormat[80];
+
+              if (GetClipboardFormatName (fmt, sFormat, 80) > 0)
+                {
+                  GdkAtom atom = gdk_atom_intern (sFormat, FALSE);
+                  data[i] = atom;
+                  i++;
+                }
+            }
+         _gdk_selection_property_store (requestor, GDK_SELECTION_TYPE_ATOM,
+                                        32, (guchar *) data, i * sizeof (GdkAtom));
+        }
+      else             
        property = GDK_NONE;
 
       API_CALL (CloseClipboard, ());
@@ -514,6 +545,86 @@ gdk_selection_convert (GdkWindow *requestor,
 
       API_CALL (CloseClipboard, ());
     }
+  else if (selection == GDK_SELECTION_CLIPBOARD &&
+           target == gdk_atom_intern ("image/bmp", TRUE))
+    {
+      if (!API_CALL (OpenClipboard, (GDK_WINDOW_HWND (requestor))))
+       return;
+      if ((hdata = GetClipboardData (CF_DIB)) != NULL)
+        {
+          BITMAPINFOHEADER *ptr;
+          guchar *data;
+
+          if ((ptr = GlobalLock (hdata)) != NULL)
+            {
+              BITMAPFILEHEADER *hdr; /* need to add a file header so gdk-pixbuf can load it */
+             gint length = GlobalSize (hdata) + sizeof(BITMAPFILEHEADER);
+             
+             GDK_NOTE (DND, g_print ("...BITMAP: %d bytes\n", length));
+             
+              data = g_try_malloc (length);
+              if (data)
+                {
+                  hdr = (BITMAPFILEHEADER *)data;
+                  hdr->bfType = 0x4d42; /* 0x42 = "B" 0x4d = "M" */
+                  /* Compute the size of the entire file. */
+                  hdr->bfSize = (DWORD) (sizeof(BITMAPFILEHEADER)
+                        + ptr->biSize + ptr->biClrUsed
+                       * sizeof(RGBQUAD) + ptr->biSizeImage);
+                  hdr->bfReserved1 = 0;
+                  hdr->bfReserved2 = 0;
+                  /* Compute the offset to the array of color indices. */
+                  hdr->bfOffBits = (DWORD) sizeof(BITMAPFILEHEADER)
+                        + ptr->biSize + ptr->biClrUsed * sizeof (RGBQUAD);
+                  /* copy the data behind it */
+                  memcpy (data + sizeof(BITMAPFILEHEADER), ptr, length - sizeof(BITMAPFILEHEADER));
+                 _gdk_selection_property_store (requestor, target, 8,
+                                                data, length);
+                }
+             GlobalUnlock (hdata);
+            }
+
+      }
+
+      API_CALL (CloseClipboard, ());
+    }
+  else if (selection == GDK_SELECTION_CLIPBOARD)
+    {
+      const char *targetname = gdk_atom_name (target);
+      UINT fmt = 0;
+
+      if (!API_CALL (OpenClipboard, (GDK_WINDOW_HWND (requestor))))
+       return;
+      /* check if its available */
+      for ( ; 0 != (fmt = EnumClipboardFormats (fmt)); )
+        {
+          char sFormat[80];
+
+          if (GetClipboardFormatName (fmt, sFormat, 80) > 0 && 
+              strcmp (sFormat, targetname) == 0)
+            {
+              if ((hdata = GetClipboardData (fmt)) != NULL)
+               {
+                 /* simply get it without conversion */
+                  guchar *ptr;
+                  gint length;
+
+                  if ((ptr = GlobalLock (hdata)) != NULL)
+                    {
+                      length = GlobalSize (hdata);
+             
+                      GDK_NOTE (DND, g_print ("... %s: %d bytes\n", targetname, length));
+             
+                      _gdk_selection_property_store (requestor, target, 8,
+                                                    g_memdup (ptr, length), length);
+                     GlobalUnlock (hdata);
+                      break;
+                    }
+                }
+            }
+        }
+      API_CALL (CloseClipboard, ());
+    }
   else if (selection == _gdk_win32_dropfiles)
     {
       /* This means he wants the names of the dropped files.
index 92075e63262ab85393bbc7830f9d96fc0a932d18..0f32280ba493deb9bcc993d9c5a672f8a02f5174 100644 (file)
@@ -2095,10 +2095,7 @@ gtk_drag_source_set (GtkWidget            *widget,
 
   site->start_button_mask = start_button_mask;
 
-  if (targets)
-    site->target_list = gtk_target_list_new (targets, n_targets);
-  else
-    site->target_list = NULL;
+  site->target_list = gtk_target_list_new (targets, n_targets);
 
   site->actions = actions;
 }