[gnome-todo/gbsneto/animations: 5/10] flatpak: Make GTK4 actually useful




commit 1991f6cd902d46102b576425e645f14bf4add0d1
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue Aug 11 14:09:51 2020 -0300

    flatpak: Make GTK4 actually useful

 build-aux/flatpak/adjusted-allocation.patch | 77 +++++++++++++++++++++++++++++
 build-aux/flatpak/org.gnome.Todo.json       |  4 ++
 2 files changed, 81 insertions(+)
---
diff --git a/build-aux/flatpak/adjusted-allocation.patch b/build-aux/flatpak/adjusted-allocation.patch
new file mode 100644
index 0000000..84dde05
--- /dev/null
+++ b/build-aux/flatpak/adjusted-allocation.patch
@@ -0,0 +1,77 @@
+From b08234828a6e301448bb12e1cde44cdb064f9147 Mon Sep 17 00:00:00 2001
+From: Georges Basile Stavracas Neto <georges stavracas gmail com>
+Date: Tue, 11 Aug 2020 13:12:36 -0300
+Subject: [PATCH] widget: Add function to get adjusted allocation
+
+---
+ gtk/gtkwidget.c | 36 ++++++++++++++++++++++++++++++++++++
+ gtk/gtkwidget.h |  6 ++++++
+ 2 files changed, 42 insertions(+)
+
+diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
+index 8f92c09a88..a5e101ded8 100644
+--- a/gtk/gtkwidget.c
++++ b/gtk/gtkwidget.c
+@@ -3733,6 +3733,42 @@ gtk_widget_adjust_size_allocation (GtkWidget     *widget,
+                     &allocation->height);
+ }
+ 
++void
++gtk_widget_get_adjusted_allocation (GtkWidget     *widget,
++                                    int            width,
++                                    int            height,
++                                    GtkAllocation *allocation)
++{
++  GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
++  GtkBorder margin, border, padding;
++  GtkAllocation adjusted;
++  GtkCssStyle *style;
++
++  adjusted.x = priv->margin.left;
++  adjusted.y = priv->margin.top;
++  adjusted.width = width - priv->margin.left - priv->margin.right;
++  adjusted.height = height - priv->margin.top - priv->margin.bottom;
++
++  gtk_widget_adjust_size_allocation (widget, &adjusted);
++
++  style = gtk_css_node_get_style (priv->cssnode);
++  get_box_margin (style, &margin);
++  get_box_border (style, &border);
++  get_box_padding (style, &padding);
++
++  /* Apply CSS transformation */
++  adjusted.x += margin.left;
++  adjusted.y += margin.top;
++  adjusted.width -= margin.left + margin.right +
++                    border.left + padding.left +
++                    border.right + padding.right;
++  adjusted.height -= margin.top + margin.bottom +
++                     border.top + padding.top +
++                     border.bottom + padding.bottom;
++
++  *allocation = adjusted;
++}
++
+ /**
+  * gtk_widget_allocate:
+  * @widget: A #GtkWidget
+diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
+index e86f07d1c0..1ec621d295 100644
+--- a/gtk/gtkwidget.h
++++ b/gtk/gtkwidget.h
+@@ -972,6 +972,12 @@ void                    gtk_widget_class_set_accessible_role    (GtkWidgetClass
+ GDK_AVAILABLE_IN_ALL
+ GtkAccessibleRole       gtk_widget_class_get_accessible_role    (GtkWidgetClass    *widget_class);
+ 
++GDK_AVAILABLE_IN_ALL
++void gtk_widget_get_adjusted_allocation (GtkWidget     *widget,
++                                         int            width,
++                                         int            height,
++                                         GtkAllocation *allocation);
++
+ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkWidget, g_object_unref)
+ G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkRequisition, gtk_requisition_free)
+ 
+-- 
+2.28.0
+
diff --git a/build-aux/flatpak/org.gnome.Todo.json b/build-aux/flatpak/org.gnome.Todo.json
index 303c15f..b99a127 100644
--- a/build-aux/flatpak/org.gnome.Todo.json
+++ b/build-aux/flatpak/org.gnome.Todo.json
@@ -200,6 +200,10 @@
                 {
                     "type": "git",
                     "url": "https://gitlab.gnome.org/GNOME/gtk.git";
+                },
+                {
+                    "type": "patch",
+                    "path": "adjusted-allocation.patch"
                 }
             ]
         },


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]