[gtk/wip/otte/widgetfactory-dnd] xxx content format parsing



commit 4c0c1a35dc36c3bfd64987a9a6dc152bbb22916f
Author: Benjamin Otte <otte redhat com>
Date:   Tue Jul 27 03:23:01 2021 +0200

    xxx content format parsing

 gdk/gdkcontentformats.c | 42 +++++++++++++++++++++++++-----------------
 1 file changed, 25 insertions(+), 17 deletions(-)
---
diff --git a/gdk/gdkcontentformats.c b/gdk/gdkcontentformats.c
index fdab3f80ec..2a35d4f8dc 100644
--- a/gdk/gdkcontentformats.c
+++ b/gdk/gdkcontentformats.c
@@ -208,7 +208,23 @@ gdk_content_formats_parse (const char *string)
   split = g_strsplit_set (string, "\t\n\f\r ", -1); /* same as g_ascii_isspace() */
   builder = gdk_content_formats_builder_new ();
 
+  /* first the GTypes */
   for (i = 0; split[i] != NULL; i++)
+    {
+      GType type;
+
+      if (split[i][0] == 0)
+        continue;
+
+      type = g_type_from_name (split[i]);
+      if (type != 0)
+        gdk_content_formats_builder_add_gtype (builder, type);
+      else
+        break;
+    }
+
+  /* then the mime types */
+  for (; split[i] != NULL; i++)
     {
       const char *mime_type;
 
@@ -217,27 +233,19 @@ gdk_content_formats_parse (const char *string)
 
       mime_type = gdk_intern_mime_type (split[i]);
       if (mime_type)
-        {
-          gdk_content_formats_builder_add_mime_type (builder, mime_type);
-        }
+        gdk_content_formats_builder_add_mime_type (builder, mime_type);
       else
-        {
-          GType type = g_type_from_name (split[i]);
-          if (type != 0)
-            {
-              gdk_content_formats_builder_add_gtype (builder, type);
-            }
-          else
-            {
-              g_strfreev (split);
-              gdk_content_formats_builder_unref (builder);
-              return NULL;
-            }
-        }
+        break;
     }
 
-  g_strfreev (split);
+  if (split[i] != NULL)
+    {
+      g_strfreev (split);
+      gdk_content_formats_builder_unref (builder);
+      return NULL;
+    }
 
+  g_strfreev (split);
   return gdk_content_formats_builder_free_to_formats (builder);
 }
 


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