50 likes | 75 Views
Event Handling in Glade. Kwangwoo Choi Department of Physics Kangwon National University. • Signals are a way to get notification when something happens and to customize object behavior according to the user's needs. • Every signal is uniquely identified by a name,
E N D
Event Handling in Glade Kwangwoo Choi Department of Physics Kangwon National University • Signals are a way to get notification when something happens and to customize object behavior according to the user's needs. • Every signal is uniquely identified by a name, “Class_name::Signal_name”, where Signal_name might be something like “clicked”.
Basic Terminology • signal • A class method, e.g. GtkButton::clicked. More precisely it is a unique class-branch/signal-name pair. This means you may not define a signal handler for a class which derives from GtkButton that is called clicked, but it is okay to share signals names if they are separate in the class tree. • default handler • The object's internal method which is invoked when the signal is emitted. • user-defined handler • A function pointer and data connected to a signal (for a particular object). • There are really two types: those which are connected normally, and those which are connected by one of the connect_after functions. • emission • the whole process of emitting a signal, including the invocation of all the different handler types mentioned above. • signal id • The unique positive (nonzero) integer used to identify a signal. It can be used instead of a name to many functions for a slight performance improvement.
Use the “delete_event” Delete_event: close Windows
Click “Add” • Gboolean • on_window1_delete_event (GtkWidget *widget, GdkEvent *event, gpointer user_data) • { • gtk_exit( 0 ); • return FALSE; • }
Summary • Signals are a way to get notification when something user's happens and to customize object behavior according to the needs.