Thread overview
Bizarre compile error in GtkD
Jun 29, 2014
Evan Davis
Jun 30, 2014
Chris
Jun 30, 2014
Mike Wey
Jun 30, 2014
Evan Davis
Jun 30, 2014
Jacob Carlborg
June 29, 2014
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
June 30, 2014
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)
June 30, 2014
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
June 30, 2014
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
June 30, 2014
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