package lablgtk3
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=d4821cdbecf3ae374f20317d63e43fe58030c3ba9657b51a2e83e652197e8eac
sha512=83f0be38a1e21737de93f88b0adac15cdcc50cf712d773720b9bc1e8d8ffdb2c660d35840f25d326a42a9d4e6537e6cef466099bf72494196b2cc79977e703e3
doc/lablgtk3/GUtil/index.html
Module GUtil
Source
Utility classes for programming with GTK objects
A nice function to use with #install_printer
The memo class provides an easy way to remember the real class of a widget. Insert all widgets of class in one single t memo
, and you can then recover their original ML object with #find
.
The ML signal mechanism
It allows one to add GTK-like signals to arbitrary objects.
As with GTK signals, you can use GtkSignal.stop_emit
inside a callback to prevent other callbacks from being called.
To add ML signals to a LablGTK object:
class mywidget_signals obj ~mysignal1 ~mysignal2 = object
inherit somewidget_signals obj
inherit add_ml_signals obj [mysignal1#disconnect; mysignal2#disconnect]
method mysignal1 = mysignal1#connect ~after
method mysignal2 = mysignal2#connect ~after
end
class mywidget obj = object (self)
inherit somewidget obj
val mysignal1 = new signal obj
val mysignal2 = new signal obj
method connect = new mywidget_signals obj ~mysignal1 ~mysignal2
method call1 = mysignal1#call
method call2 = mysignal2#call
end
You can also add ML signals to an arbitrary object; just inherit from ml_signals
in place of widget_signals
+add_ml_signals
.
class mysignals ~mysignal1 ~mysignal2 = object
inherit ml_signals [mysignal1#disconnect; mysignal2#disconnect]
method mysignal1 = mysignal1#connect ~after
method mysignal2 = mysignal2#connect ~after
end
Propagating state modifications
The variable class provides an easy way to propagate state modifications. A new variable is created by new variable init
. The #set
method just calls the set
signal, which by default only calls real_set
. real_set
sets the variable and calls changed
when needed. Deep equality is used to compare values, but check is only done if there are callbacks for changed
.