www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Bizarre compile error in GtkD

reply "Evan Davis" <cptroot gmail.com> writes:
Hello, I have a compile error when trying to use GtkD 2.3.3. When 
I try to create a FileChooseDialog, I call

new FileChooserDialog("Save File",
                       
editor.drawingArea.getParent().getParentWindow(),
                       FileChooserAction.SAVE,
                       ["OK", "Cancel"],
                       [GtkResponseType.OK, 
GtkResponseType.CANCEL]);

When I do this, I get the error

Error: constructor gtk.FileChooserDialog.FileChooserDialog.this 
(GtkFileChooserDialog* gtkFileChooserDialog) is not callable 
using argument types (string, Window, GtkFileChooserAction, 
string[], GtkResponseType[])

To test why I was getting this error, because there should be 
another constructor with that signature. After commenting out the 
one value constructor, I get the error

Error: constructor gtk.FileChooserDialog.FileChooserDialog.this 
(string title, Window parent, GtkFileChooserAction action, 
string[] buttonsText, GtkResponseType[] responses) is not 
callable using argument types (string, Window, 
GtkFileChooserAction, string[], GtkResponseType[])

I have no idea how this error exists. Can anyone help me fix it?

-Evan Davis
Jun 29 2014
next sibling parent reply "Chris" <wendlec tcd.ie> writes:
On Sunday, 29 June 2014 at 20:28:23 UTC, Evan Davis wrote:
 Hello, I have a compile error when trying to use GtkD 2.3.3. 
 When I try to create a FileChooseDialog, I call

 new FileChooserDialog("Save File",
                       
 editor.drawingArea.getParent().getParentWindow(),
                       FileChooserAction.SAVE,
                       ["OK", "Cancel"],
                       [GtkResponseType.OK, 
 GtkResponseType.CANCEL]);

 When I do this, I get the error

 Error: constructor gtk.FileChooserDialog.FileChooserDialog.this 
 (GtkFileChooserDialog* gtkFileChooserDialog) is not callable 
 using argument types (string, Window, GtkFileChooserAction, 
 string[], GtkResponseType[])

 To test why I was getting this error, because there should be 
 another constructor with that signature. After commenting out 
 the one value constructor, I get the error

 Error: constructor gtk.FileChooserDialog.FileChooserDialog.this 
 (string title, Window parent, GtkFileChooserAction action, 
 string[] buttonsText, GtkResponseType[] responses) is not 
 callable using argument types (string, Window, 
 GtkFileChooserAction, string[], GtkResponseType[])

 I have no idea how this error exists. Can anyone help me fix it?

 -Evan Davis
That looks weird. The documentation says: this(GtkFileChooserDialog* gtkFileChooserDialog); Sets our main struct and passes it to the parent class this(string title, Window parent, FileChooserAction action, string[] buttonsText = null, ResponseType[] responses = null); Creates a new GtkFileChooserDialog. This function is analogous to gtk_dialog_new_with_buttons(). Since 2.4 Params: string title Title of the dialog, or NULL Window parent Transient parent of the dialog, or NULL FileChooserAction action Open or save mode for the dialog string[] buttonsText text to go in the buttons ResponseType[] responses response ID's for the buttons Throws: ConstructionException GTK+ fails to create the object. Dunno if it's the ResponseType vs GtkResponseType (http://api.gtkd.org/src/gtk/FileChooserDialog.html)
Jun 30 2014
parent reply Mike Wey <mike-wey example.com> writes:
On 06/30/2014 01:32 PM, Chris wrote:
 Dunno if it's the ResponseType vs GtkResponseType
ResponseType is an alias for GtkReponseType, so that isn't the problem. getParentWindow() returns an gdk.Window.Window while the FileChooserDialog constructor expects an gtk.Window.Window. you probably want to use: cast(gtk.Window.Window)(editor.drawingArea.getToplevel()) if you don't have access to the variable holding your main window. -- Mike Wey
Jun 30 2014
parent "Evan Davis" <cptroot gmail.com> writes:
On Monday, 30 June 2014 at 18:42:17 UTC, Mike Wey wrote:
 On 06/30/2014 01:32 PM, Chris wrote:
 Dunno if it's the ResponseType vs GtkResponseType
ResponseType is an alias for GtkReponseType, so that isn't the problem. getParentWindow() returns an gdk.Window.Window while the FileChooserDialog constructor expects an gtk.Window.Window.
Gotcha. I completely forgot to check that because the compiler wasn't disambiguating. Thanks for the reply, worked like a charm. -Evan Davis
Jun 30 2014
prev sibling parent Jacob Carlborg <doob me.com> writes:
On 2014-06-29 22:28, Evan Davis wrote:

 I have no idea how this error exists. Can anyone help me fix it?
Perhaps some mismatch between mutable/const/immutable? -- /Jacob Carlborg
Jun 30 2014