diff options
author | Matthias Clasen <mclasen@redhat.com> | 2021-04-02 21:24:59 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2021-04-02 21:24:59 -0400 |
commit | 1e1f199b56e1d8b37cdde21c6fbcb4e902968d80 (patch) | |
tree | 103f66b3e7bc27722d96418d23ddfda423c106a3 /demos | |
parent | efb5e793a40798aa0ed0631fdb8af59c3b192973 (diff) | |
download | gtk+-1e1f199b56e1d8b37cdde21c6fbcb4e902968d80.tar.gz |
node-editor: Support pasting the image
Add a button that copies the image to the clipboard.
Diffstat (limited to 'demos')
-rw-r--r-- | demos/node-editor/node-editor-window.c | 19 | ||||
-rw-r--r-- | demos/node-editor/node-editor-window.ui | 6 |
2 files changed, 23 insertions, 2 deletions
diff --git a/demos/node-editor/node-editor-window.c b/demos/node-editor/node-editor-window.c index 03da8c67bd..ce4198d683 100644 --- a/demos/node-editor/node-editor-window.c +++ b/demos/node-editor/node-editor-window.c @@ -636,6 +636,24 @@ export_image_cb (GtkWidget *button, } static void +clip_image_cb (GtkWidget *button, + NodeEditorWindow *self) +{ + GdkTexture *texture; + GdkClipboard *clipboard; + + texture = create_texture (self); + if (texture == NULL) + return; + + clipboard = gtk_widget_get_clipboard (GTK_WIDGET (self)); + + gdk_clipboard_set_texture (clipboard, texture); + + g_object_unref (texture); +} + +static void testcase_name_entry_changed_cb (GtkWidget *button, GParamSpec *pspec, NodeEditorWindow *self) @@ -826,6 +844,7 @@ node_editor_window_class_init (NodeEditorWindowClass *class) gtk_widget_class_bind_template_callback (widget_class, open_cb); gtk_widget_class_bind_template_callback (widget_class, save_cb); gtk_widget_class_bind_template_callback (widget_class, export_image_cb); + gtk_widget_class_bind_template_callback (widget_class, clip_image_cb); gtk_widget_class_bind_template_callback (widget_class, testcase_save_clicked_cb); gtk_widget_class_bind_template_callback (widget_class, testcase_name_entry_changed_cb); gtk_widget_class_bind_template_callback (widget_class, dark_mode_cb); diff --git a/demos/node-editor/node-editor-window.ui b/demos/node-editor/node-editor-window.ui index 73b8b9ce4b..fc26719819 100644 --- a/demos/node-editor/node-editor-window.ui +++ b/demos/node-editor/node-editor-window.ui @@ -122,8 +122,10 @@ </object> </child> <child type="start"> - <object class="GtkSeparator"> - <property name="orientation">vertical</property> + <object class="GtkButton"> + <property name="icon-name">edit-copy-symbolic</property> + <property name="tooltip-text">Copy image to clipboard</property> + <signal name="clicked" handler="clip_image_cb"/> </object> </child> <child type="start"> |