[gnome-devel-docs] samples vala: A GtkApplication using GMenu.
- From: Tiffany Antopolski <antopolski src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-devel-docs] samples vala: A GtkApplication using GMenu.
- Date: Sun, 22 Apr 2012 02:25:34 +0000 (UTC)
commit 837208b196fdefa3a7108cb745b6c3ab4fd64e91
Author: Tiffany Antopolski <tiffany antopolski gmail com>
Date: Sat Apr 21 22:24:49 2012 -0400
samples vala: A GtkApplication using GMenu.
platform-demos/C/samples/menu.vala | 48 ++++++++++++++++++++++++++++++++++++
1 files changed, 48 insertions(+), 0 deletions(-)
---
diff --git a/platform-demos/C/samples/menu.vala b/platform-demos/C/samples/menu.vala
new file mode 100644
index 0000000..7c98fc5
--- /dev/null
+++ b/platform-demos/C/samples/menu.vala
@@ -0,0 +1,48 @@
+public class MyWindow : Gtk.ApplicationWindow {
+ void reverse_label (Gtk.Button button) {
+ button.label = button.label.reverse ();
+ }
+
+ internal MyWindow (MyApplication app) {
+ Object (application: app, title: "My Application");
+
+ var button = new Gtk.Button.with_label ("Click me!");
+ button.clicked.connect (reverse_label);
+ this.add (button);
+ button.show ();
+ }
+}
+
+public class MyApplication : Gtk.Application {
+ protected override void activate () {
+ new_window ();
+ }
+
+ void new_window () {
+ new MyWindow (this).show ();
+ }
+
+ const ActionEntry[] action_entries = {
+ { "new", new_window },
+ { "quit", quit }
+ };
+
+ internal MyApplication () {
+ Object (application_id: "org.example.MyApplication");
+ }
+
+ protected override void startup () {
+ base.startup ();
+
+ this.add_action_entries (action_entries, this);
+
+ var menu = new Menu ();
+ menu.append ("New", "app.new");
+ menu.append ("Quit", "app.quit");
+ this.app_menu = menu;
+ }
+}
+
+public int main (string[] args) {
+ return new MyApplication ().run (args);
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]