Closed nt8r closed 4 years ago
Indeed, should be a generic event. Do you want to provide a PR for this?
The bug seems to be in the gir; I would think something like the following would work:
diff --git a/Gtk-3.0.gir b/Gtk-3.0.gir
index 4b49bd9..64ea747 100644
--- a/Gtk-3.0.gir
+++ b/Gtk-3.0.gir
@@ -34794,8 +34794,8 @@ is clicked.</doc>
<type name="EntryIconPosition"/>
</parameter>
<parameter name="event" transfer-ownership="none">
- <doc xml:space="preserve">the button press event</doc>
- <type name="Gdk.EventButton"/>
+ <doc xml:space="preserve">the button press or touch event</doc>
+ <type name="Gdk.Event"/>
</parameter>
</parameters>
</glib:signal>
@@ -34811,8 +34811,8 @@ mouse click over an activatable icon.</doc>
<type name="EntryIconPosition"/>
</parameter>
<parameter name="event" transfer-ownership="none">
- <doc xml:space="preserve">the button release event</doc>
- <type name="Gdk.EventButton"/>
+ <doc xml:space="preserve">the button or touch release event</doc>
+ <type name="Gdk.Event"/>
</parameter>
</parameters>
</glib:signal>
Should I pr to gtk-rs/gir-files
, or is there a different workflow? If it'd be easier, feel free to apply the fix yourself. Thanks!
You'd fix it in fix.sh
, and also in GTK (the C library) by fixing the annotation in the function's documentation. Let me know if you want to do one of those, or both. I'll take care of the remaining parts :)
Does this look sane for a gir-files patch?
diff --git a/fix.sh b/fix.sh
index 17da8a0..b27ada3 100755
--- a/fix.sh
+++ b/fix.sh
@@ -12,6 +12,12 @@ xmlstarlet ed -P -L \
-u '//*[@glib:error-domain="g-option-context-error-quark"]/@glib:error-domain' -v g-option-error-quark \
GLib-2.0.gir
+# incorrectly assumes GdkEventButton when other variants may be passed
+xmlstarlet ed -P -L \
+ -u '//glib:signal[@name="icon-press"]//_:parameter[@name="event"]/_:type[@name="Gdk.EventButton"]/@name' -v "Gdk.Event" \
+ -u '//glib:signal[@name="icon-release"]//_:parameter[@name="event"]/_:type[@name="Gdk.EventButton"]/@name' -v "Gdk.Event" \
+ Gtk-3.0.gir
+
# GtkIconSize usage
xmlstarlet ed -P -L \
-u '//_:type[@c:type="GtkIconSize"]/@name' -v "IconSize" \
Yeah, assuming it does the same as your change above :)
To reproduce: construct a GtkEntry with icons and connect to the icon-pressed signal. Run the program on a device with a touchscreen (or emulate one) and touch the icon. The following panic results:
Note that 37 corresponds to a
GdkEventTouch
(perlib.rs
ingdk_sys
):The relevant code in the
gtk
crate is the following, inentry.rs
:The event here is not known to be a
GdkEventButton
, so the unwrap infrom_glib_borrow
fails.The same problem is present in
connect_icon_release
.