summaryrefslogtreecommitdiff
path: root/gdk/gdkcontentformats.c
diff options
context:
space:
mode:
authorBenjamin Otte <otte@redhat.com>2017-11-25 21:59:39 +0100
committerBenjamin Otte <otte@redhat.com>2017-12-03 05:46:47 +0100
commit134076e7387abafa1599853edad38ddd703075d3 (patch)
treea6ca759f8410a62aa9cd5857a9e307b8021c29e4 /gdk/gdkcontentformats.c
parente2014850b9ef032d922648cdc7ee644a3f9b8429 (diff)
downloadgtk+-134076e7387abafa1599853edad38ddd703075d3.tar.gz
x11: Implement claiming the X Selection with the clipboard
... and of course support writing to other apps.
Diffstat (limited to 'gdk/gdkcontentformats.c')
-rw-r--r--gdk/gdkcontentformats.c33
1 files changed, 32 insertions, 1 deletions
diff --git a/gdk/gdkcontentformats.c b/gdk/gdkcontentformats.c
index 7b4a101e13..8369cdd6ee 100644
--- a/gdk/gdkcontentformats.c
+++ b/gdk/gdkcontentformats.c
@@ -63,7 +63,7 @@
#include "gdkcontentformats.h"
#include "gdkcontentformatsprivate.h"
-#include "gdkproperty.h"
+#include <string.h>
struct _GdkContentFormats
{
@@ -81,6 +81,37 @@ G_DEFINE_BOXED_TYPE (GdkContentFormats, gdk_content_formats,
gdk_content_formats_unref)
+/**
+ * gdk_intern_mime_type:
+ * @string: (transfer none): string of a potential mime type
+ *
+ * Canonicalizes the given mime type and interns the result.
+ *
+ * If @string is not a valid mime type, %NULL is returned instead.
+ * See RFC 2048 for the syntax if mime types.
+ *
+ * Returns: An interned string for the canonicalized mime type
+ * or %NULL if the string wasn't a valid mime type
+ **/
+const char *
+gdk_intern_mime_type (const char *string)
+{
+ char *tmp;
+
+ g_return_val_if_fail (string != NULL, NULL);
+
+ if (!strchr (string, '/'))
+ return NULL;
+
+ tmp = g_ascii_strdown (string, -1);
+
+ string = g_intern_string (tmp);
+
+ g_free (tmp);
+
+ return string;
+}
+
static GdkContentFormats *
gdk_content_formats_new_take (GType * gtypes,
gsize n_gtypes,