Can GObject instances define interfaces dynamically
- From: Brian Cameron <Brian Cameron sun com>
- To: gtk-devel-list gnome org
- Cc: brian cameron sun com
- Subject: Can GObject instances define interfaces dynamically
- Date: Wed, 25 Jul 2001 13:00:09 +0100 (BST)
Gtk-Experts:
In the ATK project there are situations where it would be useful
if a GObject instance could specify that it implements additional
or fewer interfaces for a specific instance.
I know that gtype supports a function g_type_add_interface_dynamic(),
but this seems to add the new interface to all instances of the
class type. What we are looking for is a way to add an interface
to just certain instances of a class type. It doesn't seem that
GType supports any mechanism for removing an interface.
To explain a use-case where this would be a useful feature:
The ATK implementation of GtkButton is that buttons implement the
AtkAction interface. AtkAction interfaces can be used to perform
"push" actions on the button, and the AtkAction interface can be
used to querry the current state of the button. So this makes
the button accessible in the way that a person would expect a
button to work.
However, some buttons have a text label. It would be useful if
instances of button that have labels could also implement the
AtkText interface so that we could also expose detailed
information about the text in the button. AtkValue does support
a "get_description" interface which returns the text of the label,
but the AtkText interface provides much more than this (mostly
pango information like extent information, x/y screen offset
information, etc.)
In other words it would be useful if buttons that do not have
labels just implement the AtkValue interface, and buttons that
have labels implement both the AtkValue and AtkText interfaces.
Since a button could programmatically change itself from having
a label to not having a label, it is likely not possible to tell
for certain which interfaces the Atk object needs to implement when
the user firsts asks for the Atk object corresponding to the
GtkButton. Also, if the button dynamically changes itself so that
it switches from having a label to not having a label (or vice
versa), the Atk object corresponding to the GtkButton should
dynamically add/remove its interfaces accordingly.
Is it possible for a single instance of a GObject to specify that it
dynamically implements other interfaces? It would make the interface
work very cleanly in these sort of situations if GObject could do this.
If not, we can solve these sorts of problems via less elegant solutions
(like presenting the label as a child of the button).
Ideas? Perhaps there is another way to get the behavior we desire
without tackling it from this angle.
Brian
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]