
---------------------------------------------------------------
--# GtkAppChooserWidget
---------------------------------------------------------------

include GtkEngine.e

-- note: appears to be a bug in Gtk14

constant docs = `<b><u>App Chooser</u></b>
Below is an app chooser widget for file types 'image/png'.
The <u>I</u>nfo button gives more info about the selected app.
`
constant win = create(GtkWindow,"size=300x100,border_width=10,position=1,$destroy=Quit")

constant panel = create(GtkBox,"orientation=VERTICAL,spacing=5")
	add(win,panel)

constant lbl = create(GtkLabel)
	set(lbl,"markup",docs)
	add(panel,lbl)

constant appchooser = create(GtkAppChooserWidget,"image/png")
	set(appchooser,{
	  {"show default",TRUE},
	  {"show recommended",TRUE},
	  {"default text",
		"Sorry, I don't know how to handle that type of file!"},
	  {"connect","application-activated",_("Foo")}})
	add(panel,appchooser)

constant btnbox = create(GtkButtonBox)
	pack(panel,-btnbox)

constant btn1 = create(GtkButton,"gtk-quit","Quit")
constant btn2 = create(GtkButton,"gtk-info",_("Foo"))
	set(btn2,"tooltip text","Click to see a description of this program")
	add(btnbox,{btn1,btn2})

show_all(win)
main()

------------------------------------------------------------------------
function Foo()
------------------------------------------------------------------------
object app = get(appchooser,"app info")
object name = get(app,"name")
object icon = get(app,"icon")
object descr = get(app,"description")
if atom(descr) then descr = "No description available for this item" end if
object myimg = create(GtkImage)
	set(myimg,"from gicon",icon,5)
	return Info(win,"You Chose",name,descr,,,myimg)
end function


