---------------------------------------------------------------------- --# Menus ---------------------------------------------------------------------- include GtkEngine.e constant docs = `Menus Please run this from an x-term so that you can see the results when you activate a menu item! ` constant win = create(GtkWindow,"size=300x-1,position=1,$destroy=Quit") constant panel = create(GtkBox,"orientation=VERTICAL") add(win,panel) constant menubar = create(GtkMenuBar) pack(panel,menubar) constant sep = create(GtkSeparator) pack(panel,sep) constant filemenu = create(GtkMenuItem,"_File") set(menubar,"append",filemenu) constant sub1 = create(GtkMenu) set(filemenu,"submenu",sub1) enum OPEN,CLOSE,DIRTY=4 sequence f = repeat(0,9) f[1] = create(GtkMenuItem,"_Open","fOpen") f[2] = create(GtkMenuItem,"_Close","fClose") f[3] = create(GtkSeparatorMenuItem) f[4] = create(GtkCheckMenuItem,"_Dirty","fDirty") f[5] = create(GtkSeparatorMenuItem) f[6] = create(GtkRadioMenuItem,NULL,"One","BtnID",1) f[7] = create(GtkRadioMenuItem,f[6],"Two","BtnID",2) f[8] = create(GtkRadioMenuItem,f[7],"Three","BtnID",3) f[9] = create(GtkMenuItem,"_Quit","Bail") set(f[2],"sensitive",FALSE) set(sub1,"append",f) constant lbl = create(GtkLabel) set(lbl,"markup",docs) add(panel,lbl) show_all(win) main() ----------------------- global function fOpen() ----------------------- puts(1,"Open menu item clicked\n") set(f[2],"sensitive",TRUE) set(f[1],"sensitive",FALSE) return 1 end function ------------------------ global function fClose() ------------------------ puts(1,"Close menu item clicked\n") set(f[2],"sensitive",FALSE) set(f[1],"sensitive",TRUE) return 1 end function -------------------------------- global function fDirty(atom ctl) -------------------------------- printf(1,"Dirty = %d\n",get(ctl,"active")) return 1 end function ------------------------------------------ global function BtnID(atom ctl, atom id) ------------------------------------------ if get(ctl,"active") then printf(1,"Radio %d active\n",id) end if return 1 end function ---------------------- global function Bail() ---------------------- if get(f[4],"active") then Warn(win,"Sorry","The file is dirty","clean it up first!") else Quit() end if return 1 end function