[gnome-shell] StClipboard: add st_clipboard_get_mimetypes



commit 669b0f193a184b77d4ffcf93d5008e994cb0f7b5
Author: Andy Holmes <andrew g r holmes gmail com>
Date:   Thu May 21 12:24:14 2020 -0700

    StClipboard: add st_clipboard_get_mimetypes
    
    Since the `MetaSelection` of the global `StClipboard` is private (and
    should be), there is no reasonable way for extensions or external code
    to query the supported mime-types.
    
    Add `st_clipboard_get_mimetypes()` so this can be queried without
    poking around in private code.
    
    closes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2819

 src/st/st-clipboard.c | 23 +++++++++++++++++++++++
 src/st/st-clipboard.h |  3 +++
 2 files changed, 26 insertions(+)
---
diff --git a/src/st/st-clipboard.c b/src/st/st-clipboard.c
index 1dcd1e75f3..52ad4941cb 100644
--- a/src/st/st-clipboard.c
+++ b/src/st/st-clipboard.c
@@ -146,6 +146,29 @@ transfer_cb (MetaSelection *selection,
   g_free (text);
 }
 
+/**
+ * st_clipboard_get_mimetypes:
+ * @clipboard: a #StClipboard
+ *
+ * Gets a list of the mimetypes supported by the default #StClipboard.
+ *
+ * Returns: (element-type utf8) (transfer full): the supported mimetypes
+ */
+GList *
+st_clipboard_get_mimetypes (StClipboard     *clipboard,
+                            StClipboardType  type)
+{
+  MetaSelectionType selection_type;
+
+  g_return_val_if_fail (ST_IS_CLIPBOARD (clipboard), NULL);
+  g_return_val_if_fail (meta_selection != NULL, NULL);
+
+  if (!convert_type (type, &selection_type))
+    return NULL;
+
+  return meta_selection_get_mimetypes (meta_selection, selection_type);
+}
+
 /**
  * st_clipboard_get_text:
  * @clipboard: A #StCliboard
diff --git a/src/st/st-clipboard.h b/src/st/st-clipboard.h
index 60e3846010..22ef63f7fd 100644
--- a/src/st/st-clipboard.h
+++ b/src/st/st-clipboard.h
@@ -65,6 +65,9 @@ typedef void (*StClipboardCallbackFunc) (StClipboard *clipboard,
 
 StClipboard* st_clipboard_get_default (void);
 
+GList * st_clipboard_get_mimetypes (StClipboard             *clipboard,
+                                    StClipboardType          type);
+
 void st_clipboard_get_text (StClipboard             *clipboard,
                             StClipboardType          type,
                             StClipboardCallbackFunc  callback,


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