eumandy/eugtk/examples/test100.ex

57 lines
1.4 KiB
Elixir
Raw Permalink Normal View History

2016-11-25 00:33:18 -07:00
---------------------------------------------------------------------------
--# Screen Capture program
-- Calls whichever linux screenshot program is available,
-- won't work on Windows without modification.
---------------------------------------------------------------------------
include GtkEngine.e
boolean found = FALSE
object ss = {"gnome-screenshot","mate-screenshot"}
for i = 1 to length(ss) do -- find valid screenshot program;
if system_exec(sprintf("which %s",{ss[i]}),0) = 0 then
ss = ss[i]
found = TRUE
exit
end if
end for
if not found then
Warn(,"test100","Sorry","No screenshot program found")
abort(1)
end if
constant docs = `<u><b>Screen Capture</b></u>
Click the OK button to take a screenshot
with ` & ss
constant win = create(GtkWindow,"size=300x100,border_width=10,icon=camera,$destroy=Quit")
constant panel = create(GtkBox,"orientation=VERTICAL")
add(win,panel)
constant lbl = create(GtkLabel)
set(lbl,"markup",docs)
add(panel,lbl)
constant camera = create(GtkImage,"applets-screenshooter",GTK_ICON_SIZE_DIALOG)
add(panel,camera)
constant btn1 = create(GtkButton,"gtk-quit","Quit"),
btn2 = create(GtkButton,"camera#_OK",_("ScreenShot")),
box = create(GtkButtonBox)
add(box,{btn1,btn2})
pack(panel,-box)
show_all(win)
main()
-----------------------------
function ScreenShot()
-----------------------------
system(sprintf("%s -i ",{ss}),0)
return 1
end function