This tutorial will deal with the concept of signal handling in PHP-GTK 2 which is an important and fundamental, since this is what makes your application "tick"!.
You might have noticed that at the end of every PHP-GTK 2 program we write this statement:
Gtk::main(); |
Gtk::main_quit(); |
First, it will be useful to define some terms that we will use frequently.
Signal handling basically consists of connecting a signal to its signal handler, and of course, writing the signal handler itself. The job of generating the signal whenever an action occurs is taken care by PHP-GTK 2. Another thing to note is that signal generation does not guarantee that the user has performed some action. It is possible to manually generate a signal, and PHP-GTK 2 generates signals internally all the time.
A common instance of a signal being internally generated and used is when GtkAdjustment emits the "value-changed" for a GtkProgressBar to use it. Hence, some signals have a default handler already inbuilt, which will be executed whether or not you manually connect a signal handler to that signal.
Most of the times however, if you want something to happen when a signal is generated, you need to create a signal handler for it.