summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2020-04-26 19:20:47 +0000
committerMatthias Clasen <mclasen@redhat.com>2020-04-26 19:20:47 +0000
commit0b6cd34b1dbcb0ba6743655ee31edded9bdbc181 (patch)
tree7403a0742f4d922984577c90a6d432eadc13c9d8
parent764e43b8711876fd78a59f1595c4e28dfa10a65f (diff)
parente1b25eaf5a1fe0a3994f01f221f0ea4b991c8e1c (diff)
downloadgtk+-0b6cd34b1dbcb0ba6743655ee31edded9bdbc181.tar.gz
Merge branch 'matthiasc/for-master' into 'master'
widget-factory improvements See merge request GNOME/gtk!1767
-rw-r--r--demos/widget-factory/gtk-logo.webmbin0 -> 288388 bytes
-rw-r--r--demos/widget-factory/widget-factory.c93
-rw-r--r--demos/widget-factory/widget-factory.gresource.xml3
-rw-r--r--demos/widget-factory/widget-factory.ui64
-rw-r--r--gdk/default_cursor.pngbin0 -> 1252 bytes
-rw-r--r--gdk/gdkvulkancontext.c16
-rw-r--r--gdk/gen-gdk-gresources-xml.py2
-rw-r--r--gdk/wayland/gdkcursor-wayland.c11
-rw-r--r--gtk/inspector/resource-list.c18
-rw-r--r--gtk/inspector/resource-list.ui2
10 files changed, 158 insertions, 51 deletions
diff --git a/demos/widget-factory/gtk-logo.webm b/demos/widget-factory/gtk-logo.webm
new file mode 100644
index 0000000000..7baa0588d6
--- /dev/null
+++ b/demos/widget-factory/gtk-logo.webm
Binary files differ
diff --git a/demos/widget-factory/widget-factory.c b/demos/widget-factory/widget-factory.c
index 4b728c3a6c..374d06ab27 100644
--- a/demos/widget-factory/widget-factory.c
+++ b/demos/widget-factory/widget-factory.c
@@ -324,6 +324,97 @@ activate_inspector (GSimpleAction *action,
}
static void
+print_operation_done (GtkPrintOperation *op,
+ GtkPrintOperationResult res,
+ gpointer data)
+{
+ GError *error = NULL;
+
+ switch (res)
+ {
+ case GTK_PRINT_OPERATION_RESULT_ERROR:
+ gtk_print_operation_get_error (op, &error);
+ g_print ("Printing failed: %s\n", error->message);
+ g_clear_error (&error);
+ break;
+ case GTK_PRINT_OPERATION_RESULT_APPLY:
+ break;
+ case GTK_PRINT_OPERATION_RESULT_CANCEL:
+ g_print ("Printing was canceled\n");
+ break;
+ case GTK_PRINT_OPERATION_RESULT_IN_PROGRESS:
+ return;
+ default:
+ g_assert_not_reached ();
+ break;
+ }
+
+ g_object_unref (op);
+}
+
+static void
+print_operation_begin (GtkPrintOperation *op,
+ GtkPrintContext *context,
+ gpointer data)
+{
+ gtk_print_operation_set_n_pages (op, 1);
+}
+
+static void
+print_operation_page (GtkPrintOperation *op,
+ GtkPrintContext *context,
+ int page,
+ gpointer data)
+{
+ cairo_t *cr;
+ double width;
+ double aspect_ratio;
+ GdkSnapshot *snapshot;
+ GdkPaintable *paintable;
+ GskRenderNode *node;
+
+ g_print ("Save the trees!\n");
+
+ cr = gtk_print_context_get_cairo_context (context);
+ width = gtk_print_context_get_width (context);
+
+ snapshot = gtk_snapshot_new ();
+ paintable = gtk_widget_paintable_new (GTK_WIDGET (data));
+ aspect_ratio = gdk_paintable_get_intrinsic_aspect_ratio (paintable);
+ gdk_paintable_snapshot (paintable, snapshot, width, width / aspect_ratio);
+ node = gtk_snapshot_free_to_node (snapshot);
+
+ gsk_render_node_draw (node, cr);
+
+ gsk_render_node_unref (node);
+
+ g_object_unref (paintable);
+}
+
+static void
+activate_print (GSimpleAction *action,
+ GVariant *parameter,
+ gpointer user_data)
+{
+ GtkWindow *window = GTK_WINDOW (user_data);
+ GtkPrintOperation *op;
+ GtkPrintOperationResult res;
+
+ op = gtk_print_operation_new ();
+ gtk_print_operation_set_allow_async (op, TRUE);
+ g_signal_connect (op, "begin-print", G_CALLBACK (print_operation_begin), NULL);
+ g_signal_connect (op, "draw-page", G_CALLBACK (print_operation_page), window);
+ g_signal_connect (op, "done", G_CALLBACK (print_operation_done), NULL);
+
+ res = gtk_print_operation_run (op, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, window, NULL);
+
+ if (res == GTK_PRINT_OPERATION_RESULT_IN_PROGRESS)
+ return;
+
+ print_operation_done (op, res, NULL);
+}
+
+static void
spin_value_changed (GtkAdjustment *adjustment, GtkWidget *label)
{
GtkWidget *w;
@@ -1714,6 +1805,7 @@ activate (GApplication *app)
{ "open", activate_open, NULL, NULL, NULL },
{ "record", activate_record, NULL, NULL, NULL },
{ "lock", activate_lock, NULL, NULL, NULL },
+ { "print", activate_print, NULL, NULL, NULL },
};
struct {
const gchar *action_and_target;
@@ -2077,7 +2169,6 @@ main (int argc, char *argv[])
{ "water", NULL, NULL, "true", NULL },
{ "dessert", NULL, "s", "'bars'", NULL },
{ "pay", NULL, "s", NULL, NULL },
- { "print", activate_action, NULL, NULL, NULL },
{ "share", activate_action, NULL, NULL, NULL },
{ "labels", activate_action, NULL, NULL, NULL },
{ "new", activate_action, NULL, NULL, NULL },
diff --git a/demos/widget-factory/widget-factory.gresource.xml b/demos/widget-factory/widget-factory.gresource.xml
index 39d665da06..3a5c2e9c29 100644
--- a/demos/widget-factory/widget-factory.gresource.xml
+++ b/demos/widget-factory/widget-factory.gresource.xml
@@ -35,4 +35,7 @@
<file>icons/16x16/emotes/face-monkey-symbolic.symbolic.png</file>
<file>icons/16x16/apps/preferences-desktop-locale-symbolic.symbolic.png</file>
</gresource>
+ <gresource prefix="/org/gtk/WidgetFactory4">
+ <file>gtk-logo.webm</file>
+ </gresource>
</gresources>
diff --git a/demos/widget-factory/widget-factory.ui b/demos/widget-factory/widget-factory.ui
index 9060c816ce..7ed8edf1d8 100644
--- a/demos/widget-factory/widget-factory.ui
+++ b/demos/widget-factory/widget-factory.ui
@@ -1042,57 +1042,28 @@ Suspendisse feugiat quam quis dolor accumsan cursus.</property>
<child>
<object class="GtkBox" id="box26">
<property name="orientation">vertical</property>
- <property name="homogeneous">1</property>
<property name="spacing">6</property>
<property name="hexpand">1</property>
<child>
<object class="GtkFrame" id="frame1">
- <style>
- <class name="border-inset"/>
- </style>
+ <property name="valign">start</property>
<child type="label">
<object class="GtkLabel" id="label1">
- <property name="label" translatable="yes">&lt;b&gt;Inset&lt;/b&gt;</property>
- <property name="use-markup">1</property>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkFrame" id="frame2">
- <style>
- <class name="border-outset"/>
- </style>
- <child type="label">
- <object class="GtkLabel" id="label2">
- <property name="label" translatable="yes">&lt;b&gt;Outset&lt;/b&gt;</property>
- <property name="use-markup">1</property>
- </object>
- </child>
- </object>
- </child>
- <child>
- <object class="GtkFrame" id="frame3">
- <style>
- <class name="border-groove"/>
- </style>
- <child type="label">
- <object class="GtkLabel" id="label17">
- <property name="label" translatable="yes">&lt;b&gt;Groove&lt;/b&gt;</property>
+ <property name="label" translatable="yes">&lt;b&gt;Video&lt;/b&gt;</property>
<property name="use-markup">1</property>
</object>
</child>
- </object>
- </child>
- <child>
- <object class="GtkFrame" id="frame4">
- <style>
- <class name="border-ridge"/>
- </style>
- <child type="label">
- <object class="GtkLabel" id="label18">
- <property name="label" translatable="yes">&lt;b&gt;Ridge&lt;/b&gt;</property>
- <property name="use-markup">1</property>
+ <child>
+ <object class="GtkVideo">
+ <property name="halign">center</property>
+ <property name="valign">center</property>
+ <property name="margin-start">6</property>
+ <property name="margin-end">6</property>
+ <property name="margin-top">6</property>
+ <property name="margin-bottom">6</property>
+ <property name="autoplay">0</property>
+ <property name="loop">1</property>
+ <property name="file">resource:///org/gtk/WidgetFactory4/gtk-logo.webm</property>
</object>
</child>
</object>
@@ -2482,6 +2453,7 @@ microphone-sensitivity-medium-symbolic</property>
<child>
<object class="GtkButton" id="print_button">
<property name="label">Print</property>
+ <property name="action-name">win.print</property>
</object>
</child>
</object>
@@ -2754,15 +2726,17 @@ microphone-sensitivity-medium-symbolic</property>
<property name="spacing">10</property>
<child>
<object class="GtkBox">
- <property name="halign">center</property>
+ <property name="halign">fill</property>
<child>
<object class="GtkEntry">
+ <property name="hexpand">1</property>
<property name="placeholder-text" translatable="yes">Name…</property>
<property name="completion">name_completion</property>
</object>
</child>
<child>
<object class="GtkEntry">
+ <property name="hexpand">1</property>
<property name="show-emoji-icon">1</property>
<property name="placeholder-text" translatable="yes">Age…</property>
</object>
@@ -3307,7 +3281,7 @@ bad things might happen.</property>
</object>
</property>
<property name="iconic">1</property>
- <property name="action-name">app.print</property>
+ <property name="action-name">win.print</property>
<property name="hexpand">1</property>
<property name="halign">center</property>
<style>
@@ -3530,7 +3504,7 @@ bad things might happen.</property>
<attribute name="display-hint">circular-buttons</attribute>
<item>
<attribute name="verb-icon">printer-symbolic</attribute>
- <attribute name="action">app.print</attribute>
+ <attribute name="action">win.print</attribute>
</item>
<item>
<attribute name="verb-icon">emblem-shared-symbolic</attribute>
diff --git a/gdk/default_cursor.png b/gdk/default_cursor.png
new file mode 100644
index 0000000000..aa39aa4a6f
--- /dev/null
+++ b/gdk/default_cursor.png
Binary files differ
diff --git a/gdk/gdkvulkancontext.c b/gdk/gdkvulkancontext.c
index 76f120b76a..7112e6724d 100644
--- a/gdk/gdkvulkancontext.c
+++ b/gdk/gdkvulkancontext.c
@@ -97,7 +97,7 @@ gdk_vulkan_strerror (VkResult result)
{
/* If your compiler brought you here with a warning about missing
* enumeration values, you're running a newer Vulkan version than
- * the GTK developers )or you are a GTK developer) and have
+ * the GTK developers (or you are a GTK developer) and have
* encountered a newly added Vulkan error message.
* You want to add it to this enum now.
*
@@ -209,6 +209,20 @@ gdk_vulkan_strerror (VkResult result)
case VK_ERROR_UNKNOWN:
return "An unknown error has occurred; either the application has provided invalid input, or an implementation failure has occurred.";
#endif
+#if VK_HEADER_VERSION >= 135
+ case VK_ERROR_INCOMPATIBLE_VERSION_KHR:
+ return "Acceleration structure serialized with version as the version information is not compatible with device.";
+ case VK_THREAD_IDLE_KHR:
+ return "A deferred operation is not complete but there is currently no work for this thread to do at the time of this call.";
+ case VK_THREAD_DONE_KHR:
+ return "A deferred operation is not complete but there is no work remaining to assign to additional threads.";
+ case VK_OPERATION_DEFERRED_KHR:
+ return "A deferred operation was requested and at least some of the work was deferred.";
+ case VK_OPERATION_NOT_DEFERRED_KHR:
+ return "A deferred operation was requested and no operations were deferred.";
+ case VK_ERROR_PIPELINE_COMPILE_REQUIRED_EXT:
+ return "A requested pipeline creation would have required compilation, but the application requested compilation to not be performed.";
+#endif
case VK_RESULT_RANGE_SIZE:
case VK_RESULT_MAX_ENUM:
default:
diff --git a/gdk/gen-gdk-gresources-xml.py b/gdk/gen-gdk-gresources-xml.py
index 11c63552a9..bc0e541919 100644
--- a/gdk/gen-gdk-gresources-xml.py
+++ b/gdk/gen-gdk-gresources-xml.py
@@ -25,7 +25,7 @@ srcdir = sys.argv[1]
xml = '''<?xml version='1.0' encoding='UTF-8'?>
<gresources>
<gresource prefix='/org/gtk/libgdk'>
-
+ <file alias='cursor/default'>default_cursor.png</file>
'''
def get_files(subdir,extension):
diff --git a/gdk/wayland/gdkcursor-wayland.c b/gdk/wayland/gdkcursor-wayland.c
index f880b9da2d..66a461dd6c 100644
--- a/gdk/wayland/gdkcursor-wayland.c
+++ b/gdk/wayland/gdkcursor-wayland.c
@@ -162,6 +162,8 @@ _gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
int *height,
int *scale)
{
+ GdkTexture *texture;
+
if (gdk_cursor_get_name (cursor))
{
struct wl_cursor *c;
@@ -199,10 +201,12 @@ _gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
}
else
{
- GdkTexture *texture = gdk_cursor_get_texture (cursor);
cairo_surface_t *surface;
struct wl_buffer *buffer;
+ texture = gdk_cursor_get_texture (cursor);
+
+from_texture:
surface = g_hash_table_lookup (display->cursor_surface_cache, cursor);
if (surface == NULL)
{
@@ -241,6 +245,11 @@ _gdk_wayland_cursor_get_buffer (GdkWaylandDisplay *display,
hotspot_x, hotspot_y,
width, height,
scale);
+ else
+ {
+ texture = gdk_texture_new_from_resource ("/org/gtk/libgdk/cursor/default");
+ goto from_texture;
+ }
none:
*hotspot_x = 0;
diff --git a/gtk/inspector/resource-list.c b/gtk/inspector/resource-list.c
index dfc0817abd..ebb9008a28 100644
--- a/gtk/inspector/resource-list.c
+++ b/gtk/inspector/resource-list.c
@@ -30,6 +30,8 @@
#include "gtktreeselection.h"
#include "gtktreestore.h"
#include "gtkeventcontrollerkey.h"
+#include "gtkpicture.h"
+#include "gtkmediafile.h"
#include <glib/gi18n-lib.h>
@@ -51,6 +53,7 @@ struct _GtkInspectorResourceListPrivate
{
GtkTreeStore *model;
GtkTextBuffer *buffer;
+ GtkWidget *video;
GtkWidget *image;
GtkWidget *content;
GtkWidget *name_label;
@@ -193,9 +196,11 @@ populate_details (GtkInspectorResourceList *rl,
gchar *text;
gchar *content_image;
gchar *content_text;
+ gchar *content_video;
content_image = g_content_type_from_mime_type ("image/*");
content_text = g_content_type_from_mime_type ("text/*");
+ content_video = g_content_type_from_mime_type ("video/*");
data = g_bytes_get_data (bytes, &size);
type = g_content_type_guess (name, data, size, NULL);
@@ -215,9 +220,20 @@ populate_details (GtkInspectorResourceList *rl,
}
else if (g_content_type_is_a (type, content_image))
{
- gtk_image_set_from_resource (GTK_IMAGE (rl->priv->image), path);
+ gtk_picture_set_resource (GTK_PICTURE (rl->priv->image), path);
gtk_stack_set_visible_child_name (GTK_STACK (rl->priv->content), "image");
}
+ else if (g_content_type_is_a (type, content_video))
+ {
+ GtkMediaStream *stream;
+
+ stream = gtk_media_file_new_for_resource (path);
+ gtk_media_stream_set_loop (GTK_MEDIA_STREAM (stream), TRUE);
+ gtk_picture_set_paintable (GTK_PICTURE (rl->priv->image), GDK_PAINTABLE (stream));
+ gtk_stack_set_visible_child_name (GTK_STACK (rl->priv->content), "image");
+ gtk_media_stream_play (GTK_MEDIA_STREAM (stream));
+ g_object_unref (stream);
+ }
else
{
gtk_text_buffer_set_text (rl->priv->buffer, "", 0);
diff --git a/gtk/inspector/resource-list.ui b/gtk/inspector/resource-list.ui
index 3dd57024da..114e704182 100644
--- a/gtk/inspector/resource-list.ui
+++ b/gtk/inspector/resource-list.ui
@@ -230,7 +230,7 @@
<class name="view"/>
</style>
<child>
- <object class="GtkImage" id="image">
+ <object class="GtkPicture" id="image">
<property name="halign">center</property>
<property name="valign">center</property>
</object>