[gnome-devel-docs] tutorials: hello-world-vala example (new way and old way)
- From: Tiffany Antopolski <antopolski src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-devel-docs] tutorials: hello-world-vala example (new way and old way)
- Date: Sun, 8 Apr 2012 01:56:49 +0000 (UTC)
commit 2fe36b701e5a099a85acd7cf7ba5be46da9cf3fa
Author: Tiffany Antopolski <tiffany antopolski gmail com>
Date: Sat Apr 7 21:49:26 2012 -0400
tutorials: hello-world-vala example (new way and old way)
platform-demos/C/hello-world-vala/hello-world.vala | 21 ++++++++++
platform-demos/C/hello-world-vala/newway-menus.ui | 22 ++++++++++
platform-demos/C/hello-world-vala/newway.vala | 41 ++++++++++++++++++++
3 files changed, 84 insertions(+), 0 deletions(-)
---
diff --git a/platform-demos/C/hello-world-vala/hello-world.vala b/platform-demos/C/hello-world-vala/hello-world.vala
new file mode 100644
index 0000000..501f093
--- /dev/null
+++ b/platform-demos/C/hello-world-vala/hello-world.vala
@@ -0,0 +1,21 @@
+//to compile: valac hello-world.vala --pkg gtk+-3.0
+//to run: ./hello-world
+
+class HelloWorld : Gtk.Application {
+
+ /* constructor */
+ public HelloWorld () {
+ Object (application_id: "org.gnome.HelloWorld");
+ }
+
+ protected override void activate () {
+ var window = new Gtk.ApplicationWindow (this);
+ window.add (new Gtk.Label ("Hello world!\n"));
+ window.show_all ();
+ }
+}
+
+int main (string[] args) {
+ var app = new HelloWorld ();
+ return app.run ();
+}
diff --git a/platform-demos/C/hello-world-vala/newway-menus.ui b/platform-demos/C/hello-world-vala/newway-menus.ui
new file mode 100644
index 0000000..1404683
--- /dev/null
+++ b/platform-demos/C/hello-world-vala/newway-menus.ui
@@ -0,0 +1,22 @@
+<interface>
+ <menu id='app-menu'>
+ <section>
+ <item>
+ <attribute name='label' translatable="yes">_New</attribute>
+ <attribute name='action'>app.new</attribute>
+ </item>
+ </section>
+ <section>
+ <item>
+ <attribute name='label' translatable="yes">_Left</attribute>
+ <attribute name='action'>app.move</attribute>
+ <attribute name='target'>left</attribute>
+ </item>
+ <item>
+ <attribute name='label' translatable="yes">_Right</attribute>
+ <attribute name='action'>app.move</attribute>
+ <attribute name='target'>right</attribute>
+ </item>
+ </section>
+ </menu>
+</interface>
diff --git a/platform-demos/C/hello-world-vala/newway.vala b/platform-demos/C/hello-world-vala/newway.vala
new file mode 100644
index 0000000..60c3f97
--- /dev/null
+++ b/platform-demos/C/hello-world-vala/newway.vala
@@ -0,0 +1,41 @@
+//to compile: valac newway.vala --pkg gtk+-3.0
+//to run: ./newway
+
+class MyApplication : Gtk.Application {
+ protected override void activate () {
+ var window = new Gtk.ApplicationWindow (this);
+ window.add (new Gtk.Label ("Hello world!\n"));
+ window.show_all ();
+ }
+
+ void do_new () {
+ activate ();
+ }
+
+ void do_move (SimpleAction action, Variant? parameter) {
+ print ("moved: %s\n", (string) parameter);
+ }
+
+ const ActionEntry[] actions = {
+ { "new", do_new },
+ { "move", do_move, "s" }
+ };
+
+ protected override void startup () {
+ base.startup ();
+ add_action_entries (actions, this);
+
+ var builder = new Gtk.Builder ();
+ builder.add_from_file ("newway-menus.ui");
+ app_menu = builder.get_object ("app-menu") as MenuModel;
+ }
+
+ public MyApplication () {
+ Object (application_id: "org.gnome.HelloWorld");
+ }
+}
+
+int main (string[] args) {
+ var app = new MyApplication ();
+ return app.run ();
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]