I am trying to add a dialog to a small application with genie. It is an openfile dialog that should open upon clicking in a headerbar button.
Examples are lacking in Genie, so I am now trying to adapt something from vala. However, all examples that I found used a switch command that I am not being able to translate to Genie.
This is the vala code:
public void on_open_image (Button self) {
var filter = new FileFilter ();
var dialog = new FileChooserDialog ("Open image",
window,
FileChooserAction.OPEN,
Stock.OK, ResponseType.ACCEPT,
Stock.CANCEL, ResponseType.CANCEL);
filter.add_pixbuf_formats ();
dialog.add_filter (filter);
switch (dialog.run ())
{
case ResponseType.ACCEPT:
var filename = dialog.get_filename ();
image.set_from_file (filename);
break;
default:
break;
}
dialog.destroy ();
}
And this is what I worked out from the previous code:
def openfile (self:Button)
var dialog = new FileChooserDialog ("Open file",
window,
FileChooserAction.OPEN,
Stock.OK, ResponseType.ACCEPT,
Stock.CANCEL, ResponseType.CANCEL)
switch (dialog.run ())
case ResponseType.ACCEPT
var filename
filename = dialog.get_filename ()
image.set_from_file (filename)
break
default
break
dialog.destroy ()
It obviously throws an error at the case statement. How to use switch in Genie?