diff options
-rw-r--r-- | docs/reference/gtk/migrating-4to5.md | 6 | ||||
-rw-r--r-- | gdk/gdkcairo.c | 41 | ||||
-rw-r--r-- | gdk/gdkcairoprivate.h | 37 | ||||
-rw-r--r-- | gtk/gdkpixbufutils.c | 35 | ||||
-rw-r--r-- | gtk/gdkpixbufutilsprivate.h | 18 | ||||
-rw-r--r-- | gtk/gtkcssshadowvalueprivate.h | 1 | ||||
-rw-r--r-- | gtk/gtkiconcachevalidator.c | 2 | ||||
-rw-r--r-- | gtk/gtkimage.c | 7 | ||||
-rw-r--r-- | gtk/gtkimage.h | 4 | ||||
-rw-r--r-- | gtk/gtkpicture.c | 5 | ||||
-rw-r--r-- | gtk/gtkpicture.h | 4 | ||||
-rw-r--r-- | gtk/inspector/gtkdataviewer.c | 2 | ||||
-rw-r--r-- | testsuite/gtk/sorter.c | 6 | ||||
-rw-r--r-- | tools/meson.build | 4 |
14 files changed, 40 insertions, 132 deletions
diff --git a/docs/reference/gtk/migrating-4to5.md b/docs/reference/gtk/migrating-4to5.md index 30e9e2d6e0..0153846c64 100644 --- a/docs/reference/gtk/migrating-4to5.md +++ b/docs/reference/gtk/migrating-4to5.md @@ -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. diff --git a/gdk/gdkcairo.c b/gdk/gdkcairo.c index fec75fb8b5..a1236667dc 100644 --- a/gdk/gdkcairo.c +++ b/gdk/gdkcairo.c @@ -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; -} diff --git a/gdk/gdkcairoprivate.h b/gdk/gdkcairoprivate.h deleted file mode 100644 index 06a9eef9f2..0000000000 --- a/gdk/gdkcairoprivate.h +++ /dev/null @@ -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 - diff --git a/gtk/gdkpixbufutils.c b/gtk/gdkpixbufutils.c index 8d049311ac..c60335e228 100644 --- a/gtk/gdkpixbufutils.c +++ b/gtk/gdkpixbufutils.c @@ -91,7 +91,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, @@ -180,35 +180,6 @@ _gdk_pixbuf_new_from_stream (GInputStream *stream, 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 * _gdk_pixbuf_new_from_resource_at_scale (const char *resource_path, int width, @@ -464,7 +435,7 @@ gtk_make_symbolic_pixbuf_from_path (const char *path, return pixbuf; } -GdkPixbuf * +static GdkPixbuf * gtk_make_symbolic_pixbuf_from_file (GFile *file, int width, int height, @@ -576,7 +547,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) { diff --git a/gtk/gdkpixbufutilsprivate.h b/gtk/gdkpixbufutilsprivate.h index f9c9fe852c..10801722e4 100644 --- a/gtk/gdkpixbufutilsprivate.h +++ b/gtk/gdkpixbufutilsprivate.h @@ -30,21 +30,11 @@ GdkPixbuf *_gdk_pixbuf_new_from_stream_at_scale (GInputStream *stream, 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,11 +42,6 @@ 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, - int width, - int height, - double scale, - GError **error); GdkPixbuf *gtk_make_symbolic_pixbuf_from_path (const char *path, int width, int height, @@ -79,9 +64,6 @@ GdkTexture *gtk_make_symbolic_texture_from_resource (const char *path, int height, double scale, GError **error); - -GdkPaintable *gdk_paintable_new_from_bytes_scaled (GBytes *bytes, - int scale_factor); GdkPaintable *gdk_paintable_new_from_path_scaled (const char *path, int scale_factor); GdkPaintable *gdk_paintable_new_from_resource_scaled (const char *path, diff --git a/gtk/gtkcssshadowvalueprivate.h b/gtk/gtkcssshadowvalueprivate.h index ddd7f672e3..df56b0ee58 100644 --- a/gtk/gtkcssshadowvalueprivate.h +++ b/gtk/gtkcssshadowvalueprivate.h @@ -28,7 +28,6 @@ #include "gtkborder.h" #include "gtktypes.h" #include "gtkcssvalueprivate.h" -#include "gtkroundedboxprivate.h" #include "gtksnapshot.h" G_BEGIN_DECLS diff --git a/gtk/gtkiconcachevalidator.c b/gtk/gtkiconcachevalidator.c index 7cec4d486f..8ddd24a361 100644 --- a/gtk/gtkiconcachevalidator.c +++ b/gtk/gtkiconcachevalidator.c @@ -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 diff --git a/gtk/gtkimage.c b/gtk/gtkimage.c index 44690975a2..33c2841ef4 100644 --- a/gtk/gtkimage.c +++ b/gtk/gtkimage.c @@ -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, diff --git a/gtk/gtkimage.h b/gtk/gtkimage.h index 59083e1b9b..8c293c92c3 100644 --- a/gtk/gtkimage.h +++ b/gtk/gtkimage.h @@ -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 diff --git a/gtk/gtkpicture.c b/gtk/gtkpicture.c index 72ee47b195..dadd2b4b6e 100644 --- a/gtk/gtkpicture.c +++ b/gtk/gtkpicture.c @@ -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, diff --git a/gtk/gtkpicture.h b/gtk/gtkpicture.h index 919369e43d..58f2a1c836 100644 --- a/gtk/gtkpicture.h +++ b/gtk/gtkpicture.h @@ -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); diff --git a/gtk/inspector/gtkdataviewer.c b/gtk/inspector/gtkdataviewer.c index bea24dd6d9..12808c3ac1 100644 --- a/gtk/inspector/gtkdataviewer.c +++ b/gtk/inspector/gtkdataviewer.c @@ -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)); } diff --git a/testsuite/gtk/sorter.c b/testsuite/gtk/sorter.c index ee54ee1edd..33ae78f6be 100644 --- a/testsuite/gtk/sorter.c +++ b/testsuite/gtk/sorter.c @@ -305,6 +305,7 @@ test_string (void) expression = gtk_cclosure_expression_new (G_TYPE_STRING, NULL, 0, NULL, (GCallback)get_spelled_out, NULL, NULL); gtk_string_sorter_set_expression (GTK_STRING_SORTER (sorter), expression); + g_assert_true (gtk_string_sorter_get_expression (GTK_STRING_SORTER (sorter)) == expression); gtk_expression_unref (expression); assert_model (model, "8 18 11 15 5 4 14 9 19 1 7 17 6 16 10 13 3 12 20 2"); @@ -343,11 +344,16 @@ test_change (void) gtk_expression_unref (expression); gtk_string_sorter_set_ignore_case (GTK_STRING_SORTER (sorter), FALSE); + g_assert_false (gtk_string_sorter_get_ignore_case (GTK_STRING_SORTER (sorter))); g_assert_cmpint (counter, ==, 2); gtk_string_sorter_set_ignore_case (GTK_STRING_SORTER (sorter), FALSE); g_assert_cmpint (counter, ==, 2); + gtk_string_sorter_set_collation (GTK_STRING_SORTER (sorter), GTK_COLLATION_FILENAME); + g_assert_true (gtk_string_sorter_get_collation (GTK_STRING_SORTER (sorter)) == GTK_COLLATION_FILENAME); + g_assert_cmpint (counter, ==, 3); + g_object_unref (sorter); } diff --git a/tools/meson.build b/tools/meson.build index 0e90d88945..af77a7abb6 100644 --- a/tools/meson.build +++ b/tools/meson.build @@ -31,7 +31,7 @@ gtk_tools = [ 'gtk-builder-tool-screenshot.c', 'gtk-builder-tool-preview.c', 'fake-scope.c'], [libgtk_dep] ], - ['gtk4-update-icon-cache', ['updateiconcache.c'] + extra_update_icon_cache_objs, [ libgtk_static_dep ] ], + ['gtk4-update-icon-cache', ['updateiconcache.c', '../gtk/gtkiconcachevalidator.c' ] + extra_update_icon_cache_objs, [ libgtk_dep ] ], ['gtk4-encode-symbolic-svg', ['encodesymbolic.c'], [ libgtk_static_dep ] ], ] @@ -47,7 +47,7 @@ foreach tool: gtk_tools exe = executable(tool_name, sources: tool_srcs, include_directories: [confinc], - c_args: common_cflags, + c_args: common_cflags + [ '-DBUILD_TOOLS' ], dependencies: tool_deps, install: true, ) |