Skip to content

Commit

Permalink
package/libgtk4: bump to 4.17.0
Browse files Browse the repository at this point in the history
https://gitlab.gnome.org/GNOME/gtk/-/blob/4.17.0/NEWS

Note that libgtk4 never selected BR2_PACKAGE_CAIRO_{PNG,ZLIB},
this is also not needed since [1]. Instead, we have to select
BR2_PACKAGE_LIBPNG ourselves, which libgtk3 indirectly did
by including BR2_PACKAGE_CAIRO_PNG.

Also, add patches for:
 - toolchains without fenv.h. [2]
 - when cairo has been compiled without surfaces. [3]

[1] https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/7717
[2] https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/7925
[3] https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/7926

Signed-off-by: Thomas Devoogdt <[email protected]>
  • Loading branch information
ThomasDevoogdt committed Dec 20, 2024
1 parent 44b2adf commit 6e06015
Show file tree
Hide file tree
Showing 6 changed files with 234 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
From 67cf230a85dcde61ba335cb8de52c4ea2e19caf2 Mon Sep 17 00:00:00 2001
From: Thomas Devoogdt <[email protected]>
Date: Fri, 15 Nov 2024 08:22:23 +0100
Subject: [PATCH] meson.build: add a check for the fenv header

Upstream: https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/7925
Signed-off-by: Thomas Devoogdt <[email protected]>
---
meson.build | 1 +
1 file changed, 1 insertion(+)

diff --git a/meson.build b/meson.build
index 2bb6f7c299..5f51aeb8a7 100644
--- a/meson.build
+++ b/meson.build
@@ -180,6 +180,7 @@ check_headers = [
'crt/externs.h',
'dev/evdev/input.h',
'dlfcn.h',
+ 'fenv.h',
'ftw.h',
'inttypes.h',
'linux/input.h',
--
2.43.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
From 4fb5e414b627d9c5c35ea85d467b06b56f5c7ee1 Mon Sep 17 00:00:00 2001
From: Thomas Devoogdt <[email protected]>
Date: Fri, 15 Nov 2024 08:22:40 +0100
Subject: [PATCH] gtk/gtkcssnumbervalue.c: fix compilation if fenv.h is missing

../gtk/gtkcssnumbervalue.c:29:10: fatal error: fenv.h: No such file or directory
29 | #include <fenv.h>
|

Upstream: https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/7925
Signed-off-by: Thomas Devoogdt <[email protected]>
---
gtk/gtkcssnumbervalue.c | 59 ++++++++++++++++++++++++++++++++---------
1 file changed, 47 insertions(+), 12 deletions(-)

diff --git a/gtk/gtkcssnumbervalue.c b/gtk/gtkcssnumbervalue.c
index 1181c1a802..03cf30262a 100644
--- a/gtk/gtkcssnumbervalue.c
+++ b/gtk/gtkcssnumbervalue.c
@@ -26,7 +26,9 @@
#include "gtkcssstyleprivate.h"
#include "gtkprivate.h"

+#ifdef HAVE_FENV_H
#include <fenv.h>
+#endif

#define RAD_TO_DEG(x) ((x) * 180.0 / G_PI)
#define DEG_TO_RAD(x) ((x) * G_PI / 180.0)
@@ -1846,13 +1848,25 @@ gtk_css_dimension_value_is_zero (const GtkCssValue *value)
return value->dimension.value == 0;
}

-static double
-_round (guint mode, double a, double b)
+#ifdef HAVE_FENV_H
+static inline double
+_round_fenv (int mode, double a, double b)
{
- int old_mode;
- int modes[] = { FE_TONEAREST, FE_UPWARD, FE_DOWNWARD, FE_TOWARDZERO };
double result;
+ int old_mode;

+ old_mode = fegetround ();
+ fesetround (mode);
+ result = nearbyint (a/b) * b;
+ fesetround (old_mode);
+
+ return result;
+}
+#endif
+
+static double
+_round (guint mode, double a, double b)
+{
if (b == 0)
return NAN;

@@ -1880,14 +1894,35 @@ _round (guint mode, double a, double b)
}
}

- old_mode = fegetround ();
- fesetround (modes[mode]);
-
- result = nearbyint (a/b) * b;
-
- fesetround (old_mode);
-
- return result;
+ switch (mode)
+ {
+ case ROUND_NEAREST:
+#ifdef FE_TONEAREST
+ return _round_fenv (FE_TONEAREST, a, b);
+#else
+ return round (a/b) * b;
+#endif
+ case ROUND_UP:
+#ifdef FE_UPWARD
+ return _round_fenv (FE_UPWARD, a, b);
+#else
+ return (((a/b) >= 0) ? ceil (a/b) : floor (a/b)) * b;
+#endif
+ case ROUND_DOWN:
+#ifdef FE_DOWNWARD
+ return _round_fenv (FE_DOWNWARD, a, b);
+#else
+ return (((a/b) >= 0) ? floor (a/b) : ceil (a/b)) * b;
+#endif
+ case ROUND_TO_ZERO:
+#ifdef FE_TOWARDZERO
+ return _round_fenv (FE_TOWARDZERO, a, b);
+#else
+ return (((a/b) >= 0) ? floor (a/b) : ceil (a/b)) * b;
+#endif
+ default:
+ g_assert_not_reached ();
+ }
}

static double
--
2.43.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
From b60bee17ddce7c44a455fa533e23aebebbfeea59 Mon Sep 17 00:00:00 2001
From: Thomas Devoogdt <[email protected]>
Date: Fri, 15 Nov 2024 13:42:58 +0100
Subject: [PATCH] modules/printbackends/gtkprintbackendfile.c: fix compilation
if no cairo surfaces are present
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

../modules/printbackends/gtkprintbackendfile.c: In function ‘output_file_from_settings’:
../modules/printbackends/gtkprintbackendfile.c:241:20: error: label at end of compound statement
241 | case N_FORMATS:
| ^~~~~~~~~
../modules/printbackends/gtkprintbackendfile.c: In function ‘file_printer_create_cairo_surface’:
../modules/printbackends/gtkprintbackendfile.c:363:12: error: label at end of compound statement
363 | case N_FORMATS:
| ^~~~~~~~~

Upstream: https://gitlab.gnome.org/GNOME/gtk/-/merge_requests/7926
Signed-off-by: Thomas Devoogdt <[email protected]>
---
modules/printbackends/gtkprintbackendfile.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/modules/printbackends/gtkprintbackendfile.c b/modules/printbackends/gtkprintbackendfile.c
index ddfd8d4425..436c767e4f 100644
--- a/modules/printbackends/gtkprintbackendfile.c
+++ b/modules/printbackends/gtkprintbackendfile.c
@@ -55,6 +55,12 @@ typedef struct _GtkPrintBackendFileClass GtkPrintBackendFileClass;

#define _STREAM_MAX_CHUNK_SIZE 8192

+#if defined(CAIRO_HAS_PDF_SURFACE) || \
+ defined(CAIRO_HAS_PS_SURFACE) || \
+ defined(CAIRO_HAS_SVG_SURFACE)
+#define _CAIRO_HAS_SURFACE 1
+#endif
+
struct _GtkPrintBackendFileClass
{
GtkPrintBackendClass parent_class;
@@ -237,8 +243,10 @@ output_file_from_settings (GtkPrintSettings *settings,
format = format_from_settings (settings);
switch (format)
{
+#ifdef _CAIRO_HAS_SURFACE
default:
case N_FORMATS:
+#endif
#ifdef CAIRO_HAS_PDF_SURFACE
case FORMAT_PDF:
extension = "pdf";
@@ -359,8 +367,10 @@ file_printer_create_cairo_surface (GtkPrinter *printer,

switch (format)
{
+#ifdef _CAIRO_HAS_SURFACE
default:
case N_FORMATS:
+#endif
#ifdef CAIRO_HAS_PDF_SURFACE
case FORMAT_PDF:
surface = cairo_pdf_surface_create_for_stream (_cairo_write, cache_io, width, height);
@@ -727,8 +737,10 @@ file_printer_get_options (GtkPrinter *printer,
{
switch (format)
{
+#ifdef _CAIRO_HAS_SURFACE
default:
case N_FORMATS:
+#endif
#ifdef CAIRO_HAS_PDF_SURFACE
case FORMAT_PDF:
current_format = FORMAT_PDF;
@@ -741,7 +753,7 @@ file_printer_get_options (GtkPrinter *printer,
#endif
#ifdef CAIRO_HAS_SVG_SURFACE
case FORMAT_SVG:
- current_format = FORMAT_SVG;
+ current_format = FORMAT_SVG;
break;
#endif
}
@@ -854,7 +866,9 @@ file_printer_prepare_for_print (GtkPrinter *printer,
#ifdef CAIRO_HAS_PDF_SURFACE
case FORMAT_PDF:
#endif
+#ifdef _CAIRO_HAS_SURFACE
case N_FORMATS:
+#endif
gtk_print_job_set_rotate (print_job, FALSE);
break;
default:
--
2.43.0

1 change: 1 addition & 0 deletions package/libgtk4/Config.in
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ config BR2_PACKAGE_LIBGTK4
select BR2_PACKAGE_GRAPHENE
select BR2_PACKAGE_LIBEPOXY
select BR2_PACKAGE_LIBGLIB2
select BR2_PACKAGE_LIBPNG
select BR2_PACKAGE_PANGO
select BR2_PACKAGE_TIFF
# At least one backend is required
Expand Down
4 changes: 2 additions & 2 deletions package/libgtk4/libgtk4.hash
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# From https://download.gnome.org/sources/gtk/4.14/gtk-4.14.5.sha256sum
sha256 5547f2b9f006b133993e070b87c17804e051efda3913feaca1108fa2be41e24d gtk-4.14.5.tar.xz
# From https://download.gnome.org/sources/gtk/4.17/gtk-4.17.0.sha256sum
sha256 efcef355b5d903fc62a70934b1c644f39661e3c2ff44c8c53a8fcdb70c7dd97e gtk-4.17.0.tar.xz

# Hash for license file:
sha256 b7993225104d90ddd8024fd838faf300bea5e83d91203eab98e29512acebd69c COPYING
5 changes: 3 additions & 2 deletions package/libgtk4/libgtk4.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
#
################################################################################

LIBGTK4_VERSION_MAJOR = 4.14
LIBGTK4_VERSION = $(LIBGTK4_VERSION_MAJOR).5
LIBGTK4_VERSION_MAJOR = 4.17
LIBGTK4_VERSION = $(LIBGTK4_VERSION_MAJOR).0
LIBGTK4_SOURCE = gtk-$(LIBGTK4_VERSION).tar.xz
LIBGTK4_SITE = https://download.gnome.org/sources/gtk/$(LIBGTK4_VERSION_MAJOR)
LIBGTK4_LICENSE = LGPL-2.0+
Expand All @@ -21,6 +21,7 @@ LIBGTK4_DEPENDENCIES = \
graphene \
libepoxy \
libglib2 \
libpng \
pango \
$(TARGET_NLS_DEPENDENCIES)

Expand Down

0 comments on commit 6e06015

Please sign in to comment.