# GMenu (Vala)

Ryan Lortie
desrt@desrt.ca 2012
Tiffany Antopolski
tiffany.antopolski@gmail.com
Una implementación sencilla del GMenuModel
Nicolás Satragno
nsatragno@gmail.com 2012 - 2013
Daniel Mustieles
daniel.mustieles@gmail.com 2011-2013
Jorge González
jorgegonz@svn.gnome.org 2011

# GMenu

Necesita ejecutar GTK+-3.4 o superior para que funcione

Este programa no compilará con la opción de «salir» conectada hasta que se resuelva el error nº 674090. Por lo tanto, esa línea se ha comentado

Una GtkApplication con un GMenu sencillo y SimpleActions

/* A window in the application. */ public class Window : Gtk.ApplicationWindow {

/* Constructor */ public Window (Application app) { Object (application: app, title: "Gmenu Example");

var about_action = new SimpleAction ("about", null);

/* Connect the 'activate' signal to the * signal handler (aka. callback). */ about_action.activate.connect (this.about_cb);

/* Add the action to this window. */ this.add_action (about_action);

this.show (); }

/* Signal handler for 'activate' signal of the SimpleAction. */ void about_cb (SimpleAction simple, Variant? parameter) { print ("This does nothing. It is only a demonstration.\n"); } }

/* This is the Application. */ public class Application : Gtk.Application {

/* Constructor */ public Application () { Object (application_id: "org.example.application"); }

/* Override the 'activate' signal of GLib.Application. */ protected override void activate () {

/* Create a new window for this application. */ new Window (this); }

/* Override the 'startup' signal of GLib.Application. */ protected override void startup () { base.startup ();

var menu = new Menu (); menu.append ("About", "win.about"); menu.append ("Quit", "app.quit"); this.app_menu = menu;

var quit_action = new SimpleAction ("quit", null); //quit_action.activate.connect (this.quit); this.add_action (quit_action); } }

/* main function creates Application and runs it. */ int main (string[] args) { return new Application ().run (args); }

En este ejemplo se usa lo siguiente:

Gtk.Application

Gtk.ApplicationWindow

Menu

append

SimpleAction

add_action