61 lines
1.9 KiB
Elixir
Raw Permalink Normal View History

2016-11-25 00:33:18 -07:00
-------------------------------------------------------------------------
--# GtkRecentChooser
-------------------------------------------------------------------------
include GtkEngine.e
include std/net/url.e
constant win = create(GtkWindow,"size=300x100,border_width=10,position=1,$destroy=Quit")
constant panel = create(GtkBox,VERTICAL)
add(win,panel)
constant lbl = create(GtkLabel,
"markup='<b><u>RecentChooserDialog</u></b>\nClick OK to start',margin top=10")
add(panel,lbl)
constant box = create(GtkButtonBox)
pack(panel,-box)
add(box,{
create(GtkButton,"gtk-quit","Quit"),
create(GtkButton,"gtk-ok","Foo")})
show_all(win)
main()
---------------------------------------------------
global function Foo()
---------------------------------------------------
object rc_dlg = create(GtkRecentChooserDialog,"Recent Files",win)
set(rc_dlg,{
{"title","Recent files"},
{"add button","gtk-cancel", MB_CANCEL},
{"add button","gtk-open", MB_ACCEPT},
{"default size",300,300},
{"show not found",TRUE}, -- don't know the conditions in which this works
{"limit",10}, -- max number of items to display
{"show tips",TRUE}, -- shows tooltip with full path to file
{"local only",TRUE}, -- don't show networked files
{"select multiple",FALSE}, -- if true, allow selecting more than one
{"show icons",TRUE}, -- show file-type icons beside names
{"sort type",GTK_RECENT_SORT_MRU}})
object filename
if get(rc_dlg,"run") = MB_ACCEPT then
filename = get(rc_dlg,"current uri")
if sequence(filename) then
if file_exists(canonical_path(filename[8..$])) then
filename = url:decode(filename) -- in case url is encoded
display(filename) -- on terminal
show_uri(filename) -- use default app.
else
Warn(win,,filebase(filename),"has been deleted")
end if
end if
end if
set(rc_dlg,"destroy")
return 1
end function