[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
accessing enums in guile-gnome
From: |
John Steele Scott |
Subject: |
accessing enums in guile-gnome |
Date: |
Sat, 13 Jan 2007 10:54:51 +1000 |
User-agent: |
Pan/0.14.2.91 (As She Crawled Across the Table (Debian GNU/Linux)) |
I have previously asked a similar question on the g-wrap devel list:
<http://thread.gmane.org/gmane.comp.programming.g-wrap.devel/5/focus=5>,
but that mechanism doesn't seem to work in guile-gnome. So . . .
After dabbling with guile-gnome for some time, I finally used it for some
"real work" yesterday. Using glade for the UI and writing code in Scheme
makes for a fun development environment. Once I figure out how
to set it up so that I can replace procedures in a running program
(probably via guile-debugging), I will have a kickarse GUI dev kit.
Anyway, today's question. I was surprised that Gtk has no equivalent of
the Windows MessageBox function. So I wrote this one, which returns the
result of gtk-dialog-run.
(define (modal-messagebox msg . msgtype-buttontype-defaultresponse)
"Pops up a modal dialog with message @var{msg}.
Optionally the message type, button type and default button
response may be specified as second, third and fourth arguments,
respectively.
By default the dialog will be informational, with a single close button."
(let-optional msgtype-buttontype-defaultresponse
((msgtype 'info) (buttontype 'close) (default-response #f))
(let ((dialog (%gtk-message-dialog-new (get-widget
"startwindow")
'destroy-with-parent
msgtype
buttontype
msg)))
(if default-response
(gtk-dialog-set-default-response dialog default-response))
(let ((result (gtk-dialog-run dialog)))
(gtk-widget-destroy dialog)
result))))
I am using this function like so:
(if (eq? (modal-messagebox "Do stuff?"
'info
'ok-cancel
gtk-response-ok)
gtk-response-ok)
(do-something))
To get gtk-response-ok, I manually copied it's value from the Gtk docs:
(define gtk-response-ok -5)
This feels like a kludge to me. Is there a way I can get this value from
guile-gtk? Something like (enum-gtk-response-type-sym->val 'ok) ?
By the way, this is with Guile 1.6, guile-gnome 2.7.99-4, from Ubuntu
Dapper.
cheers,
John
- accessing enums in guile-gnome,
John Steele Scott <=