--------------------------------------------------------------------------- --# GtkScale and GtkEntry as progressbar --------------------------------------------------------------------------- include GtkEngine.e -- this is the main window which contains a scrollbar and a quit button; constant win = create(GtkWindow,"size=200x100,border_width=10,$destroy=Quit") constant panel = create(GtkBox,"orientation=VERTICAL,spacing=5") add(win,panel) constant lbl = create(GtkLabel) set(lbl,"markup", "GtkScrollbar using an adjustment\nand a separate level display window") add(panel,lbl) -- this adjustment links scrollbar changes to the value displayed in -- the second window constant adj = create(GtkAdjustment) set(adj,"configure",25,0,100,1) -- initial value, min, max, step constant sb = create(GtkScrollbar,0,adj) constant sigid = connect(sb,"value-changed","DisplayValue") add(panel,sb) constant btn1 = create(GtkButton,"gtk-quit","Quit") pack(panel,-btn1) -- the second window is borderless, and contains a GtkEntry which displays -- the value set by the scrollbar both as text and as a progressbar; constant vwin = create(GtkWindow,{ {"title","Value"}, {"default size",200,50}, {"background","black"}, {"border width",10}, {"position",GTK_WIN_POS_CENTER}, {"keep above",TRUE}, {"decorated",FALSE}, {"move",300,300}, {"connect","hide",_("DisconnectSignal"),sigid}}) constant lbl1 = create(GtkLabel,"font=8,color=yellow") constant vpanel = create(GtkBox,VERTICAL) add(vwin,vpanel) set(lbl1,"markup", "test83.ex : below is a GtkEntry with progressbar\n") add(vpanel,lbl1) constant vlbl = create(GtkEntry,{ {"font","Courier Bold 12"}, {"color","red"}, {"alignment",.5}, {"text","25 percent"}, {"progress fraction",0.25}}) add(vpanel,vlbl) show_all(vwin) show_all(win) main() ------------------------------------------------------------ global function DisplayValue(atom ctl) ------------------------------------------------------------ atom v = get(ctl,"value") set(vlbl,"text",sprintf("%2.0f percent",v)) set(vlbl,"progress fraction",v/100) if v = 100 then set(vwin,"background","red") else set(vwin,"background","black") end if return 1 end function ----------------------------------------------------------- function DisconnectSignal(atom ctl, integer sigid) ----------------------------------------------------------- disconnect(sb,sigid) return 1 end function