Dear readers, is there any project that has succeeded in making custom widgets using PyGTK accessible, including adding new actions? I'm having a hard time trying to do this in Sugar [1]; being able to take a peek at known-working code would help a lot. Searching the web only turned up questions and problems, not much in the way of answers and solutions. My current problem child are Palettes, the Sugar equivalent of context menus and drop-down menus. They can be attached to many different widgets (including table cells), but those widgets don't always have a Palette. There's no API [3] in ATK to add actions to an existing instance of AtkObject + AtkAction, so I'm trying to provide a custom AtkObject subclass that overrides the AtkAction methods, but otherwise just wraps the existing AtkObject. I managed to get it in a form that doesn't trigger CRITICAL errors (or Tracebacks, for that matter), but it isn't really working. I don't see any change in sniff, and my custom get_n_actions() never gets called. The name collisions between AtkObject and AtkAction [3] will certainly cause trouble (and I have some work-around code that at least helps on the Python side), but I don't think they're causing this particular issue. Rather it looks like my custom AtkObject instance doesn't get used at all on the C side. Because I need to add the custom wrappers at run-time (as mentioned above, we don't know beforehand whether a widget will have a Palette or not), I'm currently hot-patching the get_accessible() method on the fly: parent_accessible = parent.get_accessible() wrapper = AtkActionWrapper(parent_accessible) parent.get_accessible = lambda: wrapper wrapper.add_action('menu', _('Invoke Palette'), _('Pop up the Palette'), self.notify_right_click) I can imagine this hot-patching being problematic, but overriding get_accessible() in the class definition (instead of hot-patching the instance afterwards) doesn't help either. Is there a way of using AtkObject subclasses with GTK subclasses other than duplicating the entire set of custom widgets (and probably quite a few stock ones as well) and registering an AtkObject factory for each of them? Sascha [1] https://wiki.sugarlabs.org/go/What_is_Sugar%3F [2] https://bugzilla.gnome.org/show_bug.cgi?id=649804 [3] https://bugzilla.gnome.org/show_bug.cgi?id=647482 -- http://sascha.silbe.org/ http://www.infra-silbe.de/
Attachment:
pgpo9HqS8Uyf7.pgp
Description: PGP signature