guile-user
[Top][All Lists]
Advanced

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

[PATCH]: gobject: also loop args after #:gsignal. Fixes multiple signals


From: Jan Nieuwenhuizen
Subject: [PATCH]: gobject: also loop args after #:gsignal. Fixes multiple signals per class.
Date: Thu, 04 Apr 2013 11:04:37 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux)

Hi,

I suggest these patches.  Until then, I'm using inheritance and define
one signal per class.

Greetings, Jan

>From e06d6364c5776183a98a4e69d34d237736388327 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <address@hidden>
Date: Thu, 4 Apr 2013 10:56:57 +0200
Subject: [PATCH 1/2] gobject: also loop args after #:gsignal.  Fixes multiple
 signals per class.

That is, running tic-tac-toe with this patch below now works.

diff --git a/gtk/examples/tic-tac-toe.scm b/gtk/examples/tic-tac-toe.scm
index 93e323b..8c67896 100644
--- a/gtk/examples/tic-tac-toe.scm
+++ b/gtk/examples/tic-tac-toe.scm
@@ -34,6 +34,9 @@ exec guile-gnome-2 -s $0 "$@"
   buttons
   winning-combinations

+  ;; adding foo-bar-baz signal breaks tic-tac-toe with
+  ;; ERROR: Throw to key `gruntime-error' with args `("gsignal-query" "Unknown 
signal ~A on class ~A" (tic-tac-toe #<<gobject-class> <tic-tac-toe>>) ())'.
+  :gsignal '(foo-bar-baz #f)
   :gsignal '(tic-tac-toe #f))

 (define (ttt-clear ttt)
@@ -119,6 +122,7 @@ exec guile-gnome-2 -s $0 "$@"
   (show-all w)
   (g-timeout-add 100 (lambda () #t))
   (connect ttt 'tic-tac-toe (lambda (ttt) (display "Yay!\n")))
+  (connect ttt 'foo-bar-baz (lambda (ttt) (display "Nay!\n")))
   (connect w 'delete-event (lambda (ttt e) (gtk-main-quit) #f)))

 (gtk-main)
---
 glib/gnome/gobject/gobject.scm |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/glib/gnome/gobject/gobject.scm b/glib/gnome/gobject/gobject.scm
index 3e5f07d..ad6abed 100644
--- a/glib/gnome/gobject/gobject.scm
+++ b/glib/gnome/gobject/gobject.scm
@@ -131,7 +131,7 @@
   (define (install-signals!)
     ;; We parse a #:gsignal initialization argument to install signals.
     (let loop ((args initargs))
-      (if (not (null? args))
+      (when (not (null? args))
           (if (eq? (car args) #:gsignal)
               (let ((signal (cadr args)))
                 (if (not (and (list? signal) (>= (length signal) 2)))
@@ -142,8 +142,8 @@
                        (generic (gtype-class-create-signal class name 
return-type param-types)))
                   ;; Some magic to define the generic
                   (module-define! (current-module)
-                                  (generic-function-name generic) generic)))
-              (loop (cddr args))))))
+                                  (generic-function-name generic) generic))))
+             (loop (cddr args)))))
 
   (define (first pred list)
     (cond ((null? list) #f)
-- 
1.7.10.4

>From ec9328acaf2b3c8ae9df03a891465a53fbae0c9f Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <address@hidden>
Date: Thu, 4 Apr 2013 10:58:43 +0200
Subject: [PATCH 2/2] gobject: whitespace adjustment.

---
 glib/gnome/gobject/gobject.scm |   24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/glib/gnome/gobject/gobject.scm b/glib/gnome/gobject/gobject.scm
index ad6abed..a235bbf 100644
--- a/glib/gnome/gobject/gobject.scm
+++ b/glib/gnome/gobject/gobject.scm
@@ -132,18 +132,18 @@
     ;; We parse a #:gsignal initialization argument to install signals.
     (let loop ((args initargs))
       (when (not (null? args))
-          (if (eq? (car args) #:gsignal)
-              (let ((signal (cadr args)))
-                (if (not (and (list? signal) (>= (length signal) 2)))
-                    (gruntime-error "Invalid signal specification: ~A" signal))
-                (let* ((name (car signal))
-                       (return-type (cadr signal))
-                       (param-types (cddr signal))
-                       (generic (gtype-class-create-signal class name 
return-type param-types)))
-                  ;; Some magic to define the generic
-                  (module-define! (current-module)
-                                  (generic-function-name generic) generic))))
-             (loop (cddr args)))))
+       (if (eq? (car args) #:gsignal)
+           (let ((signal (cadr args)))
+             (if (not (and (list? signal) (>= (length signal) 2)))
+                 (gruntime-error "Invalid signal specification: ~A" signal))
+             (let* ((name (car signal))
+                    (return-type (cadr signal))
+                    (param-types (cddr signal))
+                    (generic (gtype-class-create-signal class name return-type 
param-types)))
+               ;; Some magic to define the generic
+               (module-define! (current-module)
+                               (generic-function-name generic) generic))))
+       (loop (cddr args)))))
 
   (define (first pred list)
     (cond ((null? list) #f)
-- 
1.7.10.4

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

reply via email to

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