49 lines
1.3 KiB
Elixir
49 lines
1.3 KiB
Elixir
|
|
--# Simple greetings in various languages
|
|
|
|
include GtkEngine.e
|
|
|
|
chdir(canonical_path("~/demos/glade"))
|
|
add(builder,"hello.glade")
|
|
|
|
include en.e -- simple greetings in various languages
|
|
include es.e -- each include exports a function hello,
|
|
include fr.e -- and the correct one is called by using
|
|
include au.e -- the namespace en:, de:, fr:, etc...
|
|
include ca.e -- flag images are loaded as well.
|
|
|
|
include about.e -- handles the about dialog
|
|
|
|
constant hello_label = pointer("label1")
|
|
|
|
main()
|
|
|
|
-- Rather than write a separate handler routine for each menu option,
|
|
-- we write a generic one which calls the appropriate function by name;
|
|
-- function name (including namespace) is specified in the Glade Widget name
|
|
-- property. See hello.glade. This can save a lot of coding in certain instances.
|
|
|
|
-----------------------------------------------------------------------
|
|
global function on_activate(object ctl)
|
|
-----------------------------------------------------------------------
|
|
object fname = get(ctl,"name") -- (in this case, a function name)
|
|
|
|
display("Calling function []",{fname}) -- run from xterm to see this
|
|
|
|
atom fn = routine_id(fname)
|
|
if fn = -1 then
|
|
Error(,,"cannot link to function",fname)
|
|
else
|
|
return call_func(fn,{ctl,hello_label})
|
|
end if
|
|
|
|
return 1
|
|
end function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|