---------------------------------------------------
-- Assistant.exu
-- Demonstrates:
-- GtkAssistant - a series of attractive dialogs
-- which walk the user thru a process
-- such as installing or setting up accounts, etc.
----------------------------------------------------
include GtkEngine.e
include std/dll.e
atom surebtn
boolean ok_to_close = FALSE
constant assistant = create(GtkAssistant)
set(assistant,"default size",600,400)
-------------------------------------------
-- Allow page 3 => page 4 only if
-- 'I'm sure' checkbox is selected
-------------------------------------------
function SureClick(atom ctl, atom page)
ok_to_close = get(surebtn,"active")
set(assistant,"page complete",page,TRUE)
return 1
end function
constant sure_click = call_back(routine_id("SureClick"))
------------------------------------------
-- Main Window
------------------------------------------
constant win = create(GtkWindow)
connect(win,"destroy",quit)
set(win,"position",GTK_WIN_POS_CENTER)
set(win,"default size",200,200)
------------------------------------------
-- Vertical container for widgets
------------------------------------------
constant panel = create(GtkVBox)
add(win,panel)
--------------------------------------------
-- Button from stock to get things started
--------------------------------------------
constant btn = create(GtkButton,"gtk-ok")
pack(panel,-btn)
set(btn,"tooltip text","Click here for a demonstration")
--------------------------------------------------------
-- Some images to use here and there...
--------------------------------------------------------
constant splash = create(GtkImage,program_path & "7300.jpg")
add(panel,splash)
-------------------------------------------------------------------------------
-- A helper function to build assistant pages programmatically
-------------------------------------------------------------------------------
function CreateAssistantPage(integer pagetype,sequence title, boolean complete)
object page = create(GtkVBox)
junk = get(assistant,"append page",page)
set(assistant,"page type",page,pagetype)
set(assistant,"page title",page,title)
set(assistant,"page complete",page,complete)
return page
end function
------------------------------------------------------------------------------------
-- Create 4 pages for the assistant
------------------------------------------------------------------------------------
constant pg1 = CreateAssistantPage(GTK_ASSISTANT_PAGE_INTRO,"Page 1: Welcome!",TRUE)
-- photo for top banner on page;
object pix = create(GtkImage,program_path & "/thumbnails/" & "Justin.jpg")
pix = get(pix,"pixbuf")
set(assistant,"page header image",pg1,pix)
-- text to display on page;
constant pg1_text = create(GtkLabel)
set(pg1_text,"markup",
"Heading\nHere you could put some text....\n" &
"\tPreferably using Pango Markup")
add(pg1,pg1_text)
constant pg2 = CreateAssistantPage(GTK_ASSISTANT_PAGE_CONTENT,"Page 2:",TRUE)
set(assistant,"page side image",pg2,pix)
add(pg2, create(GtkLabel,"You can have many 'content' pages"))
constant pg3 = CreateAssistantPage(GTK_ASSISTANT_PAGE_CONFIRM,"Page 3: Confirm",FALSE)
add(pg3, create(GtkLabel,"Click below if you are sure all is correct..."))
surebtn = create(GtkCheckButton,"Yes, I am sure!")
connect(surebtn,"clicked",sure_click,pg3)
pack(pg3, surebtn)
constant pg4 = CreateAssistantPage(GTK_ASSISTANT_PAGE_SUMMARY,"Page 4: Summary",TRUE)
add(pg4, create(GtkLabel,"That's all, folks!\nHope you liked it!"))
----------------------------------------------
-- Display assistant when ok button is pressed
----------------------------------------------
function ShowAssistant()
show_all(assistant)
return 1
end function
constant showAss = call_back(routine_id("ShowAssistant"))
-------------------------------------------------
-- Display events which may need to be handled by
-- your (real life) program
-------------------------------------------------
function Closed()
puts(1,"Assistant closed!\n")
set(assistant,"hide")
return 1
end function
constant closed = call_back(routine_id("Closed"))
function Cancelled()
puts(1,"Assistant cancelled!\n")
hide(assistant)
return 1
end function
constant cancelled = call_back(routine_id("Cancelled"))
----------------------------------------------
-- Set up call backs
----------------------------------------------
connect(btn,"clicked",showAss)
connect(assistant,"close",closed)
connect(assistant,"cancel",cancelled)
show_all(win)
main()
---------------------------------------------------------------
-- copyright 2009 by Irv Mullins, code released under the LGPL
---------------------------------------------------------------