* guile-gtk: problem in "insert-text" signal handling.
@ 2003-02-14 15:06 Stan Pinte
2003-03-16 9:06 ` Daniel Skarda
0 siblings, 1 reply; 4+ messages in thread
From: Stan Pinte @ 2003-02-14 15:06 UTC (permalink / raw)
To: guile-user; +Cc: guile-gtk
hello,
with the following program, I am getting garbage from the "new-text" variable, when introducing the second and following characters...
Is this a bug in guile-gtk-1.2-0.31, or am I only supposed to use the first charachter of the string?
thanks a lot,
Stan.
output:
inserted: ["2"]
inserted: ["3B
Lâÿ¿:6@XB
pãÿ¿¸âÿ¿³@@D@"]
inserted: ["4B
Lâÿ¿:6@XB
pãÿ¿¸âÿ¿³@@D@"]
inserted: ["7B
Lâÿ¿:6@XB
pãÿ¿¸âÿ¿³@@D@"]
inserted: ["8B
Lâÿ¿:6@XB
pãÿ¿¸âÿ¿³@@D@"]
test program:
(use-modules (ice-9 format))
(use-modules (gtk gtk))
(let ((window (gtk-window-new 'toplevel))
(button (gtk-button-new-with-label "Say Hello"))
(ref-entry (gtk-entry-new)))
(gtk-widget-set-name button "mybutton")
(gtk-widget-set-name window "mywindow")
(gtk-window-set-title window "Guile-Gtk: Hello World")
(gtk-container-border-width window 10)
; (gtk-container-add window button)
(gtk-container-add window ref-entry)
(gtk-signal-connect ref-entry "insert-text"
(lambda (new-text new-length position)
(if (string? new-text)
(format #t "inserted: [~s]~%" new-text)
(format #t "not text!!!~n"))))
(gtk-widget-show-all window)
(gtk-standalone-main window))
--
Stanislas Pinte
Computer Consultant
98, rue Bois l'Evêque
B-4000 Liège
web: http://www.altosw.be
email: alto_stan@wanadoo.be
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: guile-gtk: problem in "insert-text" signal handling.
2003-02-14 15:06 guile-gtk: problem in "insert-text" signal handling Stan Pinte
@ 2003-03-16 9:06 ` Daniel Skarda
2003-03-31 22:50 ` Kevin Ryde
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Skarda @ 2003-03-16 9:06 UTC (permalink / raw)
To: alto_stan; +Cc: guile-user, guile-gtk
Hello,
> with the following program, I am getting garbage from the "new-text" variable,
> when introducing the second and following characters...
>
> Is this a bug in guile-gtk-1.2-0.31, or am I only supposed to use the first
> charachter of the string?
I think you found a (design) bug in Gtk+ - string received by signal handler
is not terminated by '\000', the length of the string is passed as an additional
argument. Unfortunately, any other signal does not use "STRING, LENGTH" pattern
for passing string parameters. The bug is also potential source of SIGSEGV (when
no random '\000' is found, which is quite unlikely - but hey, all hideous bugs
have unlikely conditions.... )
Another sad part of the story: sgtk_callback_marshall does not now the signal
name, so all we can do now on guile-gtk part is an ugly hack:
if (n_args == 3 && GTK_FUNDAMENTAL_TYPE (args[0]) == GTK_TYPE_STRING) && ...)
/* let's hope we handle "new-text" signal.... */
Please report the bug to Gtk+ folks.
Have a nice day,
0.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: guile-gtk: problem in "insert-text" signal handling.
2003-03-16 9:06 ` Daniel Skarda
@ 2003-03-31 22:50 ` Kevin Ryde
0 siblings, 0 replies; 4+ messages in thread
From: Kevin Ryde @ 2003-03-31 22:50 UTC (permalink / raw)
To: guile-gtk
Daniel Skarda <0rfelyus@ucw.cz> writes:
>
> Another sad part of the story: sgtk_callback_marshall does not now
> the signal name, so all we can do now on guile-gtk part is an ugly
> hack:
>
> if (n_args == 3 && GTK_FUNDAMENTAL_TYPE (args[0]) == GTK_TYPE_STRING) && ...)
Perhaps the class of the object could be checked too. If it's a
GtkEditable with string+int+pointer parameters then that be tight
enough to avoid hitting anything else.
> Please report the bug to Gtk+ folks.
Looks like it's become insert-at-cursor or some such in gtk 2, taking
a just a gchar* which presumably is null-terminated.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: guile-gtk: problem in "insert-text" signal handling.
@ 2003-04-02 0:05 Daniel Skarda
0 siblings, 0 replies; 4+ messages in thread
From: Daniel Skarda @ 2003-04-02 0:05 UTC (permalink / raw)
To: guile-gtk
Kevin Ryde <user42@zip.com.au> writes:
> Perhaps the class of the object could be checked too. If it's a
> GtkEditable with string+int+pointer parameters then that be tight
> enough to avoid hitting anything else.
You are right. First I rejected the idea - I was aware of
gtk_signal_connect_object function. But fortunately there are no guile-gtk
bindings for the function, so the problem looks simple now (though check
for GtkEditale+string+... still smells like ugly hack).
0.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2003-04-02 0:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-14 15:06 guile-gtk: problem in "insert-text" signal handling Stan Pinte
2003-03-16 9:06 ` Daniel Skarda
2003-03-31 22:50 ` Kevin Ryde
2003-04-02 0:05 Daniel Skarda
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).