forked from gerito1/vala-gtk-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
filechooserbutton.vala
38 lines (30 loc) · 920 Bytes
/
filechooserbutton.vala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
* The FileChooserButton provides a Button-like widget used for the selection
* of files and/or folders from the file system.
*/
using Gtk;
public class Example : Window
{
public Example()
{
this.title = "FileChooserButton";
this.set_default_size(200, -1);
this.destroy.connect(Gtk.main_quit);
var filechooserbutton = new Gtk.FileChooserButton("Select File", Gtk.FileChooserAction.OPEN);
filechooserbutton.file_set.connect(on_file_set);
this.add(filechooserbutton);
}
private void on_file_set(FileChooserButton filechooserbutton)
{
var filename = filechooserbutton.get_filename();
stdout.printf("Selected filename: %s\n", filename);
}
public static int main(string[] args)
{
Gtk.init(ref args);
var window = new Example();
window.show_all();
Gtk.main();
return 0;
}
}