* Using Guile in a wxWidgets app
@ 2006-02-04 23:56 John Steele Scott
2006-02-05 9:42 ` Neil Jerram
0 siblings, 1 reply; 2+ messages in thread
From: John Steele Scott @ 2006-02-04 23:56 UTC (permalink / raw)
I have written a small piece about embedding Guile in wxWidgets GUI program.
You can read it at:
<http://www.toojays.net/portal/Wiki/EmbeddingGuileIntoAWxWidgetsProgram>
Does anyone have any comments about it?
In particular, I would appreciate feedback on the way I have wrapped the
wxWidgets MessageBox() function. I used symbols instead of ORing bits for
the modifier parameter, so that
(message-box "Really quit?" "Quit?" 'yes/no 'question)
is equivalent to
wxMessageBox("Really quit?", "Quit?", wxYES_NO|wxICON_QUESTION).
Also, in my MyFrame::OnQuit method, I create a variable in the Guile world,
and then look it up again after calling the hook. Is this really necessary,
or can I somehow bind *quit-do-close* directly to a SCM in
MyFrame::OnQuit's stack frame, which Guile will modify directly, removing
the need for the call to scm_variable_ref(scm_c_lookup("*quit-do-close*"))?
cheers,
John
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Using Guile in a wxWidgets app
2006-02-04 23:56 Using Guile in a wxWidgets app John Steele Scott
@ 2006-02-05 9:42 ` Neil Jerram
0 siblings, 0 replies; 2+ messages in thread
From: Neil Jerram @ 2006-02-05 9:42 UTC (permalink / raw)
Cc: guile-user
John Steele Scott <toojays@toojays.net> writes:
> I have written a small piece about embedding Guile in wxWidgets GUI program.
> You can read it at:
> <http://www.toojays.net/portal/Wiki/EmbeddingGuileIntoAWxWidgetsProgram>
>
> Does anyone have any comments about it?
Overall it looks like a great tutorial to me. (Although I'm not
familiar with wxWidgets code.)
Some detailed comments...
"if (modifiers == NULL)"
The constant indicating an empty list is SCM_EOL, not NULL, so this
should at least be (modifiers == SCM_EOL). Even better, though, would
be "if (SCM_NULLP (modifiers))".
> In particular, I would appreciate feedback on the way I have wrapped the
> wxWidgets MessageBox() function. I used symbols instead of ORing bits for
> the modifier parameter, so that
> (message-box "Really quit?" "Quit?" 'yes/no 'question)
> is equivalent to
> wxMessageBox("Really quit?", "Quit?", wxYES_NO|wxICON_QUESTION).
IMO this is a nice schemely touch. You could of course compute the
symbols ahead of time, and store them, rather than constructing them
every time message_box is called, but it doesn't matter that much.
> Also, in my MyFrame::OnQuit method, I create a variable in the Guile world,
> and then look it up again after calling the hook. Is this really necessary,
> or can I somehow bind *quit-do-close* directly to a SCM in
> MyFrame::OnQuit's stack frame, which Guile will modify directly, removing
> the need for the call to scm_variable_ref(scm_c_lookup("*quit-do-close*"))?
Well you could do this, which feels a bit more natural (and closer to
what you have requested):
SCM qdcvar = scm_c_lookup("*quit-do-close*");
scm_variable_set_x(qdcvar, SCM_BOOL_T);
scm_c_run_hook(quit_hook, SCM_EOL);
if (SCM_NFALSEP(scm_variable_ref(qdcvar)))
Close(true);
(Alternatively, you could question whether quit-hook really needs to be
a hook, rather than a single function. If it was a single function,
you could call it from C directly and use its return value instead of
the global *quit-do-close*.)
Regards,
Neil
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-02-05 9:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-04 23:56 Using Guile in a wxWidgets app John Steele Scott
2006-02-05 9:42 ` Neil Jerram
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).