------------------------------------------------------------------------ --# GtkScale with options ------------------------------------------------------------------------ include GtkEngine.e constant win = create(GtkWindow,"size=200x100,border_width=10,position=1,$destroy=Quit") constant panel = create(GtkBox,VERTICAL) add(win,panel) constant lbl = create(GtkLabel,"markup=GtkScale using an adjustment") add(panel,lbl) constant scale = create(GtkScale,{ {"orientation",HORIZONTAL}, {"range",0,100}, {"increments",0.01,1}, {"fill level",75}, {"show fill level",TRUE}, -- note: some themes do not colorize the fill level bar! {"restrict to fill level",FALSE}}) add(panel,scale) constant btn1 = create(GtkButton,"gtk-quit","Quit") pack(panel,-btn1) constant vwin = create(GtkWindow,{ -- secondary window to show current value; {"title","Value"}, {"keep above",TRUE}, {"default size",150,150}, {"transient for",win}, {"deletable",FALSE}, {"type hint",GDK_WINDOW_TYPE_HINT_DIALOG}, {"position",GTK_WIN_POS_MOUSE}}) constant vlbl = create(GtkLabel,"font='Courier bold 18',text='0'") -- for value; add(vwin,vlbl) show_all(vwin) show_all(win) constant sigid = connect(scale,"value-changed","DisplayValue") main() ------------------------------------------------------------ global function DisplayValue(atom ctl) ------------------------------------------------------------ atom val = get(ctl,"value") set(vlbl,"markup",sprintf("%2.1f",val)) if val > 75 then set(vwin,"title=OVER!,background=black") set(vlbl,"background=red,foreground=white") elsif val > 0 then set(vwin,"title=Value,background=lightgreen") set(vlbl,"background=green,foreground=black") else set(vlbl,"background=gray80,foreground=black") end if return 1 end function