[Sugar-devel] Custom accessibles in python (patch)

Daniel Narvaez dwnarvaez at gmail.com
Sun Dec 2 18:22:04 EST 2012


Hello,

for some reason I thought GtkCellRenderer was not providing an
accessible action (http://developer.gnome.org/atk/2.6/AtkAction.html)
on click and I wanted to implement a custom accessible. I found that's
not really trivial in python, because of how the atk API is designed.

I wrote a patch which allows to associate a widget with and accessible
providing the Atk.Action interface with something like this

class MyLabelAction(GObject.GObject, Atk.Action):
    def do_get_n_actions(self):
        return 1

    def do_get_name(self, i):
        return "myaction"

    def do_do_action(self, i):
        return True

class MyLabelAccessible(SugarExt.Accessible):
    def __init__(self):
        SugarExt.Accessible.__init__(self)

        self._action = None

    def do_get_action(self):
        if self._action is None:
            self._action = MyLabelAction()

        return self._action

class MyLabelClickable(Gtk.Label):
    def __init__(self):
        Gtk.Label.__init__(self, label="Huh")

        self._accessible = MyLabelAccessible()

    def do_get_accessible(self):
        return self._accessible

To solve my problem I will probably not need a custom accessible after
all, but I think it might be useful at some point. So I'm posting it
but I don't think it should be integrated yet.

-- 
Daniel Narvaez
-------------- next part --------------
A non-text attachment was scrubbed...
Name: accessible.patch
Type: application/octet-stream
Size: 5614 bytes
Desc: not available
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20121203/5c6ddea9/attachment.obj>


More information about the Sugar-devel mailing list