Re: [g-a-devel] GtkSocket/GtkPlug accessibility



Hello,

I have add AtkSocket/AtkPlug support to mate-panel here:

https://salsa.debian.org/hypra-team/mate-panel/blob/stretch-applets/debian/patches/1001_atk-socket-plug

I am however wondering whether the complexity is needed and/or whether
some of it could already be implemented in gtk.

What I had to do is:

* on the socket side:

  - create PanelSocket, a subclass of GtkSocket that creates an
    AtkSocket (actually a PanelAtkSocket, see below) and makes itself
    its accessible parent.

  - create PanelSocketAccessible, the corresponding subclass of
    GetContainerAccessible that overrides get_n_children and ref_child
    to return the AtkSocket as child of the accessible of the
    PanelSocket.

  - create PanelAtkSocket, a subclass of AtkSocket that makes its
    get_extents method call the parent's get_extents method.

* on the plug side:

  - create PanelAPlug, a subclass of GtkPlug that creates an AtkPlug
    (actually a PanelAtkPlug, see below) and set it as accessible
    parent.

  - create PanelAtkPlug, a subclass of AtkPlug that makes it parent of
    the root of the applet, and calls ref_state_set from the root of the
    applet to implement the ref_state_set method.


All of this is not specific to mate-panel so might be done by
gtk itself, and the complexity seems useless: normally AtkSocket
should directly be the accessible of GtkSocket, and ditto for
AtkPlug/GtkPlug. But AFAICT:

- To make AtkSocket the accessible of GtkSocket one would make GtkSocket
  call gtk_widget_class_set_accessible_type(GTK_TYPE_SOCKET_ACCESSIBLE).

- But gtk_widget_class_set_accessible_type checks that
  GTK_TYPE_SOCKET_ACCESSIBLE is "a subtype of the type used for
  accessibles of the parent class".
  
- Since the parent class of GtkSocket is GtkContainer,
  GtkSocketAccessible would have to be a parent of
  GtkContainerAccessible, and eventually of GtkAccessible.

- But GtkAccessible contains an AtkObject, while AtkSocket extends
  AtkObject (to store the plug id).

- Put another way, we'd want multi-heritage for GtkSocketAccessible:
  both GtkContainerAccessible and AtkSocket ; and AFAIK this is not
  supported by gobject (which makes sense: the AtkObject structure
  within GtkAccessible can't magically be extended to contain
  embedded_plug_id).

ditto for AtkPlug/GtkPlug.


Maybe another way would be to make GtkSocket/GtkPlug directly create
AtkSocket/AtkPlug, and override the get_accessible method to return the
AtkSocket/AtkPlug directly?  I didn't see such approach used in gtk
so I'm unsure if that's supposed to work?  Or perhaps there might be
possibly only a couple of bugs to fix to get it to work?

Samuel


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]