-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathmain.vala
More file actions
28 lines (22 loc) · 770 Bytes
/
main.vala
File metadata and controls
28 lines (22 loc) · 770 Bytes
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
private Adw.Avatar avatar_image;
private Gtk.FileFilter file_filter;
public void main () {
avatar_image = (Adw.Avatar) workbench.builder.get_object ("avatar_image");
file_filter = new Gtk.FileFilter ();
file_filter.add_pixbuf_formats ();
var button = (Gtk.Button) workbench.builder.get_object ("button");
button.clicked.connect (select_image.begin);
}
private async void select_image () {
var file_dialog = new Gtk.FileDialog () {
title = "Select an Avatar",
modal = true,
default_filter = file_filter
};
try {
File file = yield file_dialog.open (workbench.window, null);
avatar_image.custom_image = Gdk.Texture.from_file (file);
} catch (Error e) {
critical (e.message);
}
}