[gtk/clipboard-demo-improvements] gtk-demo: Small followup fixes
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/clipboard-demo-improvements] gtk-demo: Small followup fixes
- Date: Sun, 12 Dec 2021 18:42:44 +0000 (UTC)
commit f8855e892a0ea4964ac08163879f68731bcac623
Author: Matthias Clasen <mclasen redhat com>
Date: Sun Dec 12 13:41:24 2021 -0500
gtk-demo: Small followup fixes
Make image copy work remotely.
demos/gtk-demo/clipboard.c | 21 +++++++++++++++------
demos/gtk-demo/clipboard.ui | 5 +++++
2 files changed, 20 insertions(+), 6 deletions(-)
---
diff --git a/demos/gtk-demo/clipboard.c b/demos/gtk-demo/clipboard.c
index f7348bcdc1..4b3dbcb9c2 100644
--- a/demos/gtk-demo/clipboard.c
+++ b/demos/gtk-demo/clipboard.c
@@ -35,7 +35,12 @@ copy_button_clicked (GtkStack *source_stack,
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (child)))
{
GtkWidget *image = gtk_widget_get_first_child (child);
- gdk_clipboard_set (clipboard, GDK_TYPE_PAINTABLE, gtk_image_get_paintable (GTK_IMAGE (image)));
+ GdkPaintable *paintable = gtk_image_get_paintable (GTK_IMAGE (image));
+
+ if (GDK_IS_TEXTURE (paintable))
+ gdk_clipboard_set (clipboard, GDK_TYPE_TEXTURE, paintable);
+ else
+ gdk_clipboard_set (clipboard, GDK_TYPE_PAINTABLE, paintable);
break;
}
}
@@ -93,7 +98,8 @@ paste_received (GObject *source_object,
color = g_value_get_boxed (value);
g_object_set (child, "rgba", color, NULL);
}
- else if (G_VALUE_HOLDS (value, GDK_TYPE_PAINTABLE))
+ else if (G_VALUE_HOLDS (value, GDK_TYPE_TEXTURE) ||
+ G_VALUE_HOLDS (value, GDK_TYPE_PAINTABLE))
{
GdkPaintable *paintable;
@@ -128,12 +134,14 @@ paste_button_clicked (GtkStack *dest_stack,
clipboard = gtk_widget_get_clipboard (GTK_WIDGET (dest_stack));
formats = gdk_clipboard_get_formats (clipboard);
- if (gdk_content_formats_contain_gtype (formats, G_TYPE_FILE))
- gdk_clipboard_read_value_async (clipboard, G_TYPE_FILE, 0, NULL, paste_received, dest_stack);
- else if (gdk_content_formats_contain_gtype (formats, GDK_TYPE_RGBA))
- gdk_clipboard_read_value_async (clipboard, GDK_TYPE_RGBA, 0, NULL, paste_received, dest_stack);
+ if (gdk_content_formats_contain_gtype (formats, GDK_TYPE_TEXTURE))
+ gdk_clipboard_read_value_async (clipboard, GDK_TYPE_TEXTURE, 0, NULL, paste_received, dest_stack);
else if (gdk_content_formats_contain_gtype (formats, GDK_TYPE_PAINTABLE))
gdk_clipboard_read_value_async (clipboard, GDK_TYPE_PAINTABLE, 0, NULL, paste_received, dest_stack);
+ else if (gdk_content_formats_contain_gtype (formats, GDK_TYPE_RGBA))
+ gdk_clipboard_read_value_async (clipboard, GDK_TYPE_RGBA, 0, NULL, paste_received, dest_stack);
+ else if (gdk_content_formats_contain_gtype (formats, G_TYPE_FILE))
+ gdk_clipboard_read_value_async (clipboard, G_TYPE_FILE, 0, NULL, paste_received, dest_stack);
else if (gdk_content_formats_contain_gtype (formats, G_TYPE_STRING))
gdk_clipboard_read_value_async (clipboard, G_TYPE_STRING, 0, NULL, paste_received, dest_stack);
}
@@ -240,6 +248,7 @@ update_paste_button_sensitivity (GdkClipboard *clipboard,
if (gdk_content_formats_contain_gtype (formats, G_TYPE_FILE) ||
gdk_content_formats_contain_gtype (formats, GDK_TYPE_RGBA) ||
+ gdk_content_formats_contain_gtype (formats, GDK_TYPE_TEXTURE) ||
gdk_content_formats_contain_gtype (formats, GDK_TYPE_PAINTABLE) ||
gdk_content_formats_contain_gtype (formats, G_TYPE_STRING))
sensitive = TRUE;
diff --git a/demos/gtk-demo/clipboard.ui b/demos/gtk-demo/clipboard.ui
index 08fa51e9f8..1930fb4fda 100644
--- a/demos/gtk-demo/clipboard.ui
+++ b/demos/gtk-demo/clipboard.ui
@@ -180,6 +180,7 @@
<child>
<object class="GtkStack" id="dest_stack">
<property name="halign">end</property>
+ <property name="valign">center</property>
<child>
<object class="GtkStackPage">
<property name="name"></property>
@@ -195,6 +196,7 @@
<property name="child">
<object class="GtkLabel">
<property name="halign">end</property>
+ <property name="valign">center</property>
<property name="xalign">0</property>
<property name="ellipsize">end</property>
</object>
@@ -207,6 +209,7 @@
<property name="child">
<object class="GtkImage">
<property name="halign">end</property>
+ <property name="valign">center</property>
<style>
<class name="large-icons"/>
</style>
@@ -220,6 +223,7 @@
<property name="child">
<object class="GtkBox">
<property name="halign">end</property>
+ <property name="valign">center</property>
<child>
<object class="GtkColorSwatch">
<property name="accessible-role">img</property>
@@ -238,6 +242,7 @@
<property name="child">
<object class="GtkLabel">
<property name="halign">end</property>
+ <property name="valign">center</property>
<property name="xalign">0</property>
<property name="hexpand">1</property>
<property name="ellipsize">start</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]