[gtk+/gtk-2-24] quartz: move atom/pasteboard type conversions functions to GDK



commit a269c2f8d26a588c4b61ad605ef496e89759cc03
Author: Kristian Rietveld <kris loopnest org>
Date:   Sun Dec 30 17:09:22 2012 +0100

    quartz: move atom/pasteboard type conversions functions to GDK

 gdk/quartz/gdkquartz.h              |    4 +++
 gdk/quartz/gdkselection-quartz.c    |   40 ++++++++++++++++++++++++++++++++
 gtk/gtkdnd-quartz.c                 |    2 +-
 gtk/gtkquartz.c                     |   43 +++-------------------------------
 gtk/gtkquartz.h                     |    1 -
 tests/dummy-headers/AppKit/AppKit.h |    3 ++
 6 files changed, 52 insertions(+), 41 deletions(-)
---
diff --git a/gdk/quartz/gdkquartz.h b/gdk/quartz/gdkquartz.h
index f7d3497..3c42983 100644
--- a/gdk/quartz/gdkquartz.h
+++ b/gdk/quartz/gdkquartz.h
@@ -59,6 +59,10 @@ id        gdk_quartz_drag_context_get_dragging_info_libgtk_only (GdkDragContext
 NSEvent  *gdk_quartz_event_get_nsevent                          (GdkEvent       *event);
 GdkOSXVersion gdk_quartz_osx_version                            (void);
 
+GdkAtom   gdk_quartz_pasteboard_type_to_atom_libgtk_only        (NSString       *type);
+NSString *gdk_quartz_target_to_pasteboard_type_libgtk_only      (const gchar    *target);
+NSString *gdk_quartz_atom_to_pasteboard_type_libgtk_only        (GdkAtom         atom);
+
 G_END_DECLS
 
 #endif /* __GDK_QUARTZ_H__ */
diff --git a/gdk/quartz/gdkselection-quartz.c b/gdk/quartz/gdkselection-quartz.c
index d748861..b305532 100644
--- a/gdk/quartz/gdkselection-quartz.c
+++ b/gdk/quartz/gdkselection-quartz.c
@@ -24,6 +24,7 @@
 
 #include "gdkselection.h"
 #include "gdkproperty.h"
+#include "gdkquartz.h"
 
 gboolean
 gdk_selection_owner_set_for_display (GdkDisplay *display,
@@ -231,3 +232,42 @@ gdk_text_property_to_utf8_list_for_display (GdkDisplay    *display,
     }
 }
 
+GdkAtom
+gdk_quartz_pasteboard_type_to_atom_libgtk_only (NSString *type)
+{
+  if ([type isEqualToString:NSStringPboardType])
+    return gdk_atom_intern_static_string ("UTF8_STRING");
+  else if ([type isEqualToString:NSTIFFPboardType])
+    return gdk_atom_intern_static_string ("image/tiff");
+  else if ([type isEqualToString:NSColorPboardType])
+    return gdk_atom_intern_static_string ("application/x-color");
+  else if ([type isEqualToString:NSURLPboardType])
+    return gdk_atom_intern_static_string ("text/uri-list");
+  else
+    return gdk_atom_intern ([type UTF8String], FALSE);
+}
+
+NSString *
+gdk_quartz_target_to_pasteboard_type_libgtk_only (const char *target)
+{
+  if (strcmp (target, "UTF8_STRING") == 0)
+    return NSStringPboardType;
+  else if (strcmp (target, "image/tiff") == 0)
+    return NSTIFFPboardType;
+  else if (strcmp (target, "application/x-color") == 0)
+    return NSColorPboardType;
+  else if (strcmp (target, "text/uri-list") == 0)
+    return NSURLPboardType;
+  else
+    return [NSString stringWithUTF8String:target];
+}
+
+NSString *
+gdk_quartz_atom_to_pasteboard_type_libgtk_only (GdkAtom atom)
+{
+  gchar *target = gdk_atom_name (atom);
+  NSString *ret = gdk_quartz_target_to_pasteboard_type_libgtk_only (target);
+  g_free (target);
+
+  return ret;
+}
diff --git a/gtk/gtkdnd-quartz.c b/gtk/gtkdnd-quartz.c
index 56fdc44..28c5f78 100644
--- a/gtk/gtkdnd-quartz.c
+++ b/gtk/gtkdnd-quartz.c
@@ -152,7 +152,7 @@ struct _GtkDragFindData
   selection_data.selection = GDK_NONE;
   selection_data.data = NULL;
   selection_data.length = -1;
-  selection_data.target = _gtk_quartz_pasteboard_type_to_atom (type);
+  selection_data.target = gdk_quartz_pasteboard_type_to_atom_libgtk_only (type);
   selection_data.display = gdk_display_get_default ();
 
   if (gtk_target_list_find (info->target_list, 
diff --git a/gtk/gtkquartz.c b/gtk/gtkquartz.c
index 2f8122a..d630abc 100644
--- a/gtk/gtkquartz.c
+++ b/gtk/gtkquartz.c
@@ -77,21 +77,6 @@ _gtk_quartz_create_image_from_pixbuf (GdkPixbuf *pixbuf)
   return nsimage;
 }
 
-static NSString *
-target_to_pasteboard_type (const char *target)
-{
-  if (strcmp (target, "UTF8_STRING") == 0)
-    return NSStringPboardType;
-  else if (strcmp (target, "image/tiff") == 0)
-    return NSTIFFPboardType;
-  else if (strcmp (target, "application/x-color") == 0)
-    return NSColorPboardType;
-  else if (strcmp (target, "text/uri-list") == 0)
-    return NSURLPboardType;
-  else
-    return [NSString stringWithUTF8String:target];
-}
-
 NSSet *
 _gtk_quartz_target_list_to_pasteboard_types (GtkTargetList *target_list)
 {
@@ -101,9 +86,7 @@ _gtk_quartz_target_list_to_pasteboard_types (GtkTargetList *target_list)
   for (list = target_list->list; list; list = list->next)
     {
       GtkTargetPair *pair = list->data;
-      gchar *target = gdk_atom_name (pair->target);
-      [set addObject:target_to_pasteboard_type (target)];
-      g_free (target);
+      [set addObject:gdk_quartz_atom_to_pasteboard_type_libgtk_only (pair->target)];
     }
 
   return set;
@@ -118,27 +101,12 @@ _gtk_quartz_target_entries_to_pasteboard_types (const GtkTargetEntry *targets,
 
   for (i = 0; i < n_targets; i++)
     {
-      [set addObject:target_to_pasteboard_type (targets[i].target)];
+      [set addObject:gdk_quartz_target_to_pasteboard_type_libgtk_only (targets[i].target)];
     }
 
   return set;
 }
 
-GdkAtom 
-_gtk_quartz_pasteboard_type_to_atom (NSString *type)
-{
-  if ([type isEqualToString:NSStringPboardType])
-    return gdk_atom_intern_static_string ("UTF8_STRING");
-  else if ([type isEqualToString:NSTIFFPboardType])
-    return gdk_atom_intern_static_string ("image/tiff");
-  else if ([type isEqualToString:NSColorPboardType])
-    return gdk_atom_intern_static_string ("application/x-color");
-  else if ([type isEqualToString:NSURLPboardType])
-    return gdk_atom_intern_static_string ("text/uri-list");
-  else
-    return gdk_atom_intern ([type UTF8String], FALSE);  
-}
-
 GList *
 _gtk_quartz_pasteboard_types_to_atom_list (NSArray *array)
 {
@@ -150,7 +118,7 @@ _gtk_quartz_pasteboard_types_to_atom_list (NSArray *array)
 
   for (i = 0; i < count; i++) 
     {
-      GdkAtom atom = _gtk_quartz_pasteboard_type_to_atom ([array objectAtIndex:i]);
+      GdkAtom atom = gdk_quartz_pasteboard_type_to_atom_libgtk_only ([array objectAtIndex:i]);
 
       result = g_list_prepend (result, GDK_ATOM_TO_POINTER (atom));
     }
@@ -266,20 +234,17 @@ _gtk_quartz_set_selection_data_for_pasteboard (NSPasteboard     *pasteboard,
                                               GtkSelectionData *selection_data)
 {
   NSString *type;
-  gchar *target;
   GdkDisplay *display;
   gint format;
   const guchar *data;
   NSUInteger length;
 
-  target = gdk_atom_name (gtk_selection_data_get_target (selection_data));
   display = gtk_selection_data_get_display (selection_data);
   format = gtk_selection_data_get_format (selection_data);
   data = gtk_selection_data_get_data (selection_data);
   length = gtk_selection_data_get_length (selection_data);
 
-  type = target_to_pasteboard_type (target);
-  g_free (target);
+  type = gdk_quartz_atom_to_pasteboard_type_libgtk_only (gtk_selection_data_get_target (selection_data));
 
   if ([type isEqualTo:NSStringPboardType]) 
     [pasteboard setString:[NSString stringWithUTF8String:(const char *)data]
diff --git a/gtk/gtkquartz.h b/gtk/gtkquartz.h
index 54f4126..41fa1ee 100644
--- a/gtk/gtkquartz.h
+++ b/gtk/gtkquartz.h
@@ -31,7 +31,6 @@ NSSet   *_gtk_quartz_target_entries_to_pasteboard_types (const GtkTargetEntry *t
                                                         guint                 n_targets);
 
 GList   *_gtk_quartz_pasteboard_types_to_atom_list (NSArray  *array);
-GdkAtom _gtk_quartz_pasteboard_type_to_atom        (NSString *type);
 
 GtkSelectionData *_gtk_quartz_get_selection_data_from_pasteboard (NSPasteboard *pasteboard,
                                                                  GdkAtom       target,
diff --git a/tests/dummy-headers/AppKit/AppKit.h b/tests/dummy-headers/AppKit/AppKit.h
index 1456923..557a8a7 100644
--- a/tests/dummy-headers/AppKit/AppKit.h
+++ b/tests/dummy-headers/AppKit/AppKit.h
@@ -20,5 +20,8 @@ typedef int NSTrackingRectTag;
 @interface NSWindow {}
 @end
 
+ interface NSString {}
+ end
+
 @protocol NSDraggingInfo
 @end


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