Re: [pygtk] Actions for custom widgets in PyGTK

2012-07-31 Thread Sascha Silbe
Sascha Silbe  writes:

> 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?

The minor detail I missed was that I need to override
do_get_accessible() rather than get_accessible(). Thanks to Mike Gorse
(on #a11y) for digging out a couple of references for me.

It also seems do_get_accessible() needs to have been overridden at class
definition time, rather than being able to override it on an individual,
already initialised instance. That means adding code to each widget
class (including creating subclasses for stock GTK widgets that we're
using). Not sure yet if that's feasible; at the very least it's a major
PITA.

There's still some race condition affecting my code. One symptom is a
segfault, the other is do_get_n_actions() getting invoked on the widget,
rather than the AtkObject subclass. Both are happening at the same
location in the Python code.

Python backtrace for do_get_n_actions() invoked on the wrong class:

[...]
  File 
"/home/sascha.silbe/sugar-jhbuild/install/lib/python2.7/site-packages/jarabe/desktop/favoritesview.py",
 line 636, in __init__
BuddyIcon.__init__(self, buddy=get_owner_instance(), pixel_size=size)
  File 
"/home/sascha.silbe/sugar-jhbuild/install/lib/python2.7/site-packages/jarabe/view/buddyicon.py",
 line 38, in __init__
self._update_color()
  File 
"/home/sascha.silbe/sugar-jhbuild/install/lib/python2.7/site-packages/jarabe/view/buddyicon.py",
 line 53, in _update_color
self.props.xo_color = self._buddy.get_color()
  File "", line 2, in do_get_n_actions
  File 
"/home/sascha.silbe/sugar-jhbuild/install/lib/python2.7/site-packages/sugar/logger.py",
 line 208, in _trace
res = f(*args, **kwargs)
  File 
"/home/sascha.silbe/sugar-jhbuild/install/lib/python2.7/site-packages/jarabe/view/eventicon.py",
 line 293, in do_get_n_actions
traceback.print_stack()


gdb backtrace for the segfault (sorry about the missing debug symbols,
will have to rebuild the glib Debian package first):

#1  0x74db4724 in g_closure_invoke () from 
/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#2  0x74dc57b0 in ?? () from 
/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#3  0x74dcd72c in g_signal_emit_valist () from 
/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#4  0x74dcd8c2 in g_signal_emit () from 
/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#5  0x74db90e5 in ?? () from 
/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#6  0x74db8b2e in ?? () from 
/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#7  0x74dbc759 in g_object_set_property () from 
/usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0
#8  0x73e38e03 in set_property_from_pspec (obj=0xd572f0, 
attr_name=0x10df054 "xo_color", pspec=, pvalue=)
at 
/home/martin/debian/pkg-gnome/build-area/pygobject-2-2.28.6/gobject/pygobject.c:357
Python Exception  There is no member named in_class.: 
#9  0x73e39690 in PyGProps_setattro (self=0x1a76550, attr='xo_color', 
pvalue=) at 
/home/martin/debian/pkg-gnome/build-area/pygobject-2-2.28.6/gobject/pygobject.c:406
[...]

Just to make sure, there's only a single thread:

  Id   Target Id Frame 
* 1Thread 0x77fda700 (LWP 18084) "python" 0x7fffedeb820c in ?? () 
from /usr/lib/x86_64-linux-gnu/gtk-2.0/modules/libgail.so

Does this ring a bell for anyone? Do I need to do anything special for
memory management? Maybe for the ref_*() methods I had to override to
wrap the "original" AtkObject instance?

Sascha

[1] https://bugzilla.gnome.org/show_bug.cgi?id=647482
-- 
http://sascha.silbe.org/
http://www.infra-silbe.de/


pgp6lqviYW6Ud.pgp
Description: PGP signature
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Re: [pygtk] Actions for custom widgets in PyGTK

2012-07-31 Thread Sascha Silbe
Flavio Danesse  writes:

> https://sites.google.com/site/sugaractivities/pygi-hack

Thanks for the link, but apart from it using PyGI instead of PyGTK I
also don't see any accessibility related code in there. Maybe my post
(and especially the subject) was a bit too concise? What I'm looking for
is a way to tell accessibility tools (via ATK) what the available
actions are, not adding actions to be executed when I click on some
widget.

Sascha
-- 
http://sascha.silbe.org/
http://www.infra-silbe.de/


pgpaYpy84oetK.pgp
Description: PGP signature
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Re: [pygtk] Actions for custom widgets in PyGTK

2012-07-30 Thread Flavio Danesse
https://sites.google.com/site/sugaractivities/pygi-hack



2012/7/30 Sascha Silbe 

> 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/
>
> ___
> pygtk mailing list   pygtk@daa.com.au
> http://www.daa.com.au/mailman/listinfo/pygtk
> Read the PyGTK FAQ: http://faq.pygtk.org/
>
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

[pygtk] Actions for custom widgets in PyGTK

2012-07-30 Thread Sascha Silbe
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/


pgp3otrreXGhA.pgp
Description: PGP signature
___
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/