
------------------------------------------------------------------------
--# GtkFontFilter - show only usable or desirable fonts
-- 
-- This demonstrates the use of a font filter routine to limit the 
-- styles of font displayed by the font chooser. 
------------------------------------------------------------------------

include GtkEngine.e

constant fontlist = {"URW Chancery L","Courier","Sans","WenQuanYi Micro Hei","Ubuntu"}

constant win = create(GtkWindow,
    "size=300x100,border_width=10,position=1,$destroy=Quit")

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

constant lbl = create(GtkLabel,
    "The Font Button will let you change\n" &
    "the size and style of this label")
     add(panel,lbl)

constant btnbox = create(GtkButtonBox,"spacing=10")
    pack(panel,-btnbox)

constant fntbtn = create(GtkFontButton,
    "font name=URW Chancery L italic medium 14,use font=TRUE," &
    "title=`Choose a nice font, now, you hear?`,$font-set=ChangeFont")
    
    ifdef UNIX then -- won't work on Windows :(
	set(fntbtn,"filter func",_("FontFilter")) 
    end ifdef
	
constant okbtn = create(GtkButton,"gtk-quit","Quit")
    add(btnbox,{okbtn,fntbtn})

show_all(win)
main()

-----------------------------------------------------------------
function FontFilter(atom family, atom face, atom data)
-----------------------------------------------------------------
object name = gtk_str_func("pango_font_family_get_name",{P},{family})
return find(name,fontlist)
end function

------------------------------------------------------------------
global function ChangeFont()
------------------------------------------------------------------
object newfont = get(fntbtn,"font name")
    set(lbl,"font",newfont)
return 1
end function

