mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-12-28 06:21:14 +00:00
Merge branch 'matthiasc/for-master' into 'master'
widget-factory improvements See merge request GNOME/gtk!1767
This commit is contained in:
commit
0b6cd34b1d
BIN
demos/widget-factory/gtk-logo.webm
Normal file
BIN
demos/widget-factory/gtk-logo.webm
Normal file
Binary file not shown.
@ -323,6 +323,97 @@ activate_inspector (GSimpleAction *action,
|
||||
gtk_window_set_interactive_debugging (TRUE);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
@ -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 },
|
||||
|
@ -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>
|
||||
|
@ -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"><b>Inset</b></property>
|
||||
<property name="label" translatable="yes"><b>Video</b></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"><b>Outset</b></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"><b>Groove</b></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"><b>Ridge</b></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>
|
||||
|
BIN
gdk/default_cursor.png
Normal file
BIN
gdk/default_cursor.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
@ -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.
|
||||
*
|
||||
@ -208,6 +208,20 @@ gdk_vulkan_strerror (VkResult result)
|
||||
#if VK_HEADER_VERSION >= 131
|
||||
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:
|
||||
|
@ -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):
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user