unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
From: Jan Nieuwenhuizen <janneke@gnu.org>
To: guile-gtk-general <guile-gtk-general@gnu.org>
Cc: guile-user <guile-user@gnu.org>
Subject: [PATCH]: gobject: also loop args after #:gsignal. Fixes multiple signals per class.
Date: Thu, 04 Apr 2013 11:04:37 +0200	[thread overview]
Message-ID: <878v4yu0nu.fsf@nlvehvbe01nb29b.ddns.nl-htc01.nxp.com> (raw)

[-- 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

             reply	other threads:[~2013-04-04  9:04 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-04  9:04 Jan Nieuwenhuizen [this message]
2013-04-04 16:54 ` [PATCH]: gobject: also loop args after #:gsignal. Fixes multiple signals per class David Pirotte
2013-04-09  5:51 ` Mark H Weaver

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878v4yu0nu.fsf@nlvehvbe01nb29b.ddns.nl-htc01.nxp.com \
    --to=janneke@gnu.org \
    --cc=guile-gtk-general@gnu.org \
    --cc=guile-user@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).