From 669b0f193a184b77d4ffcf93d5008e994cb0f7b5 Mon Sep 17 00:00:00 2001 From: Andy Holmes Date: Thu, 21 May 2020 12:24:14 -0700 Subject: [PATCH] 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 1dcd1e75f..52ad4941c 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 60e384601..22ef63f7f 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,