unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* G-Golf - Getting started
@ 2021-04-12 11:35 Paul Emsley
  2021-04-12 14:33 ` Vladimir Zhbanov
  2021-04-12 16:08 ` David Pirotte
  0 siblings, 2 replies; 3+ messages in thread
From: Paul Emsley @ 2021-04-12 11:35 UTC (permalink / raw)
  To: guile-user

[-- Attachment #1: Type: text/plain, Size: 1364 bytes --]


Hi G-Golfers,

From here:
https://www.gnu.org/software/g-golf/manual/g-golf.html


   GNU G-Golf can be obtained from the following archive site http://ftp.gnu.org/gnu/g-golf/. The file will
   be named g-golf-version.tar.gz. The current version is 0.1.0, so the file you should grab is:

    http://ftp.gnu.org/gnu/g-golf/g-golf-0.1.0.tar.gz 

This directory does not exist.

So I used the git repo, built and installed. I extracted the hello-world example (attached)

$ guile -s example-1.scm  # takes about 7 seconds
guile -s example-1.scm
Backtrace:
           8 (apply-smob/1 #<catch-closure 7f8f920d22a0>)
In ice-9/boot-9.scm:
    705:2  7 (call-with-prompt _ _ #<procedure default-prompt-handle…>)
In ice-9/eval.scm:
    619:8  6 (_ #(#(#<directory (guile-user) 7f8f91d64140>)))
In ice-9/boot-9.scm:
   2312:4  5 (save-module-excursion _)
  3832:12  4 (_)
In g-golf/hl-api/function.scm:
   140:19  3 (_ . _)
In unknown file:
           2 (_ #<pointer 0x55f7a37d14f0> #<pointer 0x7f8f8e2147a0> 3 …)
In g-golf/hl-api/closure.scm:
    255:8  1 (g-closure-marshal _ _ _ _ _ _)
In /home/paule/Projects/coot/git/g-golf/build/example-1.scm:
     14:4  0 (activate _)

/home/paule/Projects/coot/git/g-golf/build/example-1.scm:14:4: In procedure activate:
In procedure module-lookup: Unbound variable: set-child

Have I done something wrong?

Thanks, 

Paul.



[-- Attachment #2: example-1.scm --]
[-- Type: text/x-scheme, Size: 707 bytes --]

;; Load Gtk
(use-modules (g-golf))
(gi-import "Gtk")

;; When the application is launched..
(define (activate app)
  ;; - Create a new window and a new button
  (let ((window (make <gtk-application-window>
                  #:title "Hello"
                  #:application app))
        (button (make <gtk-button>
                  #:label "Hello, World!")))
    ;; - Which closes the window when clicked
    (connect button
             'clicked
             (lambda (b)
               (close window)))
    (set-child window button)
    (show window)))

(let ((app (make <gtk-application>
             #:application-id "com.example.GtkApplication")))
  (connect app 'activate activate)
  (run app 0 '()))



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: G-Golf - Getting started
  2021-04-12 11:35 G-Golf - Getting started Paul Emsley
@ 2021-04-12 14:33 ` Vladimir Zhbanov
  2021-04-12 16:08 ` David Pirotte
  1 sibling, 0 replies; 3+ messages in thread
From: Vladimir Zhbanov @ 2021-04-12 14:33 UTC (permalink / raw)
  To: guile-user

Hi Paul
On Mon, Apr 12, 2021 at 12:35:58PM +0100, Paul Emsley wrote:
> Hi G-Golfers,
> 
> >From here:
> https://www.gnu.org/software/g-golf/manual/g-golf.html
> 
> 
>    GNU G-Golf can be obtained from the following archive site http://ftp.gnu.org/gnu/g-golf/. The file will
>    be named g-golf-version.tar.gz. The current version is 0.1.0, so the file you should grab is:
> 
>     http://ftp.gnu.org/gnu/g-golf/g-golf-0.1.0.tar.gz 
> 
> This directory does not exist.
> 
> So I used the git repo, built and installed. I extracted the hello-world example (attached)
> 
> $ guile -s example-1.scm  # takes about 7 seconds
> guile -s example-1.scm
> Backtrace:
>            8 (apply-smob/1 #<catch-closure 7f8f920d22a0>)
> In ice-9/boot-9.scm:
>     705:2  7 (call-with-prompt _ _ #<procedure default-prompt-handle…>)
> In ice-9/eval.scm:
>     619:8  6 (_ #(#(#<directory (guile-user) 7f8f91d64140>)))
> In ice-9/boot-9.scm:
>    2312:4  5 (save-module-excursion _)
>   3832:12  4 (_)
> In g-golf/hl-api/function.scm:
>    140:19  3 (_ . _)
> In unknown file:
>            2 (_ #<pointer 0x55f7a37d14f0> #<pointer 0x7f8f8e2147a0> 3 …)
> In g-golf/hl-api/closure.scm:
>     255:8  1 (g-closure-marshal _ _ _ _ _ _)
> In /home/paule/Projects/coot/git/g-golf/build/example-1.scm:
>      14:4  0 (activate _)
> 
> /home/paule/Projects/coot/git/g-golf/build/example-1.scm:14:4: In procedure activate:
> In procedure module-lookup: Unbound variable: set-child
> 
> Have I done something wrong?

No, git-grep tells me there is no 'set-child' function in the g-golf repository. 

I've modified the example and it now works as expected, see below:

================================8<================================
;; Load Gtk
(use-modules (g-golf))
(gi-import "Gtk")

;; When the application is launched..
(define (activate app)
  ;; - Create a new window and a new button
  (let ((window (make <gtk-application-window>
                  #:title "Hello"
                  #:application app))
        (button-box (make <gtk-button-box>))
        (button (make <gtk-button>
                  #:label "Hello, World!")))
    ;; - Which closes the window when clicked
    (connect button
             'clicked
             (lambda (b)
               (close window)))
    (gtk-container-add window button-box)
    (gtk-container-add button-box button)
    (show button)
    (show button-box)
    (show window)))

(let ((app (make <gtk-application>
             #:application-id "com.example.GtkApplication")))
  (connect app 'activate activate)
  (run app 0 '()))
================================>8================================

HTH,
  Vladimir



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: G-Golf - Getting started
  2021-04-12 11:35 G-Golf - Getting started Paul Emsley
  2021-04-12 14:33 ` Vladimir Zhbanov
@ 2021-04-12 16:08 ` David Pirotte
  1 sibling, 0 replies; 3+ messages in thread
From: David Pirotte @ 2021-04-12 16:08 UTC (permalink / raw)
  To: Paul Emsley; +Cc: guile-user

[-- Attachment #1: Type: text/plain, Size: 2689 bytes --]

Hello Paul,

> From here:
> https://www.gnu.org/software/g-golf/manual/g-golf.html

There is no G-Golf release yet - it is mentioned on the web-site, both
the home page and in the install page ... but not in the manual indeed,
didn't want to ...

> $ guile -s example-1.scm  # takes about 7 seconds
> guile -s example-1.scm

Please read the Getting Started with G-Golf, Selective Import ... you
are importing the entire Gtk namespace - here, fwiw, if I do that, it
takes 2sec, so mileage varies depending on the machine, mem ... 

> Backtrace:
>  ...
> /home/paule/Projects/coot/git/g-golf/build/example-1.scm:14:4: In
> procedure activate: In procedure module-lookup: Unbound variable:
> set-child

> Have I done something wrong?

Yes :)

	you copied and run an example which is for Gtk-4.0, but loading
	Gtk-3.0 ...

In the manual, 'Getting Started with G-Golf':

	"Please note that in the entire course of the G-Golf manual,
	unless otherwise specified, examples are based on and use
	Gtk-4.0, Gdk-4.0 and Gsk-4.0 - which is new and only available
	with Gtk-4.0."

Below, an example for Gtk-3.0 ...

David

;; below,
;; a hello-world example for GTk-3.0


#! /bin/sh
# -*- mode: scheme; coding: utf-8 -*-
exec guile -e main -s "$0" "$@"
!#


(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))

  (for-each (lambda (name)
              (gi-import-by-name "Gtk" name #:version "3.0"))
      '("Application"
        "ApplicationWindow"
        "Box"
        "Label"
        "Button")))


(define (activate app)
  (let ((window (make <gtk-application-window>
                  #:title "Hello"
                  #:default-width 320
                  #:default-height 240
                  #:application app))
        (box    (make <gtk-box>
                  #:margin-top 6
                  #:margin-start 12
                  #:margin-bottom 6
                  #:margin-end 6
                  #:orientation 'vertical))
        (label  (make <gtk-label>
                  #:label "Hello, World!"))
        (button (make <gtk-button>
                  #:label "Close")))

    (connect button
	     'clicked
	     (lambda (b)
               (close window)))

    (add window box)
    (pack-start box label #t #t 0)
    (pack-start box button #f #f 6)
    (show-all window)))


(define (main args)
  (let ((app (make <gtk-application>
               #:application-id "org.gnu.tests")))
    (connect app 'activate activate)
    (run app (length args) args)))

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-04-12 16:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-12 11:35 G-Golf - Getting started Paul Emsley
2021-04-12 14:33 ` Vladimir Zhbanov
2021-04-12 16:08 ` David Pirotte

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).