Genie global and static variables?
Posted: Sat 21 Aug 2010, 00:48
Trying to learn something so I can use Genie. This one has me stumped. How to define a global or static variable in Genie?
In the following code, in the signal handler on_new_clicked (), I would like to know how the variable 'count' could be defined as static, and how could it be defined outside the class as global?
In the following code, in the signal handler on_new_clicked (), I would like to know how the variable 'count' could be defined as static, and how could it be defined outside the class as global?
Code: Select all
[indent=4]
uses
Gtk
init
Gtk.init (ref args)
var test = new Testwin ()
test.show_all ()
Gtk.main ()
class Testwin : Window
init
title = "Test"
default_height = 100
default_width = 300
window_position = WindowPosition.CENTER
destroy += on_exit_clicked
var toolbar = new Toolbar ()
var new_button = new ToolButton.from_stock (STOCK_NEW)
var quit_button = new ToolButton.from_stock (STOCK_QUIT)
toolbar.add (new_button)
toolbar.add (quit_button)
new_button.clicked += on_new_clicked
quit_button.clicked += on_exit_clicked
var vbox = new VBox (false, 0)
vbox.pack_start (toolbar, false, true, 0)
add (vbox)
def private on_new_clicked ()
var count = 1
count += 1
var myStr = "New has been clicked " + count.to_string() + " times"
print("%s",myStr)
def private on_exit_clicked ()
Gtk.main_quit()