]> Pileus Git - ~andy/gtk/commitdiff
Add functions which look for text, image or uri targets in an array of
authorMatthias Clasen <mclasen@redhat.com>
Tue, 30 Aug 2005 05:42:37 +0000 (05:42 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Tue, 30 Aug 2005 05:42:37 +0000 (05:42 +0000)
2005-08-30  Matthias Clasen  <mclasen@redhat.com>

* gtk/gtk.symbols:
* gtk/gtkselection.h:
* gtk/gtkselection.c: Add functions which look for text, image
or uri targets in an array of atoms.   (#314089, Mark Wielaard)

ChangeLog
ChangeLog.pre-2-10
docs/reference/ChangeLog
docs/reference/gtk/gtk-sections.txt
gtk/gtk.symbols
gtk/gtkselection.c
gtk/gtkselection.h

index 10040aaac610ca5f58aae3732871a6e244d8adb3..7bdfbd12c23cb3a6c15c4b550ff00ac9551965e8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2005-08-30  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtk.symbols: 
+       * gtk/gtkselection.h:
+       * gtk/gtkselection.c: Add functions which look for text, image
+       or uri targets in an array of atoms.   (#314089, Mark Wielaard)
+
        * gtk/gtk.symbols: 
        * gtk/gtkselection.h:
        * gtk/gtkselection.c (gtk_selection_data_targets_include_uri): 
index 10040aaac610ca5f58aae3732871a6e244d8adb3..7bdfbd12c23cb3a6c15c4b550ff00ac9551965e8 100644 (file)
@@ -1,5 +1,10 @@
 2005-08-30  Matthias Clasen  <mclasen@redhat.com>
 
+       * gtk/gtk.symbols: 
+       * gtk/gtkselection.h:
+       * gtk/gtkselection.c: Add functions which look for text, image
+       or uri targets in an array of atoms.   (#314089, Mark Wielaard)
+
        * gtk/gtk.symbols: 
        * gtk/gtkselection.h:
        * gtk/gtkselection.c (gtk_selection_data_targets_include_uri): 
index f8cec45e74ec8d2be05e3ca99f16b338b72ec12b..a88aeffe1ced81a0ab644d07184cc8ba1613a412 100644 (file)
@@ -2,6 +2,7 @@
 
        * gtk/gtk-sections.txt: Add gtk_window_[sg]et_deletable.
        Add gtk_selection_data_targets_include_uri.
+       Add gtk_targets_include... functions.
 
 2005-08-29  Matthias Clasen  <mclasen@redhat.com>
 
index 26b4e4a4419d7197aeac22102c6eb063c32e7e43..ed4d89ed254597a44ba9f3200dd73caff0267bea 100644 (file)
@@ -5147,6 +5147,9 @@ gtk_selection_data_get_targets
 gtk_selection_data_targets_include_image
 gtk_selection_data_targets_include_text
 gtk_selection_data_targets_include_uri
+gtk_targets_include_image
+gtk_targets_include_text
+gtk_targets_include_uri
 gtk_selection_remove_all
 gtk_selection_clear
 gtk_selection_data_copy
index 5e31af30f48a141cbc145d650b1a5e7e9005ee81..1c1a24fbff3f8577063edce730a3ddf2863ef01f 100644 (file)
@@ -2612,6 +2612,9 @@ gtk_selection_data_set_uris
 gtk_selection_data_targets_include_image
 gtk_selection_data_targets_include_text
 gtk_selection_data_targets_include_uri
+gtk_targets_include_image
+gtk_targets_include_text
+gtk_targets_include_uri
 gtk_selection_owner_set
 gtk_selection_owner_set_for_display
 gtk_selection_remove_all
index 57294758fa527f4f9d5c3f1b41615acfeb6078c6..067409c94962d0f9ed8cdc60f8385826cdbe10c5 100644 (file)
@@ -1568,6 +1568,46 @@ gtk_selection_data_get_targets (GtkSelectionData  *selection_data,
     }
 }
 
+/**
+ * gtk_targets_include_text:
+ * @targets: an array of #GdkAtom<!-- -->s
+ * @n_targets: the length of @targets
+ * 
+ * Determines if any of the targets in @targets can be used to
+ * provide text.
+ * 
+ * Return value: %TRUE if @targets include a suitable target for text,
+ *   otherwise %FALSE.
+ *
+ * Since: 2.10
+ **/
+gboolean 
+gtk_targets_include_text (GdkAtom *targets,
+                          gint     n_targets)
+{
+  gint i;
+  gboolean result = FALSE;
+
+  /* Keep in sync with gtk_target_list_add_text_targets()
+   */
+  for (i = 0; i < n_targets; i++)
+    {
+      if (targets[i] == utf8_atom ||
+         targets[i] == text_atom ||
+         targets[i] == GDK_TARGET_STRING ||
+         targets[i] == ctext_atom ||
+         targets[i] == text_plain_atom ||
+         targets[i] == text_plain_utf8_atom ||
+         targets[i] == text_plain_locale_atom)
+       {
+         result = TRUE;
+         break;
+       }
+    }
+  
+  return result;
+}
+                                   
 /**
  * gtk_selection_data_targets_include_text:
  * @selection_data: a #GtkSelectionData object
@@ -1584,36 +1624,63 @@ gtk_selection_data_targets_include_text (GtkSelectionData *selection_data)
 {
   GdkAtom *targets;
   gint n_targets;
-  gint i;
   gboolean result = FALSE;
 
-  /* Keep in sync with gtk_target_list_add_text_targets()
-   */
   init_atoms ();
 
   if (gtk_selection_data_get_targets (selection_data, &targets, &n_targets))
     {
-      for (i=0; i < n_targets; i++)
+      result = gtk_targets_include_text (targets, n_targets);
+      g_free (targets);
+    }
+
+  return result;
+}
+
+/**
+ * gtk_targets_include_image:
+ * @targets: an array of #GdkAtom<!-- -->s
+ * @n_targets: the length of @targets
+ * @writable: whether to accept only targets for which GTK+ knows
+ *   how to convert a pixbuf into the format
+ * 
+ * Determines if any of the targets in @targets can be used to
+ * provide a #GdkPixbuf.
+ * 
+ * Return value: %TRUE if @targets include a suitable target for images,
+ *   otherwise %FALSE.
+ *
+ * Since: 2.10
+ **/
+gboolean 
+gtk_targets_include_image (GdkAtom *targets,
+                          gint     n_targets,
+                          gboolean writable)
+{
+  GtkTargetList *list;
+  GList *l;
+  gint i;
+  gboolean result = FALSE;
+
+  list = gtk_target_list_new (NULL, 0);
+  gtk_target_list_add_image_targets (list, 0, writable);
+  for (i = 0; i < n_targets && !result; i++)
+    {
+      for (l = list->list; l; l = l->next)
        {
-         if (targets[i] == utf8_atom ||
-             targets[i] == text_atom ||
-             targets[i] == GDK_TARGET_STRING ||
-             targets[i] == ctext_atom ||
-             targets[i] == text_plain_atom ||
-             targets[i] == text_plain_utf8_atom ||
-             targets[i] == text_plain_locale_atom)
+         GtkTargetPair *pair = (GtkTargetPair *)l->data;
+         if (pair->target == targets[i])
            {
              result = TRUE;
              break;
            }
        }
-
-      g_free (targets);
     }
+  gtk_target_list_unref (list);
 
   return result;
 }
-
+                                   
 /**
  * gtk_selection_data_targets_include_image:
  * @selection_data: a #GtkSelectionData object
@@ -1635,35 +1702,53 @@ gtk_selection_data_targets_include_image (GtkSelectionData *selection_data,
 {
   GdkAtom *targets;
   gint n_targets;
-  gint i;
   gboolean result = FALSE;
-  GtkTargetList *list;
-  GList *l;
 
-  /* Keep in sync with gtk_target_list_add_image_targets()
-   */
   init_atoms ();
 
   if (gtk_selection_data_get_targets (selection_data, &targets, &n_targets))
     {
-      list = gtk_target_list_new (NULL, 0);
-      gtk_target_list_add_image_targets (list, 0, writable);
-      for (i=0; i < n_targets && !result; i++)
-       {
-         for (l = list->list; l && !result; l = l->next)
-           {
-             GtkTargetPair *pair = (GtkTargetPair *)l->data;
-             if (pair->target == targets[i])
-               result = TRUE;
-           }
-       }
-      gtk_target_list_unref (list);
+      result = gtk_targets_include_image (targets, n_targets, writable);
       g_free (targets);
     }
 
   return result;
 }
 
+/**
+ * gtk_targets_include_uri:
+ * @targets: an array of #GdkAtom<!-- -->s
+ * @n_targets: the length of @targets
+ * 
+ * Determines if any of the targets in @targets can be used to
+ * provide an uri list.
+ * 
+ * Return value: %TRUE if @targets include a suitable target for uri lists,
+ *   otherwise %FALSE.
+ *
+ * Since: 2.10
+ **/
+gboolean 
+gtk_targets_include_uri (GdkAtom *targets,
+                        gint     n_targets)
+{
+  gint i;
+  gboolean result = FALSE;
+
+  /* Keep in sync with gtk_target_list_add_uri_targets()
+   */
+  for (i = 0; i < n_targets; i++)
+    {
+      if (targets[i] == text_uri_list_atom)
+       {
+         result = TRUE;
+         break;
+       }
+    }
+  
+  return result;
+}
+
 /**
  * gtk_selection_data_targets_include_uri:
  * @selection_data: a #GtkSelectionData object
@@ -1682,24 +1767,13 @@ gtk_selection_data_targets_include_uri (GtkSelectionData *selection_data)
 {
   GdkAtom *targets;
   gint n_targets;
-  gint i;
   gboolean result = FALSE;
 
-  /* Keep in sync with gtk_target_list_add_uri_targets()
-   */
   init_atoms ();
 
   if (gtk_selection_data_get_targets (selection_data, &targets, &n_targets))
     {
-      for (i=0; i < n_targets; i++)
-       {
-         if (targets[i] == text_uri_list_atom)
-           {
-             result = TRUE;
-             break;
-           }
-       }
-
+      result = gtk_targets_include_uri (targets, n_targets);
       g_free (targets);
     }
 
index a37b3f35affc4338984a126b66db9b68e4e93bb8..038a16a97217a75c5644cc125fbd0e753df1d4fe 100644 (file)
@@ -156,6 +156,13 @@ gboolean gtk_selection_data_targets_include_text (GtkSelectionData  *selection_d
 gboolean gtk_selection_data_targets_include_image (GtkSelectionData  *selection_data,
                                                   gboolean           writable);
 gboolean gtk_selection_data_targets_include_uri  (GtkSelectionData  *selection_data);
+gboolean gtk_targets_include_text                (GdkAtom *targets,
+                                                 gint     n_targets);
+gboolean gtk_targets_include_image               (GdkAtom *targets,
+                                                 gint     n_targets,
+                                                 gboolean writable);
+gboolean gtk_targets_include_uri                 (GdkAtom *targets,
+                                                 gint     n_targets);
 
 /* Called when a widget is destroyed */