#!/usr/bin/env exu
-------------------------------------------
-- ColorButton.exu Aug 4, 2008
-- Demonstrates:
--	GTK ColorButton
--	modifying window background colors
--	responding to button click events
-------------------------------------------

include GtkEngine.e
include GtkEnums.e
include GtkRoutines.e
include dll.e

-----------------------------------------------
-- calls to color dialog returns a C structure
-- unless we have to mess with it, it's easier
-- to just pass it on to the set routine,
-- which is expecting a color structure anyway.
-----------------------------------------------
function ChangeBackground(atom ctl,atom data)
	if get(ctl,"color",color_struc) then
		set(data,"modify bg",0,color_struc)
	end if
return 1
end function
constant changeBackground = call_back(routine_id("ChangeBackground"))

constant win = create(GtkWindow)
	connect(win,"destroy",quit)
	set(win,"Border width",10)
	set(win,"Default size",300,100)
	set(win,"Position",GTK_WIN_POS_CENTER)

constant panel = create(GtkVBox)
	add(win,panel)

constant lbl1 = create(GtkLabel)
	set(lbl1,"markup",
		"<b>GTK Color Button</b>\nClick to change color of window")

constant btn1 = create(GtkColorButton)
	set(btn1,"title","Choose a color for the window background")
	connect(btn1,"color-set",changeBackground,win)

pack(panel,{lbl1,btn1})

show_all(win)

main()

--------------------------------------------------------------
-- copyright 2008 by Irv Mullins, code released under the LGPL
--------------------------------------------------------------