GNOME Bugzilla – Bug 791570
Gtk.MessageDialog should allow null for message_format
Last modified: 2017-12-13 19:47:18 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
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
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.
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.
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
Created attachment 365498 [details] [review] gtk+-2.0: Mark MessageDialog constructor parameter, message_format, as nullable Patch for GTK+ 2 to apply to master
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