unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* [PATCH]: gobject: also loop args after #:gsignal. Fixes multiple signals per class.
@ 2013-04-04  9:04 Jan Nieuwenhuizen
  2013-04-04 16:54 ` David Pirotte
  2013-04-09  5:51 ` Mark H Weaver
  0 siblings, 2 replies; 3+ messages in thread
From: Jan Nieuwenhuizen @ 2013-04-04  9:04 UTC (permalink / raw)
  To: guile-gtk-general; +Cc: guile-user

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

Hi,

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

Greetings, Jan


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gobject-also-loop-args-after-gsignal.-Fixes-multiple.patch --]
[-- Type: text/x-diff, Size: 2358 bytes --]

From e06d6364c5776183a98a4e69d34d237736388327 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke@gnu.org>
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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-gobject-whitespace-adjustment.patch --]
[-- Type: text/x-diff, Size: 1969 bytes --]

From ec9328acaf2b3c8ae9df03a891465a53fbae0c9f Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke@gnu.org>
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


[-- Attachment #4: Type: text/plain, Size: 154 bytes --]


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

[-- Attachment #5: Type: text/plain, Size: 162 bytes --]

_______________________________________________
guile-gtk-general mailing list
guile-gtk-general@gnu.org
https://lists.gnu.org/mailman/listinfo/guile-gtk-general

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

end of thread, other threads:[~2013-04-09  5:51 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-04  9:04 [PATCH]: gobject: also loop args after #:gsignal. Fixes multiple signals per class Jan Nieuwenhuizen
2013-04-04 16:54 ` David Pirotte
2013-04-09  5:51 ` Mark H Weaver

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