Re: Adding a GUI

new topic     » goto parent     » topic index » view thread      » older message » newer message

We'll need a place for the user to type messages:

object input = gtk:create(GtkEntry,"sensitive=FALSE,placeholder text=Type here and hit <enter> ...") 

Why sensitive=FALSE? We aren't interested in trying to send messages until a connection is achieved. That would result in an error. So we disable it, and in our connect function, after a successful connection is made, we enable it with the following code:

gtk:connect(input,"activate","SendText") -- connect the 'activate' signal (user presses <enter>) to our SendText function; 
gtk:set(input,"sensitive",TRUE) -- enable the input field so we are allowed to type in there; 

Lastly, we'll need a few buttons:
regular buttons have 2 (or 3) parameters: icon/caption, and function to call (optional 3rd is data to pass): Check buttons don't have icons, just the caption.

object 
  btn1 = gtk:create(GtkButton,"gtk-quit","Quit"), 
  btn2 = gtk:create(GtkCheckButton,"Keep Alive Ping"), 
  btn3 = gtk:create(GtkButton,"gtk-connect",_("IRC_Connect")) 

The keep_alive_ping function we set up on a timer previously will continue to run, but we can check the state of btn2 to see if a ping is really desired:

------------------------------ 
function keep_alive_ping() --  
------------------------------ 
if atom(my_socket) then return 1 end if -- no use continuing; 
if gtk:get(btn2,"active") then -- btn2 is 'checked' = 'active'; 
-- ... do the ping; 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu