Re: Adding a GUI

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

Next, we'll need a text display inside our window to show what previously appeared in the terminal:

object  
  scrlwin = gtk:create(GtkScrolledWindow), -- needs to scroll up and down if there's lots of text; 
  viewer = gtk:create(GtkTextView,"editable=FALSE,wrap mode=3"),  
  buffer = gtk:get(viewer,"buffer") 

When we receive text via the IRC_Listen() function, we'll want to show that text here. But also, we may want to log that text to a file, so it's convenient to do both in one step. After receiving and perhaps processing the incoming text, we call:

IRC_Log(text) 
-------------------------------- 
procedure IRC_Log(object msg) -- 
-------------------------------- 
ifdef LOG then puts(logfile,msg) flush(logfile) end ifdef 
set(buffer,"insert at cursor",msg,length(msg)) -- tack new text onto end of existing text; 
set(viewer,"scroll to mark",gtk:get(buffer,"insert")) -- scroll down so latest text is visible in the window; 
set(input,"grab focus") -- set focus back to field for user-typed input (defined later); 
end procedure -- IRC_Log; 
new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu