summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--demos/widget-factory/widget-factory.c33
-rw-r--r--demos/widget-factory/widget-factory.ui54
2 files changed, 79 insertions, 8 deletions
diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c
index 8d62b89b0a..0c4b21c81c 100644
--- a/demos/widget-factory/widget-factory.c
+++ b/demos/widget-factory/widget-factory.c
@@ -696,6 +696,37 @@ on_range_to_changed (GtkSpinButton *to)
gtk_spin_button_set_value (from, v2);
}
+static GdkContentProvider *
+on_picture_drag_prepare (GtkDragSource *source,
+ double x,
+ double y,
+ gpointer unused)
+{
+ GtkWidget *picture;
+
+ picture = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (source));
+
+ return gdk_content_provider_new_typed (GDK_TYPE_TEXTURE, gtk_picture_get_paintable (GTK_PICTURE (picture)));
+}
+
+static gboolean
+on_picture_drop (GtkDropTarget *dest,
+ const GValue *value,
+ double x,
+ double y,
+ gpointer unused)
+{
+ GtkWidget *picture;
+ GdkPaintable *paintable;
+
+ picture = gtk_event_controller_get_widget (GTK_EVENT_CONTROLLER (dest));
+ paintable = g_value_get_object (value);
+
+ gtk_picture_set_paintable (GTK_PICTURE (picture), paintable);
+
+ return TRUE;
+}
+
static void
info_bar_response (GtkWidget *infobar, int response_id)
{
@@ -2040,6 +2071,8 @@ activate (GApplication *app)
"on_page_combo_changed", (GCallback)on_page_combo_changed,
"on_range_from_changed", (GCallback)on_range_from_changed,
"on_range_to_changed", (GCallback)on_range_to_changed,
+ "on_picture_drag_prepare", (GCallback)on_picture_drag_prepare,
+ "on_picture_drop", (GCallback)on_picture_drop,
"tab_close_cb", (GCallback)tab_close_cb,
"increase_icon_size", (GCallback)increase_icon_size,
"decrease_icon_size", (GCallback)decrease_icon_size,
diff --git a/demos/widget-factory/widget-factory.ui b/demos/widget-factory/widget-factory.ui
index c37ade2945..94126edb36 100644
--- a/demos/widget-factory/widget-factory.ui
+++ b/demos/widget-factory/widget-factory.ui
@@ -1251,8 +1251,21 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<child>
<object class="GtkNotebookPage">
<property name="child">
- <object class="GtkBox" id="box6">
- <property name="orientation">vertical</property>
+ <object class="GtkPicture">
+ <property name="file">resource:///org/gtk/WidgetFactory4/sunset.jpg</property>
+ <child>
+ <object class="GtkDragSource">
+ <property name="actions">copy</property>
+ <signal name="prepare" handler="on_picture_drag_prepare" swapped="no"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkDropTarget">
+ <property name="actions">copy</property>
+ <property name="formats">GdkTexture</property>
+ <signal name="drop" handler="on_picture_drop" swapped="no"/>
+ </object>
+ </child>
</object>
</property>
<property name="tab">
@@ -1265,8 +1278,21 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<child>
<object class="GtkNotebookPage">
<property name="child">
- <object class="GtkBox" id="box7">
- <property name="orientation">vertical</property>
+ <object class="GtkPicture">
+ <property name="file">resource:///org/gtk/WidgetFactory4/nyc.jpg</property>
+ <child>
+ <object class="GtkDragSource">
+ <property name="actions">copy</property>
+ <signal name="prepare" handler="on_picture_drag_prepare" swapped="no"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkDropTarget">
+ <property name="actions">copy</property>
+ <property name="formats">GdkTexture</property>
+ <signal name="drop" handler="on_picture_drop" swapped="no"/>
+ </object>
+ </child>
</object>
</property>
<property name="tab">
@@ -1278,10 +1304,22 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
</child>
<child>
<object class="GtkNotebookPage">
- <property name="position">2</property>
<property name="child">
- <object class="GtkBox" id="box8">
- <property name="orientation">vertical</property>
+ <object class="GtkPicture">
+ <property name="file">resource:///org/gtk/WidgetFactory4/beach.jpg</property>
+ <child>
+ <object class="GtkDragSource">
+ <property name="actions">copy</property>
+ <signal name="prepare" handler="on_picture_drag_prepare" swapped="no"/>
+ </object>
+ </child>
+ <child>
+ <object class="GtkDropTarget">
+ <property name="actions">copy</property>
+ <property name="formats">GdkTexture</property>
+ <signal name="drop" handler="on_picture_drop" swapped="no"/>
+ </object>
+ </child>
</object>
</property>
<property name="tab">
@@ -1299,7 +1337,7 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<child>
<object class="GtkNotebookPage">
<property name="child">
- <object class="GtkBox" id="box9">
+ <object class="GtkBox" id="box8">
<property name="orientation">vertical</property>
</object>
</property>