chapter 2 finished
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
// helloGUIWorld.vala
|
||||
int main (string[] args) {
|
||||
Gtk.init (ref args);
|
||||
|
||||
var window = new Gtk.Window ();
|
||||
window.title = "Hello UI World";
|
||||
window.border_width = 10;
|
||||
window.window_position = Gtk.WindowPosition.CENTER;
|
||||
window.set_default_size (400, 150);
|
||||
window.destroy.connect (Gtk.main_quit);
|
||||
|
||||
var button = new Gtk.Button.with_label ("Click me!");
|
||||
button.clicked.connect ( () => {
|
||||
button.label = "Thank you!";
|
||||
});
|
||||
|
||||
window.add (button);
|
||||
window.show_all ();
|
||||
|
||||
Gtk.main ();
|
||||
return 0;
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
// helloObjectWorld.vala
|
||||
|
||||
class HelloWorld {
|
||||
private string? name;
|
||||
private string name;
|
||||
|
||||
public HelloWorld (string name) {
|
||||
public HelloWorld (string? name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// helloObjectWorld.vala
|
||||
|
||||
class HelloWorld {
|
||||
private string name;
|
||||
|
||||
public HelloWorld (string? name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void greet () {
|
||||
var fullGreeting = "Hello " + this.name + "!\n";
|
||||
stdout.printf (fullGreeting);
|
||||
}
|
||||
}
|
||||
|
||||
int main (string[] args) {
|
||||
if ( args.length < 2 ) {
|
||||
stderr.printf ("Usage: %s <name>\n", args[0]);
|
||||
return -1;
|
||||
}
|
||||
HelloWorld helloWorldObject = new HelloWorld (args [1]);
|
||||
helloWorldObject.greet();
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// helloObjectWorld.vala
|
||||
|
||||
class HelloWorld {
|
||||
private string name;
|
||||
|
||||
public HelloWorld (string? name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void greet () {
|
||||
var fullGreeting = "Hello " + this.name + "!\n";
|
||||
stdout.printf (fullGreeting);
|
||||
}
|
||||
}
|
||||
|
||||
int main (string[] args) {
|
||||
if ( args.length < 2 ) {
|
||||
stderr.printf ("Usage: %s <name>\n", args[0]);
|
||||
return -1;
|
||||
}
|
||||
HelloWorld helloWorldObject = new HelloWorld (args [1]);
|
||||
helloWorldObject.greet();
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user