#!/usr/bin/env exu ---------------------------------------------------------------- -- ButtonTest.exu Aug.3, 2008 -- Demonstrates: -- Different types of GTK buttons -- Labels -- packing -- Link Buttons & linking to a web browser -- (should be run from an xterm so you can see the results) ---------------------------------------------------------------- include GtkEngine.e include GtkEnums.e include GtkRoutines.e include dll.e ---------------- main window ---------------- constant win = create(GtkWindow) connect(win,"destroy",quit) set(win,"Border Width",20) set(win,"position",GTK_WIN_POS_CENTER) set(win,"default Size",400,300) function Foo(atom ctl, atom data) object addr = peek_string(data) if system_exec("/usr/bin/env firefox " & addr,0) != 0 then return Warn(win,"What, you don't have firefox?\n Shame! Shame! Shame!") end if return 1 end function constant foo = call_back(routine_id("Foo")) -------------- vertical container ----------- constant panel = create(GtkVBox) add(win,panel) constant lbl0 = create(GtkLabel, "Run this from an x-term!\nso you can see the results\n") constant lbl1 = create(GtkLabel,"GTK Check Button") constant btn1 = create(GtkCheckButton,"_Click me! [alt-c]") constant sep1 = create(GtkHSeparator) constant lbl2 = create(GtkLabel,"GTK Radio Buttons") constant rb1 = create(GtkRadioButton,0,"_One") constant rb2 = create(GtkRadioButton,rb1,"_Two") constant sep2 = create(GtkHSeparator) constant lbl3 = create(GtkLabel,"GTK Toggle Button") constant tb1 = create(GtkToggleButton,"click _Me!") constant sep3 = create(GtkHSeparator) constant lbl4 = create(GtkLabel,"GTK Link Button") constant lb1 = create(GtkLinkButton,"http://rapideuphoria.com","Euphoria") junk = get(lb1,"set uri hook",foo) constant sep4 = create(GtkHSeparator) constant lbl5 = create(GtkLabel,"GTK Scale Button") constant sb1 = create(GtkScaleButton,1,0,100,10) constant sep5 = create(GtkHSeparator) constant lbl6 = create(GtkLabel,"GTK Volume Button") constant vb1 = create(GtkVolumeButton) ----------------------------------------------------------- -- Generic function to display results available from btns ----------------------------------------------------------- function ShowValue(atom ctl, atom data) switch data do case 1 : printf(1,"Button 1 = %d\n",get(ctl,"active")) break case 2 : if get(ctl,"active") then puts(1,"Radio btn 1 selected\n") end if break case 3 : if get(ctl,"active") then puts(1,"Radio btn 2 selected\n") end if break case 4 : printf(1,"Toggle Button = %d\n",get(ctl,"active")) break case 5 : printf(1,"Scale Button = %g\n",get(ctl,"value")) break case 6 : printf(1,"Volume Button = %f\n",get(ctl,"value")) break end switch return 1 end function constant show_value = call_back(routine_id("ShowValue")) connect(btn1,"clicked",show_value,1) connect(rb1,"clicked",show_value,2) connect(rb2,"clicked",show_value,3) connect(tb1,"toggled",show_value,4) connect(sb1,"released",show_value,5) connect(vb1,"released",show_value,6) pack(panel,{lbl0,lbl1,btn1,sep1,lbl2,rb1,rb2,sep2,lbl3,tb1,sep3}) pack(panel,{lbl4,lb1,sep4,lbl5,sb1,sep5,lbl6,vb1}) show_all(win) main() --------------------------------------------------------------- -- copyright 2008 by Irv Mullins, code released under the LGPL ---------------------------------------------------------------