65 lines
1.3 KiB
Elixir
65 lines
1.3 KiB
Elixir
|
|
||
|
--# Widget opacity, blinking icons
|
||
|
|
||
|
include GtkEngine.e
|
||
|
|
||
|
requires("3.10","Widget Opacity")
|
||
|
|
||
|
constant docs = `
|
||
|
Slide the slider bar to change the
|
||
|
opacity of the top button...
|
||
|
`
|
||
|
constant win = create(GtkWindow,{
|
||
|
{"title","Widget Opacity"},
|
||
|
{"border width",10},
|
||
|
{"connect","destroy","Quit"}})
|
||
|
|
||
|
if get(win,"is composited") = 0 then
|
||
|
Warn(win,"Sorry",
|
||
|
"This program requires",
|
||
|
"a compositing window manager")
|
||
|
end if
|
||
|
|
||
|
constant panel = create(GtkBox,VERTICAL)
|
||
|
add(win,panel)
|
||
|
|
||
|
constant btn1 = create(GtkButton,"thumbnails/clown.png#Clown")
|
||
|
set(btn1,"opacity",0.5)
|
||
|
add(panel,btn1)
|
||
|
|
||
|
constant btn2 = create(GtkButton,"thumbnails/clown.png#Clown")
|
||
|
add(panel,btn2)
|
||
|
|
||
|
constant btn2img = get(btn2,"image")
|
||
|
|
||
|
constant slider = create(GtkScale,0,0,1,.01)
|
||
|
connect(slider,"value-changed","Update")
|
||
|
set(slider,"value",0.5)
|
||
|
add(panel,slider)
|
||
|
|
||
|
constant lbl = create(GtkLabel,docs)
|
||
|
add(panel,lbl)
|
||
|
|
||
|
constant tick = create(GTimeout,100,call_back(routine_id("blink")))
|
||
|
atom x = 1
|
||
|
|
||
|
show_all(win)
|
||
|
|
||
|
main()
|
||
|
|
||
|
------------------------
|
||
|
global function Update()
|
||
|
------------------------
|
||
|
set(btn1,"opacity",get(slider,"value"))
|
||
|
return 1
|
||
|
end function
|
||
|
|
||
|
-------------------------
|
||
|
global function blink() -- strictly for fun :)
|
||
|
-------------------------
|
||
|
set(btn2img,"opacity",x)
|
||
|
x -= .1
|
||
|
if x < 0 then x = 1 end if
|
||
|
return 1
|
||
|
end function
|