guile-user
[Top][All Lists]
Advanced

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

Re: [ANN] guile-gi v0.0.1 released


From: Jan Nieuwenhuizen
Subject: Re: [ANN] guile-gi v0.0.1 released
Date: Sat, 01 Jun 2019 11:02:21 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux)

Mike Gran writes:

> Hello. I am announcing guile-gi v0.0.1.

Wow, congrats!  And thanks!

> guile-gi is a library that autogenerates Guile bindings for GObject
> libraries that provide typelib files.

I've created a package description for Guix (see attached), with some
patches (also attached).

How is is that I overlooked this thread?  I spent last Thursday --
reluctantly -- adding webkitgtk bindings to guile-gnome and debugging
an initial browser test.  With Guile-GI it worked in minutes! :-)

One of the patches adds the web browser example and the last one adds an
editor example...but that segfaults in the key-press-event handler.

I've just noticed test/closures.c -- is that intended for handlers like
key-press-event; are they different from `clicked'?

Patches also on my `wip' branch: https://gitlab.com/janneke/guile-gi.git

janneke

>From f4602d57f74cb2690b01fb23638ce2037ccd9105 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <address@hidden>
Date: Fri, 31 May 2019 19:47:21 +0200
Subject: [PATCH] gnu: Add guile-gi.

* gnu/packages/guile-xyz.scm (guile-gi): New variable.
---
 gnu/packages/guile-xyz.scm | 42 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/gnu/packages/guile-xyz.scm b/gnu/packages/guile-xyz.scm
index 365f909c2c..589e41dad2 100644
--- a/gnu/packages/guile-xyz.scm
+++ b/gnu/packages/guile-xyz.scm
@@ -53,8 +53,10 @@
   #:use-module (gnu packages gawk)
   #:use-module (gnu packages gettext)
   #:use-module (gnu packages gl)
+  #:use-module (gnu packages glib)
   #:use-module (gnu packages gnome)
   #:use-module (gnu packages gperf)
+  #:use-module (gnu packages gtk)
   #:use-module (gnu packages guile)
   #:use-module (gnu packages hurd)
   #:use-module (gnu packages image)
@@ -76,6 +78,7 @@
   #:use-module (gnu packages texinfo)
   #:use-module (gnu packages tls)
   #:use-module (gnu packages version-control)
+  #:use-module (gnu packages webkit)
   #:use-module (gnu packages xdisorg)
   #:use-module (gnu packages xorg)
   #:use-module (guix packages)
@@ -2232,3 +2235,42 @@ slashes are present and accounted for, resolving 
@code{.} and @code{..}, etc).
 Inevitably, you have to break the string up into chunks and operate on that
 list of components.  This module takes care of that for you.")
     (license license:lgpl3+)))
+
+(define-public guile-gi
+  (let ((commit "91753258892c4a1fbf7ed43ff793a00ac0f77cf6")
+        (revision "0"))
+    (package
+      (name "guile-gi")
+      (version (string-append "0.0.1-" revision "." (string-take commit 7)))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://gitlab.com/janneke/guile-gi.git";)
+                      (commit commit)))
+                (file-name (string-append name "-" version))
+                (sha256
+                 (base32
+                  "1i76jfs90p8pbx0bfrjd4sias9380pmjb9x387rx7hav4kvnsd1b"))))
+      (build-system gnu-build-system)
+      (native-inputs `(("autoconf" ,autoconf)
+                       ("automake" ,automake)
+                       ("gettext" ,gnu-gettext)
+                       ("libtool" ,libtool)
+                       ("pkg-config" ,pkg-config)
+                       ("texinfo" ,texinfo)))
+      (propagated-inputs `(("glib" ,glib)
+                           ("gobject-introspection" ,gobject-introspection)
+                           ("gssettings-desktop-schemas" 
,gsettings-desktop-schemas)
+                           ("gtk+" ,gtk+)
+                           ("guile-lib" ,guile-lib)
+                           ("webkitgtk" ,webkitgtk)))
+      (inputs `(("guile" ,guile-2.2)))
+      (arguments
+       `(#:configure-flags '("--with-gnu-filesystem-hierarchy")))
+      (home-page "https://github.com/spk121/guile-gi";)
+      (synopsis "GObject bindings for Guile")
+      (description
+       "Guile-GI is a library for Guile that allows using GObject-based
+libraries, such as GTK+3.  Its README comes with the disclaimer: This is
+pre-alpha code.")
+      (license license:gpl3+))))
-- 
2.21.0

>From f1ffa56b7ec078f0270eb6bba7a23faa11999db7 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <address@hidden>
Date: Fri, 31 May 2019 00:54:18 +0200
Subject: [PATCH 1/4] webkit browser example.

* test/browser.scm: New file.
---
 test/Makefile.am |  8 ++++++--
 test/browser.scm | 52 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+), 2 deletions(-)
 create mode 100644 test/browser.scm

diff --git a/test/Makefile.am b/test/Makefile.am
index 5fae67d..e87bf99 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -46,5 +46,9 @@ AM_SCM_LOG_FLAGS = --no-auto-compile -L $(abs_top_srcdir)/src 
-L $(abs_top_srcdi
 EXTRA_DIST = \
   $(TESTS) \
   lib.scm \
-  automake-test-lib.scm \
-  example-1.scm
+  automake-test-lib.scm
+
+exampledir = $(datadir)/doc/guile-gi
+dist_example_DATA = \
+  example-1.scm \
+  browser.scm
diff --git a/test/browser.scm b/test/browser.scm
new file mode 100644
index 0000000..d262e53
--- /dev/null
+++ b/test/browser.scm
@@ -0,0 +1,52 @@
+;; Copyright (C) 2019  Michael L. Gran
+;; Copyright (C) 2019  Jan (janneke) Nieuwenhuizen <address@hidden>
+
+;; This program is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program 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 General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <https:;;www.gnu.org/licenses/>.
+(use-modules (gi))
+
+(typelib-load "Gio" "2.0")
+(typelib-load "Gtk" "3.0")
+(typelib-load "GLib" "2.0")
+(typelib-load "WebKit2" "4.0")
+
+(define (print-hello widget data)
+  (display "Hello World\n"))
+
+(define (activate app user-data)
+  (let ((window (cast (ApplicationWindow-new app) <GtkApplicationWindow>))
+        (vbox (cast (VBox-new 0 0) <GtkVBox>))
+        (browser (cast (WebView-new) <WebKitWebView>))
+        (button-box (cast (ButtonBox-new 0) <GtkButtonBox>))
+        (button (Button-new-with-label "Hello World")))
+    (send window (set-title "Window"))
+    (send window (set-default-size 200 200))
+    (send window (show-all))
+    (send window (add vbox))
+    (send vbox (add browser))
+    (send vbox (add button-box))
+
+    (connect button (clicked print-hello #f))
+    (connect button (clicked (lambda x
+                               (send window (destroy)))
+                             #f))
+    (send browser (load-uri "http://gnu.org/s/mes";))
+    (send button-box (add button))
+    (send window (show-all))))
+
+(define (main)
+  (let ((app (Application-new "org.gtk.example" 0)))
+    (connect app (activate activate #f))
+    (send app (run (length (command-line)) (command-line)))))
+
+(main)
-- 
2.21.0

>From ac0e08efce96f26d63911658dbdaecd16461f07e Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <address@hidden>
Date: Fri, 31 May 2019 19:13:41 +0200
Subject: [PATCH 2/4] build: compile and install .go files.

---
 bootstrap       |  6 ++++++
 configure.ac    |  3 ++-
 src/Makefile.am | 11 +++++------
 3 files changed, 13 insertions(+), 7 deletions(-)
 create mode 100755 bootstrap

diff --git a/bootstrap b/bootstrap
new file mode 100755
index 0000000..8defb5d
--- /dev/null
+++ b/bootstrap
@@ -0,0 +1,6 @@
+#! /bin/sh
+
+# Create the build system.
+
+set -e -x
+exec autoreconf -vfi
diff --git a/configure.ac b/configure.ac
index 0cdd9e8..811a29b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -68,7 +68,7 @@ case "x$with_gnu_filesystem_hierarchy" in
        # Follow the GNU Filesystem Heirarchy Standard correctly
        # Installed .scm scheme libraries go here
        AC_MSG_CHECKING([Guile site directory])
-       guilesitedir="\$(datadir)/guile/site/$guile_effective_version"
+       guilesitedir="\${datadir}/guile/site/$guile_effective_version"
        AC_MSG_RESULT([$guilesitedir])
        AC_SUBST(guilesitedir)
 
@@ -207,4 +207,5 @@ AC_CONFIG_FILES([tools/uninstalled-env], [chmod +x 
tools/uninstalled-env])
 AC_CONFIG_FILES([tools/run-guile], [chmod +x tools/run-guile])
 AC_CONFIG_FILES([tools/gdb-guile], [chmod +x tools/gdb-guile])
 AC_CONFIG_FILES([tools/gdb-test], [chmod +x tools/gdb-test])
+AC_CONFIG_FILES([tools/guile-gi], [chmod +x tools/guile-gi])
 AC_OUTPUT
diff --git a/src/Makefile.am b/src/Makefile.am
index 6c96095..2040399 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -147,25 +147,26 @@ libguile_gi_la_LIBADD = \
 ################################################################
 
 pkgguilesitedir=$(guilesitedir)/gi
+pkgguileobjectdir=$(guileobjectdir)/gi
 
 dist_guilesite_DATA = \
   gi.scm
 
 dist_pkgguilesite_DATA = gi/glib-2.scm gi/gtk-3.scm gi/gio-2.scm 
gi/webkit2-4.scm
 
-guileobject_DATA = $(guilesite_DATA:%.scm=%.go)
+pkgguileobject_DATA = $(dist_guilesite_DATA:%.scm=%.go) 
$(dist_pkgguilesite_DATA:%.scm=%.go)
 
 $(pkgguileobject_DATA): libguile-gi.la
 
-GUILEC_FLAGS = -Warity-mismatch -Wformat
+GUILEC_FLAGS = -Warity-mismatch -Wformat --load-path=$(PWD)
 
 .scm.go:
        GUILE_AUTO_COMPILE=0 \
        LTDL_LIBRARY_PATH=$(abs_builddir)/.libs \
-       $(GUILE) compile --target="$(host)" $(GUILEC_FLAGS) \
+       $(GUILE_TOOLS) compile --target="$(host)" $(GUILEC_FLAGS) \
        -o "$@" "$<"
 
-CLEANFILES = $(guileobject_DATA) $(BUILT_SOURCES)
+CLEANFILES = $(pkgguileobject_DATA) $(BUILT_SOURCES)
 
 ################################################################
 # FLYMAKE
@@ -175,5 +176,3 @@ check-syntax:
        $(CC) -std=c11 $(GUILE_CFLAGS) $(GLIB_CFLAGS) $(GOBJECT_CFLAGS) \
         $(GOBJECT_INTROSPECTION_CFLAGS) $(FFI_CFLAGS) \
         -DG_LOG_DOMAIN=\"GuileGI\" $(CFLAGS) -fsyntax-only $(CHK_SOURCES)
-
-
-- 
2.21.0

>From e2bf3ca2db064d4b5232a9ad2049241eab158e6f Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <address@hidden>
Date: Fri, 31 May 2019 19:21:52 +0200
Subject: [PATCH 3/4] guix: Add guix package description.

---
 .gitignore        |  1 +
 README            |  6 ++++
 guix.scm          | 92 +++++++++++++++++++++++++++++++++++++++++++++++
 test/Makefile.am  |  3 ++
 tools/Makefile.am |  3 +-
 tools/guile-gi.in | 27 ++++++++++++++
 6 files changed, 131 insertions(+), 1 deletion(-)
 create mode 100644 guix.scm
 create mode 100644 tools/guile-gi.in

diff --git a/.gitignore b/.gitignore
index e72434b..21eb93e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -68,6 +68,7 @@ tools/gdb-test
 tools/uninstalled-env
 tools/gdb-guile
 tools/run-guile
+tools/guile-gi
 
 # executables
 fo_gen
diff --git a/README b/README
index f3c4de6..cb31e1e 100644
--- a/README
+++ b/README
@@ -21,3 +21,9 @@ box, but, you can use this library to generate those bindings
 automatically.
 
 For the moment, the docs are at https://spk121.github.io/guile-gi/
+
+Try:
+
+    guix environment --ad-hoc -l guix.scm guile
+    guile-gi test/example-1.scm
+    guile-gi test/browser.scm
diff --git a/guix.scm b/guix.scm
new file mode 100644
index 0000000..30789de
--- /dev/null
+++ b/guix.scm
@@ -0,0 +1,92 @@
+;;; Guile-GI --- GObject bindings for Guile.
+;;; Copyright (C) 2019 Jan Nieuwenhuizen <address@hidden>
+;;;
+;;; This file is part of Guile-GI.
+;;;
+;;; Guile-GI is free software: you can redistribute it and/or modify
+;;; it under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation, either version 3 of the License, or
+;;; (at your option) any later version.
+;;;
+;;; Guile-GI 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 General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with Guile-GI.  If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+;;
+;; GNU Guix development package.  To build and play, run:
+;;
+;;   guix environment --ad-hoc -l guix.scm guile
+;;
+;; To build and install, run:
+;;
+;;   guix package -f guix.scm
+;;
+;; To build it, but not install it, run:
+;;
+;;   guix build -f guix.scm
+;;
+;; To use as the basis for a development environment, run:
+;;
+;;   guix environment -l guix.scm
+;;
+;;; Code:
+
+(use-modules (srfi srfi-1)
+             (srfi srfi-26)
+             (ice-9 popen)
+             (ice-9 match)
+             (ice-9 rdelim)
+             (guix packages)
+             (guix licenses)
+             (guix gexp)
+             (guix git-download)
+             (guix build-system gnu)
+             ((guix build utils) #:select (with-directory-excursion))
+             (gnu packages)
+             (gnu packages autotools)
+             (gnu packages gettext)
+             (gnu packages glib)
+             (gnu packages gnome)
+             (gnu packages gtk)
+             (gnu packages guile)
+             (gnu packages guile-xyz)
+             (gnu packages pkg-config)
+             (gnu packages texinfo)
+             (gnu packages webkit))
+
+(define %source-dir (dirname (current-filename)))
+
+(package
+  (name "guile-gi")
+  (version "git")
+  (source (local-file %source-dir
+                      #:recursive? #t
+                      #:select? (git-predicate %source-dir)))
+  (build-system gnu-build-system)
+  (native-inputs `(("autoconf" ,autoconf)
+                   ("automake" ,automake)
+                   ("gettext" ,gnu-gettext)
+                   ("libtool" ,libtool)
+                   ("pkg-config" ,pkg-config)
+                   ("texinfo" ,texinfo)))
+  (propagated-inputs `(("glib" ,glib)
+                       ("gobject-introspection" ,gobject-introspection)
+                       ("gssettings-desktop-schemas" 
,gsettings-desktop-schemas)
+                       ("gtk+" ,gtk+)
+                       ("guile-lib" ,guile-lib)
+                       ("webkitgtk" ,webkitgtk)))
+  (inputs `(("guile" ,guile-2.2)))
+  (arguments
+   `(#:configure-flags '("--with-gnu-filesystem-hierarchy")))
+  (home-page "https://github.com/spk121/guile-gi";)
+  (synopsis "GObject bindings for Guile")
+  (description
+   "Guile-GI is a library for Guile that allows using GObject-based
+libraries, such as GTK+3.  Its README comes with the disclaimer: This
+is pre-alpha code.")
+  (license gpl3+))
diff --git a/test/Makefile.am b/test/Makefile.am
index e87bf99..14ca20d 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -36,6 +36,9 @@ TESTS = \
  bytes_new_null_size.scm \
  bytes_new_null_contents.scm
 
+XFAIL_TESTS = \
+ bytes_new_null_size.scm
+
 SCM_LOG_COMPILER = \
   ${top_builddir}/libtool \
   --dlopen=${top_builddir}/src/libguile-gi.la \
diff --git a/tools/Makefile.am b/tools/Makefile.am
index aeafaf6..b93b5ba 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -14,5 +14,6 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
 
-EXTRA_DIST = uninstalled-env.in run-guile.in gdb-guile.in gdb-test.in
+EXTRA_DIST = uninstalled-env.in run-guile.in gdb-guile.in gdb-test.in 
guile-gi.in
 
+bin_SCRIPTS = guile-gi
diff --git a/tools/guile-gi.in b/tools/guile-gi.in
new file mode 100644
index 0000000..2004bef
--- /dev/null
+++ b/tools/guile-gi.in
@@ -0,0 +1,27 @@
+#! @SHELL@
+
+# Guile-GI --- GObject bindings for Guile.
+# Copyright (C) 2019 Jan Nieuwenhuizen <address@hidden>
+#
+# This file is part of Guile-GI.
+#
+# Guile-GI is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Guile-GI 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Guile-GI.  If not, see <http://www.gnu.org/licenses/>.
+
+prefix="@prefix@"
+exec_prefix="@exec_prefix@"
+datadir="@datarootdir@"
+datarootdir="@datarootdir@"
+
+LD_LIBRARY_PATH="@address@hidden:+:}$GUIX_ENVIRONMENT${GUIX_ENVIRONMENT:+/lib:}${LIBRARY_PATH:+:}$LIBRARY_PATH{LD_IBRARY_PATH:+:}$LD_IBRARY_PATH${GUIX_PROFILE:+/lib:}$GUIX_PROFILE"\
+        exec @GUILE@ -L "@guilesitedir@" -C "@guileobjectdir@" "$@"
-- 
2.21.0

>From 91753258892c4a1fbf7ed43ff793a00ac0f77cf6 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <address@hidden>
Date: Sat, 1 Jun 2019 10:22:23 +0200
Subject: [PATCH 4/4] textview editor example...BOOM.

---
 README          |  7 ++++++
 test/editor.scm | 58 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 65 insertions(+)
 create mode 100644 test/editor.scm

diff --git a/README b/README
index cb31e1e..0c2682b 100644
--- a/README
+++ b/README
@@ -27,3 +27,10 @@ Try:
     guix environment --ad-hoc -l guix.scm guile
     guile-gi test/example-1.scm
     guile-gi test/browser.scm
+
+Or, create and run in a development environment
+
+    guix environment -l guix.scm
+    ./bootstrap && ./configure && make
+    tools/uninstalled-env tools/guile-gi test/browser.scm
+    tools/uninstalled-env tools/guile-gi test/editor.scm
diff --git a/test/editor.scm b/test/editor.scm
new file mode 100644
index 0000000..5294943
--- /dev/null
+++ b/test/editor.scm
@@ -0,0 +1,58 @@
+;; Copyright (C) 2019  Michael L. Gran
+;; Copyright (C) 2019  Jan (janneke) Nieuwenhuizen <address@hidden>
+
+;; This program is free software: you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program 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 General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program.  If not, see <https:;;www.gnu.org/licenses/>.
+(use-modules (gi))
+
+(typelib-load "Gio" "2.0")
+(typelib-load "Gtk" "3.0")
+(typelib-load "GLib" "2.0")
+(typelib-load "WebKit2" "4.0")
+
+(define (print-goodbye widget data)
+  (display "Goodbye World\n"))
+
+(define (key-press widget event)
+  (display "key\n")
+  (format "key: ~s\n" event)
+  #f)
+
+(define (activate app user-data)
+  (let ((window (cast (ApplicationWindow-new app) <GtkApplicationWindow>))
+        (vbox (cast (VBox-new 0 0) <GtkVBox>))
+        (editor (cast (TextView-new) <GtkTextView>))
+        (button-box (cast (ButtonBox-new 0) <GtkButtonBox>))
+        (button (Button-new-with-label "Quit")))
+    (send window (set-title "Window"))
+    (send window (set-default-size 200 200))
+    (send window (show-all))
+    (send window (add vbox))
+    (send vbox (add editor))
+    (send vbox (add button-box))
+    (connect button (clicked print-goodbye #f))
+    (connect button (clicked (lambda x
+                               (send window (destroy)))
+                             #f))
+    ;; disable this and we are `fine'
+    (connect editor (key-press-event key-press #f)) ;; BOOM
+    (send editor (grab-focus))
+    (send button-box (add button))
+    (send window (show-all))))
+
+(define (main)
+  (let ((app (Application-new "org.gtk.example" 0)))
+    (connect app (activate activate #f))
+    (send app (run (length (command-line)) (command-line)))))
+
+(main)
-- 
2.21.0

-- 
Jan Nieuwenhuizen <address@hidden> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar® http://AvatarAcademy.com

reply via email to

[Prev in Thread] Current Thread [Next in Thread]