]> Pileus Git - ~andy/gtk/blobdiff - gdk/win32/gdkselection-win32.c
Work on OLE2-based generic DND
[~andy/gtk] / gdk / win32 / gdkselection-win32.c
index 73588b8d90b57383332cbb9636d0517a42333031..e3936a9b3eccb6011ae0180a3c312503d3d1a74c 100644 (file)
@@ -55,18 +55,9 @@ static GdkSelProp *dropfiles_prop = NULL;
  */
 static GHashTable *sel_owner_table = NULL;
 
-/* Well-known registered clipboard image formats */
-static UINT cf_png;
-static UINT cf_jfif;
-static UINT cf_gif;
-
 /* GdkAtoms for well-known image formats */
 static GdkAtom *known_pixbuf_formats;
 static int n_known_pixbuf_formats;
-static GdkAtom image_png;
-static GdkAtom image_jpeg;
-static GdkAtom image_bmp;
-static GdkAtom image_gif;
 
 /* GdkAtoms for well-known text formats */
 static GdkAtom text_plain;
@@ -83,15 +74,6 @@ _gdk_win32_selection_init (void)
   sel_owner_table = g_hash_table_new (NULL, NULL);
   _format_atom_table = g_hash_table_new (NULL, NULL);
 
-  /* MS Office 2007, at least, offers images in common file formats
-   * using clipboard format names like "PNG" and "JFIF". So we follow
-   * the lead and map the GDK target name "image/png" to the clipboard
-   * format name "PNG" etc.
-   */
-  cf_png = RegisterClipboardFormat ("PNG");
-  cf_jfif = RegisterClipboardFormat ("JFIF");
-  cf_gif = RegisterClipboardFormat ("GIF");
-
   pixbuf_formats = gdk_pixbuf_get_formats ();
 
   n_known_pixbuf_formats = 0;
@@ -122,22 +104,17 @@ _gdk_win32_selection_init (void)
 
   g_slist_free (pixbuf_formats);
   
-  image_png = gdk_atom_intern ("image/png", FALSE);
-  image_jpeg = gdk_atom_intern ("image/jpeg", FALSE);
-  image_bmp = gdk_atom_intern ("image/bmp", FALSE);
-  image_gif = gdk_atom_intern ("image/gif", FALSE);
-
   text_plain = gdk_atom_intern ("text/plain", FALSE);
   text_plain_charset_utf_8= gdk_atom_intern ("text/plain;charset=utf-8", FALSE);
   text_plain_charset_CP1252 = gdk_atom_intern ("text/plain;charset=CP1252", FALSE);
 
   g_hash_table_replace (_format_atom_table,
-                       GINT_TO_POINTER (cf_png),
-                       image_png);
+                       GINT_TO_POINTER (_cf_png),
+                       _image_png);
 
   g_hash_table_replace (_format_atom_table,
                        GINT_TO_POINTER (CF_DIB),
-                       image_bmp);
+                       _image_bmp);
 }
 
 /* The specifications for COMPOUND_TEXT and STRING specify that C0 and
@@ -263,13 +240,13 @@ _gdk_dropfiles_store (gchar *data)
 static gchar *
 get_mapped_gdk_atom_name (GdkAtom gdk_target)
 {
-  if (gdk_target == image_png)
+  if (gdk_target == _image_png)
     return g_strdup ("PNG");
 
-  if (gdk_target == image_jpeg)
+  if (gdk_target == _image_jpeg)
     return g_strdup ("JFIF");
   
-  if (gdk_target == image_gif)
+  if (gdk_target == _image_gif)
     return g_strdup ("GIF");
   
   return gdk_atom_name (gdk_target);
@@ -451,9 +428,9 @@ gdk_selection_convert (GdkWindow *requestor,
 
       for (fmt = 0; 0 != (fmt = EnumClipboardFormats (fmt)); )
        {
-         if (fmt == cf_png)
+         if (fmt == _cf_png)
            {
-             targets[ntargets++] = image_png;
+             targets[ntargets++] = _image_png;
              has_png = TRUE;
            }
        }
@@ -469,7 +446,7 @@ gdk_selection_convert (GdkWindow *requestor,
                targets[ntargets++] = _utf8_string;
              has_text = TRUE;
            }
-         else if (fmt == cf_png)
+         else if (fmt == _cf_png)
            {
              /* Already handled above */
            }
@@ -481,21 +458,21 @@ gdk_selection_convert (GdkWindow *requestor,
               * transparency.
               */
              if (!has_bmp && !has_png)
-               targets[ntargets++] = image_bmp;
+               targets[ntargets++] = _image_bmp;
              has_bmp = TRUE;
            }
-         else if (fmt == cf_jfif)
+         else if (fmt == _cf_jfif)
            {
              /* Ditto for JPEG */
              if (!has_png)
-               targets[ntargets++] = image_jpeg;
+               targets[ntargets++] = _image_jpeg;
            }
-         else if (fmt == cf_gif)
+         else if (fmt == _cf_gif)
            {
              /* Ditto for GIF.
               */
              if (!has_png)
-               targets[ntargets++] = image_gif;
+               targets[ntargets++] = _image_gif;
            }
          else if (GetClipboardFormatName (fmt, sFormat, 80) > 0)
            {
@@ -592,7 +569,7 @@ gdk_selection_convert (GdkWindow *requestor,
 
       API_CALL (CloseClipboard, ());
     }
-  else if (selection == GDK_SELECTION_CLIPBOARD && target == image_bmp)
+  else if (selection == GDK_SELECTION_CLIPBOARD && target == _image_bmp)
     {
       if (!API_CALL (OpenClipboard, (GDK_WINDOW_HWND (requestor))))
        return;
@@ -686,7 +663,7 @@ gdk_selection_convert (GdkWindow *requestor,
 
                  if (make_dibv5)
                    {
-                     BITMAPV5HEADER *bV5 = data + sizeof (BITMAPFILEHEADER);
+                     BITMAPV5HEADER *bV5 = (BITMAPV5HEADER *) ((char *) data + sizeof (BITMAPFILEHEADER));
                      guchar *p;
                      int i;
 
@@ -741,12 +718,12 @@ gdk_selection_convert (GdkWindow *requestor,
                                       bi->biSize +
                                       bi->biClrUsed * sizeof (RGBQUAD));
 
-                     memcpy (data + sizeof (BITMAPFILEHEADER),
+                     memcpy ((char *) data + sizeof (BITMAPFILEHEADER),
                              bi,
                              data_length);
                    }
 
-                 selection_property_store (requestor, image_bmp, 8,
+                 selection_property_store (requestor, _image_bmp, 8,
                                            data, new_length);
                 }
              GlobalUnlock (hdata);
@@ -810,7 +787,7 @@ gdk_selection_convert (GdkWindow *requestor,
       if (dropfiles_prop != NULL)
        {
          selection_property_store
-           (requestor, selection, dropfiles_prop->format,
+           (requestor, dropfiles_prop->type, dropfiles_prop->format,
             dropfiles_prop->data, dropfiles_prop->length);
          g_free (dropfiles_prop);
          dropfiles_prop = NULL;
@@ -877,8 +854,6 @@ gdk_selection_property_get (GdkWindow  *requestor,
 void
 _gdk_selection_property_delete (GdkWindow *window)
 {
-  GdkSelProp *prop;
-  
   GDK_NOTE (DND, g_print ("_gdk_selection_property_delete: %p (no-op)\n",
                           GDK_WINDOW_HWND (window)));
 
@@ -1226,7 +1201,7 @@ gdk_win32_selection_add_targets (GdkWindow  *owner,
            if (!has_image)
              {
                GDK_NOTE (DND, g_print ("... SetClipboardData(PNG,NULL)\n"));
-               SetClipboardData (cf_png, NULL);
+               SetClipboardData (_cf_png, NULL);
 
                GDK_NOTE (DND, g_print ("... SetClipboardData(CF_DIB,NULL)\n"));
                SetClipboardData (CF_DIB, NULL);
@@ -1296,7 +1271,7 @@ _gdk_win32_selection_convert_to_dib (HGLOBAL  hdata,
       g_free (target_name);
     });
 
-  if (target == image_bmp)
+  if (target == _image_bmp)
     {
       /* No conversion is needed, just strip the BITMAPFILEHEADER */
       HGLOBAL hdatanew;