[gnome-devel-docs] MenuButton Vala example
- From: Tiffany Antopolski <antopolski src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-devel-docs] MenuButton Vala example
- Date: Wed, 1 Aug 2012 11:11:18 +0000 (UTC)
commit 0129ca29e58bdd9ec2a79c64f2d230c32464da7f
Author: Tiffany Antopolski <tiffany antopolski gmail com>
Date: Wed Aug 1 13:10:58 2012 +0200
MenuButton Vala example
platform-demos/C/menubutton.vala.page | 33 +++++++++++++++++++++
platform-demos/C/samples/menubutton.vala | 46 ++++++++++++++++++++++++++++++
platform-demos/Makefile.am | 2 +
3 files changed, 81 insertions(+), 0 deletions(-)
---
diff --git a/platform-demos/C/menubutton.vala.page b/platform-demos/C/menubutton.vala.page
new file mode 100644
index 0000000..886d1a7
--- /dev/null
+++ b/platform-demos/C/menubutton.vala.page
@@ -0,0 +1,33 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<page xmlns="http://projectmallard.org/1.0/"
+ xmlns:xi="http://www.w3.org/2001/XInclude"
+ type="guide" style="task"
+ id="menubutton.vala">
+ <info>
+ <link type="guide" xref="beginner.vala#buttons"/>
+ <revision version="0.1" date="2012-07-18" status="draft"/>
+
+ <credit type="author copyright">
+ <name>Tiffany Antopolski</name>
+ <email>tiffany antopolski gmail com</email>
+ <years>2012</years>
+ </credit>
+
+ <desc>A widget that shows a menu when clicked on</desc>
+ </info>
+
+ <title>MenuButton</title>
+ <media type="image" mime="image/png" src="media/menubutton.png"/>
+ <p>The GtkMenuButton widget is used to display a menu when clicked on. This menu can be provided either as a GtkMenu, or an abstract GMenuModel.
+
+The GtkMenuButton widget can hold any valid child widget. That is, it can hold almost any other standard GtkWidget. The most commonly used child is the provided GtkArrow.</p>
+
+<note><p>You need to be running GNOME 3.6 for the MenuButton to work.</p></note>
+<code mime="text/x-vala" style="numbered"><xi:include href="samples/menubutton.vala" parse="text"><xi:fallback/></xi:include></code>
+<p>
+ In this sample we used the following:
+</p>
+<list>
+ <item><p><link href="http://developer.gnome.org/gtk3/3.5/gtk3-GtkMenuButton.html">MenuButton</link></p></item>
+</list>
+</page>
diff --git a/platform-demos/C/samples/menubutton.vala b/platform-demos/C/samples/menubutton.vala
new file mode 100644
index 0000000..5a25ebd
--- /dev/null
+++ b/platform-demos/C/samples/menubutton.vala
@@ -0,0 +1,46 @@
+public class MyWindow : Gtk.ApplicationWindow {
+
+ internal MyWindow (MyApplication app) {
+ Object (application: app, title: "MenuButton Example");
+ this.set_default_size (600, 400);
+ var grid = new Gtk.Grid ();
+
+ var menubutton = new Gtk.MenuButton();
+ menubutton.set_size_request(80, 35);
+
+ var menumodel = new Menu ();
+ menumodel.append ("New", "app.new");
+ var menu = new Gtk.Menu.from_model (menumodel);
+ menubutton.set_menu (menu);
+
+ this.add(grid);
+ grid.attach(menubutton, 0, 0, 1, 1);
+ }
+}
+
+public class MyApplication : Gtk.Application {
+ protected override void activate () {
+ new MyWindow (this).show_all ();
+ }
+
+ internal MyApplication () {
+ Object (application_id: "org.example.MyApplication");
+
+ }
+
+ /* Override the 'startup' signal of GLib.Application. */
+ protected override void startup () {
+ base.startup ();
+ var new_action = new SimpleAction ("new", null);
+ new_action.activate.connect (this.new_cb);
+ this.add_action (new_action);
+}
+
+ void new_cb (SimpleAction simple, Variant? parameter) {
+ print ("You clicked \"New\"\n");
+ }
+}
+
+public int main (string[] args) {
+ return new MyApplication ().run (args);
+}
diff --git a/platform-demos/Makefile.am b/platform-demos/Makefile.am
index d2ae4c2..5882c0a 100644
--- a/platform-demos/Makefile.am
+++ b/platform-demos/Makefile.am
@@ -77,6 +77,7 @@ demo_sources = \
samples/linkbutton.py \
samples/linkbutton.vala \
samples/menubutton.js \
+ samples/menubutton.vala \
samples/menubar.vala \
samples/menubar.ui \
samples/menubar_basis.vala \
@@ -297,6 +298,7 @@ DOC_PAGES = \
magic-mirror.vala.page \
menubar.vala.page \
menubutton.js.page \
+ menubutton.vala.page \
message-board.c.page \
messagedialog.js.page \
messagedialog.py.page \
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]