GNOME Seed で FileChooserDialogを使う

GNOME Seed で FileChooserDialogを使う方法を調べた。
ソースコードは以下のとおり。

#! /usr/bin/env seed

const Gtk = imports.gi.Gtk;

Gtk.init (Seed.argv);
var filechooser_dialog = new Gtk.FileChooserDialog (
	{title : "FileChooser Dialog",
	 action : Gtk.FileChooserAction.OPEN});
filechooser_dialog.add_button (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL);
filechooser_dialog.add_button (Gtk.STOCK_OPEN, Gtk.ResponseType.ACCEPT);
if (filechooser_dialog.run () == Gtk.ResponseType.ACCEPT)
{
	print ("Open: " + filechooser_dialog.get_filename ());
}
filechooser_dialog.destroy ();

filechooser_dialog = new Gtk.FileChooserDialog (
	{title : "FileChooser Dialog",
	 action : Gtk.FileChooserAction.SAVE});
filechooser_dialog.add_button (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL);
filechooser_dialog.add_button (Gtk.STOCK_SAVE, Gtk.ResponseType.ACCEPT);
if (filechooser_dialog.run () == Gtk.ResponseType.ACCEPT)
{
	print ("Save: " + filechooser_dialog.get_filename ());
}
filechooser_dialog.destroy ();

title と action だけ JSON オブジェクトを引数にしてみた。JSON オブジェクトで指定できるのは、リファレンスの Properties を調べて欲しい。親オブジェクトのPropertiesもあるので大量に記述されているが、基本的には、gtk_file_chooser_dialog_new () の引数で指定できるものだけだと考えておけば良いと思う。

残念ながらボタンは可変引数なので、個別に追加する必要があるようだ。