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 791570 - Gtk.MessageDialog should allow null for message_format
Gtk.MessageDialog should allow null for message_format
Status: RESOLVED FIXED
Product: vala
Classification: Core
Component: Bindings: GTK+ GStreamer WebKitGTK+
0.38.x
Other Linux
: Normal normal
: ---
Assigned To: Vala maintainers
Vala maintainers
Depends on:
Blocks:
 
 
Reported: 2017-12-13 12:27 UTC by Philipp Wolfer
Modified: 2017-12-13 19:47 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gtk+-3.0: Mark MessageDialog constructor parameter, message_format, as nullable (2.03 KB, patch)
2017-12-13 13:18 UTC, Al Thomas
none Details | Review
gtk+-3.0: Mark MessageDialog constructor parameter, message_format, as nullable (1.78 KB, patch)
2017-12-13 16:17 UTC, Al Thomas
committed Details | Review
gtk+-2.0: Mark MessageDialog constructor parameter, message_format, as nullable (1.73 KB, patch)
2017-12-13 16:18 UTC, Al Thomas
committed Details | Review

Description Philipp Wolfer 2017-12-13 12:27:51 UTC
Currently the parameter message_format for Gtk.MessageDialog is a non-nulable string, so you can't do this:

var msg = new Gtk.MessageDialog (parent, Gtk.DialogFlags.MODAL,
        Gtk.MessageType.WARNING, Gtk.ButtonsType.OK, null);

But according to the documentation of gtk_message_dialog_new [1] null is allowed for when you don't want to set a message here.

Also passing null was possible with Vala before version 0.38.4, but the generated code caused a warning (see bug #791215).

[1] https://developer.gnome.org/gtk3/stable/GtkMessageDialog.html#gtk-message-dialog-new
Comment 1 Al Thomas 2017-12-13 13:02:10 UTC
This is fixed in the preview release 0.39.2. The bindings are now generated from the GIR, instead of using the older GIDL method, and that change has fixed a few things. 

In master, see:
https://git.gnome.org/browse/vala/tree/vapi/gtk+-3.0.vapi#n4989
Comment 2 Al Thomas 2017-12-13 13:18:45 UTC
Created attachment 365488 [details] [review]
gtk+-3.0: Mark MessageDialog constructor parameter, message_format, as nullable

A patch in case this needs to be changed in Vala <0.40. This works with the old GIDL method of generating the VAPI.
Comment 3 Philipp Wolfer 2017-12-13 14:17:09 UTC
Thanks a lot for the quick response and glad to see this fixed already.

Could make sense to apply your patch in <0.40 series depending on how you plan to do releases before 0.40, as this is probably a minor regression, as code built with message_format = null in Vala <= 0.38.4.
Comment 4 Al Thomas 2017-12-13 16:17:17 UTC
Created attachment 365497 [details] [review]
gtk+-3.0: Mark MessageDialog constructor parameter, message_format, as nullable

For Vala <0.40. Changes lt-vapigen to vapigen in VAPI comment from last patch
Comment 5 Al Thomas 2017-12-13 16:18:22 UTC
Created attachment 365498 [details] [review]
gtk+-2.0: Mark MessageDialog constructor parameter, message_format, as nullable

Patch for GTK+ 2 to apply to master
Comment 6 Rico Tzschichholz 2017-12-13 19:47:10 UTC
Attachment 365497 [details] pushed as 1e8be5b - gtk+-3.0: Mark MessageDialog constructor parameter, message_format, as nullable
Attachment 365498 [details] pushed as aa5b8ba - gtk+-2.0: Mark MessageDialog constructor parameter, message_format, as nullable