Use of Gtk3::Gdk::EventMask with Gtk3::Widget::{set,get,add}_events

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Use of Gtk3::Gdk::EventMask with Gtk3::Widget::{set,get,add}_events

Zakariyya Mughal
Hello,

I noticed that the methods

    $widget->set_events( ... )
    $widget->get_events( ... )
    $widget->add_events( ... )

did not seem to be taking a `Glib::Flags` of type `Gtk3::Gdk::EventMask`
as would be expected by reading the documentation. Looking at the
`gtk+-3` source code, I see that the function signatures are using
`gint` instead of `GdkEventMask`. It looks like the type annotation
needs to be updated.

While I could try to use `Glib::Type->list_values` or `${ Gtk3::Gdk::EventMask->new(...) }`,
this behaviour is surprising.

I found similar bugs in the Bugzilla here:

- Bug 642238 - [introspection] Type information not available in generated GIR files
  <https://bugzilla.gnome.org/show_bug.cgi?id=642238>,

- Bug 711873 - [introspection] no way to gtk_widget_set_events()
  <https://bugzilla.gnome.org/show_bug.cgi?id=711873>.


Regards,
- Zakariyya Mughal
_______________________________________________
gtk-perl-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-perl-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Use of Gtk3::Gdk::EventMask with Gtk3::Widget::{set,get,add}_events

"Torsten Schönfeld"
On 12.04.2017 20:51, Zakariyya Mughal wrote:

> I noticed that the methods
>
>     $widget->set_events( ... )
>     $widget->get_events( ... )
>     $widget->add_events( ... )
>
> did not seem to be taking a `Glib::Flags` of type `Gtk3::Gdk::EventMask`
> as would be expected by reading the documentation. Looking at the
> `gtk+-3` source code, I see that the function signatures are using
> `gint` instead of `GdkEventMask`. It looks like the type annotation
> needs to be updated.
Yes, that's the core of the problem, and the bug reports are there to
make the gtk+ devs know.

Until the issue is fixed in gtk+, we could use overrides in Gtk3 to hide
the problem.  With the helper functions I just added to G:O:I*, this can
be done with the attached patch.  The problem is that this would change
the semantics of Gtk3::Widget::get_events: it would now return a
Glib::Flags object instead of a raw integer.  Since Glib::Flags
currently does not support raw integers, comparisons like
$widget->get_events == 0 would now fail.  (The corresponding tests in
the patch fail.)

So, should we worry about this?  Or just go ahead anyway and document
the change?

*
https://git.gnome.org/browse/perl-Glib-Object-Introspection/commit/?id=15c0b5122fbcf588625b4f3c2c9135e78b7f321a

_______________________________________________
gtk-perl-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-perl-list

0001-Add-overrides-for-Gtk3-Widget-add_events-set_events-.patch (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Use of Gtk3::Gdk::EventMask with Gtk3::Widget::{set,get,add}_events

"Torsten Schönfeld"
On 01.05.2017 15:46, Torsten Schoenfeld wrote:
> Until the issue is fixed in gtk+, we could use overrides in Gtk3 to hide
> the problem.  With the helper functions I just added to G:O:I*, this can
> be done with the attached patch.  The problem is that this would change
> the semantics of Gtk3::Widget::get_events: it would now return a
> Glib::Flags object instead of a raw integer.  Since Glib::Flags
> currently does not support raw integers, comparisons like
> $widget->get_events == 0 would now fail.  (The corresponding tests in
> the patch fail.)

I just pushed a patch that retains some amount of backwards
compatibility via overloaded '==' and '>=' operators.

https://git.gnome.org/browse/perl-Gtk3/commit/?id=0ab5735649260695b55a6b7b788da8007f7eadd8

Please test.
_______________________________________________
gtk-perl-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-perl-list
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Use of Gtk3::Gdk::EventMask with Gtk3::Widget::{set,get,add}_events

Zakariyya Mughal
On 2017-05-07 at 15:41:19 +0200, Torsten Schoenfeld wrote:

> On 01.05.2017 15:46, Torsten Schoenfeld wrote:
> > Until the issue is fixed in gtk+, we could use overrides in Gtk3 to hide
> > the problem.  With the helper functions I just added to G:O:I*, this can
> > be done with the attached patch.  The problem is that this would change
> > the semantics of Gtk3::Widget::get_events: it would now return a
> > Glib::Flags object instead of a raw integer.  Since Glib::Flags
> > currently does not support raw integers, comparisons like
> > $widget->get_events == 0 would now fail.  (The corresponding tests in
> > the patch fail.)
>
> I just pushed a patch that retains some amount of backwards
> compatibility via overloaded '==' and '>=' operators.
>
> https://git.gnome.org/browse/perl-Gtk3/commit/?id=0ab5735649260695b55a6b7b788da8007f7eadd8
>
> Please test.

Hi,

Thanks for looking into this. I have tested the changes with an example
script and it works now <https://github.com/zmughal/learning-gtk/commit/2c9793aac7fc558d65473b6afaf5f22fde5d69c6>.

Cheers,
- Zaki Mughal

> _______________________________________________
> gtk-perl-list mailing list
> [hidden email]
> https://mail.gnome.org/mailman/listinfo/gtk-perl-list
_______________________________________________
gtk-perl-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-perl-list
Loading...