Open lscrd opened 4 years ago
Thanks for reporting.
grep -C8 "c:identifier=\"gtk_message_dialog_new\"" /usr/share/gir-1.0/Gtk-3.0.gir
The GtkMessageDialog implementation of the GtkBuildable interface exposes
the message area as an internal child with the name “message_area”.</doc>
<source-position filename="gtk+-3.24.16/gtk/gtkmessagedialog.h"
line="66"/>
<implements name="Atk.ImplementorIface"/>
<implements name="Buildable"/>
<constructor name="new"
c:identifier="gtk_message_dialog_new"
introspectable="0">
<doc xml:space="preserve"
filename="gtk+-3.24.16/gtk/gtkmessagedialog.c"
line="584">Creates a new message dialog, which is a simple dialog with some text
the user may want to see. When the user clicks a button a “response”
signal is emitted with response IDs from #GtkResponseType. See
#GtkDialog for more details.</doc>
<source-position filename="gtk+-3.24.16/gtk/gtkmessagedialog.h"
introspectable="0" indicates that this function is not provided by gobject-introspection. Generally this is the case for functions that are only needed in low level C code, or for functions that do not map well for other languages, i.e. with varargs arguments.
So we have to create that function manually. Generally we inspect API docs, try to find a C example and try to convert that to Nim. I did this for a few functions already, will investigate that case in the next few days.
Thanks for your answer and sorry for the duplicate: I should have checked that the problem had not already been reported :-(.
Now I understand the reason why the procedures are not provided. And, unfortunately, there is no GTK function to create a MessageDialog without the message (which is logic).
But, in fact, for most functions which accept a formatting string and parameters in printf style, there is no need for varargs. In Nim a simple string as last parameter would be sufficient. Nim proposes several ways to do the formatting (format procedure, “%” notation and fmt strings). And I even think that gintro should not provide an interface using the printf style with varargs.
But if, this way, it possible to simplify somewhat the problem, as you said the procedure has to be defined manually.
I looked at a way to build a message dialog using a Dialog. The layout is simple but newMessageDialog provides standard icons and standard buttons whereas newDialog lets us without guidelines. And we have no way to find the icon associated to a MessageType, no way to get the text of buttons associated to ButtonsType and no way to know the order to add them in the layout to conform to the UI manager guidelines.
So, if MessageDialog is indeed a convenience widget, I found it very useful to provide well formed basic dialogs which is not so easy to do manually.
All is ready for use of a message dialog except that the procedures to create a MessageDialog are missing. This is clearly an oversight as the procedures to create an AboutDialog are provided.
The first missing procedure is newMessageDialog and I think it will not cause any difficulties as the required types for the parameters are already available.
The second one is newMessageDialogWithMarkup. As a procedure setMarkup is provided, this one is not needed and, in fact, I’m not sure it can be easily defined (or maybe only in a limited form without the printf behavior).
For now, I have been able to define a procedure newMessageDialog by mimicking other procedures. It displays the message but, for some obscure reason, not the message type icon, so there is probably an error somewhere. Nevertheless, here is the code I have used: