Gtk.Applicationis a class that handles many important aspects of a Gtk app like uniqueness and the ID you need to identify your app to the notifications server. If you want some more details about
Gtk.Application, check out Valadoc. For now, type the following in "Application.vala".
MyApp ()we set a couple of properties for our
Gtk.Applicationobject, namely our app's ID and flags. The naming scheme we used for our app's ID is called Reverse Domain Name Notation and will ensure that your app has a unique identifier. The first line inside the
activatemethod creates a new
main_window. The fourth line sets the window title that you see at the top of the window. We also must give our window a default size so that it does not appear too small for the user to interact with it. Then in our
main ()method we create a new instance of our
Gtk.Applicationand run it.
Gtk.Buttonwith the label "Click me!"
Gtk.ApplicationWindowand declare that we want to show all of the window's contents.
gitto track revisions in this folder
gitto push your code to GitHub.
valaccommand and the argument
--pkg gtk+-3.0? What we did there was make use of a "library". If you're not familiar with the idea of libraries, a library is a collection of methods that your program can use. So this argument tells
valacto include the GTK+ library (version 3.0) when compiling our app.
Gtk"Namespace" to declare that we want to use methods from GTK (specifically,
Gtk.Button.with_label). Notice that there is a hierarchy at play. If you want to explore that hierarchy in more detail, you can check out Valadoc.