Compare commits
82 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f8efc6f1fa | |||
| e79851502c | |||
| 0132ab046b | |||
| c2ba1d69a1 | |||
| 847739aed7 | |||
| 4d66598f31 | |||
| 2ec1bd7248 | |||
| 646d1a8923 | |||
| 4a8a6e9f70 | |||
| 0a9d25c9e8 | |||
| 188677724c | |||
| 22cd3ea268 | |||
| 71a231b71d | |||
| 112fe06323 | |||
| 8bcb918de5 | |||
| 6f6293c38c | |||
| 1b885cc317 | |||
| 9dd83ab354 | |||
| 0bbc6f8932 | |||
| 1ad4c04b2a | |||
| 0bbe68db0b | |||
| b2a3a5e226 | |||
| 0434ad3bd9 | |||
| 9d3046f187 | |||
| 6b2c088a29 | |||
| 4efc736a6e | |||
| 2b0e3a5b1a | |||
| bac41ce644 | |||
| 2b0ad09423 | |||
| f5955feea1 | |||
| 853e8719c6 | |||
| 8d528350b9 | |||
| d51c92f54d | |||
| b9bd7124c0 | |||
| 14f67550d0 | |||
| ee6ef41e71 | |||
| fde3d2cd50 | |||
| 099955b0c0 | |||
| b530ade8c6 | |||
| 3a9234dadc | |||
| 3e27232028 | |||
| c2676ad785 | |||
| 4a1598dc2a | |||
| 5f70b00bea | |||
| 3377460fb8 | |||
| 05a0aca5ab | |||
| 9463e0f56c | |||
| 1c308431a6 | |||
| fb996f6e6d | |||
| edfd37dfe2 | |||
| 4bede73f62 | |||
| 0b59290bad | |||
| e8c7d0e5ec | |||
| 3fb06ca29d | |||
| 013401b594 | |||
| 484c4bdf22 | |||
| 133231e12b | |||
| ef2024736d | |||
| ed265f6a7e | |||
| 0152286fa0 | |||
| 4ef560d3b8 | |||
| 343472931d | |||
| 41b606b16d | |||
| f83c00c928 | |||
| f497cb2b6e | |||
| 2f8c0b7aec | |||
| d517b25ea3 | |||
| 37345670c8 | |||
| 89d993b6ec | |||
| 250a5c0dfd | |||
| af3ceb5755 | |||
| 982a696311 | |||
| e5f1e4545d | |||
| bf87a40b20 | |||
| 18b8baaf25 | |||
| 4c69192837 | |||
| c01be6cac7 | |||
| 8b4e7a638c | |||
| 59acec21d4 | |||
| 38f610f85e | |||
| 5393173afa | |||
| 9b1026886b |
@@ -1 +1,2 @@
|
||||
/subprojects/*/
|
||||
.flatpak-builder/
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ stages:
|
||||
variables:
|
||||
COMMON_MESON_FLAGS: "-Dwerror=true -Dcairo:werror=false -Dgi-docgen:werror=false -Dgraphene:werror=false -Dlibepoxy:werror=false -Dlibsass:werror=false -Dpango:werror=false -Dsassc:werror=false -Dgdk-pixbuf:werror=false -Dglib:werror=false -Dlibcloudproviders:werror=false -Dlibpng:werror=false -Dlibtiff:werror=false -Dsysprof:werror=false -Dwayland-protocols:werror=false -Dharfbuzz:werror=false -Dfreetype2:werror=false -Dfontconfig:werror=false -Dfribidi:werror=false -Dlibffi:werror=false -Dlibjpeg-turbo:werror=false -Dmutest:werror=false -Dpixman:werror=false -Dproxy-libintl:werror=false"
|
||||
BACKEND_FLAGS: "-Dx11-backend=true -Dwayland-backend=true -Dbroadway-backend=true"
|
||||
FEATURE_FLAGS: "-Dvulkan=enabled -Dcloudproviders=enabled -Dbuild-demos=false -Dbuild-examples=false -Dbuild-tests=false -Dbuild-testsuite=true"
|
||||
FEATURE_FLAGS: "-Dvulkan=enabled -Dcloudproviders=enabled -Dbuild-testsuite=true"
|
||||
MESON_TEST_TIMEOUT_MULTIPLIER: 3
|
||||
FEDORA_IMAGE: "registry.gitlab.gnome.org/gnome/gtk/fedora:v46"
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ update_image (void)
|
||||
cairo_t *cr;
|
||||
GdkPixbuf *pixbuf;
|
||||
GdkPixbuf *pixbuf2;
|
||||
GdkTexture *texture;
|
||||
cairo_font_options_t *fopt;
|
||||
cairo_hint_style_t hintstyle;
|
||||
cairo_hint_metrics_t hintmetrics;
|
||||
@@ -120,8 +121,17 @@ update_image (void)
|
||||
cairo_destroy (cr);
|
||||
g_object_unref (layout);
|
||||
|
||||
pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, cairo_image_surface_get_width (surface), cairo_image_surface_get_height (surface));
|
||||
pixbuf2 = gdk_pixbuf_scale_simple (pixbuf, gdk_pixbuf_get_width (pixbuf) * scale, gdk_pixbuf_get_height (pixbuf) * scale, GDK_INTERP_NEAREST);
|
||||
pixbuf = gdk_pixbuf_new_from_data (cairo_image_surface_get_data (surface),
|
||||
GDK_COLORSPACE_RGB, TRUE, 8,
|
||||
cairo_image_surface_get_width (surface),
|
||||
cairo_image_surface_get_height (surface),
|
||||
cairo_image_surface_get_stride (surface),
|
||||
NULL, NULL);
|
||||
|
||||
pixbuf2 = gdk_pixbuf_scale_simple (pixbuf,
|
||||
gdk_pixbuf_get_width (pixbuf) * scale,
|
||||
gdk_pixbuf_get_height (pixbuf) * scale,
|
||||
GDK_INTERP_NEAREST);
|
||||
|
||||
g_object_unref (pixbuf);
|
||||
cairo_surface_destroy (surface);
|
||||
@@ -278,14 +288,24 @@ retry:
|
||||
pango_layout_iter_free (iter);
|
||||
g_object_unref (layout);
|
||||
|
||||
pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, cairo_image_surface_get_width (surface), cairo_image_surface_get_height (surface));
|
||||
pixbuf2 = gdk_pixbuf_scale_simple (pixbuf, gdk_pixbuf_get_width (pixbuf) * scale, gdk_pixbuf_get_height (pixbuf) * scale, GDK_INTERP_NEAREST);
|
||||
pixbuf = gdk_pixbuf_new_from_data (cairo_image_surface_get_data (surface),
|
||||
GDK_COLORSPACE_RGB, TRUE, 8,
|
||||
cairo_image_surface_get_width (surface),
|
||||
cairo_image_surface_get_height (surface),
|
||||
cairo_image_surface_get_stride (surface),
|
||||
NULL, NULL);
|
||||
|
||||
pixbuf2 = gdk_pixbuf_scale_simple (pixbuf,
|
||||
gdk_pixbuf_get_width (pixbuf) * scale,
|
||||
gdk_pixbuf_get_height (pixbuf) * scale,
|
||||
GDK_INTERP_NEAREST);
|
||||
g_object_unref (pixbuf);
|
||||
cairo_surface_destroy (surface);
|
||||
}
|
||||
|
||||
gtk_picture_set_pixbuf (GTK_PICTURE (image), pixbuf2);
|
||||
|
||||
texture = gdk_texture_new_for_pixbuf (pixbuf2);
|
||||
gtk_picture_set_paintable (GTK_PICTURE (image), GDK_PAINTABLE (texture));
|
||||
g_object_unref (pixbuf2);
|
||||
g_object_unref (pixbuf2);
|
||||
}
|
||||
|
||||
|
||||
+10
-11
@@ -30,6 +30,7 @@ progressive_prepared_callback (GdkPixbufLoader *loader,
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
GtkWidget *picture;
|
||||
GdkTexture *texture;
|
||||
|
||||
picture = GTK_WIDGET (data);
|
||||
|
||||
@@ -40,7 +41,9 @@ progressive_prepared_callback (GdkPixbufLoader *loader,
|
||||
*/
|
||||
gdk_pixbuf_fill (pixbuf, 0xaaaaaaff);
|
||||
|
||||
gtk_picture_set_pixbuf (GTK_PICTURE (picture), pixbuf);
|
||||
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
||||
gtk_picture_set_paintable (GTK_PICTURE (picture), GDK_PAINTABLE (texture));
|
||||
g_object_unref (texture);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -51,22 +54,18 @@ progressive_updated_callback (GdkPixbufLoader *loader,
|
||||
int height,
|
||||
gpointer data)
|
||||
{
|
||||
GtkWidget *picture;
|
||||
GdkPixbuf *pixbuf;
|
||||
GtkWidget *picture = GTK_WIDGET (data);
|
||||
GdkTexture *texture;
|
||||
|
||||
picture = GTK_WIDGET (data);
|
||||
|
||||
pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
|
||||
gtk_picture_set_pixbuf (GTK_PICTURE (picture), NULL);
|
||||
gtk_picture_set_pixbuf (GTK_PICTURE (picture), pixbuf);
|
||||
texture = gdk_texture_new_for_pixbuf (gdk_pixbuf_loader_get_pixbuf (loader));
|
||||
gtk_picture_set_paintable (GTK_PICTURE (picture), GDK_PAINTABLE (texture));
|
||||
g_object_unref (texture);
|
||||
}
|
||||
|
||||
static int
|
||||
progressive_timeout (gpointer data)
|
||||
{
|
||||
GtkWidget *picture;
|
||||
|
||||
picture = GTK_WIDGET (data);
|
||||
GtkWidget *picture = GTK_WIDGET (data);
|
||||
|
||||
/* This shows off fully-paranoid error handling, so looks scary.
|
||||
* You could factor out the error handling code into a nice separate
|
||||
|
||||
@@ -1701,6 +1701,13 @@ node_editor_window_init (NodeEditorWindow *self)
|
||||
" }\n"
|
||||
" transform: translate(0, 140);\n"
|
||||
"}", -1);
|
||||
|
||||
if (g_getenv ("GSK_RENDERER"))
|
||||
{
|
||||
char *new_title = g_strdup_printf ("GTK Node Editor - %s", g_getenv ("GSK_RENDERER"));
|
||||
gtk_window_set_title (GTK_WINDOW (self), new_title);
|
||||
g_free (new_title);
|
||||
}
|
||||
}
|
||||
|
||||
NodeEditorWindow *
|
||||
|
||||
@@ -1210,12 +1210,12 @@ typedef struct {
|
||||
static void
|
||||
add_background (GtkWidget *flowbox,
|
||||
const char *filename,
|
||||
GdkPixbuf *pixbuf,
|
||||
GdkTexture *texture,
|
||||
gboolean is_resource)
|
||||
{
|
||||
GtkWidget *child;
|
||||
|
||||
child = gtk_picture_new_for_pixbuf (pixbuf);
|
||||
child = gtk_picture_new_for_paintable (GDK_PAINTABLE (texture));
|
||||
gtk_widget_set_size_request (child, 110, 70);
|
||||
gtk_flow_box_insert (GTK_FLOW_BOX (flowbox), child, -1);
|
||||
child = gtk_widget_get_parent (child);
|
||||
@@ -1231,6 +1231,7 @@ background_loaded_cb (GObject *source,
|
||||
{
|
||||
BackgroundData *bd = data;
|
||||
GdkPixbuf *pixbuf;
|
||||
GdkTexture *texture;
|
||||
GError *error = NULL;
|
||||
|
||||
pixbuf = gdk_pixbuf_new_from_stream_finish (res, &error);
|
||||
@@ -1241,8 +1242,11 @@ background_loaded_cb (GObject *source,
|
||||
return;
|
||||
}
|
||||
|
||||
add_background (bd->flowbox, bd->filename, pixbuf, FALSE);
|
||||
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
||||
add_background (bd->flowbox, bd->filename, texture, FALSE);
|
||||
|
||||
g_object_unref (texture);
|
||||
g_object_unref (pixbuf);
|
||||
g_free (bd->filename);
|
||||
g_free (bd);
|
||||
}
|
||||
@@ -1259,7 +1263,10 @@ populate_flowbox (GtkWidget *flowbox)
|
||||
GInputStream *stream;
|
||||
BackgroundData *bd;
|
||||
GdkPixbuf *pixbuf;
|
||||
GdkTexture *texture;
|
||||
GtkWidget *child;
|
||||
guchar *data;
|
||||
GBytes *bytes;
|
||||
int i;
|
||||
const char *resources[] = {
|
||||
"sunset.jpg", "portland-rose.jpg", "beach.jpg", "nyc.jpg"
|
||||
@@ -1270,9 +1277,14 @@ populate_flowbox (GtkWidget *flowbox)
|
||||
|
||||
g_object_set_data (G_OBJECT (flowbox), "populated", GUINT_TO_POINTER (1));
|
||||
|
||||
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 110, 70);
|
||||
gdk_pixbuf_fill (pixbuf, 0xffffffff);
|
||||
child = gtk_picture_new_for_pixbuf (pixbuf);
|
||||
data = g_malloc (4 * 110 * 70);
|
||||
memset (data, 0xff, 4 * 110 * 70);
|
||||
bytes = g_bytes_new_take (data, 4 * 110 * 70);
|
||||
texture = gdk_memory_texture_new (110, 70, GDK_MEMORY_DEFAULT, bytes, 4 * 110);
|
||||
child = gtk_picture_new_for_paintable (GDK_PAINTABLE (texture));
|
||||
g_object_unref (texture);
|
||||
g_bytes_unref (bytes);
|
||||
|
||||
gtk_widget_add_css_class (child, "frame");
|
||||
gtk_flow_box_insert (GTK_FLOW_BOX (flowbox), child, -1);
|
||||
|
||||
@@ -1280,7 +1292,10 @@ populate_flowbox (GtkWidget *flowbox)
|
||||
{
|
||||
filename = g_strconcat ("/org/gtk/WidgetFactory4/", resources[i], NULL);
|
||||
pixbuf = gdk_pixbuf_new_from_resource_at_scale (filename, 110, 110, TRUE, NULL);
|
||||
add_background (flowbox, filename, pixbuf, TRUE);
|
||||
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
||||
add_background (flowbox, filename, texture, TRUE);
|
||||
g_object_unref (texture);
|
||||
g_object_unref (pixbuf);
|
||||
}
|
||||
|
||||
location = "/usr/share/backgrounds/gnome";
|
||||
|
||||
@@ -220,6 +220,6 @@ clipboard.cut, clipboard.copy, clipboard.paste
|
||||
selection.delete, selection.select-all
|
||||
: Selection operations on entries, text view and labels
|
||||
|
||||
color.select, color.customize:
|
||||
color.select, color.customize
|
||||
: Operate on colors in a `GtkColorChooserWidget`. These actions are
|
||||
unusual in that they have the non-trivial parameter type (dddd):
|
||||
unusual in that they have the non-trivial parameter type (dddd).
|
||||
|
||||
@@ -103,14 +103,15 @@ fields, but e.g. buttons can take the focus too.
|
||||
|
||||
Input widgets can be given the focus by clicking on them, but focus
|
||||
can also be moved around with certain key events (this is known as
|
||||
“keyboard navigation”). GTK reserves the <kbd>Tab</kbd> key to move the focus
|
||||
to the next location, and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move it back to the previous
|
||||
one. In addition many containers allow “directional navigation” with
|
||||
the arrow keys.
|
||||
“keyboard navigation”).
|
||||
GTK reserves the <kbd>Tab</kbd> key to move the focus to the next location,
|
||||
and <kbd>Shift</kbd>+<kbd>Tab</kbd> to move it back to the previous one.
|
||||
In addition many containers allow “directional navigation” with the arrow keys.
|
||||
|
||||
Many widgets can be “activated” to trigger and action. E.g., you can
|
||||
activate a button or switch by clicking on them, but you can also
|
||||
activate them with the keyboard, by using the <kbd>Enter</kbd> or <kbd>␣</kbd> keys.
|
||||
Many widgets can be “activated” to trigger and action.
|
||||
E.g., you can activate a button or switch by clicking on them,
|
||||
but you can also activate them with the keyboard,
|
||||
by using the <kbd>Enter</kbd> or <kbd>Space</kbd> keys.
|
||||
|
||||
Apart from keyboard navigation, activation and directly typing into
|
||||
entries or text views, GTK widgets can use key events for activating
|
||||
@@ -121,15 +122,17 @@ GTK has traditionally supported different kinds of shortcuts:
|
||||
|
||||
- Accelerators are any other shortcuts that can be activated regardless
|
||||
of where the focus is, and typically trigger global actions, such as
|
||||
Ctrl-Q to quit an application.
|
||||
- Mnemonics are usually triggered using Alt as a modifier for a letter.
|
||||
<kbd>Ctrl</kbd>+<kbd>Q</kbd> to quit an application.
|
||||
- Mnemonics are usually triggered using <kbd>Alt</kbd>
|
||||
as a modifier for a letter.
|
||||
They are used in places where a label is associated with a control,
|
||||
and are indicated by underlining the letter in the label. As a special
|
||||
case, inside menus (i.e. inside `GtkPopoverMenu`), mnemonics can be
|
||||
triggered without the modifier.
|
||||
- Key bindings are specific to individual widgets, such as Ctrl-C or
|
||||
Ctrl-V in an entry copy to or paste from the clipboard. They are only
|
||||
triggered when the widget has focus.
|
||||
- Key bindings are specific to individual widgets,
|
||||
such as <kbd>Ctrl</kbd>+<kbd>C</kbd> or <kbd>Ctrl</kbd>+<kbd>V</kbd>
|
||||
in an entry copy to or paste from the clipboard.
|
||||
They are only triggered when the widget has focus.
|
||||
|
||||
GTK handles accelerators and mnemonics in a global scope, during the
|
||||
capture phase, and key bindings locally, during the target phase.
|
||||
@@ -208,4 +211,4 @@ sequence, so setting the state on one does transfer the state to
|
||||
the others. They also are mutually exclusive, within a widget
|
||||
where may be only one gesture group claiming a given sequence.
|
||||
If another gesture group claims later that same sequence, the
|
||||
first group will deny the sequence:
|
||||
first group will deny the sequence.
|
||||
|
||||
@@ -133,3 +133,9 @@ The function gtk_widget_get_allocation() is also going away. It does not have a
|
||||
replacement, but the previously mentioned alternatives can be used for it too.
|
||||
|
||||
The function gtk_widget_get_allocated_baseline() has been renamed to [method@Gtk.Widget.get_baseline].
|
||||
|
||||
## Stop using GdkPixbuf
|
||||
|
||||
GTK is moving away from GdkPixbuf as the primary API for transporting image data, in favor
|
||||
of GdkTexture. APIs that are accepting or returning GdkPixbufs are being replaced by equivalent
|
||||
APIs using GdkTexture or GdkPaintable objects.
|
||||
|
||||
+2
-2
@@ -57,7 +57,7 @@ window_paste (GSimpleAction *action,
|
||||
{
|
||||
GtkWindow *window = GTK_WINDOW (user_data);
|
||||
GtkTextView *text = g_object_get_data ((GObject*)window, "plugman-text");
|
||||
|
||||
|
||||
gtk_text_buffer_paste_clipboard (gtk_text_view_get_buffer (text),
|
||||
gtk_widget_get_clipboard (GTK_WIDGET (text)),
|
||||
NULL,
|
||||
@@ -221,7 +221,7 @@ plugin_action (GAction *action,
|
||||
g_message ("Color: %s", g_action_get_name (action));
|
||||
|
||||
css_provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (css_provider, css_to_load, -1);
|
||||
gtk_css_provider_load_from_string (css_provider, css_to_load);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (css_provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
|
||||
@@ -157,6 +157,9 @@ convert_no_alpha (guchar *dest_data,
|
||||
*
|
||||
* Returns: (nullable) (transfer full): A newly-created pixbuf with a
|
||||
* reference count of 1
|
||||
*
|
||||
* Deprecated: 4.12: Use [class@Gdk.Texture] and subclasses instead
|
||||
* cairo surfaces and pixbufs
|
||||
*/
|
||||
GdkPixbuf *
|
||||
gdk_pixbuf_get_from_surface (cairo_surface_t *surface,
|
||||
@@ -234,6 +237,9 @@ pixbuf_texture_unref_cb (guchar *pixels,
|
||||
* to draw it on screen.
|
||||
*
|
||||
* Returns: (transfer full) (nullable): a new `GdkPixbuf`
|
||||
*
|
||||
* Deprecated: 4.12: Use [class@Gdk.Texture] and subclasses instead
|
||||
* cairo surfaces and pixbufs
|
||||
*/
|
||||
GdkPixbuf *
|
||||
gdk_pixbuf_get_from_texture (GdkTexture *texture)
|
||||
@@ -33,13 +33,13 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_12
|
||||
GdkPixbuf *gdk_pixbuf_get_from_surface (cairo_surface_t *surface,
|
||||
int src_x,
|
||||
int src_y,
|
||||
int width,
|
||||
int height);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_12
|
||||
GdkPixbuf *gdk_pixbuf_get_from_texture (GdkTexture *texture);
|
||||
|
||||
G_END_DECLS
|
||||
@@ -0,0 +1,7 @@
|
||||
gdk_deprecated_sources = [
|
||||
'deprecated/gdkpixbuf.c',
|
||||
]
|
||||
|
||||
gdk_deprecated_headers = [
|
||||
'deprecated/gdkpixbuf.h',
|
||||
]
|
||||
@@ -61,7 +61,7 @@
|
||||
#include <gdk/gdkmonitor.h>
|
||||
#include <gdk/gdkpaintable.h>
|
||||
#include <gdk/gdkpango.h>
|
||||
#include <gdk/gdkpixbuf.h>
|
||||
#include <gdk/deprecated/gdkpixbuf.h>
|
||||
#include <gdk/gdkpopup.h>
|
||||
#include <gdk/gdkpopuplayout.h>
|
||||
#include <gdk/gdkrectangle.h>
|
||||
|
||||
+3
-38
@@ -17,7 +17,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "gdkcairoprivate.h"
|
||||
#include "gdkcairo.h"
|
||||
|
||||
#include "gdkrgba.h"
|
||||
#include "gdktexture.h"
|
||||
@@ -90,7 +90,7 @@ gdk_cairo_region (cairo_t *cr,
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
gdk_cairo_surface_paint_pixbuf (cairo_surface_t *surface,
|
||||
const GdkPixbuf *pixbuf)
|
||||
{
|
||||
@@ -171,7 +171,7 @@ gdk_cairo_set_source_pixbuf (cairo_t *cr,
|
||||
*
|
||||
* Returns: %TRUE if the extents fit in a `GdkRectangle`, %FALSE if not
|
||||
*/
|
||||
gboolean
|
||||
static gboolean
|
||||
_gdk_cairo_surface_extents (cairo_surface_t *surface,
|
||||
GdkRectangle *extents)
|
||||
{
|
||||
@@ -303,38 +303,3 @@ gdk_cairo_region_create_from_surface (cairo_surface_t *surface)
|
||||
|
||||
return region;
|
||||
}
|
||||
|
||||
cairo_region_t *
|
||||
gdk_cairo_region_from_clip (cairo_t *cr)
|
||||
{
|
||||
cairo_rectangle_list_t *rectangles;
|
||||
cairo_region_t *region;
|
||||
int i;
|
||||
|
||||
rectangles = cairo_copy_clip_rectangle_list (cr);
|
||||
|
||||
if (rectangles->status != CAIRO_STATUS_SUCCESS)
|
||||
return NULL;
|
||||
|
||||
region = cairo_region_create ();
|
||||
for (i = 0; i < rectangles->num_rectangles; i++)
|
||||
{
|
||||
cairo_rectangle_int_t clip_rect;
|
||||
cairo_rectangle_t *rect;
|
||||
|
||||
rect = &rectangles->rectangles[i];
|
||||
|
||||
/* Here we assume clip rects are ints for direct targets, which
|
||||
is true for cairo */
|
||||
clip_rect.x = (int)rect->x;
|
||||
clip_rect.y = (int)rect->y;
|
||||
clip_rect.width = (int)rect->width;
|
||||
clip_rect.height = (int)rect->height;
|
||||
|
||||
cairo_region_union_rectangle (region, &clip_rect);
|
||||
}
|
||||
|
||||
cairo_rectangle_list_destroy (rectangles);
|
||||
|
||||
return region;
|
||||
}
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@
|
||||
#endif
|
||||
|
||||
#include <gdk/gdktypes.h>
|
||||
#include <gdk/gdkpixbuf.h>
|
||||
#include <gdk/deprecated/gdkpixbuf.h>
|
||||
#include <pango/pangocairo.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
/* GDK - The GIMP Drawing Kit
|
||||
* Copyright (C) 2020 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "gdkcairo.h"
|
||||
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
#include <cairo.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
gboolean _gdk_cairo_surface_extents (cairo_surface_t *surface,
|
||||
GdkRectangle *extents);
|
||||
|
||||
void gdk_cairo_surface_paint_pixbuf (cairo_surface_t *surface,
|
||||
const GdkPixbuf *pixbuf);
|
||||
|
||||
cairo_region_t *gdk_cairo_region_from_clip (cairo_t *cr);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include "gdkcontentserializer.h"
|
||||
|
||||
#include "gdkcontentformats.h"
|
||||
#include "gdkpixbuf.h"
|
||||
#include "deprecated/gdkpixbuf.h"
|
||||
#include "filetransferportalprivate.h"
|
||||
#include "gdktextureprivate.h"
|
||||
#include "gdkrgba.h"
|
||||
@@ -642,7 +642,9 @@ pixbuf_serializer (GdkContentSerializer *serializer)
|
||||
else if (G_VALUE_HOLDS (value, GDK_TYPE_TEXTURE))
|
||||
{
|
||||
GdkTexture *texture = g_value_get_object (value);
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
pixbuf = gdk_pixbuf_get_from_texture (texture);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -371,6 +371,12 @@ gdk_draw_context_begin_frame_full (GdkDrawContext *context,
|
||||
priv->surface->paint_context = g_object_ref (context);
|
||||
|
||||
GDK_DRAW_CONTEXT_GET_CLASS (context)->begin_frame (context, prefers_high_depth, priv->frame_region);
|
||||
|
||||
cairo_region_intersect_rectangle (priv->frame_region,
|
||||
&(cairo_rectangle_int_t) {
|
||||
0, 0,
|
||||
priv->surface->width, priv->surface->height
|
||||
});
|
||||
}
|
||||
|
||||
#ifdef HAVE_SYSPROF
|
||||
|
||||
@@ -225,17 +225,17 @@ gdk_texture_downloader_download_into (const GdkTextureDownloader *self,
|
||||
/**
|
||||
* gdk_texture_downloader_download_bytes:
|
||||
* @self: the downloader
|
||||
* @out_stride: (out): The stride of the resulting data in bytes.
|
||||
* @out_stride: (out): The stride of the resulting data in bytes
|
||||
*
|
||||
* Downloads the given texture pixels into a `GBytes`. The rowstride will
|
||||
* be stored in the stride value.
|
||||
*
|
||||
* This function will abort if it tries to download a large texture and
|
||||
* fails to allocate memory. If you think that may happen, you should
|
||||
* handle memory allocation yourself and use
|
||||
* gdk_texture_downloader_download_into() once allocation succeeded.
|
||||
* fails to allocate memory. If you think that may happen, you should handle
|
||||
* memory allocation yourself and use [method@Gdk.TextureDownloader.download_into]
|
||||
* once allocation succeeded.
|
||||
*
|
||||
* Returns: The downloaded pixels.
|
||||
* Returns: The downloaded pixels
|
||||
*
|
||||
* Since: 4.10
|
||||
**/
|
||||
|
||||
+7
-4
@@ -135,7 +135,8 @@ gdk_toplevel_default_export_handle_finish (GdkToplevel *toplevel,
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_toplevel_default_unexport_handle (GdkToplevel *toplevel)
|
||||
gdk_toplevel_default_unexport_handle (GdkToplevel *toplevel,
|
||||
const char *handle)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -791,7 +792,7 @@ gdk_toplevel_export_handle (GdkToplevel *toplevel,
|
||||
* @result: the `GAsyncResult`
|
||||
* @error: return location for an error
|
||||
*
|
||||
* Finishes the [method@Gdk.Toplevel.export_handle] cal and
|
||||
* Finishes the [method@Gdk.Toplevel.export_handle] call and
|
||||
* returns the resulting handle.
|
||||
*
|
||||
* Returns: (nullable) (transfer full): the exported handle,
|
||||
@@ -810,6 +811,7 @@ gdk_toplevel_export_handle_finish (GdkToplevel *toplevel,
|
||||
/*< private >
|
||||
* gdk_toplevel_unexport_handle:
|
||||
* @toplevel: a `GdkToplevel`
|
||||
* @handle: the handle to unexport
|
||||
*
|
||||
* Destroys the handle that was obtained with [method@Gdk.Toplevel.export_handle].
|
||||
*
|
||||
@@ -819,7 +821,8 @@ gdk_toplevel_export_handle_finish (GdkToplevel *toplevel,
|
||||
* Since: 4.10
|
||||
*/
|
||||
void
|
||||
gdk_toplevel_unexport_handle (GdkToplevel *toplevel)
|
||||
gdk_toplevel_unexport_handle (GdkToplevel *toplevel,
|
||||
const char *handle)
|
||||
{
|
||||
GDK_TOPLEVEL_GET_IFACE (toplevel)->unexport_handle (toplevel);
|
||||
GDK_TOPLEVEL_GET_IFACE (toplevel)->unexport_handle (toplevel, handle);
|
||||
}
|
||||
|
||||
@@ -49,7 +49,8 @@ struct _GdkToplevelInterface
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
void (* unexport_handle) (GdkToplevel *toplevel);
|
||||
void (* unexport_handle) (GdkToplevel *toplevel,
|
||||
const char *handle);
|
||||
};
|
||||
|
||||
typedef enum
|
||||
@@ -82,7 +83,8 @@ char *gdk_toplevel_export_handle_finish (GdkToplevel *toplevel,
|
||||
GAsyncResult *result,
|
||||
GError **error);
|
||||
|
||||
void gdk_toplevel_unexport_handle (GdkToplevel *toplevel);
|
||||
void gdk_toplevel_unexport_handle (GdkToplevel *toplevel,
|
||||
const char *handle);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
+4
-3
@@ -1,3 +1,5 @@
|
||||
subdir('deprecated')
|
||||
|
||||
gdk_public_sources = files([
|
||||
'gdk.c',
|
||||
'gdkapplaunchcontext.c',
|
||||
@@ -38,7 +40,6 @@ gdk_public_sources = files([
|
||||
'gdkmonitor.c',
|
||||
'gdkpaintable.c',
|
||||
'gdkpango.c',
|
||||
'gdkpixbuf.c',
|
||||
'gdkpipeiostream.c',
|
||||
'gdkrectangle.c',
|
||||
'gdkrgba.c',
|
||||
@@ -94,7 +95,6 @@ gdk_public_headers = files([
|
||||
'gdkmonitor.h',
|
||||
'gdkpaintable.h',
|
||||
'gdkpango.h',
|
||||
'gdkpixbuf.h',
|
||||
'gdkrectangle.h',
|
||||
'gdkrgba.h',
|
||||
'gdkseat.h',
|
||||
@@ -112,8 +112,9 @@ gdk_public_headers = files([
|
||||
'gdkdragsurface.h',
|
||||
])
|
||||
install_headers(gdk_public_headers, subdir: 'gtk-4.0/gdk/')
|
||||
install_headers(gdk_deprecated_headers, subdir: 'gtk-4.0/gdk/deprecated')
|
||||
|
||||
gdk_sources = gdk_public_sources
|
||||
gdk_sources = gdk_public_sources + gdk_deprecated_sources
|
||||
|
||||
gdk_private_h_sources = files([
|
||||
'gdkeventsprivate.h',
|
||||
|
||||
@@ -1148,7 +1148,10 @@ gdk_wayland_surface_destroy (GdkSurface *surface,
|
||||
|
||||
gdk_wayland_surface_hide_surface (surface);
|
||||
|
||||
gdk_wayland_surface_destroy_wl_surface (GDK_WAYLAND_SURFACE(surface));
|
||||
if (GDK_IS_TOPLEVEL (surface))
|
||||
gdk_wayland_toplevel_destroy (GDK_TOPLEVEL (surface));
|
||||
|
||||
gdk_wayland_surface_destroy_wl_surface (GDK_WAYLAND_SURFACE (surface));
|
||||
|
||||
frame_clock = gdk_surface_get_frame_clock (surface);
|
||||
g_signal_handlers_disconnect_by_func (frame_clock, on_frame_clock_before_paint, surface);
|
||||
|
||||
@@ -39,3 +39,4 @@ void gdk_wayland_toplevel_announce_ssd (GdkToplevel *toplevel);
|
||||
gboolean gdk_wayland_toplevel_inhibit_idle (GdkToplevel *toplevel);
|
||||
void gdk_wayland_toplevel_uninhibit_idle (GdkToplevel *toplevel);
|
||||
|
||||
void gdk_wayland_toplevel_destroy (GdkToplevel *toplevel);
|
||||
|
||||
@@ -54,11 +54,16 @@ static void gdk_wayland_toplevel_sync_parent (GdkWaylandToplevel *to
|
||||
static void gdk_wayland_toplevel_sync_parent_of_imported (GdkWaylandToplevel *toplevel);
|
||||
static void gdk_wayland_surface_create_xdg_toplevel (GdkWaylandToplevel *toplevel);
|
||||
static void gdk_wayland_toplevel_sync_title (GdkWaylandToplevel *toplevel);
|
||||
static gboolean gdk_wayland_toplevel_is_exported (GdkWaylandToplevel *toplevel);
|
||||
static void unset_transient_for_exported (GdkWaylandToplevel *toplevel);
|
||||
|
||||
/* {{{ GdkWaylandToplevel definition */
|
||||
|
||||
typedef struct {
|
||||
struct zxdg_exported_v1 *xdg_exported;
|
||||
struct zxdg_exported_v2 *xdg_exported_v2;
|
||||
char *handle;
|
||||
} GdkWaylandExported;
|
||||
|
||||
/**
|
||||
* GdkWaylandToplevel:
|
||||
*
|
||||
@@ -83,8 +88,7 @@ struct _GdkWaylandToplevel
|
||||
GdkWaylandToplevel *transient_for;
|
||||
|
||||
struct org_kde_kwin_server_decoration *server_decoration;
|
||||
struct zxdg_exported_v1 *xdg_exported;
|
||||
struct zxdg_exported_v2 *xdg_exported_v2;
|
||||
GList *exported;
|
||||
|
||||
struct {
|
||||
int width;
|
||||
@@ -102,12 +106,6 @@ struct _GdkWaylandToplevel
|
||||
gboolean size_is_fixed;
|
||||
} next_layout;
|
||||
|
||||
struct {
|
||||
GdkWaylandToplevelExported callback;
|
||||
gpointer user_data;
|
||||
GDestroyNotify destroy_func;
|
||||
} exported;
|
||||
|
||||
struct {
|
||||
gboolean was_set;
|
||||
|
||||
@@ -1280,9 +1278,6 @@ gdk_wayland_toplevel_finalize (GObject *object)
|
||||
|
||||
display_wayland->toplevels = g_list_remove (display_wayland->toplevels, self);
|
||||
|
||||
if (gdk_wayland_toplevel_is_exported (self))
|
||||
gdk_wayland_toplevel_unexport_handle (GDK_TOPLEVEL (self));
|
||||
|
||||
g_free (self->application.application_id);
|
||||
g_free (self->application.app_menu_path);
|
||||
g_free (self->application.menubar_path);
|
||||
@@ -1747,8 +1742,12 @@ xdg_exported_handle_v1 (void *data,
|
||||
struct zxdg_exported_v1 *zxdg_exported_v1,
|
||||
const char *handle)
|
||||
{
|
||||
g_task_return_pointer (G_TASK (data), g_strdup (handle), g_free);
|
||||
g_object_unref (data);
|
||||
GTask *task = G_TASK (data);
|
||||
GdkWaylandExported *exported = (GdkWaylandExported *)g_task_get_task_data (task);
|
||||
|
||||
exported->handle = g_strdup (handle);
|
||||
g_task_return_pointer (task, g_strdup (handle), g_free);
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
static const struct zxdg_exported_v1_listener xdg_exported_listener_v1 = {
|
||||
@@ -1760,8 +1759,12 @@ xdg_exported_handle_v2 (void *data,
|
||||
struct zxdg_exported_v2 *zxdg_exported_v2,
|
||||
const char *handle)
|
||||
{
|
||||
g_task_return_pointer (G_TASK (data), g_strdup (handle), g_free);
|
||||
g_object_unref (data);
|
||||
GTask *task = G_TASK (data);
|
||||
GdkWaylandExported *exported = (GdkWaylandExported *)g_task_get_task_data (task);
|
||||
|
||||
exported->handle = g_strdup (handle);
|
||||
g_task_return_pointer (task, g_strdup (handle), g_free);
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
static const struct zxdg_exported_v2_listener xdg_exported_listener_v2 = {
|
||||
@@ -1784,19 +1787,27 @@ gdk_wayland_toplevel_real_export_handle (GdkToplevel *toplevel,
|
||||
|
||||
if (display_wayland->xdg_exporter_v2)
|
||||
{
|
||||
wayland_toplevel->xdg_exported_v2 =
|
||||
GdkWaylandExported *exported = g_new0 (GdkWaylandExported, 1);
|
||||
exported->xdg_exported_v2 =
|
||||
zxdg_exporter_v2_export_toplevel (display_wayland->xdg_exporter_v2,
|
||||
gdk_wayland_surface_get_wl_surface (surface));
|
||||
zxdg_exported_v2_add_listener (wayland_toplevel->xdg_exported_v2,
|
||||
zxdg_exported_v2_add_listener (exported->xdg_exported_v2,
|
||||
&xdg_exported_listener_v2, task);
|
||||
|
||||
wayland_toplevel->exported = g_list_prepend (wayland_toplevel->exported, exported);
|
||||
g_task_set_task_data (task, exported, NULL);
|
||||
}
|
||||
else if (display_wayland->xdg_exporter)
|
||||
{
|
||||
wayland_toplevel->xdg_exported =
|
||||
GdkWaylandExported *exported = g_new0 (GdkWaylandExported, 1);
|
||||
exported->xdg_exported =
|
||||
zxdg_exporter_v1_export (display_wayland->xdg_exporter,
|
||||
gdk_wayland_surface_get_wl_surface (surface));
|
||||
zxdg_exported_v1_add_listener (wayland_toplevel->xdg_exported,
|
||||
zxdg_exported_v1_add_listener (exported->xdg_exported,
|
||||
&xdg_exported_listener_v1, task);
|
||||
|
||||
wayland_toplevel->exported = g_list_prepend (wayland_toplevel->exported, exported);
|
||||
g_task_set_task_data (task, exported, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1815,15 +1826,36 @@ gdk_wayland_toplevel_real_export_handle_finish (GdkToplevel *toplevel,
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_toplevel_real_unexport_handle (GdkToplevel *toplevel)
|
||||
destroy_exported (GdkWaylandExported *exported)
|
||||
{
|
||||
g_clear_pointer (&exported->handle, g_free);
|
||||
g_clear_pointer (&exported->xdg_exported_v2, zxdg_exported_v2_destroy);
|
||||
g_clear_pointer (&exported->xdg_exported, zxdg_exported_v1_destroy);
|
||||
g_free (exported);
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_wayland_toplevel_real_unexport_handle (GdkToplevel *toplevel,
|
||||
const char *handle)
|
||||
{
|
||||
GdkWaylandToplevel *wayland_toplevel = GDK_WAYLAND_TOPLEVEL (toplevel);
|
||||
|
||||
g_return_if_fail (GDK_IS_WAYLAND_TOPLEVEL (toplevel));
|
||||
g_return_if_fail (wayland_toplevel->xdg_exported_v2 || wayland_toplevel->xdg_exported);
|
||||
g_return_if_fail (handle != NULL);
|
||||
|
||||
g_clear_pointer (&wayland_toplevel->xdg_exported_v2, zxdg_exported_v2_destroy);
|
||||
g_clear_pointer (&wayland_toplevel->xdg_exported, zxdg_exported_v1_destroy);
|
||||
for (GList *l = wayland_toplevel->exported; l; l = l->next)
|
||||
{
|
||||
GdkWaylandExported *exported = l->data;
|
||||
|
||||
if (exported->handle && strcmp (exported->handle, handle) == 0)
|
||||
{
|
||||
wayland_toplevel->exported = g_list_delete_link (wayland_toplevel->exported, l);
|
||||
destroy_exported (exported);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
g_warn_if_reached ();
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -2255,6 +2287,32 @@ gdk_wayland_toplevel_set_dbus_properties (GdkToplevel *toplevel,
|
||||
maybe_set_gtk_surface_dbus_properties (wayland_toplevel);
|
||||
}
|
||||
|
||||
void
|
||||
gdk_wayland_toplevel_destroy (GdkToplevel *toplevel)
|
||||
{
|
||||
GdkWaylandToplevel *self = GDK_WAYLAND_TOPLEVEL (toplevel);
|
||||
|
||||
while (self->exported)
|
||||
{
|
||||
GdkWaylandExported *exported = self->exported->data;
|
||||
self->exported = g_list_delete_link (self->exported, self->exported);
|
||||
if (exported->handle == NULL)
|
||||
{
|
||||
GTask *task;
|
||||
|
||||
if (exported->xdg_exported_v2)
|
||||
task = G_TASK (wl_proxy_get_user_data ((struct wl_proxy *) exported->xdg_exported_v2));
|
||||
else
|
||||
task = G_TASK (wl_proxy_get_user_data ((struct wl_proxy *) exported->xdg_exported));
|
||||
|
||||
g_task_return_new_error (task, G_IO_ERROR, G_IO_ERROR_FAILED, "Surface was destroyed");
|
||||
g_object_unref (task);
|
||||
}
|
||||
|
||||
destroy_exported (exported);
|
||||
}
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Toplevel API */
|
||||
|
||||
@@ -2397,12 +2455,6 @@ gdk_wayland_toplevel_uninhibit_idle (GdkToplevel *toplevel)
|
||||
* marking surfaces as transient for out-of-process surfaces.
|
||||
*/
|
||||
|
||||
static gboolean
|
||||
gdk_wayland_toplevel_is_exported (GdkWaylandToplevel *toplevel)
|
||||
{
|
||||
return toplevel->xdg_exported != NULL || toplevel->xdg_exported_v2 != NULL;
|
||||
}
|
||||
|
||||
typedef struct {
|
||||
GdkWaylandToplevelExported callback;
|
||||
gpointer user_data;
|
||||
@@ -2450,6 +2502,12 @@ export_handle_done (GObject *source,
|
||||
* from another surface as transient for this one, see
|
||||
* [method@GdkWayland.WaylandToplevel.set_transient_for_exported].
|
||||
*
|
||||
* Before 4.12, this API could not safely be used multiple times,
|
||||
* since there was no reference counting for handles. Starting with
|
||||
* 4.12, every call to this function obtains a new handle, and every
|
||||
* call to [method@GdkWayland.WaylandToplevel.drop_exported_handle] drops
|
||||
* just the handle that it is given.
|
||||
*
|
||||
* Note that this API depends on an unstable Wayland protocol,
|
||||
* and thus may require changes in the future.
|
||||
*
|
||||
@@ -2486,15 +2544,53 @@ gdk_wayland_toplevel_export_handle (GdkToplevel *toplevel,
|
||||
* It is an error to call this function on a surface that
|
||||
* does not have a handle.
|
||||
*
|
||||
* Since 4.12, this function does nothing. Use
|
||||
* [method@GdkWayland.WaylandToplevel.drop_exported_handle] instead to drop a
|
||||
* handle that was obtained with [method@GdkWayland.WaylandToplevel.export_handle].
|
||||
*
|
||||
* Note that this API depends on an unstable Wayland protocol,
|
||||
* and thus may require changes in the future.
|
||||
*
|
||||
* Deprecated: 4.12: Use [method@GdkWayland.WaylandToplevel.drop_exported_handle]
|
||||
* instead, this function does nothing
|
||||
*/
|
||||
void
|
||||
gdk_wayland_toplevel_unexport_handle (GdkToplevel *toplevel)
|
||||
{
|
||||
g_return_if_fail (GDK_IS_WAYLAND_TOPLEVEL (toplevel));
|
||||
GdkWaylandToplevel *wayland_toplevel = GDK_WAYLAND_TOPLEVEL (toplevel);
|
||||
|
||||
gdk_toplevel_unexport_handle (toplevel);
|
||||
if (wayland_toplevel->exported != NULL &&
|
||||
wayland_toplevel->exported->next == NULL)
|
||||
{
|
||||
GdkWaylandExported *exported = wayland_toplevel->exported->data;
|
||||
|
||||
if (exported->handle)
|
||||
{
|
||||
gdk_toplevel_unexport_handle (toplevel, exported->handle);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
g_warning ("Use gdk_wayland_toplevel_drop_exported_handle()");
|
||||
}
|
||||
|
||||
/**
|
||||
* gdk_wayland_toplevel_drop_exported_handle:
|
||||
* @toplevel: (type GdkWaylandToplevel): the `GdkToplevel` that was exported
|
||||
* @handle: the handle to drop
|
||||
*
|
||||
* Destroy a handle that was obtained with gdk_wayland_toplevel_export_handle().
|
||||
*
|
||||
* Note that this API depends on an unstable Wayland protocol,
|
||||
* and thus may require changes in the future.
|
||||
*
|
||||
* Since: 4.12
|
||||
*/
|
||||
void
|
||||
gdk_wayland_toplevel_drop_exported_handle (GdkToplevel *toplevel,
|
||||
const char *handle)
|
||||
{
|
||||
gdk_toplevel_unexport_handle (toplevel, handle);
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -52,9 +52,13 @@ gboolean gdk_wayland_toplevel_export_handle (GdkToplevel
|
||||
gpointer user_data,
|
||||
GDestroyNotify destroy_func);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_12_FOR(gdk_wayland_toplevel_drop_exported_handle)
|
||||
void gdk_wayland_toplevel_unexport_handle (GdkToplevel *toplevel);
|
||||
|
||||
GDK_AVAILABLE_IN_4_12
|
||||
void gdk_wayland_toplevel_drop_exported_handle (GdkToplevel *toplevel,
|
||||
const char *handle);
|
||||
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
gboolean gdk_wayland_toplevel_set_transient_for_exported (GdkToplevel *toplevel,
|
||||
const char *parent_handle_str);
|
||||
|
||||
@@ -5318,7 +5318,8 @@ gdk_x11_toplevel_export_handle_finish (GdkToplevel *toplevel,
|
||||
}
|
||||
|
||||
static void
|
||||
gdk_x11_toplevel_unexport_handle (GdkToplevel *toplevel)
|
||||
gdk_x11_toplevel_unexport_handle (GdkToplevel *toplevel,
|
||||
const char *handle)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -579,7 +579,7 @@ discard_batch (GskGLCommandQueue *self)
|
||||
self->batches.len--;
|
||||
}
|
||||
|
||||
void
|
||||
gboolean
|
||||
gsk_gl_command_queue_begin_draw (GskGLCommandQueue *self,
|
||||
GskGLUniformProgram *program,
|
||||
guint width,
|
||||
@@ -596,7 +596,7 @@ gsk_gl_command_queue_begin_draw (GskGLCommandQueue *self,
|
||||
* of batches we can have in one frame.
|
||||
*/
|
||||
if (will_ignore_batch (self))
|
||||
return;
|
||||
return FALSE;
|
||||
|
||||
self->program_info = program;
|
||||
|
||||
@@ -617,6 +617,8 @@ gsk_gl_command_queue_begin_draw (GskGLCommandQueue *self,
|
||||
self->fbo_max = MAX (self->fbo_max, batch->draw.framebuffer);
|
||||
|
||||
self->in_draw = TRUE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -721,6 +723,10 @@ gsk_gl_command_queue_split_draw (GskGLCommandQueue *self)
|
||||
|
||||
g_assert (GSK_IS_GL_COMMAND_QUEUE (self));
|
||||
g_assert (self->batches.len > 0);
|
||||
|
||||
if (will_ignore_batch (self))
|
||||
return;
|
||||
|
||||
g_assert (self->in_draw == TRUE);
|
||||
|
||||
program = self->program_info;
|
||||
|
||||
@@ -331,7 +331,7 @@ void gsk_gl_command_queue_delete_program (GskGLCommandQueue
|
||||
void gsk_gl_command_queue_clear (GskGLCommandQueue *self,
|
||||
guint clear_bits,
|
||||
const graphene_rect_t *viewport);
|
||||
void gsk_gl_command_queue_begin_draw (GskGLCommandQueue *self,
|
||||
gboolean gsk_gl_command_queue_begin_draw (GskGLCommandQueue *self,
|
||||
GskGLUniformProgram *program_info,
|
||||
guint width,
|
||||
guint height);
|
||||
|
||||
@@ -124,7 +124,7 @@ gsk_gl_compiler_new (GskGLDriver *driver,
|
||||
self->driver = g_object_ref (driver);
|
||||
self->debug_shaders = !!debug_shaders;
|
||||
|
||||
context = gsk_gl_command_queue_get_context (self->driver->shared_command_queue);
|
||||
context = gsk_gl_driver_get_context (self->driver);
|
||||
|
||||
if (gdk_gl_context_get_use_es (context))
|
||||
{
|
||||
|
||||
@@ -1131,7 +1131,7 @@ gsk_gl_driver_lookup_shader (GskGLDriver *self,
|
||||
return program;
|
||||
}
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
#if 0
|
||||
void
|
||||
gsk_gl_driver_save_texture_to_png (GskGLDriver *driver,
|
||||
int texture_id,
|
||||
|
||||
@@ -175,7 +175,7 @@ GskGLProgram * gsk_gl_driver_lookup_shader (GskGLDriver *s
|
||||
GskGLShader *shader,
|
||||
GError **error);
|
||||
|
||||
#ifdef G_ENABLE_DEBUG
|
||||
#if 0
|
||||
void gsk_gl_driver_save_texture_to_png (GskGLDriver *self,
|
||||
int texture_id,
|
||||
int width,
|
||||
|
||||
+957
-913
File diff suppressed because it is too large
Load Diff
@@ -4413,6 +4413,11 @@ gsk_shadow_node_draw (GskRenderNode *node,
|
||||
pattern = cairo_pop_group (cr);
|
||||
cairo_restore (cr);
|
||||
|
||||
cairo_save (cr);
|
||||
/* clip so the blur area stays small */
|
||||
gsk_cairo_rectangle (cr, &node->bounds);
|
||||
cairo_clip (cr);
|
||||
|
||||
for (i = 0; i < self->n_shadows; i++)
|
||||
{
|
||||
GskShadow *shadow = &self->shadows[i];
|
||||
@@ -4434,6 +4439,7 @@ gsk_shadow_node_draw (GskRenderNode *node,
|
||||
|
||||
cairo_set_source (cr, pattern);
|
||||
cairo_paint (cr);
|
||||
cairo_restore (cr);
|
||||
|
||||
cairo_pattern_destroy (pattern);
|
||||
}
|
||||
|
||||
@@ -1081,20 +1081,21 @@ parse_declarations (GtkCssParser *parser,
|
||||
{
|
||||
if (gtk_css_parser_try_ident (parser, declarations[i].name))
|
||||
{
|
||||
if (parsed & (1 << i))
|
||||
{
|
||||
gtk_css_parser_warn_syntax (parser, "Variable \"%s\" defined multiple times", declarations[i].name);
|
||||
/* Unset, just to be sure */
|
||||
parsed &= ~(1 << i);
|
||||
if (declarations[i].clear_func)
|
||||
declarations[i].clear_func (declarations[i].result);
|
||||
}
|
||||
|
||||
if (!gtk_css_parser_try_token (parser, GTK_CSS_TOKEN_COLON))
|
||||
{
|
||||
gtk_css_parser_error_syntax (parser, "Expected ':' after variable declaration");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (parsed & (1 << i))
|
||||
{
|
||||
gtk_css_parser_warn_syntax (parser, "Variable \"%s\" defined multiple times", declarations[i].name);
|
||||
/* Unset, just to be sure */
|
||||
parsed &= ~(1 << i);
|
||||
if (declarations[i].clear_func)
|
||||
declarations[i].clear_func (declarations[i].result);
|
||||
}
|
||||
if (!declarations[i].parse_func (parser, context, declarations[i].result))
|
||||
{
|
||||
/* nothing to do */
|
||||
|
||||
@@ -689,230 +689,6 @@ gsk_rounded_rect_intersect_with_rect (const GskRoundedRect *self,
|
||||
return GSK_INTERSECTION_NONEMPTY;
|
||||
}
|
||||
|
||||
static inline void
|
||||
rect_corner (const graphene_rect_t *r,
|
||||
unsigned int i,
|
||||
graphene_point_t *p)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case GSK_CORNER_TOP_LEFT:
|
||||
graphene_rect_get_top_left (r, p);
|
||||
break;
|
||||
case GSK_CORNER_TOP_RIGHT:
|
||||
graphene_rect_get_top_right (r, p);
|
||||
break;
|
||||
case GSK_CORNER_BOTTOM_RIGHT:
|
||||
graphene_rect_get_bottom_right (r, p);
|
||||
break;
|
||||
case GSK_CORNER_BOTTOM_LEFT:
|
||||
graphene_rect_get_bottom_left (r, p);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
corner_rect (const GskRoundedRect *s,
|
||||
unsigned int i,
|
||||
graphene_rect_t *r)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case GSK_CORNER_TOP_LEFT:
|
||||
graphene_rect_init (r,
|
||||
s->bounds.origin.x,
|
||||
s->bounds.origin.y,
|
||||
s->corner[i].width,
|
||||
s->corner[i].height);
|
||||
break;
|
||||
case GSK_CORNER_TOP_RIGHT:
|
||||
graphene_rect_init (r,
|
||||
s->bounds.origin.x + s->bounds.size.width - s->corner[i].width,
|
||||
s->bounds.origin.y,
|
||||
s->corner[i].width,
|
||||
s->corner[i].height);
|
||||
break;
|
||||
case GSK_CORNER_BOTTOM_RIGHT:
|
||||
graphene_rect_init (r,
|
||||
s->bounds.origin.x + s->bounds.size.width - s->corner[i].width,
|
||||
s->bounds.origin.y + s->bounds.size.height - s->corner[i].height,
|
||||
s->corner[i].width,
|
||||
s->corner[i].height);
|
||||
break;
|
||||
case GSK_CORNER_BOTTOM_LEFT:
|
||||
graphene_rect_init (r,
|
||||
s->bounds.origin.x,
|
||||
s->bounds.origin.y + s->bounds.size.height - s->corner[i].height,
|
||||
s->corner[i].width,
|
||||
s->corner[i].height);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
point_in_interior (const graphene_point_t *p,
|
||||
const graphene_rect_t *r)
|
||||
{
|
||||
if (graphene_rect_contains_point (r, p))
|
||||
{
|
||||
if (p->x > r->origin.x && p->x < r->origin.x + r->size.width)
|
||||
return TRUE;
|
||||
|
||||
if (p->y > r->origin.y && p->y < r->origin.y + r->size.height)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
GskRoundedRectIntersection
|
||||
gsk_rounded_rect_intersect (const GskRoundedRect *self,
|
||||
const GskRoundedRect *other,
|
||||
GskRoundedRect *result)
|
||||
{
|
||||
if (!graphene_rect_intersection (&self->bounds, &other->bounds, &result->bounds))
|
||||
return GSK_INTERSECTION_EMPTY;
|
||||
|
||||
for (unsigned int i = 0; i < 4; i++)
|
||||
{
|
||||
graphene_point_t p, p1, p2;
|
||||
|
||||
rect_corner (&self->bounds, i, &p1);
|
||||
rect_corner (&other->bounds, i, &p2);
|
||||
rect_corner (&result->bounds, i, &p);
|
||||
|
||||
if (graphene_point_equal (&p, &p1))
|
||||
{
|
||||
if (graphene_point_equal (&p, &p2))
|
||||
{
|
||||
graphene_rect_t c;
|
||||
graphene_rect_t d;
|
||||
|
||||
corner_rect (self, i, &c);
|
||||
corner_rect (other, i, &d);
|
||||
|
||||
/* corners coincide */
|
||||
if (graphene_rect_contains_rect (&c, &d))
|
||||
{
|
||||
graphene_point_t q1, q2;
|
||||
|
||||
rect_corner (&c, (i + 1) % 4, &q1);
|
||||
rect_corner (&c, (i + 3) % 4, &q2);
|
||||
|
||||
if (gsk_rounded_rect_contains_point (other, &q1) &&
|
||||
gsk_rounded_rect_contains_point (other, &q2))
|
||||
result->corner[i] = self->corner[i];
|
||||
else
|
||||
return GSK_INTERSECTION_NOT_REPRESENTABLE;
|
||||
}
|
||||
else if (graphene_rect_contains_rect (&d, &c))
|
||||
{
|
||||
graphene_point_t q1, q2;
|
||||
|
||||
rect_corner (&d, (i + 1) % 4, &q1);
|
||||
rect_corner (&d, (i + 3) % 4, &q2);
|
||||
|
||||
if (gsk_rounded_rect_contains_point (self, &q1) &&
|
||||
gsk_rounded_rect_contains_point (self, &q2))
|
||||
result->corner[i] = other->corner[i];
|
||||
else
|
||||
return GSK_INTERSECTION_NOT_REPRESENTABLE;
|
||||
}
|
||||
else
|
||||
return GSK_INTERSECTION_NOT_REPRESENTABLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
graphene_rect_t c;
|
||||
graphene_point_t q1, q2;
|
||||
|
||||
corner_rect (self, i, &c);
|
||||
|
||||
rect_corner (&c, (i + 1) % 4, &q1);
|
||||
rect_corner (&c, (i + 3) % 4, &q2);
|
||||
|
||||
if (gsk_rounded_rect_contains_point (other, &q1) &&
|
||||
gsk_rounded_rect_contains_point (other, &q2))
|
||||
{
|
||||
if (gsk_rounded_rect_contains_point (other, &p))
|
||||
result->corner[i] = self->corner[i];
|
||||
else
|
||||
#if 1
|
||||
return GSK_INTERSECTION_NEEDS_QUARTIC;
|
||||
#else
|
||||
if (/* no intersection for i */)
|
||||
result->corner[i] = self->corner[i];
|
||||
else
|
||||
return GSK_INTERSECTION_NOT_REPRESENTABLE;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
return GSK_INTERSECTION_NOT_REPRESENTABLE;
|
||||
}
|
||||
}
|
||||
else if (graphene_point_equal (&p, &p2))
|
||||
{
|
||||
graphene_rect_t d;
|
||||
graphene_point_t q1, q2;
|
||||
|
||||
corner_rect (other, i, &d);
|
||||
|
||||
rect_corner (&d, (i + 1) % 4, &q1);
|
||||
rect_corner (&d, (i + 3) % 4, &q2);
|
||||
|
||||
if (gsk_rounded_rect_contains_point (self, &q1) &&
|
||||
gsk_rounded_rect_contains_point (self, &q2))
|
||||
{
|
||||
if (gsk_rounded_rect_contains_point (self, &p))
|
||||
result->corner[i] = other->corner[i];
|
||||
else
|
||||
#if 1
|
||||
return GSK_INTERSECTION_NEEDS_QUARTIC;
|
||||
#else
|
||||
if (/* no intersection for i */
|
||||
result->corner[i] = other->corner[i];
|
||||
else
|
||||
return GSK_INTERSECTION_NOT_REPRESENTABLE;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
return GSK_INTERSECTION_NOT_REPRESENTABLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
graphene_rect_t c, d;
|
||||
|
||||
corner_rect (self, (i + 2) % 4, &c);
|
||||
if (graphene_rect_contains_point (&c, &p) &&
|
||||
!gsk_rounded_rect_contains_point (self, &p))
|
||||
return GSK_INTERSECTION_EMPTY;
|
||||
|
||||
corner_rect (other, (i + 2) % 4, &d);
|
||||
if (graphene_rect_contains_point (&d, &p) &&
|
||||
!gsk_rounded_rect_contains_point (other, &p))
|
||||
return GSK_INTERSECTION_EMPTY;
|
||||
|
||||
for (unsigned int j = 0; j < 4; j++)
|
||||
{
|
||||
corner_rect (self, j, &c);
|
||||
corner_rect (other, j, &d);
|
||||
|
||||
if (point_in_interior (&p, &c) ||
|
||||
point_in_interior (&p, &d))
|
||||
return GSK_INTERSECTION_NOT_REPRESENTABLE;
|
||||
}
|
||||
|
||||
result->corner[i] = (graphene_size_t) { 0, 0 };
|
||||
}
|
||||
}
|
||||
|
||||
return GSK_INTERSECTION_NONEMPTY;
|
||||
}
|
||||
|
||||
static void
|
||||
append_arc (cairo_t *cr, double angle1, double angle2, gboolean negative)
|
||||
{
|
||||
|
||||
@@ -37,17 +37,13 @@ char * gsk_rounded_rect_to_string (const GskRounde
|
||||
typedef enum {
|
||||
GSK_INTERSECTION_EMPTY,
|
||||
GSK_INTERSECTION_NONEMPTY,
|
||||
GSK_INTERSECTION_NOT_REPRESENTABLE,
|
||||
GSK_INTERSECTION_NEEDS_QUARTIC
|
||||
GSK_INTERSECTION_NOT_REPRESENTABLE
|
||||
} GskRoundedRectIntersection;
|
||||
|
||||
GskRoundedRectIntersection gsk_rounded_rect_intersect_with_rect (const GskRoundedRect *self,
|
||||
const graphene_rect_t *rect,
|
||||
GskRoundedRect *result) G_GNUC_PURE;
|
||||
|
||||
GskRoundedRectIntersection gsk_rounded_rect_intersect (const GskRoundedRect *self,
|
||||
const GskRoundedRect *other,
|
||||
GskRoundedRect *result) G_GNUC_PURE;
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ gsk_vulkan_clip_intersect_rounded_rect (GskVulkanClip *dest,
|
||||
break;
|
||||
|
||||
case GSK_VULKAN_CLIP_NONE:
|
||||
dest->type = gsk_rounded_rect_is_circular (&dest->rect) ? GSK_VULKAN_CLIP_ROUNDED_CIRCULAR : GSK_VULKAN_CLIP_ROUNDED;
|
||||
dest->type = gsk_rounded_rect_is_circular (rounded) ? GSK_VULKAN_CLIP_ROUNDED_CIRCULAR : GSK_VULKAN_CLIP_ROUNDED;
|
||||
gsk_rounded_rect_init_copy (&dest->rect, rounded);
|
||||
break;
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ gsk_vulkan_render_pass_new (GdkVulkanContext *context,
|
||||
graphene_matrix_init_ortho (&self->p,
|
||||
viewport->origin.x, viewport->origin.x + viewport->size.width,
|
||||
viewport->origin.y, viewport->origin.y + viewport->size.height,
|
||||
ORTHO_NEAR_PLANE,
|
||||
2 * ORTHO_NEAR_PLANE - ORTHO_FAR_PLANE,
|
||||
ORTHO_FAR_PLANE);
|
||||
|
||||
if (signal_semaphore != VK_NULL_HANDLE) // this is a dependent pass
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
# FIXME: what's up with these?
|
||||
#gsk_private_vulkan_include_shaders = [
|
||||
# 'clip.frag.glsl',
|
||||
# 'clip.vert.glsl',
|
||||
# 'constants.glsl',
|
||||
# 'rounded-rect.glsl',
|
||||
#]
|
||||
gsk_private_vulkan_include_shaders = [
|
||||
'clip.frag.glsl',
|
||||
'clip.vert.glsl',
|
||||
'constants.glsl',
|
||||
'rounded-rect.glsl',
|
||||
]
|
||||
|
||||
gsk_private_vulkan_fragment_shaders = [
|
||||
'blendmode.frag',
|
||||
@@ -51,6 +50,7 @@ foreach shader: gsk_private_vulkan_shaders
|
||||
compiled_shader = custom_target(spv_shader,
|
||||
input: shader,
|
||||
output: spv_shader,
|
||||
depend_files: gsk_private_vulkan_include_shaders,
|
||||
command: [
|
||||
glslc,
|
||||
stage_arg,
|
||||
@@ -61,6 +61,7 @@ foreach shader: gsk_private_vulkan_shaders
|
||||
compiled_clip_shader = custom_target(clip_spv_shader,
|
||||
input: shader,
|
||||
output: clip_spv_shader,
|
||||
depend_files: gsk_private_vulkan_include_shaders,
|
||||
command: [
|
||||
glslc,
|
||||
stage_arg,
|
||||
@@ -71,6 +72,7 @@ foreach shader: gsk_private_vulkan_shaders
|
||||
compiled_clip_rounded_shader = custom_target(clip_rounded_spv_shader,
|
||||
input: shader,
|
||||
output: clip_rounded_spv_shader,
|
||||
depend_files: gsk_private_vulkan_include_shaders,
|
||||
command: [
|
||||
glslc,
|
||||
stage_arg,
|
||||
|
||||
@@ -31,6 +31,7 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
typedef struct {
|
||||
GtkWindow *parent;
|
||||
char *handle;
|
||||
GAppLaunchContext *context;
|
||||
char *uri;
|
||||
GTask *task;
|
||||
@@ -39,9 +40,10 @@ typedef struct {
|
||||
static void
|
||||
gtk_show_uri_data_free (GtkShowUriData *data)
|
||||
{
|
||||
if (data->parent)
|
||||
gtk_window_unexport_handle (data->parent);
|
||||
if (data->parent && data->handle)
|
||||
gtk_window_unexport_handle (data->parent, data->handle);
|
||||
g_clear_object (&data->parent);
|
||||
g_free (data->handle);
|
||||
g_clear_object (&data->context);
|
||||
g_free (data->uri);
|
||||
g_clear_object (&data->task);
|
||||
@@ -72,7 +74,10 @@ window_handle_exported (GtkWindow *window,
|
||||
GtkShowUriData *data = user_data;
|
||||
|
||||
if (handle)
|
||||
g_app_launch_context_setenv (data->context, "PARENT_WINDOW_ID", handle);
|
||||
{
|
||||
g_app_launch_context_setenv (data->context, "PARENT_WINDOW_ID", handle);
|
||||
data->handle = g_strdup (handle);
|
||||
}
|
||||
|
||||
g_app_info_launch_default_for_uri_async (data->uri,
|
||||
data->context,
|
||||
|
||||
@@ -17,11 +17,13 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
#include "gdkpixbufutilsprivate.h"
|
||||
#include "gdktextureutilsprivate.h"
|
||||
#include "gtkscalerprivate.h"
|
||||
|
||||
#include "gdk/gdktextureprivate.h"
|
||||
|
||||
/* {{{ Pixbuf helpers */
|
||||
|
||||
static GdkPixbuf *
|
||||
load_from_stream (GdkPixbufLoader *loader,
|
||||
GInputStream *stream,
|
||||
@@ -91,7 +93,7 @@ size_prepared_cb (GdkPixbufLoader *loader,
|
||||
* load the image at its original size times the
|
||||
* given scale.
|
||||
*/
|
||||
GdkPixbuf *
|
||||
static GdkPixbuf *
|
||||
_gdk_pixbuf_new_from_stream_scaled (GInputStream *stream,
|
||||
double scale,
|
||||
GCancellable *cancellable,
|
||||
@@ -145,7 +147,7 @@ size_prepared_cb2 (GdkPixbufLoader *loader,
|
||||
gdk_pixbuf_loader_set_size (loader, width, height);
|
||||
}
|
||||
|
||||
GdkPixbuf *
|
||||
static GdkPixbuf *
|
||||
_gdk_pixbuf_new_from_stream_at_scale (GInputStream *stream,
|
||||
int width,
|
||||
int height,
|
||||
@@ -172,44 +174,7 @@ _gdk_pixbuf_new_from_stream_at_scale (GInputStream *stream,
|
||||
return pixbuf;
|
||||
}
|
||||
|
||||
GdkPixbuf *
|
||||
_gdk_pixbuf_new_from_stream (GInputStream *stream,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
return _gdk_pixbuf_new_from_stream_scaled (stream, 0, cancellable, error);
|
||||
}
|
||||
|
||||
/* Like gdk_pixbuf_new_from_resource_at_scale, but
|
||||
* load the image at its original size times the
|
||||
* given scale.
|
||||
*/
|
||||
GdkPixbuf *
|
||||
_gdk_pixbuf_new_from_resource_scaled (const char *resource_path,
|
||||
double scale,
|
||||
GError **error)
|
||||
{
|
||||
GInputStream *stream;
|
||||
GdkPixbuf *pixbuf;
|
||||
|
||||
stream = g_resources_open_stream (resource_path, 0, error);
|
||||
if (stream == NULL)
|
||||
return NULL;
|
||||
|
||||
pixbuf = _gdk_pixbuf_new_from_stream_scaled (stream, scale, NULL, error);
|
||||
g_object_unref (stream);
|
||||
|
||||
return pixbuf;
|
||||
}
|
||||
|
||||
GdkPixbuf *
|
||||
_gdk_pixbuf_new_from_resource (const char *resource_path,
|
||||
GError **error)
|
||||
{
|
||||
return _gdk_pixbuf_new_from_resource_scaled (resource_path, 0, error);
|
||||
}
|
||||
|
||||
GdkPixbuf *
|
||||
static GdkPixbuf *
|
||||
_gdk_pixbuf_new_from_resource_at_scale (const char *resource_path,
|
||||
int width,
|
||||
int height,
|
||||
@@ -227,9 +192,11 @@ _gdk_pixbuf_new_from_resource_at_scale (const char *resource_path,
|
||||
g_object_unref (stream);
|
||||
|
||||
return pixbuf;
|
||||
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Symbolic processing */
|
||||
|
||||
static GdkPixbuf *
|
||||
load_symbolic_svg (const char *escaped_file_data,
|
||||
int width,
|
||||
@@ -335,19 +302,17 @@ gtk_make_symbolic_pixbuf_from_data (const char *file_data,
|
||||
char *escaped_file_data;
|
||||
|
||||
/* Fetch size from the original icon */
|
||||
{
|
||||
GInputStream *stream = g_memory_input_stream_new_from_data (file_data, file_len, NULL);
|
||||
GdkPixbuf *reference = gdk_pixbuf_new_from_stream (stream, NULL, error);
|
||||
GInputStream *stream = g_memory_input_stream_new_from_data (file_data, file_len, NULL);
|
||||
GdkPixbuf *reference = gdk_pixbuf_new_from_stream (stream, NULL, error);
|
||||
|
||||
g_object_unref (stream);
|
||||
g_object_unref (stream);
|
||||
|
||||
if (!reference)
|
||||
return NULL;
|
||||
if (!reference)
|
||||
return NULL;
|
||||
|
||||
icon_width = gdk_pixbuf_get_width (reference);
|
||||
icon_height = gdk_pixbuf_get_height (reference);
|
||||
g_object_unref (reference);
|
||||
}
|
||||
icon_width = gdk_pixbuf_get_width (reference);
|
||||
icon_height = gdk_pixbuf_get_height (reference);
|
||||
g_object_unref (reference);
|
||||
|
||||
escaped_file_data = g_base64_encode ((guchar *) file_data, file_len);
|
||||
icon_width_str = g_strdup_printf ("%d", icon_width);
|
||||
@@ -418,12 +383,12 @@ out:
|
||||
return pixbuf;
|
||||
}
|
||||
|
||||
GdkPixbuf *
|
||||
gtk_make_symbolic_pixbuf_from_resource (const char *path,
|
||||
int width,
|
||||
int height,
|
||||
double scale,
|
||||
GError **error)
|
||||
static GdkPixbuf *
|
||||
make_symbolic_pixbuf_from_resource (const char *path,
|
||||
int width,
|
||||
int height,
|
||||
double scale,
|
||||
GError **error)
|
||||
{
|
||||
GBytes *bytes;
|
||||
const char *data;
|
||||
@@ -443,12 +408,12 @@ gtk_make_symbolic_pixbuf_from_resource (const char *path,
|
||||
return pixbuf;
|
||||
}
|
||||
|
||||
GdkPixbuf *
|
||||
gtk_make_symbolic_pixbuf_from_path (const char *path,
|
||||
int width,
|
||||
int height,
|
||||
double scale,
|
||||
GError **error)
|
||||
static GdkPixbuf *
|
||||
make_symbolic_pixbuf_from_path (const char *path,
|
||||
int width,
|
||||
int height,
|
||||
double scale,
|
||||
GError **error)
|
||||
{
|
||||
char *data;
|
||||
gsize size;
|
||||
@@ -464,12 +429,12 @@ gtk_make_symbolic_pixbuf_from_path (const char *path,
|
||||
return pixbuf;
|
||||
}
|
||||
|
||||
GdkPixbuf *
|
||||
gtk_make_symbolic_pixbuf_from_file (GFile *file,
|
||||
int width,
|
||||
int height,
|
||||
double scale,
|
||||
GError **error)
|
||||
static GdkPixbuf *
|
||||
make_symbolic_pixbuf_from_file (GFile *file,
|
||||
int width,
|
||||
int height,
|
||||
double scale,
|
||||
GError **error)
|
||||
{
|
||||
char *data;
|
||||
gsize size;
|
||||
@@ -485,6 +450,91 @@ gtk_make_symbolic_pixbuf_from_file (GFile *file,
|
||||
return pixbuf;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Texture API */
|
||||
|
||||
GdkTexture *
|
||||
gdk_texture_new_from_stream_at_scale (GInputStream *stream,
|
||||
int width,
|
||||
int height,
|
||||
gboolean aspect,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
GdkTexture *texture = NULL;
|
||||
|
||||
pixbuf = _gdk_pixbuf_new_from_stream_at_scale (stream, width, height, aspect, cancellable, error);
|
||||
if (pixbuf)
|
||||
{
|
||||
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
||||
g_object_unref (pixbuf);
|
||||
}
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
GdkTexture *
|
||||
gdk_texture_new_from_stream (GInputStream *stream,
|
||||
GCancellable *cancellable,
|
||||
GError **error)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
GdkTexture *texture = NULL;
|
||||
|
||||
pixbuf = _gdk_pixbuf_new_from_stream_scaled (stream, 0, cancellable, error);
|
||||
if (pixbuf)
|
||||
{
|
||||
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
||||
g_object_unref (pixbuf);
|
||||
}
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
GdkTexture *
|
||||
gdk_texture_new_from_resource_at_scale (const char *path,
|
||||
int width,
|
||||
int height,
|
||||
gboolean preserve_aspect,
|
||||
GError **error)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
GdkTexture *texture = NULL;
|
||||
|
||||
pixbuf = _gdk_pixbuf_new_from_resource_at_scale (path, width, height, preserve_aspect, error);
|
||||
if (pixbuf)
|
||||
{
|
||||
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
||||
g_object_unref (pixbuf);
|
||||
}
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Symbolic texture API */
|
||||
|
||||
GdkTexture *
|
||||
gdk_texture_new_from_path_symbolic (const char *path,
|
||||
int width,
|
||||
int height,
|
||||
double scale,
|
||||
GError **error)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
GdkTexture *texture = NULL;
|
||||
|
||||
pixbuf = make_symbolic_pixbuf_from_path (path, width, height, scale, error);
|
||||
if (pixbuf)
|
||||
{
|
||||
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
||||
g_object_unref (pixbuf);
|
||||
}
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
GdkTexture *
|
||||
gtk_load_symbolic_texture_from_resource (const char *path)
|
||||
{
|
||||
@@ -492,16 +542,16 @@ gtk_load_symbolic_texture_from_resource (const char *path)
|
||||
}
|
||||
|
||||
GdkTexture *
|
||||
gtk_make_symbolic_texture_from_resource (const char *path,
|
||||
int width,
|
||||
int height,
|
||||
double scale,
|
||||
GError **error)
|
||||
gdk_texture_new_from_resource_symbolic (const char *path,
|
||||
int width,
|
||||
int height,
|
||||
double scale,
|
||||
GError **error)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
GdkTexture *texture = NULL;
|
||||
|
||||
pixbuf = gtk_make_symbolic_pixbuf_from_resource (path, width, height, scale, error);
|
||||
pixbuf = make_symbolic_pixbuf_from_resource (path, width, height, scale, error);
|
||||
if (pixbuf)
|
||||
{
|
||||
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
||||
@@ -522,7 +572,7 @@ gtk_load_symbolic_texture_from_file (GFile *file)
|
||||
if (stream == NULL)
|
||||
return NULL;
|
||||
|
||||
pixbuf = _gdk_pixbuf_new_from_stream (stream, NULL, NULL);
|
||||
pixbuf = gdk_pixbuf_new_from_stream (stream, NULL, NULL);
|
||||
g_object_unref (stream);
|
||||
if (pixbuf == NULL)
|
||||
return NULL;
|
||||
@@ -534,22 +584,25 @@ gtk_load_symbolic_texture_from_file (GFile *file)
|
||||
}
|
||||
|
||||
GdkTexture *
|
||||
gtk_make_symbolic_texture_from_file (GFile *file,
|
||||
int width,
|
||||
int height,
|
||||
double scale,
|
||||
GError **error)
|
||||
gdk_texture_new_from_file_symbolic (GFile *file,
|
||||
int width,
|
||||
int height,
|
||||
double scale,
|
||||
GError **error)
|
||||
{
|
||||
GdkPixbuf *pixbuf;
|
||||
GdkTexture *texture;
|
||||
|
||||
pixbuf = gtk_make_symbolic_pixbuf_from_file (file, width, height, scale, error);
|
||||
pixbuf = make_symbolic_pixbuf_from_file (file, width, height, scale, error);
|
||||
texture = gdk_texture_new_for_pixbuf (pixbuf);
|
||||
g_object_unref (pixbuf);
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
/* {{{ Scaled paintable API */
|
||||
|
||||
typedef struct {
|
||||
int scale_factor;
|
||||
} LoaderData;
|
||||
@@ -576,7 +629,7 @@ on_loader_size_prepared (GdkPixbufLoader *loader,
|
||||
height * loader_data->scale_factor);
|
||||
}
|
||||
|
||||
GdkPaintable *
|
||||
static GdkPaintable *
|
||||
gdk_paintable_new_from_bytes_scaled (GBytes *bytes,
|
||||
int scale_factor)
|
||||
{
|
||||
@@ -680,3 +733,7 @@ gdk_paintable_new_from_file_scaled (GFile *file,
|
||||
|
||||
return paintable;
|
||||
}
|
||||
|
||||
/* }}} */
|
||||
|
||||
/* vim:set foldmethod=marker expandtab: */
|
||||
@@ -21,30 +21,6 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GdkPixbuf *_gdk_pixbuf_new_from_stream (GInputStream *stream,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
GdkPixbuf *_gdk_pixbuf_new_from_stream_at_scale (GInputStream *stream,
|
||||
int width,
|
||||
int height,
|
||||
gboolean aspect,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
GdkPixbuf *_gdk_pixbuf_new_from_stream_scaled (GInputStream *stream,
|
||||
double scale,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
GdkPixbuf *_gdk_pixbuf_new_from_resource (const char *resource_path,
|
||||
GError **error);
|
||||
GdkPixbuf *_gdk_pixbuf_new_from_resource_at_scale (const char *resource_path,
|
||||
int width,
|
||||
int height,
|
||||
gboolean preserve_aspect,
|
||||
GError **error);
|
||||
GdkPixbuf *_gdk_pixbuf_new_from_resource_scaled (const char *resource_path,
|
||||
double scale,
|
||||
GError **error);
|
||||
|
||||
GdkPixbuf *gtk_make_symbolic_pixbuf_from_data (const char *data,
|
||||
gsize len,
|
||||
int width,
|
||||
@@ -52,36 +28,41 @@ GdkPixbuf *gtk_make_symbolic_pixbuf_from_data (const char *data,
|
||||
double scale,
|
||||
const char *debug_output_to,
|
||||
GError **error);
|
||||
GdkPixbuf *gtk_make_symbolic_pixbuf_from_file (GFile *file,
|
||||
|
||||
GdkTexture *gdk_texture_new_from_stream (GInputStream *stream,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
GdkTexture *gdk_texture_new_from_stream_at_scale (GInputStream *stream,
|
||||
int width,
|
||||
int height,
|
||||
gboolean aspect,
|
||||
GCancellable *cancellable,
|
||||
GError **error);
|
||||
GdkTexture *gdk_texture_new_from_resource_at_scale (const char *path,
|
||||
int width,
|
||||
int height,
|
||||
gboolean aspect,
|
||||
GError **error);
|
||||
|
||||
GdkTexture *gdk_texture_new_from_path_symbolic (const char *path,
|
||||
int width,
|
||||
int height,
|
||||
double scale,
|
||||
GError **error);
|
||||
GdkPixbuf *gtk_make_symbolic_pixbuf_from_path (const char *path,
|
||||
GdkTexture *gdk_texture_new_from_file_symbolic (GFile *file,
|
||||
int width,
|
||||
int height,
|
||||
double scale,
|
||||
GError **error);
|
||||
GdkPixbuf *gtk_make_symbolic_pixbuf_from_resource (const char *path,
|
||||
int width,
|
||||
int height,
|
||||
double scale,
|
||||
GError **error);
|
||||
GdkTexture *gtk_load_symbolic_texture_from_file (GFile *file);
|
||||
GdkTexture *gtk_make_symbolic_texture_from_file (GFile *file,
|
||||
int width,
|
||||
int height,
|
||||
double scale,
|
||||
GError **error);
|
||||
GdkTexture *gtk_load_symbolic_texture_from_resource (const char *data);
|
||||
GdkTexture *gtk_make_symbolic_texture_from_resource (const char *path,
|
||||
GdkTexture *gdk_texture_new_from_resource_symbolic (const char *path,
|
||||
int width,
|
||||
int height,
|
||||
double scale,
|
||||
GError **error);
|
||||
|
||||
GdkPaintable *gdk_paintable_new_from_bytes_scaled (GBytes *bytes,
|
||||
int scale_factor);
|
||||
GdkTexture *gtk_load_symbolic_texture_from_file (GFile *file);
|
||||
GdkTexture *gtk_load_symbolic_texture_from_resource (const char *data);
|
||||
|
||||
GdkPaintable *gdk_paintable_new_from_path_scaled (const char *path,
|
||||
int scale_factor);
|
||||
GdkPaintable *gdk_paintable_new_from_resource_scaled (const char *path,
|
||||
@@ -90,4 +71,3 @@ GdkPaintable *gdk_paintable_new_from_file_scaled (GFile *file,
|
||||
int scale_factor);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "gtkcssimageprivate.h"
|
||||
#include "gtkcsspalettevalueprivate.h"
|
||||
#include "gtkcsscolorvalueprivate.h"
|
||||
#include "gdkpixbufutilsprivate.h"
|
||||
#include "gdktextureutilsprivate.h"
|
||||
|
||||
#include "gtkstyleproviderprivate.h"
|
||||
|
||||
@@ -110,7 +110,7 @@ gtk_css_image_recolor_load_texture (GtkCssImageRecolor *recolor,
|
||||
if (g_str_has_suffix (uri, ".symbolic.png"))
|
||||
recolor->texture = gtk_load_symbolic_texture_from_resource (resource_path);
|
||||
else
|
||||
recolor->texture = gtk_make_symbolic_texture_from_resource (resource_path, 0, 0, 1.0, NULL);
|
||||
recolor->texture = gdk_texture_new_from_resource_symbolic (resource_path, 0, 0, 1.0, NULL);
|
||||
|
||||
g_free (resource_path);
|
||||
}
|
||||
@@ -119,7 +119,7 @@ gtk_css_image_recolor_load_texture (GtkCssImageRecolor *recolor,
|
||||
if (g_str_has_suffix (uri, ".symbolic.png"))
|
||||
recolor->texture = gtk_load_symbolic_texture_from_file (recolor->file);
|
||||
else
|
||||
recolor->texture = gtk_make_symbolic_texture_from_file (recolor->file, 0, 0, 1.0, NULL);
|
||||
recolor->texture = gdk_texture_new_from_file_symbolic (recolor->file, 0, 0, 1.0, NULL);
|
||||
}
|
||||
|
||||
g_free (uri);
|
||||
|
||||
+1
-15
@@ -47,21 +47,7 @@ gtk_css_image_url_load_image (GtkCssImageUrl *url,
|
||||
return url->loaded_image;
|
||||
}
|
||||
|
||||
/* We special case resources here so we can use gdk_texture_new_from_resource. */
|
||||
if (g_file_has_uri_scheme (url->file, "resource"))
|
||||
{
|
||||
char *uri = g_file_get_uri (url->file);
|
||||
char *resource_path = g_uri_unescape_string (uri + strlen ("resource://"), NULL);
|
||||
|
||||
texture = gdk_texture_new_from_resource (resource_path);
|
||||
|
||||
g_free (resource_path);
|
||||
g_free (uri);
|
||||
}
|
||||
else
|
||||
{
|
||||
texture = gdk_texture_new_from_file (url->file, &local_error);
|
||||
}
|
||||
texture = gdk_texture_new_from_file (url->file, &local_error);
|
||||
|
||||
if (texture == NULL)
|
||||
{
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include "gtkborder.h"
|
||||
#include "gtktypes.h"
|
||||
#include "gtkcssvalueprivate.h"
|
||||
#include "gtkroundedboxprivate.h"
|
||||
#include "gtksnapshot.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
@@ -52,6 +52,7 @@ typedef struct {
|
||||
|
||||
const char *method_name;
|
||||
|
||||
char *exported_handle;
|
||||
GtkWindow *exported_window;
|
||||
PortalErrorHandler error_handler;
|
||||
} FilechooserPortalData;
|
||||
@@ -79,7 +80,11 @@ filechooser_portal_data_clear (FilechooserPortalData *data)
|
||||
|
||||
if (data->exported_window)
|
||||
{
|
||||
gtk_window_unexport_handle (data->exported_window);
|
||||
if (data->exported_handle)
|
||||
{
|
||||
gtk_window_unexport_handle (data->exported_window, data->exported_handle);
|
||||
g_clear_pointer (&data->exported_handle, g_free);
|
||||
}
|
||||
g_clear_object (&data->exported_window);
|
||||
}
|
||||
|
||||
@@ -460,6 +465,7 @@ window_handle_exported (GtkWindow *window,
|
||||
gtk_grab_add (GTK_WIDGET (data->grab_widget));
|
||||
}
|
||||
|
||||
data->exported_handle = g_strdup (handle_str);
|
||||
show_portal_file_chooser (self, handle_str);
|
||||
}
|
||||
|
||||
|
||||
@@ -580,7 +580,10 @@ gtk_file_chooser_widget_finalize (GObject *object)
|
||||
stop_loading_and_clear_list_model (impl, FALSE);
|
||||
search_clear_model (impl, FALSE);
|
||||
recent_clear_model (impl, FALSE);
|
||||
g_clear_object (&impl->recent_model);
|
||||
g_clear_object (&impl->search_model);
|
||||
g_clear_object (&impl->model_for_search);
|
||||
g_clear_object (&impl->browse_files_model);
|
||||
|
||||
g_clear_object (&impl->selection_model);
|
||||
g_clear_object (&impl->sort_model);
|
||||
@@ -3961,6 +3964,7 @@ set_list_model (GtkFileChooserWidget *impl,
|
||||
|
||||
set_busy_cursor (impl, TRUE);
|
||||
|
||||
g_clear_object (&impl->browse_files_model);
|
||||
impl->browse_files_model =
|
||||
_gtk_file_system_model_new_for_directory (impl->current_folder, MODEL_ATTRIBUTES);
|
||||
|
||||
|
||||
@@ -747,7 +747,9 @@ gtk_file_system_model_monitor_change (GFileMonitor * monitor,
|
||||
case G_FILE_MONITOR_EVENT_CREATED:
|
||||
case G_FILE_MONITOR_EVENT_CHANGED:
|
||||
case G_FILE_MONITOR_EVENT_ATTRIBUTE_CHANGED:
|
||||
/* We can treat all of these the same way */
|
||||
if (g_file_equal (file, model->dir))
|
||||
return;
|
||||
/* We can treat all children the same way */
|
||||
g_file_query_info_async (file,
|
||||
model->attributes,
|
||||
G_FILE_QUERY_INFO_NONE,
|
||||
|
||||
+4
-3
@@ -553,7 +553,8 @@ static int
|
||||
gtk_grid_view_get_unknown_row_size (GtkGridView *self,
|
||||
GArray *heights)
|
||||
{
|
||||
g_return_val_if_fail (heights->len > 0, 0);
|
||||
if (heights->len == 0)
|
||||
return 0;
|
||||
|
||||
/* return the median and hope rows are generally uniform with few outliers */
|
||||
g_array_sort (heights, compare_ints);
|
||||
@@ -657,7 +658,7 @@ gtk_grid_view_measure_list (GtkWidget *widget,
|
||||
gtk_grid_view_measure_column_size (self, &col_min, &col_nat);
|
||||
for_size = MAX (for_size, col_min * (int) self->min_columns);
|
||||
n_columns = gtk_grid_view_compute_n_columns (self, for_size, xspacing, col_min, col_nat);
|
||||
column_size = for_size / n_columns;
|
||||
column_size = (for_size + xspacing) / n_columns - xspacing;
|
||||
|
||||
i = 0;
|
||||
row_height = 0;
|
||||
@@ -770,7 +771,7 @@ gtk_grid_view_size_allocate (GtkWidget *widget,
|
||||
orientation == GTK_ORIENTATION_VERTICAL ? width : height,
|
||||
xspacing,
|
||||
col_min, col_nat);
|
||||
self->column_width = (orientation == GTK_ORIENTATION_VERTICAL ? width : height) / self->n_columns;
|
||||
self->column_width = ((orientation == GTK_ORIENTATION_VERTICAL ? width : height) + xspacing) / self->n_columns - xspacing;
|
||||
self->column_width = MAX (self->column_width, col_min);
|
||||
|
||||
/* step 2: determine height of known rows */
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include <glib.h>
|
||||
#include <gdk-pixbuf/gdk-pixdata.h>
|
||||
|
||||
#if defined(G_ENABLE_DEBUG) || defined(BUILD_TOOLS)
|
||||
|
||||
#define VERBOSE(x)
|
||||
|
||||
@@ -401,3 +402,4 @@ gtk_icon_cache_validate (CacheInfo *info)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
+14
-40
@@ -51,7 +51,7 @@
|
||||
#include "gtkstyleproviderprivate.h"
|
||||
#include "gtksymbolicpaintable.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gdkpixbufutilsprivate.h"
|
||||
#include "gdktextureutilsprivate.h"
|
||||
#include "gdk/gdktextureprivate.h"
|
||||
#include "gdk/gdkprofilerprivate.h"
|
||||
|
||||
@@ -3747,22 +3747,15 @@ icon_ensure_texture__locked (GtkIconPaintable *icon,
|
||||
{
|
||||
if (icon->is_svg)
|
||||
{
|
||||
GdkPixbuf *source_pixbuf;
|
||||
|
||||
if (gtk_icon_paintable_is_symbolic (icon))
|
||||
source_pixbuf = gtk_make_symbolic_pixbuf_from_resource (icon->filename,
|
||||
icon->texture = gdk_texture_new_from_resource_symbolic (icon->filename,
|
||||
pixel_size, pixel_size,
|
||||
icon->desired_scale,
|
||||
&load_error);
|
||||
else
|
||||
source_pixbuf = _gdk_pixbuf_new_from_resource_at_scale (icon->filename,
|
||||
icon->texture = gdk_texture_new_from_resource_at_scale (icon->filename,
|
||||
pixel_size, pixel_size,
|
||||
TRUE, &load_error);
|
||||
if (source_pixbuf)
|
||||
{
|
||||
icon->texture = gdk_texture_new_for_pixbuf (source_pixbuf);
|
||||
g_object_unref (source_pixbuf);
|
||||
}
|
||||
}
|
||||
else
|
||||
icon->texture = gdk_texture_new_from_resource (icon->filename);
|
||||
@@ -3771,10 +3764,8 @@ icon_ensure_texture__locked (GtkIconPaintable *icon,
|
||||
{
|
||||
if (icon->is_svg)
|
||||
{
|
||||
GdkPixbuf *source_pixbuf;
|
||||
|
||||
if (gtk_icon_paintable_is_symbolic (icon))
|
||||
source_pixbuf = gtk_make_symbolic_pixbuf_from_path (icon->filename,
|
||||
icon->texture = gdk_texture_new_from_path_symbolic (icon->filename,
|
||||
pixel_size, pixel_size,
|
||||
icon->desired_scale,
|
||||
&load_error);
|
||||
@@ -3783,22 +3774,16 @@ icon_ensure_texture__locked (GtkIconPaintable *icon,
|
||||
GFile *file = g_file_new_for_path (icon->filename);
|
||||
GInputStream *stream = G_INPUT_STREAM (g_file_read (file, NULL, &load_error));
|
||||
|
||||
g_object_unref (file);
|
||||
if (stream)
|
||||
{
|
||||
source_pixbuf = _gdk_pixbuf_new_from_stream_at_scale (stream,
|
||||
icon->texture = gdk_texture_new_from_stream_at_scale (stream,
|
||||
pixel_size, pixel_size,
|
||||
TRUE, NULL,
|
||||
&load_error);
|
||||
g_object_unref (stream);
|
||||
}
|
||||
else
|
||||
source_pixbuf = NULL;
|
||||
}
|
||||
if (source_pixbuf)
|
||||
{
|
||||
icon->texture = gdk_texture_new_for_pixbuf (source_pixbuf);
|
||||
g_object_unref (source_pixbuf);
|
||||
|
||||
g_object_unref (file);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -3809,35 +3794,24 @@ icon_ensure_texture__locked (GtkIconPaintable *icon,
|
||||
else
|
||||
{
|
||||
GInputStream *stream;
|
||||
GdkPixbuf *source_pixbuf;
|
||||
|
||||
g_assert (icon->loadable);
|
||||
|
||||
stream = g_loadable_icon_load (icon->loadable,
|
||||
pixel_size,
|
||||
NULL, NULL,
|
||||
&load_error);
|
||||
stream = g_loadable_icon_load (icon->loadable, pixel_size, NULL, NULL, &load_error);
|
||||
if (stream)
|
||||
{
|
||||
/* SVG icons are a special case - we just immediately scale them
|
||||
* to the desired size
|
||||
*/
|
||||
if (icon->is_svg)
|
||||
{
|
||||
source_pixbuf = _gdk_pixbuf_new_from_stream_at_scale (stream,
|
||||
pixel_size, pixel_size,
|
||||
TRUE, NULL,
|
||||
&load_error);
|
||||
}
|
||||
icon->texture = gdk_texture_new_from_stream_at_scale (stream,
|
||||
pixel_size, pixel_size,
|
||||
TRUE, NULL,
|
||||
&load_error);
|
||||
else
|
||||
source_pixbuf = _gdk_pixbuf_new_from_stream (stream,
|
||||
NULL, &load_error);
|
||||
icon->texture = gdk_texture_new_from_stream (stream, NULL, &load_error);
|
||||
|
||||
g_object_unref (stream);
|
||||
if (source_pixbuf)
|
||||
{
|
||||
icon->texture = gdk_texture_new_for_pixbuf (source_pixbuf);
|
||||
g_object_unref (source_pixbuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+8
-1
@@ -31,7 +31,7 @@
|
||||
#include "gtksnapshot.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gdkpixbufutilsprivate.h"
|
||||
#include "gdktextureutilsprivate.h"
|
||||
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
@@ -475,6 +475,9 @@ gtk_image_new_from_resource (const char *resource_path)
|
||||
* want that, you should use [ctor@Gtk.Image.new_from_icon_name].
|
||||
*
|
||||
* Returns: a new `GtkImage`
|
||||
*
|
||||
* Deprecated: 4.12: Use [ctor@Gtk.Image.new_from_paintable] and
|
||||
* [ctor@Gdk.Texture.new_for_pixbuf] instead
|
||||
*/
|
||||
GtkWidget*
|
||||
gtk_image_new_from_pixbuf (GdkPixbuf *pixbuf)
|
||||
@@ -483,7 +486,9 @@ gtk_image_new_from_pixbuf (GdkPixbuf *pixbuf)
|
||||
|
||||
image = g_object_new (GTK_TYPE_IMAGE, NULL);
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
gtk_image_set_from_pixbuf (image, pixbuf);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
||||
return GTK_WIDGET (image);
|
||||
}
|
||||
@@ -711,6 +716,8 @@ gtk_image_set_from_resource (GtkImage *image,
|
||||
* Note: This is a helper for [method@Gtk.Image.set_from_paintable],
|
||||
* and you can't get back the exact pixbuf once this is called,
|
||||
* only a paintable.
|
||||
*
|
||||
* Deprecated: 4.12: Use [method@Gtk.Image.set_from_paintable] instead
|
||||
*/
|
||||
void
|
||||
gtk_image_set_from_pixbuf (GtkImage *image,
|
||||
|
||||
+2
-2
@@ -74,7 +74,7 @@ GDK_AVAILABLE_IN_ALL
|
||||
GtkWidget* gtk_image_new_from_file (const char *filename);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkWidget* gtk_image_new_from_resource (const char *resource_path);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_12_FOR(gtk_image_new_from_paintable)
|
||||
GtkWidget* gtk_image_new_from_pixbuf (GdkPixbuf *pixbuf);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkWidget* gtk_image_new_from_paintable (GdkPaintable *paintable);
|
||||
@@ -91,7 +91,7 @@ void gtk_image_set_from_file (GtkImage *image,
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_image_set_from_resource (GtkImage *image,
|
||||
const char *resource_path);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_12_FOR(gtk_image_set_from_paintable)
|
||||
void gtk_image_set_from_pixbuf (GtkImage *image,
|
||||
GdkPixbuf *pixbuf);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
|
||||
+13
-10
@@ -597,7 +597,7 @@ gtk_list_tile_get_position (GtkListItemManager *self,
|
||||
}
|
||||
else
|
||||
{
|
||||
pos = 0;
|
||||
pos = 0;
|
||||
}
|
||||
|
||||
for (parent = gtk_rb_tree_node_get_parent (tile);
|
||||
@@ -715,6 +715,7 @@ static void
|
||||
gtk_list_tile_set_type (GtkListTile *tile,
|
||||
GtkListTileType type)
|
||||
{
|
||||
g_assert (tile != NULL);
|
||||
if (tile->type == type)
|
||||
return;
|
||||
|
||||
@@ -845,7 +846,8 @@ gtk_list_item_manager_remove_items (GtkListItemManager *self,
|
||||
if (offset)
|
||||
tile = gtk_list_item_manager_ensure_split (self, tile, offset);
|
||||
header = gtk_list_tile_get_previous_skip (tile);
|
||||
if (header->type != GTK_LIST_TILE_HEADER && header->type != GTK_LIST_TILE_UNMATCHED_HEADER)
|
||||
if (header != NULL &&
|
||||
(header->type != GTK_LIST_TILE_HEADER && header->type != GTK_LIST_TILE_UNMATCHED_HEADER))
|
||||
header = NULL;
|
||||
|
||||
while (n_items > 0)
|
||||
@@ -911,7 +913,7 @@ gtk_list_item_manager_add_items (GtkListItemManager *self,
|
||||
GtkListItemChange *change,
|
||||
guint position,
|
||||
guint n_items)
|
||||
{
|
||||
{
|
||||
GtkListTile *tile;
|
||||
guint offset;
|
||||
gboolean has_sections;
|
||||
@@ -952,7 +954,7 @@ gtk_list_item_manager_add_items (GtkListItemManager *self,
|
||||
}
|
||||
if (offset)
|
||||
tile = gtk_list_item_manager_ensure_split (self, tile, offset);
|
||||
|
||||
|
||||
tile = gtk_rb_tree_insert_before (self->items, tile);
|
||||
tile->type = GTK_LIST_TILE_ITEM;
|
||||
tile->n_items = n_items;
|
||||
@@ -962,7 +964,7 @@ gtk_list_item_manager_add_items (GtkListItemManager *self,
|
||||
{
|
||||
GtkListTile *section = gtk_list_tile_get_previous_skip (tile);
|
||||
|
||||
if (section->type == GTK_LIST_TILE_HEADER)
|
||||
if (section != NULL && section->type == GTK_LIST_TILE_HEADER)
|
||||
{
|
||||
gtk_list_item_change_clear_header (change, §ion->widget);
|
||||
gtk_list_tile_set_type (section,
|
||||
@@ -1207,7 +1209,7 @@ gtk_list_item_manager_insert_section (GtkListItemManager *self,
|
||||
{
|
||||
GtkListTile *tile, *footer, *header;
|
||||
guint offset;
|
||||
|
||||
|
||||
tile = gtk_list_item_manager_get_nth (self, pos, &offset);
|
||||
if (tile == NULL)
|
||||
{
|
||||
@@ -1225,7 +1227,8 @@ gtk_list_item_manager_insert_section (GtkListItemManager *self,
|
||||
tile = gtk_list_item_manager_ensure_split (self, tile, offset);
|
||||
|
||||
header = gtk_list_tile_get_previous_skip (tile);
|
||||
if (header->type == GTK_LIST_TILE_HEADER || header->type == GTK_LIST_TILE_UNMATCHED_HEADER)
|
||||
if (header != NULL &&
|
||||
(header->type == GTK_LIST_TILE_HEADER || header->type == GTK_LIST_TILE_UNMATCHED_HEADER))
|
||||
{
|
||||
if (header_type == GTK_LIST_TILE_HEADER)
|
||||
gtk_list_tile_set_type (header, header_type);
|
||||
@@ -1257,7 +1260,7 @@ gtk_list_tile_find_widget_before (GtkListTile *tile)
|
||||
for (other = gtk_rb_tree_node_get_previous (tile);
|
||||
other;
|
||||
other = gtk_rb_tree_node_get_previous (other))
|
||||
{
|
||||
{
|
||||
if (other->widget)
|
||||
return other->widget;
|
||||
}
|
||||
@@ -1460,7 +1463,7 @@ gtk_list_item_manager_model_items_changed_cb (GListModel *model,
|
||||
GtkListTile *tile, *new_tile;
|
||||
GtkWidget *insert_after;
|
||||
guint i, offset;
|
||||
|
||||
|
||||
tile = gtk_list_item_manager_get_nth (self, position, &offset);
|
||||
for (new_tile = tile ? gtk_rb_tree_node_get_previous (tile) : gtk_rb_tree_get_last (self->items);
|
||||
new_tile && new_tile->widget == NULL;
|
||||
@@ -1576,7 +1579,7 @@ gtk_list_item_manager_model_items_changed_cb (GListModel *model,
|
||||
GtkListItemTracker *tracker = l->data;
|
||||
GtkListTile *tile;
|
||||
|
||||
if (tracker->widget != NULL ||
|
||||
if (tracker->widget != NULL ||
|
||||
tracker->position == GTK_INVALID_LIST_POSITION)
|
||||
continue;
|
||||
|
||||
|
||||
+49
-5
@@ -46,6 +46,7 @@
|
||||
#include "gtkorientable.h"
|
||||
#include "gtksizerequest.h"
|
||||
#include "gtkprivate.h"
|
||||
#include "gtkselectionmodel.h"
|
||||
#include "gtkstack.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
@@ -1172,7 +1173,7 @@ gtk_notebook_class_init (GtkNotebookClass *class)
|
||||
*
|
||||
* A selection model with the pages.
|
||||
*/
|
||||
properties[PROP_PAGES] =
|
||||
properties[PROP_PAGES] =
|
||||
g_param_spec_object ("pages", NULL, NULL,
|
||||
G_TYPE_LIST_MODEL,
|
||||
GTK_PARAM_READABLE);
|
||||
@@ -1358,7 +1359,7 @@ gtk_notebook_class_init (GtkNotebookClass *class)
|
||||
/**
|
||||
* GtkNotebook|menu.popup:
|
||||
*
|
||||
* Opens the context menu.
|
||||
* Opens the context menu.
|
||||
*/
|
||||
gtk_widget_class_install_action (widget_class, "menu.popup", NULL, gtk_notebook_popup_menu);
|
||||
|
||||
@@ -1827,7 +1828,7 @@ gtk_notebook_reorder_tab (GtkNotebook *notebook,
|
||||
page_num = reorder_tab (notebook, child->next, notebook->focus_tab);
|
||||
else
|
||||
page_num = reorder_tab (notebook, child, notebook->focus_tab);
|
||||
|
||||
|
||||
gtk_notebook_child_reordered (notebook, notebook->focus_tab->data);
|
||||
for (element = notebook->children, i = 0; element; element = element->next, i++)
|
||||
{
|
||||
@@ -7131,7 +7132,7 @@ gtk_notebook_get_page (GtkNotebook *notebook,
|
||||
list = gtk_notebook_find_child (notebook, child);
|
||||
if (list != NULL)
|
||||
page = list->data;
|
||||
|
||||
|
||||
return page;
|
||||
}
|
||||
|
||||
@@ -7197,8 +7198,51 @@ gtk_notebook_pages_list_model_init (GListModelInterface *iface)
|
||||
iface->get_n_items = gtk_notebook_pages_get_n_items;
|
||||
iface->get_item = gtk_notebook_pages_get_item;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_notebook_pages_is_selected (GtkSelectionModel *model,
|
||||
guint position)
|
||||
{
|
||||
GtkNotebookPages *pages = GTK_NOTEBOOK_PAGES (model);
|
||||
GtkNotebookPage *page;
|
||||
|
||||
page = g_list_nth_data (pages->notebook->children, position);
|
||||
if (page == NULL)
|
||||
return FALSE;
|
||||
|
||||
return page == pages->notebook->cur_page;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gtk_notebook_pages_select_item (GtkSelectionModel *model,
|
||||
guint position,
|
||||
gboolean exclusive)
|
||||
{
|
||||
GtkNotebookPages *pages = GTK_NOTEBOOK_PAGES (model);
|
||||
GtkNotebookPage *page;
|
||||
|
||||
page = g_list_nth_data (pages->notebook->children, position);
|
||||
if (page == NULL)
|
||||
return FALSE;
|
||||
|
||||
if (page == pages->notebook->cur_page)
|
||||
return FALSE;
|
||||
|
||||
gtk_notebook_switch_page (pages->notebook, page);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_notebook_pages_selection_model_init (GtkSelectionModelInterface *iface)
|
||||
{
|
||||
iface->is_selected = gtk_notebook_pages_is_selected;
|
||||
iface->select_item = gtk_notebook_pages_select_item;
|
||||
}
|
||||
|
||||
G_DEFINE_TYPE_WITH_CODE (GtkNotebookPages, gtk_notebook_pages, G_TYPE_OBJECT,
|
||||
G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL, gtk_notebook_pages_list_model_init))
|
||||
G_IMPLEMENT_INTERFACE (G_TYPE_LIST_MODEL, gtk_notebook_pages_list_model_init)
|
||||
G_IMPLEMENT_INTERFACE (GTK_TYPE_SELECTION_MODEL, gtk_notebook_pages_selection_model_init))
|
||||
|
||||
static void
|
||||
gtk_notebook_pages_init (GtkNotebookPages *pages)
|
||||
|
||||
@@ -334,8 +334,8 @@ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
|
||||
static GtkOrdering
|
||||
gtk_numeric_sorter_compare (GtkSorter *sorter,
|
||||
gpointer item1,
|
||||
gpointer item2)
|
||||
gpointer item1,
|
||||
gpointer item2)
|
||||
{
|
||||
GtkNumericSorter *self = GTK_NUMERIC_SORTER (sorter);
|
||||
GValue value1 = G_VALUE_INIT;
|
||||
|
||||
@@ -108,6 +108,7 @@ enum {
|
||||
|
||||
typedef struct {
|
||||
GtkWindow *parent;
|
||||
char *parent_handle;
|
||||
GFile *file;
|
||||
char *uri;
|
||||
gboolean open_folder;
|
||||
@@ -128,8 +129,9 @@ open_uri_data_free (OpenUriData *data)
|
||||
g_clear_object (&data->connection);
|
||||
if (data->cancel_handler)
|
||||
g_signal_handler_disconnect (data->cancellable, data->cancel_handler);
|
||||
if (data->parent)
|
||||
gtk_window_unexport_handle (data->parent);
|
||||
if (data->parent && data->parent_handle)
|
||||
gtk_window_unexport_handle (data->parent, data->parent_handle);
|
||||
g_free (data->parent_handle);
|
||||
g_clear_object (&data->parent);
|
||||
g_clear_object (&data->file);
|
||||
g_free (data->uri);
|
||||
@@ -426,6 +428,8 @@ window_handle_exported (GtkWindow *window,
|
||||
GAppLaunchContext *context;
|
||||
char *activation_token = NULL;
|
||||
|
||||
data->parent_handle = g_strdup (handle);
|
||||
|
||||
if (window)
|
||||
display = gtk_widget_get_display (GTK_WIDGET (window));
|
||||
else
|
||||
|
||||
+11
-1
@@ -873,8 +873,18 @@ gtk_path_bar_get_mount_callback (GObject *source,
|
||||
{
|
||||
GFile *file = G_FILE (source);
|
||||
struct SetFileInfo *file_info = data;
|
||||
GError *error = NULL;
|
||||
|
||||
file_info->mount = g_file_find_enclosing_mount_finish (file, result, NULL);
|
||||
file_info->mount = g_file_find_enclosing_mount_finish (file, result,
|
||||
&error);
|
||||
|
||||
if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
|
||||
{
|
||||
gtk_path_bar_set_file_finish (file_info, FALSE);
|
||||
g_clear_error (&error);
|
||||
return;
|
||||
}
|
||||
g_clear_error (&error);
|
||||
|
||||
if (file_info->mount)
|
||||
file_info->root_file = g_mount_get_root (file_info->mount);
|
||||
|
||||
+6
-1
@@ -28,7 +28,7 @@
|
||||
#include "gtksnapshot.h"
|
||||
#include "gtktypebuiltins.h"
|
||||
#include "gtkwidgetprivate.h"
|
||||
#include "gdkpixbufutilsprivate.h"
|
||||
#include "gdktextureutilsprivate.h"
|
||||
|
||||
/**
|
||||
* GtkPicture:
|
||||
@@ -525,6 +525,9 @@ gtk_picture_new_for_paintable (GdkPaintable *paintable)
|
||||
* The pixbuf must not be modified after passing it to this function.
|
||||
*
|
||||
* Returns: a new `GtkPicture`
|
||||
*
|
||||
* Deprecated: 4.12: Use [ctor@Gtk.Picture.new_for_paintable] and
|
||||
* [ctor@Gdk.Texture.new_for_pixbuf] instead
|
||||
*/
|
||||
GtkWidget*
|
||||
gtk_picture_new_for_pixbuf (GdkPixbuf *pixbuf)
|
||||
@@ -779,6 +782,8 @@ gtk_picture_set_resource (GtkPicture *self,
|
||||
* See [ctor@Gtk.Picture.new_for_pixbuf] for details.
|
||||
*
|
||||
* This is a utility function that calls [method@Gtk.Picture.set_paintable].
|
||||
*
|
||||
* Deprecated: 4.12: Use [method@Gtk.Picture.set_paintable] instead
|
||||
*/
|
||||
void
|
||||
gtk_picture_set_pixbuf (GtkPicture *self,
|
||||
|
||||
+2
-2
@@ -39,7 +39,7 @@ GDK_AVAILABLE_IN_ALL
|
||||
GtkWidget* gtk_picture_new (void);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkWidget* gtk_picture_new_for_paintable (GdkPaintable *paintable);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_12_FOR(gtk_pixbuf_new_for_paintable)
|
||||
GtkWidget* gtk_picture_new_for_pixbuf (GdkPixbuf *pixbuf);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GtkWidget* gtk_picture_new_for_file (GFile *file);
|
||||
@@ -64,7 +64,7 @@ void gtk_picture_set_filename (GtkPicture
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
void gtk_picture_set_resource (GtkPicture *self,
|
||||
const char *resource_path);
|
||||
GDK_AVAILABLE_IN_ALL
|
||||
GDK_DEPRECATED_IN_4_12_FOR(gtk_picture_set_paintable)
|
||||
void gtk_picture_set_pixbuf (GtkPicture *self,
|
||||
GdkPixbuf *pixbuf);
|
||||
|
||||
|
||||
@@ -48,6 +48,7 @@ typedef struct {
|
||||
GtkPrintOperationResult result;
|
||||
GtkPrintOperationPrintFunc print_cb;
|
||||
GtkWindow *parent;
|
||||
char *handle;
|
||||
GMainLoop *loop;
|
||||
guint32 token;
|
||||
GDestroyNotify destroy;
|
||||
@@ -62,8 +63,9 @@ portal_data_free (gpointer data)
|
||||
{
|
||||
PortalData *portal = data;
|
||||
|
||||
if (portal->parent)
|
||||
gtk_window_unexport_handle (portal->parent);
|
||||
if (portal->parent && portal->handle)
|
||||
gtk_window_unexport_handle (portal->parent, portal->handle);
|
||||
g_free (portal->handle);
|
||||
g_object_unref (portal->op);
|
||||
g_object_unref (portal->proxy);
|
||||
if (portal->loop)
|
||||
@@ -547,6 +549,8 @@ window_handle_exported (GtkWindow *window,
|
||||
{
|
||||
PortalData *portal = user_data;
|
||||
|
||||
portal->handle = g_strdup (handle_str);
|
||||
|
||||
g_dbus_proxy_call (portal->proxy,
|
||||
"PreparePrint",
|
||||
g_variant_new ("(ss@a{sv}@a{sv}@a{sv})",
|
||||
|
||||
@@ -329,7 +329,7 @@ gtk_property_lookup_list_model_get_property (GObject *object,
|
||||
break;
|
||||
|
||||
case PROP_PROPERTY:
|
||||
g_value_set_object (value, self->property);
|
||||
g_value_set_string (value, self->property);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -408,7 +408,7 @@ gtk_property_lookup_list_model_class_init (GtkPropertyLookupListModelClass *klas
|
||||
*/
|
||||
properties[PROP_OBJECT] =
|
||||
g_param_spec_object ("object", NULL, NULL,
|
||||
G_TYPE_LIST_MODEL,
|
||||
G_TYPE_OBJECT,
|
||||
GTK_PARAM_READWRITE | G_PARAM_EXPLICIT_NOTIFY);
|
||||
|
||||
g_object_class_install_properties (object_class, NUM_PROPERTIES, properties);
|
||||
@@ -417,6 +417,7 @@ gtk_property_lookup_list_model_class_init (GtkPropertyLookupListModelClass *klas
|
||||
static void
|
||||
gtk_property_lookup_list_model_init (GtkPropertyLookupListModel *self)
|
||||
{
|
||||
self->item_type = G_TYPE_OBJECT;
|
||||
self->items = g_ptr_array_new ();
|
||||
/* add sentinel */
|
||||
g_ptr_array_add (self->items, NULL);
|
||||
|
||||
+14
-2
@@ -6291,6 +6291,17 @@ prefix_handle (GdkDisplay *display,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static const char *
|
||||
unprefix_handle (const char *handle)
|
||||
{
|
||||
if (g_str_has_prefix (handle, "wayland:"))
|
||||
return handle + strlen ("wayland:");
|
||||
else if (g_str_has_prefix (handle, "x11:"))
|
||||
return handle + strlen ("x1!:");
|
||||
else
|
||||
return handle;
|
||||
}
|
||||
|
||||
static void
|
||||
export_handle_done (GObject *source,
|
||||
GAsyncResult *result,
|
||||
@@ -6336,11 +6347,12 @@ gtk_window_export_handle (GtkWindow *window,
|
||||
}
|
||||
|
||||
void
|
||||
gtk_window_unexport_handle (GtkWindow *window)
|
||||
gtk_window_unexport_handle (GtkWindow *window,
|
||||
const char *handle)
|
||||
{
|
||||
GtkWindowPrivate *priv = gtk_window_get_instance_private (window);
|
||||
|
||||
gdk_toplevel_unexport_handle (GDK_TOPLEVEL (priv->surface));
|
||||
gdk_toplevel_unexport_handle (GDK_TOPLEVEL (priv->surface), unprefix_handle (handle));
|
||||
}
|
||||
|
||||
static GtkPointerFocus *
|
||||
|
||||
@@ -79,7 +79,8 @@ typedef void (*GtkWindowHandleExported) (GtkWindow *window,
|
||||
gboolean gtk_window_export_handle (GtkWindow *window,
|
||||
GtkWindowHandleExported callback,
|
||||
gpointer user_data);
|
||||
void gtk_window_unexport_handle (GtkWindow *window);
|
||||
void gtk_window_unexport_handle (GtkWindow *window,
|
||||
const char *handle);
|
||||
|
||||
GtkWidget * gtk_window_lookup_pointer_focus_widget (GtkWindow *window,
|
||||
GdkDevice *device,
|
||||
|
||||
@@ -261,7 +261,9 @@ gtk_data_viewer_load_value (GtkDataViewer *self,
|
||||
}
|
||||
else if (g_type_is_a (G_VALUE_TYPE (value), GDK_TYPE_PIXBUF))
|
||||
{
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
self->contents = gtk_picture_new_for_pixbuf (g_value_get_object (value));
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
gtk_widget_set_size_request (self->contents, 256, 256);
|
||||
gtk_widget_set_parent (self->contents, GTK_WIDGET (self));
|
||||
}
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ gtk_cargs = [
|
||||
# introspected
|
||||
gtk_private_sources = files([
|
||||
'fnmatch.c',
|
||||
'gdkpixbufutils.c',
|
||||
'gdktextureutils.c',
|
||||
'gsettings-mapping.c',
|
||||
'gtkaccessibleattributeset.c',
|
||||
'gtkaccessiblevalue.c',
|
||||
|
||||
@@ -298,6 +298,7 @@ elif cc.get_id() == 'gcc' or cc.get_id() == 'clang'
|
||||
'address',
|
||||
'array-bounds',
|
||||
'empty-body',
|
||||
'enum-int-mismatch',
|
||||
'implicit',
|
||||
'implicit-fallthrough', # For non-gcc
|
||||
'implicit-fallthrough=5', # For GCC, only recognize the attribute and no comments
|
||||
|
||||
@@ -66,7 +66,7 @@ main(int argc, char **argv)
|
||||
gtk_revealer_set_child (GTK_REVEALER (revealer), grid);
|
||||
|
||||
cssprovider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (cssprovider, "* { padding: 2px; text-shadow: 5px 5px 2px grey; }", -1);
|
||||
gtk_css_provider_load_from_string (cssprovider, "* { padding: 2px; text-shadow: 5px 5px 2px grey; }");
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (cssprovider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
|
||||
+1
-9
@@ -1,5 +1,6 @@
|
||||
gtk_tests = [
|
||||
# testname, optional extra sources
|
||||
['testfilelauncher'],
|
||||
['input'],
|
||||
['testpopup'],
|
||||
['testupload'],
|
||||
@@ -24,13 +25,11 @@ gtk_tests = [
|
||||
['testbaseline'],
|
||||
['testbaseline2'],
|
||||
['testcalendar'],
|
||||
['testclipboard2'],
|
||||
['testcombo'],
|
||||
['testcolumnview'],
|
||||
['testcombochange'],
|
||||
['testcellrenderertext'],
|
||||
['testdialog'],
|
||||
['testdnd'],
|
||||
['testdnd2'],
|
||||
['testdndresize'],
|
||||
['testellipsise'],
|
||||
@@ -146,13 +145,6 @@ foreach t: gtk_tests
|
||||
)
|
||||
endforeach
|
||||
|
||||
executable('testroundedrect',
|
||||
sources: [ 'testroundedrect.c' ],
|
||||
include_directories: [confinc, gdkinc],
|
||||
c_args: test_args + common_cflags,
|
||||
dependencies: [libgtk_static_dep, libm],
|
||||
)
|
||||
|
||||
if libsysprof_dep.found()
|
||||
executable('testperf',
|
||||
sources: 'testperf.c',
|
||||
|
||||
@@ -360,15 +360,15 @@ main (int argc, char *argv[])
|
||||
gtk_init ();
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider,
|
||||
gtk_css_provider_load_from_string (provider,
|
||||
".black-bg { background-color: black; }"
|
||||
".red-bg { background-color: red; }"
|
||||
".blue-bg { background-color: blue; }", -1);
|
||||
".blue-bg { background-color: blue; }");
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
g_object_unref (provider);
|
||||
|
||||
|
||||
if (g_getenv ("RTL"))
|
||||
gtk_widget_set_default_direction (GTK_TEXT_DIR_RTL);
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ main (int argc, char **argv)
|
||||
gtk_init ();
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider, css, -1);
|
||||
gtk_css_provider_load_from_string (provider, css);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
|
||||
@@ -1,461 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Red Hat, Inc.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static GdkTexture *
|
||||
render_paintable_to_texture (GdkPaintable *paintable)
|
||||
{
|
||||
GtkSnapshot *snapshot;
|
||||
GskRenderNode *node;
|
||||
int width, height;
|
||||
cairo_surface_t *surface;
|
||||
cairo_t *cr;
|
||||
GdkTexture *texture;
|
||||
GBytes *bytes;
|
||||
|
||||
width = gdk_paintable_get_intrinsic_width (paintable);
|
||||
height = gdk_paintable_get_intrinsic_height (paintable);
|
||||
|
||||
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
|
||||
|
||||
snapshot = gtk_snapshot_new ();
|
||||
gdk_paintable_snapshot (paintable, snapshot, width, height);
|
||||
node = gtk_snapshot_free_to_node (snapshot);
|
||||
|
||||
cr = cairo_create (surface);
|
||||
gsk_render_node_draw (node, cr);
|
||||
cairo_destroy (cr);
|
||||
|
||||
gsk_render_node_unref (node);
|
||||
|
||||
bytes = g_bytes_new_with_free_func (cairo_image_surface_get_data (surface),
|
||||
cairo_image_surface_get_height (surface)
|
||||
* cairo_image_surface_get_stride (surface),
|
||||
(GDestroyNotify) cairo_surface_destroy,
|
||||
cairo_surface_reference (surface));
|
||||
texture = gdk_memory_texture_new (cairo_image_surface_get_width (surface),
|
||||
cairo_image_surface_get_height (surface),
|
||||
GDK_MEMORY_DEFAULT,
|
||||
bytes,
|
||||
cairo_image_surface_get_stride (surface));
|
||||
g_bytes_unref (bytes);
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
return texture;
|
||||
}
|
||||
|
||||
static void
|
||||
clipboard_changed_cb (GdkClipboard *clipboard,
|
||||
GtkWidget *stack)
|
||||
{
|
||||
GtkWidget *child;
|
||||
|
||||
gtk_stack_set_visible_child_name (GTK_STACK (stack), "info");
|
||||
|
||||
child = gtk_stack_get_child_by_name (GTK_STACK (stack), "image");
|
||||
gtk_image_clear (GTK_IMAGE (child));
|
||||
|
||||
child = gtk_stack_get_child_by_name (GTK_STACK (stack), "text");
|
||||
gtk_label_set_text (GTK_LABEL (child), "");
|
||||
}
|
||||
|
||||
static void
|
||||
texture_loaded_cb (GObject *clipboard,
|
||||
GAsyncResult *res,
|
||||
gpointer data)
|
||||
{
|
||||
GError *error = NULL;
|
||||
GdkTexture *texture;
|
||||
|
||||
texture = gdk_clipboard_read_texture_finish (GDK_CLIPBOARD (clipboard), res, &error);
|
||||
if (texture == NULL)
|
||||
{
|
||||
g_print ("%s\n", error->message);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_image_set_from_paintable (data, GDK_PAINTABLE (texture));
|
||||
g_object_unref (texture);
|
||||
}
|
||||
|
||||
static void
|
||||
text_loaded_cb (GObject *clipboard,
|
||||
GAsyncResult *res,
|
||||
gpointer data)
|
||||
{
|
||||
GError *error = NULL;
|
||||
char *text;
|
||||
|
||||
text = gdk_clipboard_read_text_finish (GDK_CLIPBOARD (clipboard), res, &error);
|
||||
if (text == NULL)
|
||||
{
|
||||
g_print ("%s\n", error->message);
|
||||
g_error_free (error);
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_label_set_text (data, text);
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
static void
|
||||
visible_child_changed_cb (GtkWidget *stack,
|
||||
GParamSpec *pspec,
|
||||
GdkClipboard *clipboard)
|
||||
{
|
||||
const char *visible_child = gtk_stack_get_visible_child_name (GTK_STACK (stack));
|
||||
|
||||
if (visible_child == NULL)
|
||||
{
|
||||
/* nothing to do here but avoiding crashes in g_str_equal() */
|
||||
}
|
||||
else if (g_str_equal (visible_child, "image"))
|
||||
{
|
||||
GtkWidget *image = gtk_stack_get_child_by_name (GTK_STACK (stack), "image");
|
||||
|
||||
gdk_clipboard_read_texture_async (clipboard,
|
||||
NULL,
|
||||
texture_loaded_cb,
|
||||
image);
|
||||
}
|
||||
else if (g_str_equal (visible_child, "text"))
|
||||
{
|
||||
GtkWidget *label = gtk_stack_get_child_by_name (GTK_STACK (stack), "text");
|
||||
|
||||
gdk_clipboard_read_text_async (clipboard,
|
||||
NULL,
|
||||
text_loaded_cb,
|
||||
label);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef G_OS_UNIX /* portal usage supported on *nix only */
|
||||
|
||||
static GSList *
|
||||
get_file_list (const char *dir)
|
||||
{
|
||||
GFileEnumerator *enumerator;
|
||||
GFile *file;
|
||||
GFileInfo *info;
|
||||
GSList *list = NULL;
|
||||
|
||||
file = g_file_new_for_path (dir);
|
||||
enumerator = g_file_enumerate_children (file, "standard::name,standard::type", 0, NULL, NULL);
|
||||
g_object_unref (file);
|
||||
if (enumerator == NULL)
|
||||
return NULL;
|
||||
|
||||
while (g_file_enumerator_iterate (enumerator, &info, &file, NULL, NULL) && file != NULL)
|
||||
{
|
||||
/* the portal can't handle directories */
|
||||
if (g_file_info_get_file_type (info) != G_FILE_TYPE_REGULAR)
|
||||
continue;
|
||||
|
||||
list = g_slist_prepend (list, g_object_ref (file));
|
||||
}
|
||||
|
||||
return g_slist_reverse (list);
|
||||
}
|
||||
|
||||
#else /* G_OS_UNIX -- original non-portal-enabled code */
|
||||
|
||||
static GList *
|
||||
get_file_list (const char *dir)
|
||||
{
|
||||
GFileEnumerator *enumerator;
|
||||
GFile *file;
|
||||
GList *list = NULL;
|
||||
|
||||
file = g_file_new_for_path (dir);
|
||||
enumerator = g_file_enumerate_children (file, "standard::name", 0, NULL, NULL);
|
||||
g_object_unref (file);
|
||||
if (enumerator == NULL)
|
||||
return NULL;
|
||||
|
||||
while (g_file_enumerator_iterate (enumerator, NULL, &file, NULL, NULL) && file != NULL)
|
||||
list = g_list_prepend (list, g_object_ref (file));
|
||||
|
||||
return g_list_reverse (list);
|
||||
}
|
||||
|
||||
#endif /* !G_OS_UNIX */
|
||||
|
||||
static void
|
||||
format_list_add_row (GtkWidget *list,
|
||||
const char *format_name,
|
||||
GdkContentFormats *formats)
|
||||
{
|
||||
GtkWidget *box;
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
|
||||
gtk_box_append (GTK_BOX (box), gtk_label_new (format_name));
|
||||
|
||||
gdk_content_formats_unref (formats);
|
||||
gtk_list_box_insert (GTK_LIST_BOX (list), box, -1);
|
||||
}
|
||||
|
||||
static void
|
||||
clipboard_formats_change_cb (GdkClipboard *clipboard,
|
||||
GParamSpec *pspec,
|
||||
GtkWidget *list)
|
||||
{
|
||||
GdkContentFormats *formats;
|
||||
GtkWidget *row;
|
||||
const char * const *mime_types;
|
||||
const GType *gtypes;
|
||||
gsize i, n;
|
||||
|
||||
while ((row = GTK_WIDGET (gtk_list_box_get_row_at_index (GTK_LIST_BOX (list), 0))))
|
||||
gtk_list_box_remove (GTK_LIST_BOX (list), row);
|
||||
|
||||
formats = gdk_clipboard_get_formats (clipboard);
|
||||
|
||||
gtypes = gdk_content_formats_get_gtypes (formats, &n);
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
format_list_add_row (list,
|
||||
g_type_name (gtypes[i]),
|
||||
gdk_content_formats_new_for_gtype (gtypes[i]));
|
||||
}
|
||||
|
||||
mime_types = gdk_content_formats_get_mime_types (formats, &n);
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
format_list_add_row (list,
|
||||
mime_types[i],
|
||||
gdk_content_formats_new ((const char *[2]) { mime_types[i], NULL }, 1));
|
||||
}
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
get_formats_list (GdkClipboard *clipboard)
|
||||
{
|
||||
GtkWidget *sw, *list;
|
||||
|
||||
sw = gtk_scrolled_window_new ();
|
||||
|
||||
list = gtk_list_box_new ();
|
||||
g_signal_connect_object (clipboard, "notify::formats", G_CALLBACK (clipboard_formats_change_cb), list, 0);
|
||||
clipboard_formats_change_cb (clipboard, NULL, list);
|
||||
gtk_scrolled_window_set_child (GTK_SCROLLED_WINDOW (sw), list);
|
||||
|
||||
return sw;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
get_contents_widget (GdkClipboard *clipboard)
|
||||
{
|
||||
GtkWidget *stack, *child;
|
||||
|
||||
stack = gtk_stack_new ();
|
||||
gtk_widget_set_hexpand (stack, TRUE);
|
||||
gtk_widget_set_vexpand (stack, TRUE);
|
||||
g_signal_connect (stack, "notify::visible-child", G_CALLBACK (visible_child_changed_cb), clipboard);
|
||||
g_signal_connect_object (clipboard, "changed", G_CALLBACK (clipboard_changed_cb), stack, 0);
|
||||
|
||||
child = get_formats_list (clipboard);
|
||||
gtk_stack_add_titled (GTK_STACK (stack), child, "info", "Info");
|
||||
|
||||
child = gtk_image_new ();
|
||||
gtk_stack_add_titled (GTK_STACK (stack), child, "image", "Image");
|
||||
|
||||
child = gtk_label_new (NULL);
|
||||
gtk_label_set_wrap (GTK_LABEL (child), TRUE);
|
||||
gtk_stack_add_titled (GTK_STACK (stack), child, "text", "Text");
|
||||
|
||||
return stack;
|
||||
}
|
||||
|
||||
static void
|
||||
provider_button_clicked_cb (GtkWidget *button,
|
||||
GdkClipboard *clipboard)
|
||||
{
|
||||
gdk_clipboard_set_content (clipboard,
|
||||
g_object_get_data (G_OBJECT (button), "provider"));
|
||||
}
|
||||
|
||||
static void
|
||||
add_provider_button (GtkWidget *box,
|
||||
GdkContentProvider *provider,
|
||||
GdkClipboard *clipboard,
|
||||
const char *name)
|
||||
{
|
||||
GtkWidget *button;
|
||||
|
||||
button = gtk_button_new_with_label (name);
|
||||
g_signal_connect (button, "clicked", G_CALLBACK (provider_button_clicked_cb), clipboard);
|
||||
if (provider)
|
||||
g_object_set_data_full (G_OBJECT (button), "provider", provider, g_object_unref);
|
||||
|
||||
gtk_box_append (GTK_BOX (box), button);
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
get_button_list (GdkClipboard *clipboard,
|
||||
const char *info)
|
||||
{
|
||||
static const guchar invalid_utf8[] = { 'L', 'i', 'b', 'e', 'r', 't', 0xe9, ',', ' ',
|
||||
0xc9, 'g', 'a', 'l', 'i', 't', 0xe9, ',', ' ',
|
||||
'F', 'r', 'a', 't', 'e', 'r', 'n', 'i', 't', 0xe9, 0 };
|
||||
GtkWidget *box;
|
||||
GtkIconPaintable *icon;
|
||||
GdkTexture *texture;
|
||||
GValue value = G_VALUE_INIT;
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
|
||||
gtk_box_append (GTK_BOX (box), gtk_label_new (info));
|
||||
|
||||
add_provider_button (box,
|
||||
NULL,
|
||||
clipboard,
|
||||
"Empty");
|
||||
|
||||
g_value_init (&value, GDK_TYPE_PIXBUF);
|
||||
icon = gtk_icon_theme_lookup_icon (gtk_icon_theme_get_for_display (gdk_clipboard_get_display (clipboard)),
|
||||
"utilities-terminal",
|
||||
NULL,
|
||||
48, 1,
|
||||
gtk_widget_get_direction (box),
|
||||
0);
|
||||
texture = render_paintable_to_texture (GDK_PAINTABLE (icon));
|
||||
g_value_take_object (&value, gdk_pixbuf_get_from_texture (texture));
|
||||
g_object_unref (texture);
|
||||
g_object_unref (icon);
|
||||
add_provider_button (box,
|
||||
gdk_content_provider_new_for_value (&value),
|
||||
clipboard,
|
||||
"GdkPixbuf");
|
||||
g_value_unset (&value);
|
||||
|
||||
add_provider_button (box,
|
||||
gdk_content_provider_new_typed (G_TYPE_STRING, "Hello Clipboard ☺"),
|
||||
clipboard,
|
||||
"gchararry");
|
||||
|
||||
add_provider_button (box,
|
||||
gdk_content_provider_new_for_bytes ("text/plain;charset=utf-8",
|
||||
g_bytes_new_static ("𝕳𝖊𝖑𝖑𝖔 𝖀𝖓𝖎𝖈𝖔𝖉𝖊",
|
||||
strlen ("𝕳𝖊𝖑𝖑𝖔 𝖀𝖓𝖎𝖈𝖔𝖉𝖊") + 1)),
|
||||
clipboard,
|
||||
"text/plain");
|
||||
|
||||
add_provider_button (box,
|
||||
gdk_content_provider_new_for_bytes ("text/plain;charset=utf-8",
|
||||
g_bytes_new_static (invalid_utf8, sizeof(invalid_utf8))),
|
||||
clipboard,
|
||||
"Invalid UTF-8");
|
||||
|
||||
g_value_init (&value, G_TYPE_FILE);
|
||||
g_value_take_object (&value, g_file_new_for_path (g_get_home_dir ()));
|
||||
add_provider_button (box,
|
||||
gdk_content_provider_new_for_value (&value),
|
||||
clipboard,
|
||||
"home directory");
|
||||
g_value_unset (&value);
|
||||
|
||||
g_value_init (&value, GDK_TYPE_FILE_LIST);
|
||||
g_value_take_boxed (&value, get_file_list (g_get_home_dir ()));
|
||||
add_provider_button (box,
|
||||
gdk_content_provider_new_for_value (&value),
|
||||
clipboard,
|
||||
"files in home");
|
||||
return box;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
get_clipboard_widget (GdkClipboard *clipboard,
|
||||
GdkClipboard *alt_clipboard,
|
||||
const char *name)
|
||||
{
|
||||
GtkWidget *vbox, *hbox, *stack, *switcher;
|
||||
|
||||
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
|
||||
gtk_box_append (GTK_BOX (hbox), vbox);
|
||||
gtk_box_append (GTK_BOX (vbox), gtk_label_new (name));
|
||||
switcher = gtk_stack_switcher_new ();
|
||||
gtk_box_append (GTK_BOX (vbox), switcher);
|
||||
stack = get_contents_widget (clipboard);
|
||||
gtk_box_append (GTK_BOX (vbox), stack);
|
||||
gtk_stack_switcher_set_stack (GTK_STACK_SWITCHER (switcher), GTK_STACK (stack));
|
||||
gtk_box_append (GTK_BOX (hbox), get_button_list (clipboard, "Set Locally:"));
|
||||
if (clipboard != alt_clipboard)
|
||||
gtk_box_append (GTK_BOX (hbox), get_button_list (alt_clipboard, "Set Remotely:"));
|
||||
|
||||
return hbox;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
get_window_contents (GdkDisplay *display,
|
||||
GdkDisplay *alt_display)
|
||||
{
|
||||
GtkWidget *box;
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
||||
gtk_box_set_homogeneous (GTK_BOX (box), TRUE);
|
||||
gtk_box_append (GTK_BOX (box),
|
||||
get_clipboard_widget (gdk_display_get_clipboard (display),
|
||||
gdk_display_get_clipboard (alt_display),
|
||||
"Clipboard"));
|
||||
gtk_box_append (GTK_BOX (box),
|
||||
get_clipboard_widget (gdk_display_get_primary_clipboard (display),
|
||||
gdk_display_get_primary_clipboard (alt_display),
|
||||
"Primary Clipboard"));
|
||||
|
||||
return box;
|
||||
}
|
||||
|
||||
static void
|
||||
quit_cb (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
gboolean *done = data;
|
||||
|
||||
*done = TRUE;
|
||||
|
||||
g_main_context_wakeup (NULL);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
GtkWidget *window;
|
||||
GdkDisplay *alt_display;
|
||||
gboolean done = FALSE;
|
||||
|
||||
gtk_init ();
|
||||
|
||||
alt_display = gdk_display_open (NULL);
|
||||
if (alt_display == NULL)
|
||||
alt_display = gdk_display_get_default ();
|
||||
|
||||
window = gtk_window_new ();
|
||||
g_signal_connect (window, "destroy", G_CALLBACK (quit_cb), &done);
|
||||
gtk_window_set_child (GTK_WINDOW (window),
|
||||
get_window_contents (gtk_widget_get_display (window),
|
||||
alt_display));
|
||||
|
||||
gtk_window_present (GTK_WINDOW (window));
|
||||
|
||||
while (!done)
|
||||
g_main_context_iteration (NULL, TRUE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
-597
@@ -1,597 +0,0 @@
|
||||
/* testdnd.c
|
||||
* Copyright (C) 1998 Red Hat, Inc.
|
||||
* Author: Owen Taylor
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "gtk/gtk.h"
|
||||
|
||||
/* Target side drag signals */
|
||||
|
||||
/* XPM */
|
||||
static const char * drag_icon_xpm[] = {
|
||||
"36 48 9 1",
|
||||
" c None",
|
||||
". c #020204",
|
||||
"+ c #8F8F90",
|
||||
"@ c #D3D3D2",
|
||||
"# c #AEAEAC",
|
||||
"$ c #ECECEC",
|
||||
"% c #A2A2A4",
|
||||
"& c #FEFEFC",
|
||||
"* c #BEBEBC",
|
||||
" .....................",
|
||||
" ..&&&&&&&&&&&&&&&&&&&.",
|
||||
" ...&&&&&&&&&&&&&&&&&&&.",
|
||||
" ..&.&&&&&&&&&&&&&&&&&&&.",
|
||||
" ..&&.&&&&&&&&&&&&&&&&&&&.",
|
||||
" ..&&&.&&&&&&&&&&&&&&&&&&&.",
|
||||
" ..&&&&.&&&&&&&&&&&&&&&&&&&.",
|
||||
" ..&&&&&.&&&@&&&&&&&&&&&&&&&.",
|
||||
" ..&&&&&&.*$%$+$&&&&&&&&&&&&&.",
|
||||
" ..&&&&&&&.%$%$+&&&&&&&&&&&&&&.",
|
||||
" ..&&&&&&&&.#&#@$&&&&&&&&&&&&&&.",
|
||||
" ..&&&&&&&&&.#$**#$&&&&&&&&&&&&&.",
|
||||
" ..&&&&&&&&&&.&@%&%$&&&&&&&&&&&&&.",
|
||||
" ..&&&&&&&&&&&.&&&&&&&&&&&&&&&&&&&.",
|
||||
" ..&&&&&&&&&&&&.&&&&&&&&&&&&&&&&&&&.",
|
||||
"................&$@&&&@&&&&&&&&&&&&.",
|
||||
".&&&&&&&+&&#@%#+@#@*$%$+$&&&&&&&&&&.",
|
||||
".&&&&&&&+&&#@#@&&@*%$%$+&&&&&&&&&&&.",
|
||||
".&&&&&&&+&$%&#@&#@@#&#@$&&&&&&&&&&&.",
|
||||
".&&&&&&@#@@$&*@&@#@#$**#$&&&&&&&&&&.",
|
||||
".&&&&&&&&&&&&&&&&&&&@%&%$&&&&&&&&&&.",
|
||||
".&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&.",
|
||||
".&&&&&&&&$#@@$&&&&&&&&&&&&&&&&&&&&&.",
|
||||
".&&&&&&&&&+&$+&$&@&$@&&$@&&&&&&&&&&.",
|
||||
".&&&&&&&&&+&&#@%#+@#@*$%&+$&&&&&&&&.",
|
||||
".&&&&&&&&&+&&#@#@&&@*%$%$+&&&&&&&&&.",
|
||||
".&&&&&&&&&+&$%&#@&#@@#&#@$&&&&&&&&&.",
|
||||
".&&&&&&&&@#@@$&*@&@#@#$#*#$&&&&&&&&.",
|
||||
".&&&&&&&&&&&&&&&&&&&&&$%&%$&&&&&&&&.",
|
||||
".&&&&&&&&&&$#@@$&&&&&&&&&&&&&&&&&&&.",
|
||||
".&&&&&&&&&&&+&$%&$$@&$@&&$@&&&&&&&&.",
|
||||
".&&&&&&&&&&&+&&#@%#+@#@*$%$+$&&&&&&.",
|
||||
".&&&&&&&&&&&+&&#@#@&&@*#$%$+&&&&&&&.",
|
||||
".&&&&&&&&&&&+&$+&*@&#@@#&#@$&&&&&&&.",
|
||||
".&&&&&&&&&&$%@@&&*@&@#@#$#*#&&&&&&&.",
|
||||
".&&&&&&&&&&&&&&&&&&&&&&&$%&%$&&&&&&.",
|
||||
".&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&.",
|
||||
".&&&&&&&&&&&&&&$#@@$&&&&&&&&&&&&&&&.",
|
||||
".&&&&&&&&&&&&&&&+&$%&$$@&$@&&$@&&&&.",
|
||||
".&&&&&&&&&&&&&&&+&&#@%#+@#@*$%$+$&&.",
|
||||
".&&&&&&&&&&&&&&&+&&#@#@&&@*#$%$+&&&.",
|
||||
".&&&&&&&&&&&&&&&+&$+&*@&#@@#&#@$&&&.",
|
||||
".&&&&&&&&&&&&&&$%@@&&*@&@#@#$#*#&&&.",
|
||||
".&&&&&&&&&&&&&&&&&&&&&&&&&&&$%&%$&&.",
|
||||
".&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&.",
|
||||
".&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&.",
|
||||
".&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&.",
|
||||
"...................................."};
|
||||
|
||||
/* XPM */
|
||||
static const char * trashcan_closed_xpm[] = {
|
||||
"64 80 17 1",
|
||||
" c None",
|
||||
". c #030304",
|
||||
"+ c #5A5A5C",
|
||||
"@ c #323231",
|
||||
"# c #888888",
|
||||
"$ c #1E1E1F",
|
||||
"% c #767677",
|
||||
"& c #494949",
|
||||
"* c #9E9E9C",
|
||||
"= c #111111",
|
||||
"- c #3C3C3D",
|
||||
"; c #6B6B6B",
|
||||
"> c #949494",
|
||||
", c #282828",
|
||||
"' c #808080",
|
||||
") c #545454",
|
||||
"! c #AEAEAC",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ==......=$$...=== ",
|
||||
" ..$------)+++++++++++++@$$... ",
|
||||
" ..=@@-------&+++++++++++++++++++-.... ",
|
||||
" =.$$@@@-&&)++++)-,$$$$=@@&+++++++++++++,..$ ",
|
||||
" .$$$$@@&+++++++&$$$@@@@-&,$,-++++++++++;;;&.. ",
|
||||
" $$$$,@--&++++++&$$)++++++++-,$&++++++;%%'%%;;$@ ",
|
||||
" .-@@-@-&++++++++-@++++++++++++,-++++++;''%;;;%*-$ ",
|
||||
" +------++++++++++++++++++++++++++++++;;%%%;;##*!. ",
|
||||
" =+----+++++++++++++++++++++++;;;;;;;;;;;;%'>>). ",
|
||||
" .=)&+++++++++++++++++;;;;;;;;;;;;;;%''>>#>#@. ",
|
||||
" =..=&++++++++++++;;;;;;;;;;;;;%###>>###+%== ",
|
||||
" .&....=-+++++%;;####''''''''''##'%%%)..#. ",
|
||||
" .+-++@....=,+%#####'%%%%%%%%%;@$-@-@*++!. ",
|
||||
" .+-++-+++-&-@$$=$=......$,,,@;&)+!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" =+-++-+++-+++++++++!++++!++++!+++!++!+++= ",
|
||||
" $.++-+++-+++++++++!++++!++++!+++!++!+.$ ",
|
||||
" =.++++++++++++++!++++!++++!+++!++.= ",
|
||||
" $..+++++++++++++++!++++++...$ ",
|
||||
" $$=.............=$$ ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" "};
|
||||
|
||||
/* XPM */
|
||||
static const char * trashcan_open_xpm[] = {
|
||||
"64 80 17 1",
|
||||
" c None",
|
||||
". c #030304",
|
||||
"+ c #5A5A5C",
|
||||
"@ c #323231",
|
||||
"# c #888888",
|
||||
"$ c #1E1E1F",
|
||||
"% c #767677",
|
||||
"& c #494949",
|
||||
"* c #9E9E9C",
|
||||
"= c #111111",
|
||||
"- c #3C3C3D",
|
||||
"; c #6B6B6B",
|
||||
"> c #949494",
|
||||
", c #282828",
|
||||
"' c #808080",
|
||||
") c #545454",
|
||||
"! c #AEAEAC",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" .=.==.,@ ",
|
||||
" ==.,@-&&&)-= ",
|
||||
" .$@,&++;;;%>*- ",
|
||||
" $,-+)+++%%;;'#+. ",
|
||||
" =---+++++;%%%;%##@. ",
|
||||
" @)++++++++;%%%%'#%$ ",
|
||||
" $&++++++++++;%%;%##@= ",
|
||||
" ,-++++)+++++++;;;'#%) ",
|
||||
" @+++&&--&)++++;;%'#'-. ",
|
||||
" ,&++-@@,,,,-)++;;;'>'+, ",
|
||||
" =-++&@$@&&&&-&+;;;%##%+@ ",
|
||||
" =,)+)-,@@&+++++;;;;%##%&@ ",
|
||||
" @--&&,,@&)++++++;;;;'#)@ ",
|
||||
" ---&)-,@)+++++++;;;%''+, ",
|
||||
" $--&)+&$-+++++++;;;%%'';- ",
|
||||
" .,-&+++-$&++++++;;;%''%&= ",
|
||||
" $,-&)++)-@++++++;;%''%), ",
|
||||
" =,@&)++++&&+++++;%'''+$@&++++++ ",
|
||||
" .$@-++++++++++++;'#';,........=$@&++++ ",
|
||||
" =$@@&)+++++++++++'##-.................=&++ ",
|
||||
" .$$@-&)+++++++++;%#+$.....................=)+ ",
|
||||
" $$,@-)+++++++++;%;@=........................,+ ",
|
||||
" .$$@@-++++++++)-)@=............................ ",
|
||||
" $,@---)++++&)@===............................,. ",
|
||||
" $-@---&)))-$$=..............................=)!. ",
|
||||
" --&-&&,,$=,==...........................=&+++!. ",
|
||||
" =,=$..=$+)+++++&@$=.............=$@&+++++!++!. ",
|
||||
" .)-++-+++++++++++++++++++++++++++!++!++!. ",
|
||||
" .+-++-+++++++++++++++++++++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!+++!!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" .+-++-+++-+++++++++!++++!++++!+++!++!++!. ",
|
||||
" =+-++-+++-+++++++++!++++!++++!+++!++!+++= ",
|
||||
" $.++-+++-+++++++++!++++!++++!+++!++!+.$ ",
|
||||
" =.++++++++++++++!++++!++++!+++!++.= ",
|
||||
" $..+++++++++++++++!++++++...$ ",
|
||||
" $$==...........==$$ ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" ",
|
||||
" "};
|
||||
|
||||
GdkPixbuf *trashcan_open;
|
||||
GdkPixbuf *trashcan_closed;
|
||||
|
||||
|
||||
static GdkDragAction
|
||||
action_make_unique (GdkDragAction action)
|
||||
{
|
||||
if (gdk_drag_action_is_unique (action))
|
||||
return action;
|
||||
|
||||
if (action & GDK_ACTION_COPY)
|
||||
return GDK_ACTION_COPY;
|
||||
|
||||
if (action & GDK_ACTION_MOVE)
|
||||
return GDK_ACTION_MOVE;
|
||||
|
||||
if (action & GDK_ACTION_LINK)
|
||||
return GDK_ACTION_LINK;
|
||||
|
||||
g_assert_not_reached ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static GdkDragAction
|
||||
trash_drag_enter (GtkDropTarget *dest,
|
||||
GdkDrop *drop,
|
||||
double x,
|
||||
double y,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
char *s;
|
||||
|
||||
gtk_image_set_from_pixbuf (GTK_IMAGE (widget), trashcan_open);
|
||||
|
||||
s = gdk_content_formats_to_string (gdk_drop_get_formats (drop));
|
||||
g_print ("trash enter: %s\n", s);
|
||||
g_free (s);
|
||||
|
||||
return action_make_unique (gdk_drop_get_actions (drop));;
|
||||
}
|
||||
|
||||
static GdkDragAction
|
||||
trash_drag_leave (GtkDropTarget *dest,
|
||||
GdkDrop *drop,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
char *s;
|
||||
|
||||
gtk_image_set_from_pixbuf (GTK_IMAGE (widget), trashcan_closed);
|
||||
|
||||
s = gdk_content_formats_to_string (gdk_drop_get_formats (drop));
|
||||
g_print ("trash leave: %s\n", s);
|
||||
g_free (s);
|
||||
|
||||
return action_make_unique (gdk_drop_get_actions (drop));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
trash_drag_drop (GtkDropTarget *dest,
|
||||
GdkDrop *drop,
|
||||
double x,
|
||||
double y,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
char *s;
|
||||
|
||||
s = gdk_content_formats_to_string (gdk_drop_get_formats (drop));
|
||||
g_print ("trash drop: %s\n", s);
|
||||
g_free (s);
|
||||
|
||||
gdk_drop_finish (drop, action_make_unique (gdk_drop_get_actions (drop)));
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
label_drag_drop (GtkDropTarget *dest,
|
||||
const GValue *value,
|
||||
int x,
|
||||
int y,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
g_print ("Received \"%s\" in label\n", g_value_get_string (value));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* The following is a rather elaborate example demonstrating/testing
|
||||
* changing of the window hierarchy during a drag - in this case,
|
||||
* via a "spring-loaded" popup window.
|
||||
*/
|
||||
static GtkWidget *popup_window = NULL;
|
||||
|
||||
static gboolean popped_up = FALSE;
|
||||
static gboolean in_popup = FALSE;
|
||||
static guint popdown_timer = 0;
|
||||
static guint popup_timer = 0;
|
||||
|
||||
static int
|
||||
popdown_cb (gpointer data)
|
||||
{
|
||||
popdown_timer = 0;
|
||||
|
||||
gtk_widget_set_visible (popup_window, FALSE);
|
||||
popped_up = FALSE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
popup_enter (GtkDropTarget *dest)
|
||||
{
|
||||
g_print ("popup enter\n");
|
||||
if (!in_popup)
|
||||
{
|
||||
in_popup = TRUE;
|
||||
if (popdown_timer)
|
||||
{
|
||||
g_print ("removed popdown\n");
|
||||
g_source_remove (popdown_timer);
|
||||
popdown_timer = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
popup_leave (GtkDropTarget *dest)
|
||||
{
|
||||
g_print ("popup leave\n");
|
||||
if (in_popup)
|
||||
{
|
||||
in_popup = FALSE;
|
||||
if (!popdown_timer)
|
||||
{
|
||||
g_print ("added popdown\n");
|
||||
popdown_timer = g_timeout_add (500, popdown_cb, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
popup_drop (GtkDropTarget *dest)
|
||||
{
|
||||
popdown_cb (NULL);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
popup_cb (gpointer data)
|
||||
{
|
||||
if (!popped_up)
|
||||
{
|
||||
if (!popup_window)
|
||||
{
|
||||
GtkWidget *button;
|
||||
GtkWidget *grid;
|
||||
int i, j;
|
||||
|
||||
popup_window = gtk_window_new ();
|
||||
|
||||
grid = gtk_grid_new ();
|
||||
|
||||
for (i=0; i<3; i++)
|
||||
for (j=0; j<3; j++)
|
||||
{
|
||||
char buffer[128];
|
||||
GtkDropTarget *dest;
|
||||
|
||||
g_snprintf(buffer, sizeof(buffer), "%d,%d", i, j);
|
||||
button = gtk_button_new_with_label (buffer);
|
||||
gtk_widget_set_hexpand (button, TRUE);
|
||||
gtk_widget_set_vexpand (button, TRUE);
|
||||
gtk_grid_attach (GTK_GRID (grid), button, i, j, 1, 1);
|
||||
|
||||
dest = gtk_drop_target_new (G_TYPE_STRING, GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||
g_signal_connect (dest, "enter", G_CALLBACK (popup_enter), NULL);
|
||||
g_signal_connect (dest, "leave", G_CALLBACK (popup_leave), NULL);
|
||||
g_signal_connect (dest, "drop", G_CALLBACK (popup_drop), NULL);
|
||||
gtk_widget_add_controller (button, GTK_EVENT_CONTROLLER (dest));
|
||||
}
|
||||
gtk_window_set_child (GTK_WINDOW (popup_window), grid);
|
||||
}
|
||||
gtk_widget_set_visible (popup_window, TRUE);
|
||||
popped_up = TRUE;
|
||||
}
|
||||
|
||||
popup_timer = FALSE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
popsite_enter (GtkDropControllerMotion *motion)
|
||||
{
|
||||
g_print ("popsite enter\n");
|
||||
if (!popup_timer)
|
||||
popup_timer = g_timeout_add (500, popup_cb, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
popsite_leave (GtkDropControllerMotion *motion)
|
||||
{
|
||||
g_print ("popsite leave\n");
|
||||
if (popup_timer)
|
||||
{
|
||||
g_source_remove (popup_timer);
|
||||
popup_timer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
quit_cb (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
gboolean *done = data;
|
||||
|
||||
*done = TRUE;
|
||||
|
||||
g_main_context_wakeup (NULL);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
GtkWidget *window;
|
||||
GtkWidget *grid;
|
||||
GtkWidget *label;
|
||||
GtkWidget *pixmap;
|
||||
GtkWidget *button;
|
||||
GdkPixbuf *drag_icon;
|
||||
GdkTexture *texture;
|
||||
GdkContentProvider *content;
|
||||
GtkDragSource *source;
|
||||
GtkDropTarget *dest;
|
||||
GtkDropTargetAsync *async;
|
||||
GtkEventController *controller;
|
||||
gboolean done = FALSE;
|
||||
|
||||
gtk_init ();
|
||||
|
||||
window = gtk_window_new ();
|
||||
g_signal_connect (window, "destroy",
|
||||
G_CALLBACK (quit_cb), &done);
|
||||
|
||||
|
||||
grid = gtk_grid_new ();
|
||||
gtk_window_set_child (GTK_WINDOW (window), grid);
|
||||
|
||||
drag_icon = gdk_pixbuf_new_from_xpm_data (drag_icon_xpm);
|
||||
texture = gdk_texture_new_for_pixbuf (drag_icon);
|
||||
g_object_unref (drag_icon);
|
||||
trashcan_open = gdk_pixbuf_new_from_xpm_data (trashcan_open_xpm);
|
||||
trashcan_closed = gdk_pixbuf_new_from_xpm_data (trashcan_closed_xpm);
|
||||
|
||||
label = gtk_label_new ("Drop Here\n");
|
||||
|
||||
dest = gtk_drop_target_new (G_TYPE_STRING, GDK_ACTION_COPY | GDK_ACTION_MOVE);
|
||||
g_signal_connect (dest, "drop", G_CALLBACK (label_drag_drop), NULL);
|
||||
gtk_widget_add_controller (label, GTK_EVENT_CONTROLLER (dest));
|
||||
|
||||
gtk_widget_set_hexpand (label, TRUE);
|
||||
gtk_widget_set_vexpand (label, TRUE);
|
||||
gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1);
|
||||
|
||||
label = gtk_label_new ("Popup\n");
|
||||
|
||||
controller = gtk_drop_controller_motion_new ();
|
||||
g_signal_connect (controller, "enter", G_CALLBACK (popsite_enter), NULL);
|
||||
g_signal_connect (controller, "leave", G_CALLBACK (popsite_leave), NULL);
|
||||
gtk_widget_add_controller (label, controller);
|
||||
|
||||
gtk_widget_set_hexpand (label, TRUE);
|
||||
gtk_widget_set_vexpand (label, TRUE);
|
||||
gtk_grid_attach (GTK_GRID (grid), label, 1, 1, 1, 1);
|
||||
|
||||
pixmap = gtk_image_new_from_pixbuf (trashcan_closed);
|
||||
async = gtk_drop_target_async_new (NULL, GDK_ACTION_ALL);
|
||||
g_signal_connect (async, "drag-enter", G_CALLBACK (trash_drag_enter), pixmap);
|
||||
g_signal_connect (async, "drag-leave", G_CALLBACK (trash_drag_leave), pixmap);
|
||||
g_signal_connect (async, "drop", G_CALLBACK (trash_drag_drop), pixmap);
|
||||
gtk_widget_add_controller (pixmap, GTK_EVENT_CONTROLLER (async));
|
||||
|
||||
gtk_widget_set_hexpand (pixmap, TRUE);
|
||||
gtk_widget_set_vexpand (pixmap, TRUE);
|
||||
gtk_grid_attach (GTK_GRID (grid), pixmap, 1, 0, 1, 1);
|
||||
|
||||
|
||||
/* Drag site */
|
||||
|
||||
button = gtk_label_new ("Drag Here\n");
|
||||
|
||||
source = gtk_drag_source_new ();
|
||||
content = gdk_content_provider_new_typed (G_TYPE_STRING, "I'm data!");
|
||||
gtk_drag_source_set_content (source, content);
|
||||
g_object_unref (content);
|
||||
gtk_drag_source_set_actions (source, GDK_ACTION_COPY|GDK_ACTION_MOVE);
|
||||
gtk_widget_add_controller (button, GTK_EVENT_CONTROLLER (source));
|
||||
gtk_drag_source_set_icon (source, GDK_PAINTABLE (texture), 0, 0);
|
||||
|
||||
g_object_unref (texture);
|
||||
|
||||
gtk_widget_set_hexpand (button, TRUE);
|
||||
gtk_widget_set_vexpand (button, TRUE);
|
||||
gtk_grid_attach (GTK_GRID (grid), button, 0, 1, 1, 1);
|
||||
|
||||
gtk_window_present (GTK_WINDOW (window));
|
||||
|
||||
while (!done)
|
||||
g_main_context_iteration (NULL, TRUE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -161,12 +161,11 @@ main (int argc, char *argv[])
|
||||
gtk_init ();
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider,
|
||||
".dnd {"
|
||||
"background-color: red;"
|
||||
"border-top: 10px solid rebeccapurple;"
|
||||
"}",
|
||||
-1);
|
||||
gtk_css_provider_load_from_string (provider,
|
||||
".dnd {"
|
||||
"background-color: red;"
|
||||
"border-top: 10px solid rebeccapurple;"
|
||||
"}");
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER(provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
|
||||
@@ -159,18 +159,18 @@ main (int argc, char **argv)
|
||||
gtk_grid_attach (GTK_GRID (grid), entry, 1, 1, 1, 1);
|
||||
gtk_editable_set_text (GTK_EDITABLE (entry), "Right-to-left");
|
||||
gtk_widget_set_direction (entry, GTK_TEXT_DIR_RTL);
|
||||
|
||||
|
||||
gtk_entry_set_icon_from_icon_name (GTK_ENTRY (entry),
|
||||
GTK_ENTRY_ICON_PRIMARY,
|
||||
"document-save-symbolic");
|
||||
gtk_entry_set_icon_tooltip_text (GTK_ENTRY (entry),
|
||||
GTK_ENTRY_ICON_PRIMARY,
|
||||
"Save a file");
|
||||
|
||||
|
||||
content = gdk_content_provider_new_typed (G_TYPE_STRING, "Amazing");
|
||||
gtk_entry_set_icon_drag_source (GTK_ENTRY (entry),
|
||||
GTK_ENTRY_ICON_PRIMARY,
|
||||
content, GDK_ACTION_COPY);
|
||||
content, GDK_ACTION_COPY);
|
||||
g_object_unref (content);
|
||||
|
||||
/*
|
||||
@@ -298,7 +298,7 @@ main (int argc, char **argv)
|
||||
|
||||
GtkCssProvider *provider;
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider, cssdata, -1);
|
||||
gtk_css_provider_load_from_string (provider, cssdata);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (), GTK_STYLE_PROVIDER (provider), 800);
|
||||
gtk_window_present (GTK_WINDOW (window));
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
static void
|
||||
launched_cb (GObject *source,
|
||||
GAsyncResult *result,
|
||||
gpointer data)
|
||||
{
|
||||
GtkFileLauncher *launcher = GTK_FILE_LAUNCHER (source);
|
||||
GError *error = NULL;
|
||||
|
||||
if (!gtk_file_launcher_launch_finish (launcher, result, &error))
|
||||
{
|
||||
g_print ("Launching failed: %s\n", error->message);
|
||||
g_error_free (error);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
GtkWidget *window;
|
||||
GtkFileLauncher *launcher;
|
||||
|
||||
gtk_init ();
|
||||
|
||||
window = gtk_window_new ();
|
||||
|
||||
launcher = gtk_file_launcher_new (NULL);
|
||||
|
||||
gtk_window_present (GTK_WINDOW (window));
|
||||
|
||||
for (int i = 1; i < argc; i++)
|
||||
{
|
||||
GFile *file = g_file_new_for_commandline_arg (argv[i]);
|
||||
|
||||
g_print ("launching %s\n", argv[i]);
|
||||
|
||||
gtk_file_launcher_set_file (launcher, file);
|
||||
gtk_file_launcher_launch (launcher, GTK_WINDOW (window), NULL, launched_cb, NULL);
|
||||
g_object_unref (file);
|
||||
}
|
||||
|
||||
while (g_list_model_get_n_items (gtk_window_get_toplevels ()) > 0)
|
||||
g_main_context_iteration (NULL, FALSE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
+2
-3
@@ -265,7 +265,7 @@ main (int argc, char *argv[])
|
||||
gtk_init ();
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider,
|
||||
gtk_css_provider_load_from_string (provider,
|
||||
":hover {"
|
||||
" box-shadow: inset 0px 0px 0px 1px red;"
|
||||
" }"
|
||||
@@ -274,8 +274,7 @@ main (int argc, char *argv[])
|
||||
" }"
|
||||
" window :not(.title):hover * {"
|
||||
" background: goldenrod;"
|
||||
" }",
|
||||
-1);
|
||||
" }");
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (), GTK_STYLE_PROVIDER (provider), 800);
|
||||
g_object_unref (provider);
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ add_custom_css (void)
|
||||
"}";
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider, data, -1);
|
||||
gtk_css_provider_load_from_string (provider, data);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
|
||||
@@ -99,7 +99,7 @@ main (int argc, char **argv)
|
||||
gtk_init ();
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider, css, -1);
|
||||
gtk_css_provider_load_from_string (provider, css);
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
|
||||
@@ -22,7 +22,7 @@ overlay_get_child_position (GtkOverlay *overlay,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
GtkWidget *win, *overlay, *grid, *main_child, *child, *label, *sw;
|
||||
@@ -32,13 +32,12 @@ main (int argc, char *argv[])
|
||||
gtk_init ();
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider,
|
||||
"label { border: 3px solid black; border-radius: 5px; padding: 2px; }"
|
||||
".top { border-top-style: none; border-top-right-radius: 0px; border-top-left-radius: 0px; }"
|
||||
".bottom { border-bottom-style: none; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; }"
|
||||
".left { border-left-style: none; border-top-left-radius: 0px; border-bottom-left-radius: 0px; }"
|
||||
".right { border-right-style: none; border-top-right-radius: 0px; border-bottom-right-radius: 0px; }",
|
||||
-1);
|
||||
gtk_css_provider_load_from_string (provider,
|
||||
"label { border: 3px solid black; border-radius: 5px; padding: 2px; }"
|
||||
".top { border-top-style: none; border-top-right-radius: 0px; border-top-left-radius: 0px; }"
|
||||
".bottom { border-bottom-style: none; border-bottom-right-radius: 0px; border-bottom-left-radius: 0px; }"
|
||||
".left { border-left-style: none; border-top-left-radius: 0px; border-bottom-left-radius: 0px; }"
|
||||
".right { border-right-style: none; border-top-right-radius: 0px; border-bottom-right-radius: 0px; }");
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
|
||||
|
||||
+1
-1
@@ -59,7 +59,7 @@ main (int argc, char *argv[])
|
||||
gtk_init ();
|
||||
|
||||
provider = gtk_css_provider_new ();
|
||||
gtk_css_provider_load_from_data (provider, css, -1);
|
||||
gtk_css_provider_load_from_string (provider, css);
|
||||
|
||||
gtk_style_context_add_provider_for_display (gdk_display_get_default (),
|
||||
GTK_STYLE_PROVIDER (provider),
|
||||
|
||||
@@ -1,312 +0,0 @@
|
||||
#include <gtk/gtk.h>
|
||||
#include <gtk/css/gtkcssparserprivate.h>
|
||||
#include <gsk/gskroundedrectprivate.h>
|
||||
|
||||
#define TEST_TYPE_WIDGET (test_widget_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (TestWidget, test_widget, TEST, WIDGET, GtkWidget)
|
||||
|
||||
struct _TestWidget
|
||||
{
|
||||
GtkWidget parent_instance;
|
||||
|
||||
GskRoundedRect rect1;
|
||||
GskRoundedRect rect2;
|
||||
GskRoundedRect rect3;
|
||||
GskRoundedRectIntersection result;
|
||||
};
|
||||
|
||||
struct _TestWidgetClass
|
||||
{
|
||||
GtkWidgetClass parent_class;
|
||||
};
|
||||
|
||||
G_DEFINE_TYPE (TestWidget, test_widget, GTK_TYPE_WIDGET)
|
||||
|
||||
static void
|
||||
test_widget_init (TestWidget *self)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
test_widget_measure (GtkWidget *widget,
|
||||
GtkOrientation orientation,
|
||||
int for_size,
|
||||
int *minimum,
|
||||
int *natural,
|
||||
int *minimum_baseline,
|
||||
int *natural_baseline)
|
||||
{
|
||||
TestWidget *self = TEST_WIDGET (widget);
|
||||
|
||||
if (orientation == GTK_ORIENTATION_VERTICAL)
|
||||
*minimum = *natural = MAX (self->rect1.bounds.origin.x + self->rect1.bounds.size.width,
|
||||
self->rect2.bounds.origin.x + self->rect2.bounds.size.width);
|
||||
else
|
||||
*minimum = *natural = MAX (self->rect1.bounds.origin.y + self->rect1.bounds.size.height,
|
||||
self->rect2.bounds.origin.y + self->rect2.bounds.size.height);
|
||||
}
|
||||
|
||||
static void
|
||||
test_widget_snapshot (GtkWidget *widget,
|
||||
GtkSnapshot *snapshot)
|
||||
{
|
||||
TestWidget *self = TEST_WIDGET (widget);
|
||||
float widths[4] = { 1, 1, 1, 1 };
|
||||
GdkRGBA colors1[4];
|
||||
GdkRGBA colors2[4];
|
||||
GdkRGBA colors3[4];
|
||||
GskRoundedRect rect3;
|
||||
|
||||
gdk_rgba_parse (&colors1[0], "red");
|
||||
colors1[1] = colors1[2] = colors1[3] = colors1[0];
|
||||
|
||||
gdk_rgba_parse (&colors2[0], "blue");
|
||||
colors2[1] = colors2[2] = colors2[3] = colors2[0];
|
||||
|
||||
gdk_rgba_parse (&colors3[0], "magenta");
|
||||
colors3[1] = colors3[2] = colors3[3] = colors3[0];
|
||||
|
||||
gtk_snapshot_append_border (snapshot, &self->rect1, widths, colors1);
|
||||
gtk_snapshot_append_border (snapshot, &self->rect2, widths, colors2);
|
||||
|
||||
switch (gsk_rounded_rect_intersect (&self->rect1, &self->rect2, &rect3))
|
||||
{
|
||||
case GSK_INTERSECTION_NONEMPTY:
|
||||
gtk_snapshot_append_border (snapshot, &rect3, widths, colors3);
|
||||
break;
|
||||
default:
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
test_widget_class_init (TestWidgetClass *class)
|
||||
{
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class);
|
||||
|
||||
widget_class->snapshot = test_widget_snapshot;
|
||||
widget_class->measure = test_widget_measure;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
test_widget_new (void)
|
||||
{
|
||||
return g_object_new (TEST_TYPE_WIDGET, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
update_intersection (TestWidget *self)
|
||||
{
|
||||
self->result = gsk_rounded_rect_intersect (&self->rect1, &self->rect2, &self->rect3);
|
||||
}
|
||||
|
||||
static void
|
||||
test_widget_set_rect1 (TestWidget *self,
|
||||
GskRoundedRect *rect)
|
||||
{
|
||||
self->rect1 = *rect;
|
||||
update_intersection (self);
|
||||
gtk_widget_queue_resize (GTK_WIDGET (self));
|
||||
}
|
||||
|
||||
static void
|
||||
test_widget_set_rect2 (TestWidget *self,
|
||||
GskRoundedRect *rect)
|
||||
{
|
||||
self->rect2 = *rect;
|
||||
update_intersection (self);
|
||||
gtk_widget_queue_resize (GTK_WIDGET (self));
|
||||
}
|
||||
|
||||
static gboolean
|
||||
parse_rect (GtkCssParser *parser,
|
||||
graphene_rect_t *out_rect)
|
||||
{
|
||||
double numbers[4];
|
||||
|
||||
if (!gtk_css_parser_consume_number (parser, &numbers[0]) ||
|
||||
!gtk_css_parser_consume_number (parser, &numbers[1]) ||
|
||||
!gtk_css_parser_consume_number (parser, &numbers[2]) ||
|
||||
!gtk_css_parser_consume_number (parser, &numbers[3]))
|
||||
return FALSE;
|
||||
|
||||
graphene_rect_init (out_rect, numbers[0], numbers[1], numbers[2], numbers[3]);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
parse_rounded_rect (GtkCssParser *parser,
|
||||
GskRoundedRect *out_rect)
|
||||
{
|
||||
graphene_rect_t r;
|
||||
graphene_size_t corners[4];
|
||||
double d;
|
||||
guint i;
|
||||
|
||||
if (!parse_rect (parser, &r))
|
||||
return FALSE;
|
||||
|
||||
if (!gtk_css_parser_try_delim (parser, '/'))
|
||||
{
|
||||
gsk_rounded_rect_init_from_rect (out_rect, &r, 0);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (!gtk_css_parser_has_number (parser))
|
||||
break;
|
||||
if (!gtk_css_parser_consume_number (parser, &d))
|
||||
return FALSE;
|
||||
corners[i].width = d;
|
||||
}
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
gtk_css_parser_error_syntax (parser, "Expected a number");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* The magic (i - 1) >> 1 below makes it take the correct value
|
||||
* according to spec. Feel free to check the 4 cases
|
||||
*/
|
||||
for (; i < 4; i++)
|
||||
corners[i].width = corners[(i - 1) >> 1].width;
|
||||
if (gtk_css_parser_try_delim (parser, '/'))
|
||||
{
|
||||
gtk_css_parser_consume_token (parser);
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
if (!gtk_css_parser_has_number (parser))
|
||||
break;
|
||||
if (!gtk_css_parser_consume_number (parser, &d))
|
||||
return FALSE;
|
||||
corners[i].height = d;
|
||||
}
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
gtk_css_parser_error_syntax (parser, "Expected a number");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for (; i < 4; i++)
|
||||
corners[i].height = corners[(i - 1) >> 1].height;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < 4; i++)
|
||||
corners[i].height = corners[i].width;
|
||||
}
|
||||
|
||||
gsk_rounded_rect_init (out_rect, &r, &corners[0], &corners[1], &corners[2], &corners[3]);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static GtkWidget *label;
|
||||
|
||||
static void
|
||||
update_label (GtkLabel *label,
|
||||
GskRoundedRectIntersection result)
|
||||
{
|
||||
const char *labels[] = {
|
||||
"Empty", "Not empty", "Not representable", "Who knows"
|
||||
};
|
||||
|
||||
gtk_label_set_label (label, labels[result]);
|
||||
}
|
||||
|
||||
static void
|
||||
activate1_cb (GtkEntry *entry, TestWidget *test)
|
||||
{
|
||||
GtkCssParser *parser;
|
||||
const char *text;
|
||||
GBytes *bytes;
|
||||
GskRoundedRect rect;
|
||||
|
||||
text = gtk_editable_get_text (GTK_EDITABLE (entry));
|
||||
bytes = g_bytes_new_static (text, strlen (text) + 1);
|
||||
parser = gtk_css_parser_new_for_bytes (bytes, NULL, NULL, NULL, NULL);
|
||||
|
||||
if (parse_rounded_rect (parser, &rect))
|
||||
{
|
||||
test_widget_set_rect1 (test, &rect);
|
||||
update_label (GTK_LABEL (label), test->result);
|
||||
}
|
||||
|
||||
gtk_css_parser_unref (parser);
|
||||
g_bytes_unref (bytes);
|
||||
}
|
||||
|
||||
static void
|
||||
activate2_cb (GtkEntry *entry, TestWidget *test)
|
||||
{
|
||||
GtkCssParser *parser;
|
||||
const char *text;
|
||||
GBytes *bytes;
|
||||
GskRoundedRect rect;
|
||||
|
||||
text = gtk_editable_get_text (GTK_EDITABLE (entry));
|
||||
bytes = g_bytes_new_static (text, strlen (text) + 1);
|
||||
parser = gtk_css_parser_new_for_bytes (bytes, NULL, NULL, NULL, NULL);
|
||||
|
||||
if (parse_rounded_rect (parser, &rect))
|
||||
{
|
||||
test_widget_set_rect2 (test, &rect);
|
||||
update_label (GTK_LABEL (label), test->result);
|
||||
}
|
||||
|
||||
gtk_css_parser_unref (parser);
|
||||
g_bytes_unref (bytes);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
GtkWidget *window;
|
||||
GtkWidget *box;
|
||||
GtkWidget *grid;
|
||||
GtkWidget *entry1;
|
||||
GtkWidget *entry2;
|
||||
GtkWidget *test;
|
||||
|
||||
gtk_init ();
|
||||
|
||||
window = gtk_window_new ();
|
||||
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
|
||||
|
||||
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
|
||||
gtk_window_set_child (GTK_WINDOW (window), box);
|
||||
|
||||
grid = gtk_grid_new ();
|
||||
gtk_box_append (GTK_BOX (box), grid);
|
||||
|
||||
test = test_widget_new ();
|
||||
gtk_widget_set_hexpand (test, TRUE);
|
||||
gtk_widget_set_vexpand (test, TRUE);
|
||||
gtk_widget_set_halign (test, GTK_ALIGN_CENTER);
|
||||
gtk_widget_set_valign (test, GTK_ALIGN_CENTER);
|
||||
gtk_box_append (GTK_BOX (box), test);
|
||||
|
||||
entry1 = gtk_entry_new ();
|
||||
g_signal_connect (entry1, "activate", G_CALLBACK (activate1_cb), test);
|
||||
gtk_grid_attach (GTK_GRID (grid), entry1, 0, 0, 1, 1);
|
||||
|
||||
entry2 = gtk_entry_new ();
|
||||
g_signal_connect (entry2, "activate", G_CALLBACK (activate2_cb), test);
|
||||
gtk_grid_attach (GTK_GRID (grid), entry2, 0, 1, 1, 1);
|
||||
|
||||
label = gtk_label_new ("");
|
||||
gtk_grid_attach (GTK_GRID (grid), label, 0, 2, 1, 1);
|
||||
|
||||
gtk_window_present (GTK_WINDOW (window));
|
||||
|
||||
while (g_list_model_get_n_items (gtk_window_get_toplevels ()) > 0)
|
||||
g_main_context_iteration (NULL, FALSE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -466,6 +466,8 @@ test_data = [
|
||||
'radial-positions.errors',
|
||||
'radial-positions.ref.css',
|
||||
'radial.ref.css',
|
||||
'resource-url.css',
|
||||
'resource-url.ref.css',
|
||||
'rotate3d-crash.css',
|
||||
'rotate3d-crash.errors',
|
||||
'rotate3d-crash.ref.css',
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
window { background-image: url("resource://"); }
|
||||
|
||||
button { background-image: url("resource://doesnotexist.jpg"); }
|
||||
@@ -0,0 +1,7 @@
|
||||
window {
|
||||
background-image: none /* invalid image */;
|
||||
}
|
||||
|
||||
button {
|
||||
background-image: none /* invalid image */;
|
||||
}
|
||||
@@ -218,6 +218,37 @@ test_parse_fail (void)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
test_match (void)
|
||||
{
|
||||
GdkContentFormatsBuilder *builder;
|
||||
GdkContentFormats *formats, *formats2;
|
||||
|
||||
builder = gdk_content_formats_builder_new ();
|
||||
gdk_content_formats_builder_ref (builder);
|
||||
|
||||
gdk_content_formats_builder_add_gtype (builder, GDK_TYPE_RGBA);
|
||||
gdk_content_formats_builder_add_mime_type (builder, "image/png");
|
||||
formats = gdk_content_formats_builder_free_to_formats (builder);
|
||||
|
||||
gdk_content_formats_builder_add_gtype (builder, G_TYPE_STRING);
|
||||
gdk_content_formats_builder_add_mime_type (builder, "text/plain");
|
||||
formats2 = gdk_content_formats_builder_free_to_formats (builder);
|
||||
|
||||
g_assert_false (gdk_content_formats_match (formats, formats2));
|
||||
|
||||
gdk_content_formats_unref (formats2);
|
||||
|
||||
builder = gdk_content_formats_builder_new ();
|
||||
gdk_content_formats_builder_add_mime_type (builder, "image/png");
|
||||
formats2 = gdk_content_formats_builder_free_to_formats (builder);
|
||||
|
||||
g_assert_true (gdk_content_formats_match (formats, formats2));
|
||||
|
||||
gdk_content_formats_unref (formats2);
|
||||
gdk_content_formats_unref (formats);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
@@ -238,6 +269,7 @@ main (int argc, char *argv[])
|
||||
g_test_add_func ("/contentformats/parse_fail", test_parse_fail);
|
||||
g_test_add_func ("/contentformats/print_and_parse", test_print_and_parse);
|
||||
g_test_add_func ("/contentformats/union", test_union);
|
||||
g_test_add_func ("/contentformats/match", test_match);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
||||
@@ -67,6 +67,85 @@ test_allowed_backends (gconstpointer data)
|
||||
g_object_unref (context);
|
||||
}
|
||||
|
||||
static void
|
||||
test_use_es (void)
|
||||
{
|
||||
GdkDisplay *display;
|
||||
GdkGLContext *context;
|
||||
GError *error = NULL;
|
||||
GdkGLAPI allowed_apis, api;
|
||||
GdkGLContext *shared;
|
||||
|
||||
display = gdk_display_get_default ();
|
||||
if (!gdk_display_prepare_gl (display, &error))
|
||||
{
|
||||
g_test_skip_printf ("no GL support: %s", error->message);
|
||||
g_clear_error (&error);
|
||||
return;
|
||||
}
|
||||
|
||||
context = gdk_display_create_gl_context (display, &error);
|
||||
g_assert_nonnull (context);
|
||||
g_assert_no_error (error);
|
||||
|
||||
g_object_set (context, "allowed-apis", GDK_GL_API_GL | GDK_GL_API_GLES, NULL);
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
gdk_gl_context_set_use_es (context, 1);
|
||||
g_assert_true (gdk_gl_context_get_allowed_apis (context) == GDK_GL_API_GLES);
|
||||
gdk_gl_context_set_use_es (context, 0);
|
||||
g_assert_true (gdk_gl_context_get_allowed_apis (context) == GDK_GL_API_GL);
|
||||
gdk_gl_context_set_use_es (context, -1);
|
||||
g_assert_true (gdk_gl_context_get_allowed_apis (context) == (GDK_GL_API_GL | GDK_GL_API_GLES));
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
||||
api = gdk_gl_context_realize (context, &error);
|
||||
g_assert_no_error (error);
|
||||
g_assert_true (api != 0);
|
||||
|
||||
g_object_get (context,
|
||||
"allowed-apis", &allowed_apis,
|
||||
"api", &api,
|
||||
"shared-context", &shared,
|
||||
NULL);
|
||||
|
||||
g_assert_true (allowed_apis == (GDK_GL_API_GL | GDK_GL_API_GLES));
|
||||
g_assert_true (api == GDK_GL_API_GL || api == GDK_GL_API_GLES);
|
||||
g_assert_null (shared);
|
||||
|
||||
g_object_unref (context);
|
||||
}
|
||||
|
||||
static void
|
||||
test_version (void)
|
||||
{
|
||||
GdkDisplay *display;
|
||||
GdkGLContext *context;
|
||||
GError *error = NULL;
|
||||
int major, minor;
|
||||
|
||||
display = gdk_display_get_default ();
|
||||
if (!gdk_display_prepare_gl (display, &error))
|
||||
{
|
||||
g_test_skip_printf ("no GL support: %s", error->message);
|
||||
g_clear_error (&error);
|
||||
return;
|
||||
}
|
||||
|
||||
context = gdk_display_create_gl_context (display, &error);
|
||||
g_assert_nonnull (context);
|
||||
g_assert_no_error (error);
|
||||
|
||||
gdk_gl_context_get_required_version (context, &major, &minor);
|
||||
g_assert_true (major == 0 && minor == 0);
|
||||
|
||||
gdk_gl_context_set_required_version (context, 4, 0);
|
||||
gdk_gl_context_get_required_version (context, &major, &minor);
|
||||
g_assert_true (major == 4 && minor == 0);
|
||||
|
||||
g_object_unref (context);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
@@ -77,5 +156,8 @@ main (int argc, char *argv[])
|
||||
g_test_add_data_func ("/allowed-apis/gles", GSIZE_TO_POINTER (GDK_GL_API_GLES), test_allowed_backends);
|
||||
g_test_add_data_func ("/allowed-apis/all", GSIZE_TO_POINTER (GDK_GL_API_GL | GDK_GL_API_GLES), test_allowed_backends);
|
||||
|
||||
g_test_add_func ("/allowed-apis/use-es", test_use_es);
|
||||
g_test_add_func ("/allowed-apis/version", test_version);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
||||
+117
-7
@@ -1,5 +1,7 @@
|
||||
#include <gtk/gtk.h>
|
||||
#include <epoxy/gl.h>
|
||||
#include "gdk/gdktextureprivate.h"
|
||||
#include "gdk/gdkglcontextprivate.h"
|
||||
|
||||
static cairo_surface_t *
|
||||
make_surface (void)
|
||||
@@ -20,6 +22,23 @@ make_surface (void)
|
||||
return surface;
|
||||
}
|
||||
|
||||
static unsigned int
|
||||
make_gl_texture (GdkGLContext *context,
|
||||
cairo_surface_t *surface)
|
||||
{
|
||||
unsigned int id;
|
||||
|
||||
glGenTextures (1, &id);
|
||||
glActiveTexture (GL_TEXTURE0);
|
||||
glBindTexture (GL_TEXTURE_2D, id);
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 64, 64, 0, GL_BGRA, GL_UNSIGNED_BYTE,
|
||||
cairo_image_surface_get_data (surface));
|
||||
|
||||
g_assert_true (glGetError () == GL_NO_ERROR);
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
enum {
|
||||
SAME_CONTEXT,
|
||||
NO_CONTEXT,
|
||||
@@ -59,13 +78,7 @@ test_gltexture (int test)
|
||||
|
||||
gdk_gl_context_make_current (context);
|
||||
|
||||
glGenTextures (1, &id);
|
||||
glActiveTexture (GL_TEXTURE0);
|
||||
glBindTexture (GL_TEXTURE_2D, id);
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, GL_RGBA8, 64, 64, 0, GL_BGRA, GL_UNSIGNED_BYTE,
|
||||
cairo_image_surface_get_data (surface));
|
||||
|
||||
g_assert_true (glGetError () == GL_NO_ERROR);
|
||||
id = make_gl_texture (context, surface);
|
||||
|
||||
if (test == NO_CONTEXT)
|
||||
gdk_gl_context_clear_current ();
|
||||
@@ -122,6 +135,102 @@ test_gltexture_shared_context (void)
|
||||
test_gltexture (SHARED_CONTEXT);
|
||||
}
|
||||
|
||||
static void
|
||||
test_gltexture_updates (void)
|
||||
{
|
||||
GdkDisplay *display;
|
||||
GdkGLContext *context;
|
||||
GdkGLTextureBuilder *builder;
|
||||
cairo_surface_t *surface;
|
||||
GError *error = NULL;
|
||||
unsigned int id;
|
||||
guchar *data;
|
||||
gpointer sync;
|
||||
GdkTexture *old_texture;
|
||||
GdkTexture *texture;
|
||||
cairo_region_t *update_region, *diff;
|
||||
|
||||
display = gdk_display_get_default ();
|
||||
if (!gdk_display_prepare_gl (display, &error))
|
||||
{
|
||||
g_test_message ("no GL support: %s", error->message);
|
||||
g_test_skip ("no GL support");
|
||||
g_clear_error (&error);
|
||||
return;
|
||||
}
|
||||
|
||||
context = gdk_display_create_gl_context (display, &error);
|
||||
g_assert_nonnull (context);
|
||||
g_assert_no_error (error);
|
||||
|
||||
builder = gdk_gl_texture_builder_new ();
|
||||
gdk_gl_texture_builder_set_id (builder, 10);
|
||||
|
||||
surface = make_surface ();
|
||||
|
||||
gdk_gl_context_make_current (context);
|
||||
|
||||
id = make_gl_texture (context, surface);
|
||||
|
||||
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
||||
old_texture = gdk_gl_texture_new (context, id, 64, 64, NULL, NULL);
|
||||
G_GNUC_END_IGNORE_DEPRECATIONS
|
||||
|
||||
id = make_gl_texture (context, surface);
|
||||
|
||||
if (gdk_gl_context_has_sync (context))
|
||||
sync = glFenceSync (GL_SYNC_GPU_COMMANDS_COMPLETE, 0);
|
||||
else
|
||||
sync = NULL;
|
||||
|
||||
update_region = cairo_region_create_rectangle (&(cairo_rectangle_int_t) { 10, 10, 32, 32 });
|
||||
|
||||
builder = gdk_gl_texture_builder_new ();
|
||||
g_object_set (builder,
|
||||
"context", context,
|
||||
"id", id,
|
||||
"width", 64,
|
||||
"height", 64,
|
||||
"sync", sync,
|
||||
"update-texture", old_texture,
|
||||
"update-region", update_region,
|
||||
NULL);
|
||||
|
||||
g_assert_true (gdk_gl_texture_builder_get_sync (builder) == sync);
|
||||
g_assert_true (gdk_gl_texture_builder_get_update_texture (builder) == old_texture);
|
||||
g_assert_true (cairo_region_equal (gdk_gl_texture_builder_get_update_region (builder), update_region));
|
||||
|
||||
texture = gdk_gl_texture_builder_build (builder, NULL, NULL);
|
||||
|
||||
data = g_malloc0 (64 * 64 * 4);
|
||||
gdk_texture_download (texture, data, 64 * 4);
|
||||
|
||||
g_assert_true (memcmp (data, cairo_image_surface_get_data (surface), 64 * 64 * 4) == 0);
|
||||
|
||||
diff = cairo_region_create ();
|
||||
gdk_texture_diff (texture, old_texture, diff);
|
||||
g_assert_true (cairo_region_equal (diff, update_region));
|
||||
cairo_region_destroy (diff);
|
||||
|
||||
diff = cairo_region_create ();
|
||||
gdk_texture_diff (old_texture, texture, diff);
|
||||
g_assert_true (cairo_region_equal (diff, update_region));
|
||||
cairo_region_destroy (diff);
|
||||
|
||||
g_free (data);
|
||||
g_object_unref (texture);
|
||||
g_object_unref (builder);
|
||||
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
if (sync)
|
||||
glDeleteSync (sync);
|
||||
cairo_region_destroy (update_region);
|
||||
g_object_unref (old_texture);
|
||||
|
||||
g_object_unref (context);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
@@ -130,6 +239,7 @@ main (int argc, char *argv[])
|
||||
g_test_add_func ("/gltexture/same-context", test_gltexture_same_context);
|
||||
g_test_add_func ("/gltexture/no-context", test_gltexture_no_context);
|
||||
g_test_add_func ("/gltexture/shared-context", test_gltexture_shared_context);
|
||||
g_test_add_func ("/gltexture/updates", test_gltexture_updates);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ tests = [
|
||||
{ 'name': 'displaymanager' },
|
||||
{ 'name': 'encoding' },
|
||||
{ 'name': 'glcontext' },
|
||||
{ 'name': 'gltexture' },
|
||||
{ 'name': 'keysyms' },
|
||||
{ 'name': 'memorytexture' },
|
||||
{ 'name': 'rectangle' },
|
||||
@@ -55,6 +54,7 @@ endforeach
|
||||
internal_tests = [
|
||||
'image',
|
||||
'texture',
|
||||
'gltexture',
|
||||
]
|
||||
|
||||
foreach t : internal_tests
|
||||
|
||||
@@ -355,6 +355,45 @@ test_texture_diff (void)
|
||||
g_object_unref (texture2);
|
||||
}
|
||||
|
||||
static void
|
||||
test_texture_downloader (void)
|
||||
{
|
||||
GdkTexture *texture;
|
||||
GdkTexture *texture2;
|
||||
GdkTextureDownloader *downloader;
|
||||
GdkTextureDownloader *downloader2;
|
||||
gsize stride;
|
||||
GBytes *bytes;
|
||||
guchar *data;
|
||||
|
||||
texture = gdk_texture_new_from_resource ("/org/gtk/libgtk/icons/16x16/places/user-trash.png");
|
||||
texture2 = gdk_texture_new_from_resource ("/org/gtk/libgtk/icons/16x16/places/user-trash.png");
|
||||
|
||||
downloader = gdk_texture_downloader_new (texture);
|
||||
|
||||
downloader2 = gdk_texture_downloader_copy (downloader);
|
||||
g_assert_true (gdk_texture_downloader_get_texture (downloader2) == texture);
|
||||
gdk_texture_downloader_free (downloader2);
|
||||
|
||||
gdk_texture_downloader_set_texture (downloader, texture2);
|
||||
gdk_texture_downloader_set_format (downloader, GDK_MEMORY_R16G16B16A16);
|
||||
g_assert_true (gdk_texture_downloader_get_format (downloader) == GDK_MEMORY_R16G16B16A16);
|
||||
|
||||
bytes = gdk_texture_downloader_download_bytes (downloader, &stride);
|
||||
|
||||
g_assert_true (stride == 4 * 2 * 16);
|
||||
g_assert_true (g_bytes_get_size (bytes) == stride * 16);
|
||||
|
||||
data = g_malloc (stride * 16);
|
||||
gdk_texture_downloader_download_into (downloader, data, stride);
|
||||
|
||||
g_assert_true (memcmp (data, g_bytes_get_data (bytes, NULL), stride * 16) == 0);
|
||||
|
||||
g_free (data);
|
||||
g_bytes_unref (bytes);
|
||||
gdk_texture_downloader_free (downloader);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
@@ -370,6 +409,7 @@ main (int argc, char *argv[])
|
||||
g_test_add_func ("/texture/icon/load-async", test_texture_icon_async);
|
||||
g_test_add_func ("/texture/icon/serialize", test_texture_icon_serialize);
|
||||
g_test_add_func ("/texture/diff", test_texture_diff);
|
||||
g_test_add_func ("/texture/downloader", test_texture_downloader);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
color {
|
||||
bounds: 0 0 50 50;
|
||||
color: rgb(0,0,0);
|
||||
}
|
||||
clip {
|
||||
clip: 10 10 30 30;
|
||||
child: transform {
|
||||
transform: translate(10, 10);
|
||||
child: opacity {
|
||||
opacity: 0.8;
|
||||
child: color {
|
||||
bounds: -50 -50 100 100;
|
||||
color: rgb(255,0,0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 167 B |
@@ -0,0 +1,18 @@
|
||||
color {
|
||||
bounds: 0 0 150 50;
|
||||
color: rgb(0,0,0);
|
||||
}
|
||||
clip {
|
||||
clip: 50 0 50 50;
|
||||
child: cross-fade {
|
||||
progress: 0.6;
|
||||
start: color {
|
||||
bounds: 0 0 50 50;
|
||||
color: rgb(255,0,0);
|
||||
}
|
||||
end: color {
|
||||
bounds: 100 0 50 50;
|
||||
color: rgb(0,0,255);
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 214 B |
@@ -0,0 +1,28 @@
|
||||
transform {
|
||||
transform: translate3d(0, 0, -10000);
|
||||
child: color {
|
||||
bounds: 0 0 50 50;
|
||||
color: rgb(255,0,0);
|
||||
}
|
||||
}
|
||||
transform {
|
||||
transform: translate3d(0, 0, -10001);
|
||||
child: color {
|
||||
bounds: 50 0 50 50;
|
||||
color: rgb(255,255,0);
|
||||
}
|
||||
}
|
||||
transform {
|
||||
transform: translate3d(0, 0, 10000);
|
||||
child: color {
|
||||
bounds: 0 50 50 50;
|
||||
color: rgb(0,255,0);
|
||||
}
|
||||
}
|
||||
transform {
|
||||
transform: translate3d(0, 0, 10001);
|
||||
child: color {
|
||||
bounds: 50 50 50 50;
|
||||
color: rgb(0,0,255);
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 331 B |
@@ -31,9 +31,11 @@ compare_render_tests = [
|
||||
'clipped-repeat-3d-ngl',
|
||||
'clipped_rounded_clip',
|
||||
'clip-nested1',
|
||||
'clip-translate-offscreen',
|
||||
'color-blur0',
|
||||
'color-matrix-identity',
|
||||
'color-matrix-parsing',
|
||||
'crossfade-clip-both-children',
|
||||
'cross-fade-in-opacity',
|
||||
'cross-fade-in-rotate',
|
||||
'css-background',
|
||||
@@ -88,6 +90,7 @@ compare_render_tests = [
|
||||
'texture-url',
|
||||
'transform-in-transform',
|
||||
'transform-in-transform-in-transform',
|
||||
'z-transform-clipping-bounds-3d',
|
||||
]
|
||||
|
||||
# these are too sensitive to differences in the renderers
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
<data>:5:10-11: error: GTK_CSS_PARSER_WARNING_SYNTAX
|
||||
<data>:6:8-9: error: GTK_CSS_PARSER_WARNING_SYNTAX
|
||||
<data>:5:3-10: error: GTK_CSS_PARSER_WARNING_SYNTAX
|
||||
<data>:6:3-8: error: GTK_CSS_PARSER_WARNING_SYNTAX
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user