이 GtkApplication에서는 현재 디렉터리의 그림파일을 보여줍니다.
그림 파일을 제대로 불러오지 않았다면, 그림에 "깨진 그림" 아이콘이 들어갑니다. 이 코드가 동작하려면 현재 디렉터리에
public class MyWindow : Gtk.ApplicationWindow {
internal MyWindow (MyApplication app) {
Object (application: app, title: "Welcome to GNOME");
var image = new Gtk.Image ();
image.set_from_file ("gnome-image.png");
this.add (image);
this.set_default_size (300, 300);
}
}
public class MyApplication : Gtk.Application {
protected override void activate () {
new MyWindow (this).show_all ();
}
internal MyApplication () {
Object (application_id: "org.example.MyApplication");
}
}
public int main (string[] args) {
return new MyApplication ().run (args);
}
이 예제는 다음 참고자료가 필요합니다:
GtkApplication
GtkApplicationWindow
GtkImage