After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 635460 - implement signal handler overriding
implement signal handler overriding
Status: RESOLVED OBSOLETE
Product: pygobject
Classification: Bindings
Component: introspection
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on: 637215
Blocks:
 
 
Reported: 2010-11-21 19:48 UTC by Paolo Borelli
Modified: 2012-04-09 12:53 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test program (377 bytes, text/plain)
2010-11-21 19:49 UTC, Paolo Borelli
  Details
patch (6.21 KB, patch)
2010-11-25 19:01 UTC, Paolo Borelli
needs-work Details | Review

Description Paolo Borelli 2010-11-21 19:48:52 UTC
Maybe I am just rusty or not aware of some detail of pygi, but subclassing GtkDialog and overriding the "response" handler does not seem to work.

Minimal testcase attached
Comment 1 Paolo Borelli 2010-11-21 19:49:20 UTC
Created attachment 174977 [details]
test program
Comment 2 johnp 2010-11-22 22:53:47 UTC
I don't see any response vfuncs, only a signal.  In which case you need to do a dialog.connect('response', self.do_response, None)
Comment 3 Paolo Borelli 2010-11-22 23:08:50 UTC
mmm... weird, note that the same code used to work in pygtk
Comment 4 Paolo Borelli 2010-11-22 23:10:05 UTC
Beside GtkDialog has response vfunc:

...
struct _GtkDialogClass
{
  GtkWindowClass parent_class;

  void (* response) (GtkDialog *dialog, gint response_id);
...
Comment 5 Paolo Borelli 2010-11-25 19:00:31 UTC
It turns out that signal overriding is totally missing in pygobject.
I am changing the summary.

The following patch implements it, but it does not actually work since it seems that get_class_closure never returns anything from the g-i side of things :(
Comment 6 Paolo Borelli 2010-11-25 19:01:01 UTC
Created attachment 175269 [details] [review]
patch
Comment 7 Tomeu Vizoso 2011-01-07 11:41:01 UTC
I hope that soon vfuncs associated to a signal will appear in the .gir like the others, so this won't be needed.
Comment 8 Paolo Borelli 2011-01-07 12:50:02 UTC
I think that even if signal vfunc are reported in the gir, there are still problems to be fixed (and maybe in part addressed by this patch):

 - get_class_closure should either be fixed in gi, wrapped and used in pygobject or dropped from g-i... at the moment it is very confusing to understand which is the proper way to obtain a signal vfunc
 - while conventionally signals have a vfunc in the class struct, that is not mandatory
Comment 9 Tomeu Vizoso 2011-01-08 18:20:01 UTC
(In reply to comment #8)
> I think that even if signal vfunc are reported in the gir, there are still
> problems to be fixed (and maybe in part addressed by this patch):
> 
>  - get_class_closure should either be fixed in gi, wrapped and used in
> pygobject or dropped from g-i... at the moment it is very confusing to
> understand which is the proper way to obtain a signal vfunc

Why do app authors need to obtain a signal's vfunc? If all vfuncs make to the .gir, app authors can choose to implement/override any of the available vfuncs, or listen to signals. The API author decides what should be available.

>  - while conventionally signals have a vfunc in the class struct, that is not
> mandatory

How could you override a signal? You override vfuncs and that's now possible as all vfuncs will be present in the .gir.
Comment 10 Paolo Borelli 2011-01-08 18:39:13 UTC
(In reply to comment #9)
> 
> How could you override a signal? You override vfuncs and that's now possible as
> all vfuncs will be present in the .gir.

I think the object has the infrastructure to override signal handlers without having access to the vfunc pointer in the class structure:

 g_signal_override_class_closure

I think it was added to be able to add signals without breaking ABI. I am not sure how common its use is.



That said, my point is very simple: g-i has the function g_signal_info_get_class_closure but it is currently broken. If the bindings do not need to use it, it should be removed, if the bindings need it then it should be fixed and pygobject should use it.
Comment 11 Tomeu Vizoso 2011-01-09 08:50:36 UTC
(In reply to comment #10)
> (In reply to comment #9)
> 
> That said, my point is very simple: g-i has the function
> g_signal_info_get_class_closure but it is currently broken. If the bindings do
> not need to use it, it should be removed, if the bindings need it then it
> should be fixed and pygobject should use it.

Ok, right now I cannot see any need for it. Should this ticket be closed or reworded somehow?
Comment 12 Tomeu Vizoso 2012-01-24 15:40:22 UTC
Comment on attachment 175269 [details] [review]
patch

In case we still want this, the patch will need a testcase.
Comment 13 Martin Pitt 2012-04-09 12:53:25 UTC
The demo program works just fine now, i. e. you can just simply override the do_response() function now. So the primary issue here is fixed.

Bug 434924 deals with making it easier to define new signals, BTW.