[gnome-shell/wip/carlosg/screenshots-to-clipboard: 1/3] st: Add StClipboard method to set arbitrary clipboard content
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/carlosg/screenshots-to-clipboard: 1/3] st: Add StClipboard method to set arbitrary clipboard content
- Date: Wed, 6 Nov 2019 12:46:17 +0000 (UTC)
commit 40f87b8e89f07944f81eda51f1b46926bb8065b2
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Nov 6 00:40:17 2019 +0100
st: Add StClipboard method to set arbitrary clipboard content
This complements the current text-based API.
https://gitlab.gnome.org/GNOME/mutter/issues/789
src/st/st-clipboard.c | 39 +++++++++++++++++++++++++++++++--------
src/st/st-clipboard.h | 5 +++++
2 files changed, 36 insertions(+), 8 deletions(-)
---
diff --git a/src/st/st-clipboard.c b/src/st/st-clipboard.c
index b2d8e7f940..1dcd1e75f3 100644
--- a/src/st/st-clipboard.c
+++ b/src/st/st-clipboard.c
@@ -194,6 +194,36 @@ st_clipboard_get_text (StClipboard *clipboard,
data);
}
+/**
+ * st_clipboard_set_content:
+ * @clipboard: A #StClipboard
+ * @type: The type of clipboard that you want to set
+ * @mimetype: content mimetype
+ * @bytes: content data
+ *
+ * Sets the clipboard content.
+ **/
+void
+st_clipboard_set_content (StClipboard *clipboard,
+ StClipboardType type,
+ const gchar *mimetype,
+ GBytes *bytes)
+{
+ MetaSelectionType selection_type;
+ MetaSelectionSource *source;
+
+ g_return_if_fail (ST_IS_CLIPBOARD (clipboard));
+ g_return_if_fail (meta_selection != NULL);
+ g_return_if_fail (bytes != NULL);
+
+ if (!convert_type (type, &selection_type))
+ return;
+
+ source = meta_selection_source_memory_new (mimetype, bytes);
+ meta_selection_set_owner (meta_selection, selection_type, source);
+ g_object_unref (source);
+}
+
/**
* st_clipboard_set_text:
* @clipboard: A #StClipboard
@@ -207,22 +237,15 @@ st_clipboard_set_text (StClipboard *clipboard,
StClipboardType type,
const gchar *text)
{
- MetaSelectionType selection_type;
- MetaSelectionSource *source;
GBytes *bytes;
g_return_if_fail (ST_IS_CLIPBOARD (clipboard));
g_return_if_fail (meta_selection != NULL);
g_return_if_fail (text != NULL);
- if (!convert_type (type, &selection_type))
- return;
-
bytes = g_bytes_new_take (g_strdup (text), strlen (text));
- source = meta_selection_source_memory_new ("text/plain;charset=utf-8", bytes);
+ st_clipboard_set_content (clipboard, type, "text/plain;charset=utf-8", bytes);
g_bytes_unref (bytes);
-
- meta_selection_set_owner (meta_selection, selection_type, source);
}
void
diff --git a/src/st/st-clipboard.h b/src/st/st-clipboard.h
index 86e67e1eeb..60e3846010 100644
--- a/src/st/st-clipboard.h
+++ b/src/st/st-clipboard.h
@@ -73,6 +73,11 @@ void st_clipboard_set_text (StClipboard *clipboard,
StClipboardType type,
const gchar *text);
+void st_clipboard_set_content (StClipboard *clipboard,
+ StClipboardType type,
+ const gchar *mimetype,
+ GBytes *bytes);
+
void st_clipboard_set_selection (MetaSelection *selection);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]