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()