summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Pirotte <david@altosw.be>2023-01-09 18:19:34 -0300
committerDavid Pirotte <david@altosw.be>2023-01-09 18:19:34 -0300
commit6a9e1801d158d40c9a355d7fd3925cb736f753df (patch)
treec56258ff2f104b5364154d77432f74b9cd352d56
parent644a8d042c965aa28d8a3f27f4b6f112e59c2bcb (diff)
parent548ffab63a7890da87bdce1d153b131838a0790e (diff)
Prepare 0.8.0-a.2v0.8.0-a.2
* Merge branch 'devel'.
-rw-r--r--INSTALL12
-rw-r--r--NEWS70
-rw-r--r--README26
-rw-r--r--am/guile.mk1
-rw-r--r--configure.ac6
-rw-r--r--doc/Makefile.am1
-rw-r--r--doc/cr-support-struct.texi91
-rw-r--r--doc/g-golf.texi4
-rw-r--r--doc/introduction.texi32
-rw-r--r--doc/preface.texi6
-rw-r--r--doc/ug-ggv-utils.texi57
-rw-r--r--doc/ug-ggv.texi2
-rw-r--r--doc/variables.texi10
-rw-r--r--examples/gtk-4/drawing-widget.pngbin0 -> 5166 bytes
-rwxr-xr-xexamples/gtk-4/drawing-widget.scm91
-rw-r--r--examples/gtk-4/peg-solitaire.pngbin8294 -> 8652 bytes
-rwxr-xr-xexamples/gtk-4/peg-solitaire.scm29
-rw-r--r--g-golf/gi/cache-gi.scm132
-rw-r--r--g-golf/gi/cache-others.scm32
-rw-r--r--g-golf/gi/struct-info.scm3
-rw-r--r--g-golf/hl-api/callable.scm4
-rw-r--r--g-golf/hl-api/gobject.scm8
-rw-r--r--g-golf/hl-api/object.scm25
-rw-r--r--g-golf/hl-api/utils.scm18
-rw-r--r--g-golf/hl-api/vfunc.scm40
-rw-r--r--g-golf/override/gdk.scm5
-rw-r--r--g-golf/support/struct.scm38
27 files changed, 505 insertions, 238 deletions
diff --git a/INSTALL b/INSTALL
index 8c7e35d..68545b7 100644
--- a/INSTALL
+++ b/INSTALL
@@ -4,7 +4,7 @@
#+BEGIN_COMMENT
-Copyright (C) 2016 - 2022
+Copyright (C) 2016 - 2023
Free Software Foundation, Inc.
This document is part of GNU G-Golf.
@@ -33,14 +33,14 @@ GNU G-Golf needs the following software to run:
[[http://www.nongnu.org/guile-lib/][Guile-Lib]] >= 0.2.5
Glib-2.0 >= 2.48.0
Gobject-2.0 >= 2.48.0
- GObject-Introspection-1.0 >= 1.48.0
+ GObject-Introspection-1.0 >= 1.72.0
** Install from the tarball
G-Golf release are [[http://ftp.gnu.org/gnu/g-golf/][here]]. The latest tarballs are:
- g-golf-0.8.0-a.1.tar.gz
- g-golf-0.8.0-a.1.tar.gz.sig
+ g-golf-0.8.0-a.2.tar.gz
+ g-golf-0.8.0-a.2.tar.gz.sig
[ GPG Key: A3057AD7
[ gpg --keyserver keys.gnupg.net --recv-keys A3057AD7
@@ -49,8 +49,8 @@ Assuming you have satisfied the dependencies, open a terminal and
proceed with the following steps:
cd <download-path>
- tar zxf g-golf-0.8.0-a.1.tar.gz
- cd g-golf-0.8.0-a.1
+ tar zxf g-golf-0.8.0-a.2.tar.gz
+ cd g-golf-0.8.0-a.2
./configure [--prefix=/your/prefix] [--with-guile-site=yes]
make
make install
diff --git a/NEWS b/NEWS
index 51840f8..bfb6059 100644
--- a/NEWS
+++ b/NEWS
@@ -4,7 +4,7 @@
#+BEGIN_COMMENT
-Copyright (C) 2016 - 2022
+Copyright (C) 2016 - 2023
Free Software Foundation, Inc.
This document is part of GNU G-Golf.
@@ -26,24 +26,66 @@ warranty.
* Latest News
-** December 2022
+** January 2023
-[[http://www.gnu.org/software/g-golf][GNU G-Golf]] version 0.8.0-a.1 is released.
+[[http://www.gnu.org/software/g-golf][GNU G-Golf]] version 0.8.0-a.2 is released.
-This is the first release of the upcoming 0.8.0 release, now available
+This is the second release of the upcoming 0.8.0 release, now available
for testing.
-#+BEGIN_COMMENT
-This is the first release of G-Golf.
+*** Changes since 0.8.0-a.1
-Here is a summary of the changes since version 0.0.0. See GNU G-Golf
-[[http://git.savannah.gnu.org/cgit/g-golf.git][git summary]] and [[http://git.savannah.gnu.org/cgit/g-golf.git/log/][git log]] for a complete description:
-#+END_COMMENT
+Here is a summary of the noteworthy changes since version 0.8.0-a.1. See
+G-Golf [[http://git.savannah.gnu.org/cgit/g-golf.git][git summary]] and [[http://git.savannah.gnu.org/cgit/g-golf.git/log/][git log]] for a complete list and description.
-* Older News
+**** Dependencies
-#+BEGIN_COMMENT
-This is the first release of G-Golf.
+GObject-Introspection-1.0 >= 1.72.0
-For older News, see [[http://www.gnu.org/software/g-golf/news.html][here]]
-#+END_COMMENT
+G-Golf uses GI girffi innterfaces, some only available since 1.72.0.
+
+**** New interfaces
+
+allocate-c-struct
+
+**** Examples
+
+Peg Solitaire
+
+The peg snapshots (which are what users drag while playing the game) now
+also have rounded corners. Before this improvment, they were being
+clipped by their <gtk-image> instance hosts, which use both a css
+border-radius style option and the overflow property, but users were
+dragging a squared rectangle snapshot.
+
+Drawing Widget
+
+New example, which demonstrates how implement a widget that does some
+custom drawing.
+
+**** Performance
+
+~15% improvement
+
+ Note: by performance, until otherwise specified, we only refer to and
+ measure how fast G-Golf imports the entire Gtk 4.0 typelib.
+
+After some changes made to the G-Golf main GI cache, importing Gtk-4.0
+shows a ~15% improvement.
+
+**** Bug fixing
+
+VFunc
+
+A VFunc specializer may also be a g-object class, as the newly added
+example demonstrates. Prior to this fix, a VFunc specializer was assumed
+to (always) be a g-interface class (as in the peg-solitaire example).
+
+GObject.TypeInstance
+
+GObject.TypeInstance fundamental class support fix. They must inherit
+<gtype-instance> and specify <gtype-class> as their metaclass.
+
+* Older News
+
+For older News, see [[http://www.gnu.org/software/g-golf/news.html][here]].
diff --git a/README b/README
index 4624a4e..48e4474 100644
--- a/README
+++ b/README
@@ -4,7 +4,7 @@
#+BEGIN_COMMENT
-Copyright (C) 2016 - 2022
+Copyright (C) 2016 - 2023
Free Software Foundation, Inc.
This document is part of GNU G-Golf.
@@ -26,18 +26,22 @@ warranty.
* GNU G-Golf
-[[http://www.gnu.org/software/g-golf][GNU G-Golf]]
-GNOME: ([[http://www.gnu.org/software/guile][Guile]] Object Library for).
+[[http://www.gnu.org/software/g-golf][G-Golf]]
+GNOME: (Guile Object Library for).
** Description
-G-Golf is a Guile Object Library for [[https://www.gnome.org/][GNOME]].
+[[http://www.gnu.org/software/g-golf][G-Golf]] is a [[https://www.gnu.org/software/guile/][Guile]] Object Library for [[https://www.gnome.org/][GNOME]].
G-Golf is tool to develop fast and feature-rich graphical applications,
-with a recognizable look and feel.
+with a recognizable look and feel. Here is an overview of the [[https://developer.gnome.org/documentation/introduction/overview/libraries.html][GNOME
+platform libraries]], accessible using G-Golf.
-Here is an overview of the [[https://developer.gnome.org/documentation/introduction/overview/libraries.html][GNOME platform libraries]], accessible using
-G-Golf.
+In particular, [[https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/][libadwaita]] provides a number of widgets that change their
+layout based on the available space. This can be used to make
+applications adapt their UI between desktop and mobile devices. The
+[[https://wiki.gnome.org/Apps/Web][GNOME Web]] (best known through its code name, Epiphany, is a good example
+of such an adaptive UI.
G-Golf uses [[https://docs.gtk.org/glib/index.html][GLib]], [[https://docs.gtk.org/gobject/index.html][GObject]] and [[https://gi.readthedocs.io/en/latest/][GObject Introspection]]. As it imports a
[[https://gi.readthedocs.io/en/latest/][Typelib]] (a GObject introspectable library), G-Golf defines GObject
@@ -46,8 +50,8 @@ are defined and added to their corresponding generic function. Simple
functions are defined as scheme procedures.
Here is an example, an excerpt taken from the peg-solitaire game, that
-shows the implementation of GtkApplication activate signal callback
-in G-Golf:
+shows the implementation, for the peg-solitaire game, of the
+GtkApplication activate signal callback in G-Golf:
#+BEGIN_SRC scheme
(define (activate app)
@@ -77,9 +81,9 @@ points to its source code, in the G-Golf sources [[http://git.savannah.gnu.org/c
** Latest News
-December 2022
+January 2023
-GNU G-Golf version 0.8.0-a.1 is released.
+GNU G-Golf version 0.8.0-a.2 is released.
Visit the NEWS file or see the [[http://git.savannah.gnu.org/cgit/g-golf.git/tree/NEWS][News]] page for the list of visible changes
since the last release, as well as older news.
diff --git a/am/guile.mk b/am/guile.mk
index 43e09ff..5e23d93 100644
--- a/am/guile.mk
+++ b/am/guile.mk
@@ -26,6 +26,7 @@ godir=@SITECCACHEDIR@
GOBJECTS = $(SOURCES:%.scm=%.go)
+.NOTPARALLEL: $(GOBJETS)
nobase_mod_DATA = $(SOURCES) $(NOCOMP_SOURCES)
nobase_go_DATA = $(GOBJECTS)
diff --git a/configure.ac b/configure.ac
index b4bac88..6887c75 100644
--- a/configure.ac
+++ b/configure.ac
@@ -6,7 +6,7 @@ dnl
define(G_GOLF_CONFIGURE_COPYRIGHT,[[
-Copyright (C) 2016 - 2022
+Copyright (C) 2016 - 2023
Free Software Foundation, Inc.
This file is part of GNU G-Golf
@@ -31,7 +31,7 @@ AC_PREREQ(2.69)
AC_INIT(
[g-golf],
- [0.8.0-a.1],
+ [0.8.0-a.2],
[bug-g-golf@gnu.org])
AC_CONFIG_AUX_DIR([build-aux])
@@ -87,7 +87,7 @@ AC_SUBST([SITEDIR])
AC_SUBST([SITECCACHEDIR])
-PKG_CHECK_MODULES(GOBJECT_INTROSPECTION, gobject-introspection-1.0 >= 1.48.0)
+PKG_CHECK_MODULES(GOBJECT_INTROSPECTION, gobject-introspection-1.0 >= 1.72.0)
AC_SUBST(GOBJECT_INTROSPECTION_CFLAGS)
AC_SUBST(GOBJECT_INTROSPECTION_LIBS)
diff --git a/doc/Makefile.am b/doc/Makefile.am
index 94e9bd1..a8f1a3e 100644
--- a/doc/Makefile.am
+++ b/doc/Makefile.am
@@ -55,6 +55,7 @@ g_golf_TEXINFOS = \
ug-ggv-cache.texi \
ug-ggv-customization.texi \
ug-ggv-vfunc.texi \
+ ug-ggv-utils.texi \
cr.texi \
cr-overview.texi \
cr-ov-structure-and-naming-conventions.texi \
diff --git a/doc/cr-support-struct.texi b/doc/cr-support-struct.texi
index b435381..20a413f 100644
--- a/doc/cr-support-struct.texi
+++ b/doc/cr-support-struct.texi
@@ -20,10 +20,11 @@ types.
@end indentedblock
-@subheading Procedures and Accessors
+@subheading Procedures, Accessors and Methods
@indentedblock
@table @code
+@item @ref{!g-type____}
@item @ref{!g-name_}
@item @ref{!name____}
@item @ref{!alignment}
@@ -31,10 +32,12 @@ types.
@item @ref{!is-gtype-struct?}
@item @ref{!is-foreign?}
@item @ref{!field-types}
+@item @ref{!field-desc}
@item @ref{!scm-types}
@item @ref{!init-vals}
@item @ref{!is-opaque?}
@item @ref{!is-semi-opaque?}
+@item @ref{field-offset}
@end table
@end indentedblock
@@ -50,51 +53,46 @@ types.
@anchor{<gi-struct>}
@deftp Class <gi-struct>
-The @code{<gi-struct>} class is a subclass of @code{<struct>}. Its
-@code{class-direct-slots} are:
+@code{<gi-struct>} is a class. It's an instance of @code{<class>}.
+
+Superclasses are:
@indentedblock
@table @code
-@item @emph{g-name}
-#:accessor !g-name @*
-#:init-keyword #:g-name
-
-@item @emph{name}
-#:accessor !name
-
-@item @emph{alignment}
-#:accessor !alignment @*
-#:init-keyword #:alignment
-
-@item @emph{size}
-#:accessor !size @*
-#:init-keyword #:size
-
-@item @emph{is-gtype-struct?}
-#:accessor !is-gtype-struct? @*
-#:init-keyword #:is-gtype-struct?
-
-@item @emph{field-types}
-#:accessor !field-types @*
-#:init-keyword #:field-types
+@item <object>
+@end table
+@end indentedblock
-@item @emph{scm-types}
-#:accessor !scm-types
+Class Precedence List is:
-@item @emph{init-vals}
-#:accessor !init-vals
+@indentedblock
+@table @code
+@item <g-struct>
+@item <object>
+@item <top>
+@end table
+@end indentedblock
-@item @emph{is-opaque?}
-#:accessor !is-opaque?
+Directs slots are:
-@item @emph{is-semi-opaque}
-#:accessor !is-semi-opaque?
+@indentedblock
+@table @code
+@item g-type
+@item g-name
+@item name
+@item alignment
+@item size
+@item is-gtype-struct?
+@item is-foreign?
+@item field-types
+@item field-desc
+@item scm-types
+@item init-vals
+@item is-opaque?
+@item is-semi-opaque?
@end table
@end indentedblock
-The @code{name} and @code{scm-types} slots are automatically
-initialized.
-
Instances of the @code{<gi-struct>} are immutable (to be precise, there
are not meant to be mutated, see @ref{GOOPS Notes and Conventions},
'Slots are not Immutable').
@@ -103,6 +101,7 @@ are not meant to be mutated, see @ref{GOOPS Notes and Conventions},
@subheading Procedures and Accessors
+@anchor{!g-type____}
@anchor{!g-name_}
@anchor{!name____}
@anchor{!alignment}
@@ -110,14 +109,17 @@ are not meant to be mutated, see @ref{GOOPS Notes and Conventions},
@anchor{!is-gtype-struct?}
@anchor{!is-foreign?}
@anchor{!field-types}
+@anchor{!field-desc}
@anchor{!scm-types}
@anchor{!init-vals}
-@deffn Accessor !g-name (inst <gi-struct>)
+@deffn Accessor !g-type (inst <gi-struct>)
+@deffnx Accessor !g-name (inst <gi-struct>)
@deffnx Accessor !name (inst <gi-struct>)
@deffnx Accessor !alignment (inst <gi-struct>)
@deffnx Accessor !size (inst <gi-struct>)
@deffnx Accessor !is-gtype-struct? (inst <gi-struct>)
@deffnx Accessor !field-types (inst <gi-struct>)
+@deffnx Accessor !field-desc (inst <gi-struct>)
@deffnx Accessor !scm-types (inst <gi-struct>)
@deffnx Accessor !init-vals (inst <gi-struct>)
@@ -148,9 +150,22 @@ Returns @code{#t} if @var{inst} is @samp{semi-opaque}, otherwise,
it returns @code{#f}.
A <gi-struct> instance is said to be @samp{semi-opaque} when one of its
-field types is @code{void}.
+field types is @code{void}, @code{interface} or if the total size of the
+@code{scm-types} differs from the @var{inst} size slot vlue.
@samp{Semi-opaque} boxed types should never be @samp{decoded}, nor
@samp{encoded}. Instead, procedures, accessors and methods should
@samp{blindingly} receive, pass and/or return their pointer(s).
@end deffn
+
+
+@anchor{field-offset}
+@deffn Method field-offset (inst <gi-struct>) field-name
+
+Returns an integer.
+
+Obtain and returns the @var{field-name} offset for @var{inst}, It is an
+error to call this method if there is no such @var
+{field-name} defined
+for @var{inst}.
+@end deffn
diff --git a/doc/g-golf.texi b/doc/g-golf.texi
index 9500231..d90f6db 100644
--- a/doc/g-golf.texi
+++ b/doc/g-golf.texi
@@ -1,7 +1,7 @@
\input texinfo
@c -*- mode: texinfo; coding: utf-8 -*-
@c This is part of the GNU G-Golf Reference Manual.
-@c Copyright (C) 2016 - 2022 Free Software Foundation, Inc.
+@c Copyright (C) 2016 - 2023 Free Software Foundation, Inc.
@setfilename g-golf.info
@@ -19,7 +19,7 @@
@copying
This manual documents GNU G-Golf version @value{VERSION}.
-Copyright (C) 2016 - 2022 Free Software Foundation, Inc.
+Copyright (C) 2016 - 2023 Free Software Foundation, Inc.
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
diff --git a/doc/introduction.texi b/doc/introduction.texi
index b6bdaae..cdd317f 100644
--- a/doc/introduction.texi
+++ b/doc/introduction.texi
@@ -23,7 +23,7 @@
@node About G-Golf
@section About G-Golf
-GNU G-Golf @*
+G-Golf @*
GNOME: (Guile Object Library for).
@@ -38,6 +38,13 @@ applications, with a clean and recognizable look and feel. Here is an
overview of the @uref{@value{UGNOME-Libraries}, GNOME platform
libraries}, accessible using G-Golf.
+In particular, @uref{@value{ULIBADWAITA}, libadwaita} provides a number
+of widgets that change their layout based on the available space. This
+can be used to make applications adapt their UI between desktop and
+mobile devices. The @uref{@value{UGNOME-Web}, GNOME Web} (best known
+through its code name, Epiphany, is a good example of such an adaptive
+UI.
+
G-Golf uses @uref{@value{UGLIB}, Glib}, @uref{@value{UGOBJECT}, GObject}
and @uref{@value{UGI-OVERVIEW}, GObject Introspection}. As it imports a
@uref{@value{UGI-OVERVIEW}, Typelib} (a GObject introspectable library),
@@ -86,7 +93,7 @@ Savannah}.
@node Obtaining and installing G-Golf
@section Obtaining and installing G-Golf
-GNU G-Golf can be obtained from the following archive site
+G-Golf can be obtained from the following archive site
@uref{@value{UG-GOLF-RELEASES}}. The file will be named
g-golf-version.tar.gz. The current version is @value{VERSION}, so the
file you should grab is:
@@ -96,7 +103,7 @@ file you should grab is:
@subheading Dependencies
-GNU G-Golf needs the following software to run:
+G-Golf needs the following software to run:
@itemize @bullet
@@ -110,7 +117,9 @@ Automake >= 1.14
Makeinfo >= 6.6
@item
-@uref{@value{UGUILE}, Guile} >= 2.0.14 [allows 2.2 3.0 (>= 3.0.7)]
+@uref{@value{UGUILE}, Guile} >= 2.0.14
+
+[allows 2.2 and 3.0 (>= 3.0.7)]
@item
@uref{@value{UGUILE-LIB}, Guile-Lib} >= 0.2.5
@@ -122,7 +131,20 @@ Makeinfo >= 6.6
@uref{@value{UGOBJECT}, Gobject-2.0} >= 2.48.0
@item
-@uref{@value{UGI}, GObject-Introspection-1.0} >= 1.48.0
+@uref{@value{UGI}, GObject-Introspection-1.0} >= 1.72.0
+
+@end itemize
+
+G-Golf currently needs the following additional software to run its
+test-suite:
+
+@itemize @bullet
+
+@item
+@uref{@value{UCLUTTER}, Clutter-1.0} >= 1.24.0
+
+@item
+@uref{@value{UGTK3}, Gtk-3.0} >= 3.10.0
@end itemize
diff --git a/doc/preface.texi b/doc/preface.texi
index fb0c1b9..f41afb2 100644
--- a/doc/preface.texi
+++ b/doc/preface.texi
@@ -1,6 +1,6 @@
@c -*-texinfo-*-
@c This is part of the GNU G-Golf Reference Manual.
-@c Copyright (C) 2016 - 2021 Free Software Foundation, Inc.
+@c Copyright (C) 2016 - 2022 Free Software Foundation, Inc.
@c See the file g-golf.texi for copying conditions.
@@ -37,8 +37,8 @@ You are most welcome to join and help. Visit G-Golf's web site at
@unnumberedsec Join the GNU Project
@cindex the GNU Project
-GNU G-Golf is part of the GNU Operating System, developed by the GNU
-Project.
+@uref{@value{UG-GOLF}, G-Golf} is part of the GNU Operating System,
+developed by the @uref{@value{UGNU-Project}, GNU Project}.
If you are the author of an awesome program and want to join us in
writing Free (libre) Software, please consider making it an official GNU
diff --git a/doc/ug-ggv-utils.texi b/doc/ug-ggv-utils.texi
new file mode 100644
index 0000000..cf770ea
--- /dev/null
+++ b/doc/ug-ggv-utils.texi
@@ -0,0 +1,57 @@
+@c -*-texinfo-*-
+@c This is part of the GNU G-Golf Reference Manual.
+@c Copyright (C) 2022 - 2023 Free Software Foundation, Inc.
+@c See the file g-golf.texi for copying conditions.
+
+
+@node Utils Arcade
+@subsection Utils Arcade
+
+Utils Arcade. G-Golf utilities.
+
+
+@subheading Syntax
+
+@indentedblock
+@table @code
+@item @ref{allocate-c-struct}
+@end table
+@end indentedblock
+
+
+@subheading Description
+
+Welcome to the G-Golf Utils Arcade.
+
+
+@subheading Syntax
+
+@anchor{allocate-c-struct}
+@deffn Syntax allocate-c-struct name . fields
+
+Returns a (or more) pointer(s).
+
+This syntax takes the @var{name} of a GI upstream library C
+struct@footnote{More specifically, an unquoted scheme representation
+name of a GI upstream library C struct.} and returns a pointer to a
+newly - scheme allocated, zero initialized - memory block.
+
+When @var{fields} is not null?, it returns additional value(s), one for
+each specified field name, a pointer to the field in the C struct.
+
+Here is an example, an excerpt form the peg-solitaire.scm example,
+distributed with G-Golf. The example shows how to obtain a pointer to
+newly allocated block for a @code{GskRoundedRect}, as well as a pointer
+to its @code{bounds} field:
+
+@example
+(receive (outline outline:bounds)
+ (allocate-c-struct gsk-rounded-rect bounds)
+ ...
+ (push-rounded-clip snapshot outline)
+ (append-color snapshot
+ '(0.61 0.1 0.47 1.0)
+ outline:bounds)
+ ...)
+@end example
+@end deffn
diff --git a/doc/ug-ggv.texi b/doc/ug-ggv.texi
index ebc29ac..4150500 100644
--- a/doc/ug-ggv.texi
+++ b/doc/ug-ggv.texi
@@ -12,9 +12,11 @@
* Cache Park:: Accessing G-Golf caches.
* Customization Square:: G-Golf customization functionality.
* VFunc Alley:: VFunc G-Golf support.
+* Utils Arcade:: G-Golf utilities.
@end menu
@include ug-ggv-cache.texi
@include ug-ggv-customization.texi
@include ug-ggv-vfunc.texi
+@include ug-ggv-utils.texi
diff --git a/doc/variables.texi b/doc/variables.texi
index 7c83ad8..85aa505 100644
--- a/doc/variables.texi
+++ b/doc/variables.texi
@@ -65,6 +65,9 @@
@set UGNOME-Libraries https://developer.gnome.org/documentation/introduction/overview/libraries.html
+@set ULIBADWAITA https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/
+@set UGNOME-Web https://wiki.gnome.org/Apps/Web
+
@set UGLIB https://developer.gnome.org/glib/stable/
@set UGLIB-Mem-Alloc https://developer.gnome.org/glib/stable/glib-Memory-Allocation.html
@set UGLIB-Main-Event-Loop https://developer.gnome.org/glib/stable/glib-The-Main-Event-Loop.html
@@ -95,6 +98,12 @@
@set UGOBJECT-Object-add-toggle-ref https://docs.gtk.org/gobject/method.Object.add_toggle_ref.html
@c
+@c Clutter-1.0
+@c
+@set UCLUTTER http://blogs.gnome.org/clutter/
+
+
+@c
@c Gtk-3.0, Gdk-3.0
@c
@set UGTK3 https://developer.gnome.org/gtk3/stable
@@ -162,6 +171,7 @@
@c GNU
@c
+@set UGNU-Project http://www.gnu.org/
@set UGNU-PHILOSOPHY https://gnu.org/philosophy/free-sw.html
@set UGNU-EVALUATION https://www.gnu.org/help/evaluation.html
@set UGNU-HELP https://www.gnu.org/help/help.html
diff --git a/examples/gtk-4/drawing-widget.png b/examples/gtk-4/drawing-widget.png
new file mode 100644
index 0000000..ba3a41c
--- /dev/null
+++ b/examples/gtk-4/drawing-widget.png
Binary files differ
diff --git a/examples/gtk-4/drawing-widget.scm b/examples/gtk-4/drawing-widget.scm
new file mode 100755
index 0000000..e9610fd
--- /dev/null
+++ b/examples/gtk-4/drawing-widget.scm
@@ -0,0 +1,91 @@
+#! /bin/sh
+# -*- mode: scheme; coding: utf-8 -*-
+exec guile -e main -s "$0" "$@"
+!#
+
+
+;;;;
+;;;; Copyright (C) 2023
+;;;; Free Software Foundation, Inc.
+
+;;;; This file is part of GNU G-Golf
+
+;;;; GNU G-Golf 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 3 of the
+;;;; License, or (at your option) any later version.
+
+;;;; GNU G-Golf 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 GNU G-Golf. If not, see
+;;;; <https://www.gnu.org/licenses/lgpl.html>.
+;;;;
+
+;;; Commentary:
+
+;;; Code:
+
+
+(eval-when (expand load eval)
+ (use-modules (oop goops))
+
+ (default-duplicate-binding-handler
+ '(merge-generics replace warn-override-core warn last))
+
+ (use-modules (g-golf))
+
+ (g-irepository-require "Gtk" #:version "4.0")
+ (for-each (lambda (name)
+ (gi-import-by-name "Gtk" name))
+ '("Application"
+ "ApplicationWindow")))
+
+
+(define-class <drawing-widget> (<gtk-widget>))
+
+(define-vfunc (snapshot-vfunc (self <drawing-widget>) snapshot)
+ (let ((width (/ (get-width self) 2))
+ (height (/ (get-height self) 2)))
+ (append-color snapshot
+ ;; '(0.8 0.0 0.0 1.0) ;; %tango-scarlet-red
+ '(0.93 0.08 0.08 1.0) ;; danger red
+ (graphene-rect-init (graphene-rect-alloc)
+ 0 0 width height))
+ (append-color snapshot
+ ;; '(0.31 0.6 0.02 1.0) ;; %tango-chameleon-dark
+ '(0.18 0.8 0.44 1.0) ;; icon green
+ (graphene-rect-init (graphene-rect-alloc)
+ width 0 width height))
+ (append-color snapshot
+ ;; '(0.93 0.83 0.0 1.0) ;; %tango-butter
+ '(0.99 0.74 0.29 1.0) ;; icon yellow
+ (graphene-rect-init (graphene-rect-alloc)
+ 0 height width height))
+ (append-color snapshot
+ ;; '(0.13 0.29 0.53 1.0) ;; %tango-sky-blue-dark
+ '(0.16 0.5 0.73 1.0) ;; abyss blue
+ (graphene-rect-init (graphene-rect-alloc)
+ width height width height))))
+
+
+(define (activate app)
+ (let ((window (make <gtk-application-window>
+ #:title "Drawing Widget"
+ #:default-width 320
+ #:default-height 320
+ #:application app))
+ (drawing-widget (make <drawing-widget>)))
+ (set-child window drawing-widget)
+ (show window)))
+
+
+(define (main args)
+ (let ((app (make <gtk-application>
+ #:application-id "org.gtk.example")))
+ (connect app 'activate activate)
+ (let ((status (g-application-run app (length args) args)))
+ (exit status))))
diff --git a/examples/gtk-4/peg-solitaire.png b/examples/gtk-4/peg-solitaire.png
index 96e37f2..076158f 100644
--- a/examples/gtk-4/peg-solitaire.png
+++ b/examples/gtk-4/peg-solitaire.png
Binary files differ
diff --git a/examples/gtk-4/peg-solitaire.scm b/examples/gtk-4/peg-solitaire.scm
index 9c88e72..6c4c30e 100755
--- a/examples/gtk-4/peg-solitaire.scm
+++ b/examples/gtk-4/peg-solitaire.scm
@@ -80,16 +80,23 @@ exec guile -e main -s "$0" "$@"
;; method explicitly and temporarily comment the width height args.
(define-vfunc (snapshot-vfunc (self <solitaire-peg>) snapshot width height)
- (append-color snapshot
- ;; '(0.6 0.3 0.0 1.0) ;; gtk4-demo
- ;; '(0.2 0.4 0.64 1.0) ;; tango-sky-blue
- ;; '(0.46 0.31 0.48 1.0) ;; tango-plum
- '(0.61 0.1 0.47 1.0) ;; vocaloid
- (graphene-rect-init (graphene-rect-alloc)
- 0 0
- ;; width height
- (get-intrinsic-width self)
- (get-intrinsic-height self))))
+ (receive (outline outline:bounds)
+ (allocate-c-struct gsk-rounded-rect bounds)
+ (gsk-rounded-rect-init-from-rect outline
+ (graphene-rect-init (graphene-rect-alloc)
+ 0 0
+ ;; width height
+ (get-intrinsic-width self)
+ (get-intrinsic-height self))
+ 3.5) ;; px - approx. 0.3em [default fontsize]
+ (push-rounded-clip snapshot outline)
+ (append-color snapshot
+ '(0.61 0.1 0.47 1.0) ;; vocaloid
+ outline:bounds)
+ ;; pop is a guile scheme syntax, hence its name is protected, See
+ ;; the 'Customization Square', 'GI Syntax Name Protect' section of
+ ;; the G-Golf manual for more on this subject.
+ (pop_ snapshot)))
;;;
@@ -243,10 +250,10 @@ exec guile -e main -s "$0" "$@"
(define %css-data
".solitaire-field {
- border-radius: .3em;
border: 1px solid lightgray;
/* border: 3px solid #d4cbb6; texinfo code border */
/* border: 3px solid #495106; tango trash outline */
+ border-radius: 3.5px; /* approx. 0.3em [default fontsize] */
/* padding: 2px; */
}")
diff --git a/g-golf/gi/cache-gi.scm b/g-golf/gi/cache-gi.scm
index aa6612d..bdb7e3e 100644
--- a/g-golf/gi/cache-gi.scm
+++ b/g-golf/gi/cache-gi.scm
@@ -23,114 +23,84 @@
;;; Commentary:
-;; We need a cache mecanism to avoid reconstructing things on-the-fly
-;; unnecessarily, such as already imported <gi-enum> instances. Till we
-;; need something else, let's keep it simple. We'll use an alist of
-;; alists to start with. For example:
-
-;; (... (enum . ((clutter-actor-align . #<<gi-enum> 5629de89fcc0>))))
-
;;; Code:
-;; Hack to mark this module as non-declarative in Guile 3+ (which would
-;; otherwise print a warning) but not break when compiling on earlier
-;; versions of Guile. Thanks to David Thompson who wrote this macro and
-;; shared his solution withus on irc ...
-(define-syntax-rule (define-module* name args ...)
- (cond-expand
- (guile-3
- (define-module name
- #:declarative? #f
- args ...))
- (guile
- (define-module name args ...))))
-
-
-(define-module* (g-golf gi cache-gi)
+
+(define-module (g-golf gi cache-gi)
#:use-module (ice-9 match)
#:use-module (srfi srfi-1)
#:use-module (system foreign)
#:use-module (g-golf gobject boxed-types)
- #:export (%gi-cache
+ #:export (gi-cache
gi-cache-ref
gi-cache-set!
gi-cache-remove!
- gi-cache-show
- gi-cache-find))
+ gi-cache-find
+ gi-cache-show))
-(define %gi-cache #f)
+(define %dimfi
+ (@ (g-golf support utils) dimfi))
+
+(define gi-cache #f)
(define gi-cache-ref #f)
(define gi-cache-set! #f)
(define gi-cache-remove! #f)
-(define gi-cache-show #f)
(define gi-cache-find #f)
(eval-when (expand load eval)
- (let ((gi-cache '()))
-
- (set! %gi-cache
- (lambda () gi-cache))
+ (letrec* ((enum-cache (make-hash-table 1013))
+ (function-cache (make-hash-table 5591))
+ (struct-cache (make-hash-table 1013))
+ (boxed-cache (make-hash-table 1013))
+ (union-cache (make-hash-table 1013))
+ (flags-cache (make-hash-table 1013))
+ (%gi-cache (lambda (m-key)
+ (case m-key
+ ((enum) enum-cache)
+ ((function) function-cache)
+ ((struct) struct-cache)
+ ((boxed) boxed-cache)
+ ((union) union-cache)
+ ((flags) flags-cache)
+ (else
+ (scm-error 'invalid-cache-name #f "Invalid cache name: ~S"
+ (list m-key) #f))))))
+
+ (set! gi-cache %gi-cache)
(set! gi-cache-ref
(lambda (m-key s-key)
- ;; m-key, s-key stand for main key, secondary key
- (let ((subcache (assq-ref gi-cache m-key)))
- (and subcache
- (assq-ref subcache s-key)))))
+ ;; m-key: main key; s-key: secondary key
+ (hashq-ref (%gi-cache m-key) s-key)))
(set! gi-cache-set!
(lambda (m-key s-key val)
- (let ((subcache (assq-ref gi-cache m-key)))
- (set! gi-cache
- (assq-set! gi-cache m-key
- (assq-set! (or subcache '()) s-key
- val))))))
+ ;; m-key: main key; s-key: secondary key
+ (hashq-set! (%gi-cache m-key) s-key val)))
(set! gi-cache-remove!
(lambda (m-key s-key)
- ;; m-key, s-key stand for main key, secondary key
- (let ((subcache (assq-ref gi-cache m-key)))
- (and subcache
- (let ((m-entry (assq-remove! subcache s-key)))
- (if (null? m-entry)
- (set! gi-cache
- (assq-remove! gi-cache m-key))
- (set! gi-cache
- (assq-set! gi-cache m-key m-entry))))))))
-
- (set! gi-cache-show
- (lambda* (#:optional (m-key #f))
- (format #t "gi-cache~%")
- (if m-key
- (begin
- (format #t " ~A~%" m-key)
- (match (assq-ref gi-cache m-key)
- (#f
- (format #t " -- is empty --~%"))
- (else
- (for-each (lambda (s-entry)
- (match s-entry
- ((s-key . s-val)
- (format #t " ~A~% ~S~%" s-key s-val))))
- (assq-ref gi-cache m-key)))))
- (for-each (lambda (m-entry)
- (match m-entry
- ((m-key . m-vals)
- (format #t " ~A~%" m-key))))
- gi-cache))
- (values)))
+ ;; m-key: main key; s-key: secondary key
+ (hashq-remove! (%gi-cache m-key) s-key)))
(set! gi-cache-find
- (lambda (m-key pred)
- "Obtains the %gi-cache subcache for M-KEY, an (S-KEY . S-VAL) alist,
-and returns a list of the S-KEY for which (PRED S-VAL) was satisfied."
- (filter-map
- (lambda (s-entry)
- (match s-entry
- ((s-key . s-val)
- (and (pred s-val)
- s-key))))
- (assq-ref gi-cache m-key))))))
+ (lambda (m-key lookup)
+ (let ((lookup-str (if (string? lookup)
+ lookup
+ (symbol->string lookup))))
+ (hash-fold (lambda (key val results)
+ (let ((key-str (symbol->string key)))
+ (if (string-contains key-str lookup-str)
+ (cons (cons key val) results)
+ results)))
+ '()
+ (%gi-cache m-key)))))
+
+ (set! gi-cache-show
+ (lambda (m-key)
+ (hash-for-each (lambda (key value)
+ (%dimfi key value))
+ (%gi-cache m-key))))))
diff --git a/g-golf/gi/cache-others.scm b/g-golf/gi/cache-others.scm
index 1620488..5ea2048 100644
--- a/g-golf/gi/cache-others.scm
+++ b/g-golf/gi/cache-others.scm
@@ -187,16 +187,6 @@
;;; The g-boxed(instance) gobject allocated cache
;;;
-;; in this case, we need to use a normal hash table, because when a
-;; guardian returns a pointer, as part of an after-gc-hook procedure, a
-;; weak hash table would already have cleared the entry, and unlike for
-;; the other caches, we need to retreive the g-type of the (opaque)
-;; boxedtype pointer.
-
-;; a consequence of the above, is that we can't hold a reference to the
-;; ffi pointer, otherwise it would never become unreachable ... and
-;; hence, we specifically use the pointer address as the key.
-
(define %g-boxed-ga-cache #f)
(define g-boxed-ga-cache-ref #f)
(define g-boxed-ga-cache-set! #f)
@@ -206,7 +196,7 @@
(eval-when (expand load eval)
(let* ((%g-boxed-ga-cache-default-size 1013)
(g-boxed-ga-cache
- (make-weak-value-hash-table %g-boxed-ga-cache-default-size)))
+ (make-weak-key-hash-table %g-boxed-ga-cache-default-size)))
(set! %g-boxed-ga-cache
(lambda () g-boxed-ga-cache))
@@ -216,8 +206,8 @@
(hashq-ref g-boxed-ga-cache ptr)))
(set! g-boxed-ga-cache-set!
- (lambda (ptr bv)
- (hashq-set! g-boxed-ga-cache ptr bv)))
+ (lambda (ptr g-type)
+ (hashq-set! g-boxed-ga-cache ptr g-type)))
(set! g-boxed-ga-cache-remove!
(lambda (ptr)
@@ -227,13 +217,22 @@
(lambda ()
(hash-for-each (lambda (key value)
(%dimfi key value))
- g-boxed-ga-cache)))))
+ g-boxed-ga-cache)))))
;;;
;;; g-boxed-ga-guard
;;;
+;; The idea was to automatically call g-boxed-free, but 'as is', it
+;; can't work, as the mem is gobject allocated, (1) the guardian would
+;; never trigger and (2), even if it did, by the type the after-gc-hook
+;; is reached, the hash table entry has been cleared, hence we'd have
+;; lost the access to the boxed g-type, which is required to call
+;; g-boxed-free - (g-boxed-free g-type ptr).
+
+;; With this said, I'll keep the code for another possible affectation.
+
(define-syntax make-g-boxed-ga-guard
(syntax-rules ()
((make-g-boxed-ga-guard)
@@ -245,10 +244,7 @@
(let ((ptr (guardian)))
(when ptr
#;(%dimfi " cleaning" ptr)
- (let ((g-type (g-boxed-ga-cache-ref ptr)))
- (g-boxed-ga-cache-remove! ptr)
- (g-boxed-free g-type ptr)
- (loop)))))))
+ (loop))))))
(lambda (ptr g-type)
(g-boxed-ga-cache-set! ptr g-type)
(guardian ptr)
diff --git a/g-golf/gi/struct-info.scm b/g-golf/gi/struct-info.scm
index 5fe63ef..22650d3 100644
--- a/g-golf/gi/struct-info.scm
+++ b/g-golf/gi/struct-info.scm
@@ -74,7 +74,8 @@
#:size (g-struct-info-get-size info)
#:is-gtype-struct? (g-struct-info-is-gtype-struct info)
#:is-foreign? (g-struct-info-is-foreign info)
- #:field-types field-types)))
+ #:field-types field-types
+ #:field-desc (gi-struct-field-desc info))))
(define (gi-struct-field-desc info)
(letrec ((struct-field-desc
diff --git a/g-golf/hl-api/callable.scm b/g-golf/hl-api/callable.scm
index cbc966a..8d84a6f 100644
--- a/g-golf/hl-api/callable.scm
+++ b/g-golf/hl-api/callable.scm
@@ -637,11 +637,11 @@
(g-boxed-sa-guard bv-ptr bv)
bv-ptr)
;; when bv is #f, it (indirectly) means that
- ;; memory was allocated by the caller.
+ ;; memory is allocated by the callee
(if (null-pointer? foreign)
#f
(begin
- (g-boxed-ga-guard foreign g-type)
+ #;(g-boxed-ga-guard foreign g-type)
foreign))))
(parse-c-struct foreign (!scm-types gi-type)))))))
((union)
diff --git a/g-golf/hl-api/gobject.scm b/g-golf/hl-api/gobject.scm
index 7f88f13..18a4012 100644
--- a/g-golf/hl-api/gobject.scm
+++ b/g-golf/hl-api/gobject.scm
@@ -1,7 +1,7 @@
;; -*- mode: scheme; coding: utf-8 -*-
;;;;
-;;;; Copyright (C) 2018 - 2022
+;;;; Copyright (C) 2018 - 2023
;;;; Free Software Foundation, Inc.
;;;; This file is part of GNU G-Golf
@@ -54,7 +54,8 @@
warn
last)
- #:export (<gobject>
+ #:export (<gobject-class>
+ <gobject>
gobject-class?
<ginterface>
ginterface-class?
@@ -421,6 +422,7 @@
(define-class <ginterface> (<gtype-instance>)
#:info #t
+ #:g-type -1 ;; g-object-find-class-by-g-type
#:metaclass <gobject-class>)
(define (ginterface-class? class)
@@ -454,7 +456,7 @@
;; subclass GdkClipboard.
(define (g-object-find-class-by-g-type g-type)
- (let loop ((classes (class-subclasses <gobject>)))
+ (let loop ((classes (class-subclasses <gtype-instance>)))
(match classes
(() #f)
((head . tail)
diff --git a/g-golf/hl-api/object.scm b/g-golf/hl-api/object.scm
index 10c382c..191b175 100644
--- a/g-golf/hl-api/object.scm
+++ b/g-golf/hl-api/object.scm
@@ -1,7 +1,7 @@
;; -*- mode: scheme; coding: utf-8 -*-
;;;;
-;;;; Copyright (C) 2019 - 2022
+;;;; Copyright (C) 2019 - 2023
;;;; Free Software Foundation, Inc.
;;;; This file is part of GNU G-Golf
@@ -38,7 +38,6 @@
#:use-module (g-golf hl-api n-decl)
#:use-module (g-golf hl-api gtype)
#:use-module (g-golf hl-api gobject)
- ;; #:use-module (g-golf hl-api function)
#:duplicates (merge-generics
replace
@@ -60,16 +59,14 @@
(module (resolve-module '(g-golf hl-api gobject)))
(r-info-cpl (g-object-info-cpl info #:reversed-order? #t)))
(unless (is-g-object-subclass? r-info-cpl)
- ;; A 'fundamental type' class, not a GObject subclass. We need to
- ;; create the parent 'of all', which is the first element of the
- ;; reversed info-cpl list computed above. It could very well be
- ;; that the class has no child, but we need to created it before
- ;; to run the following code, which parse the r-info-cpl assuming
- ;; the parent class always exists - what must exist, to be
- ;; precise, is the corresponding goops class.
+ ;; A 'GObject.TypeInstance' class, not a 'GObject.Object' class.
+ ;; We need to check if the parent 'of all' (which is the first
+ ;; element of the r(eversed)-info-cpl list computed above) exists,
+ ;; and create its goops proxy class if it does not exist yet.
(match r-info-cpl
((parent . rest)
- (g-object-import-with-supers parent '() module
+ (g-object-import-with-supers parent `(,<gtype-instance>) module
+ #:metaclass <gtype-class>
#:with-methods? with-methods?
#:force? force?))))
(let loop ((r-info-cpl r-info-cpl))
@@ -111,7 +108,10 @@
(member "GObject" info-cpl is-g-object-info-cpl-item?)))
(define* (g-object-import-with-supers child supers module
- #:key (with-methods? #t) (force? #f))
+ #:key
+ (metaclass #f)
+ (with-methods? #t)
+ (force? #f))
(match child
((info namespace name)
(unless (member namespace
@@ -131,7 +131,8 @@
'()
#:name c-name
#:info info
- #:g-struct-fields g-struct-fields)))
+ #:g-struct-fields g-struct-fields
+ #:metaclass metaclass)))
(module-define! module c-name c-inst)
(module-add! public-i c-name
(module-variable module c-name))
diff --git a/g-golf/hl-api/utils.scm b/g-golf/hl-api/utils.scm
index 1f3dad8..9cb315b 100644
--- a/g-golf/hl-api/utils.scm
+++ b/g-golf/hl-api/utils.scm
@@ -1,7 +1,7 @@
;; -*- mode: scheme; coding: utf-8 -*-
;;;;
-;;;; Copyright (C) 2020 - 2021
+;;;; Copyright (C) 2020 - 2023
;;;; Free Software Foundation, Inc.
;;;; This file is part of GNU G-Golf
@@ -28,7 +28,7 @@
(define-module (g-golf hl-api utils)
#:use-module (ice-9 match)
- #:use-module (srfi srfi-1)
+ #:use-module ((srfi srfi-1) #:select (member))
#:use-module (oop goops)
#:use-module (g-golf support)
#:use-module (g-golf gi)
@@ -44,8 +44,8 @@
last)
#:export (gi-find-by-property-name
-
- scm->g-type))
+ scm->g-type
+ allocate-c-struct))
#;(g-export )
@@ -90,3 +90,13 @@
(!g-type v-class))
(else
(error "Unimplemented scm->g-type for " value)))))
+
+(define-macro (allocate-c-struct name . fields)
+ `(let* ((gi-struct (gi-cache-ref 'boxed ',name))
+ (ocs-bv (make-bytevector (!size gi-struct)))
+ (ocs-bv-ptr (bytevector->pointer ocs-bv)))
+ (values ocs-bv-ptr
+ ,@(map (lambda (field)
+ `(gi-pointer-inc ocs-bv-ptr
+ (field-offset gi-struct ',field)))
+ fields))))
diff --git a/g-golf/hl-api/vfunc.scm b/g-golf/hl-api/vfunc.scm
index a4b9170..1304cdd 100644
--- a/g-golf/hl-api/vfunc.scm
+++ b/g-golf/hl-api/vfunc.scm
@@ -104,29 +104,35 @@
(define (add-vfunc-closure inst)
(receive (closure callback-closure)
(g-golf-vfunc-closure inst)
- (let* ((g-class (vfunc-find-g-class inst))
- (iface-type (!g-type (!specializer inst)))
- (iface-struct (g-type-interface-peek g-class iface-type)))
+ (let* ((vfunc-g-object-class-specializer
+ (find-vfunc-g-object-class-specializer inst))
+ (specializer (!specializer inst))
+ (iface/class-struct (if (ginterface-class? specializer)
+ (g-type-interface-peek
+ (!g-class vfunc-g-object-class-specializer)
+ (!g-type specializer))
+ (g-type-class-peek
+ (!g-type vfunc-g-object-class-specializer)))))
(slot-set! inst
'callback (!callback callback-closure))
(match (vfunc-struct-field inst)
((type-tag offset flags)
- (bv-ptr-set! (gi-pointer-inc iface-struct offset)
+ (bv-ptr-set! (gi-pointer-inc iface/class-struct offset)
closure))))))
-(define (vfunc-find-g-class inst)
- ;; There can only be one GObject class - as GObject is a single inheritance
- ;; oop system - in the list of the <vfunc> inst specializers. That's the one
- ;; we need the g-class slot value of.
- (!g-class (let loop ((specializers (slot-ref inst 'specializers)))
- (match specializers
- (()
- (scm-error 'impossible #f "No GObject specializer for: ~S"
- (list (!name inst)) #f))
- ((specializer . rests)
- (or (and (gobject-class? specializer)
- specializer)
- (loop rests)))))))
+(define (find-vfunc-g-object-class-specializer inst)
+ ;; There can only be one GObject class - as GObject is a single
+ ;; inheritance oop system - in the list of the <vfunc> inst
+ ;; specializers.
+ (let loop ((specializers (slot-ref inst 'specializers)))
+ (match specializers
+ (()
+ (scm-error 'impossible #f "No GObject specializer for: ~S"
+ (list (!name inst)) #f))
+ ((specializer . rests)
+ (or (and (gobject-class? specializer)
+ specializer)
+ (loop rests))))))
(define (vfunc-struct-field inst)
(assq-ref (!g-struct-fields (!specializer inst))
diff --git a/g-golf/override/gdk.scm b/g-golf/override/gdk.scm
index 7107c5a..11af607 100644
--- a/g-golf/override/gdk.scm
+++ b/g-golf/override/gdk.scm
@@ -61,6 +61,11 @@
(g-value (g-value-init g-type))
(dum (i-func content-provider g-value))
(value (g-value-get-value g-value)))
+ (g-boxed-free (g-param-spec-type
+ (g-object-class-find-property
+ (!g-class (class-of content-provider))
+ "formats"))
+ content-formats)
(g-value-unset g-value)
value))
'(0)))
diff --git a/g-golf/support/struct.scm b/g-golf/support/struct.scm
index 57ceb0a..5ec2061 100644
--- a/g-golf/support/struct.scm
+++ b/g-golf/support/struct.scm
@@ -1,7 +1,7 @@
;; -*- mode: scheme; coding: utf-8 -*-
;;;;
-;;;; Copyright (C) 2019 - 2020
+;;;; Copyright (C) 2019 - 2022
;;;; Free Software Foundation, Inc.
;;;; This file is part of GNU G-Golf
@@ -27,6 +27,9 @@
(define-module (g-golf support struct)
+ #:use-module (ice-9 match)
+ #:use-module (system foreign)
+ #:use-module (srfi srfi-1)
#:use-module (oop goops)
#:use-module (g-golf support goops)
#:use-module (g-golf support g-export)
@@ -50,10 +53,13 @@
!is-gtype-struct?
!is-foreign?
!field-types
+ !field-desc
!scm-types
!init-vals
!is-opaque?
- !is-semi-opaque?)
+ !is-semi-opaque?
+
+ field-offset)
(define-class <gi-struct> ()
@@ -73,6 +79,8 @@
#:init-keyword #:is-foreign?)
(field-types #:accessor !field-types
#:init-keyword #:field-types)
+ (field-desc #:accessor !field-desc
+ #:init-keyword #:field-desc)
(scm-types #:accessor !scm-types)
(init-vals #:accessor !init-vals)
(is-opaque? #:accessor !is-opaque?)
@@ -87,8 +95,24 @@
'g-name g-name
'name (g-name->name g-name)))
(and field-types
- (mslot-set! self
- 'scm-types (map gi-type-tag->ffi field-types)
- 'init-vals (map gi-type-tag->init-val field-types)
- 'is-opaque? (null? (!field-types self))
- 'is-semi-opaque? (if (memq 'void field-types) #t #f)))))
+ (let ((scm-types (map gi-type-tag->ffi field-types))
+ (opaque? (null? field-types)))
+ (mslot-set! self
+ 'scm-types scm-types
+ 'init-vals (map gi-type-tag->init-val field-types)
+ 'is-opaque? opaque?
+ 'is-semi-opaque? (if (or opaque?
+ (memq 'void field-types)
+ (memq 'interface field-types)
+ (not (= (!size self)
+ (reduce + 0 (map sizeof scm-types)))))
+ #t
+ #f))))))
+
+(define-method (field-offset (self <gi-struct>) field-name)
+ (match (assq-ref (!field-desc self) field-name)
+ (#f
+ (scm-error 'invalid-field-name #f "No such field : ~A"
+ (list field-name) #f))
+ ((type-tag offset flags)
+ offset)))