|
Packit |
1470ea |
|
|
Packit |
1470ea |
<page xmlns="http://projectmallard.org/1.0/" xmlns:its="http://www.w3.org/2005/11/its" xmlns:xi="http://www.w3.org/2001/XInclude" type="guide" style="task" id="statusbar.js" xml:lang="es">
|
|
Packit |
1470ea |
<info>
|
|
Packit |
1470ea |
<title type="text">Statusbar (JavaScript)</title>
|
|
Packit |
1470ea |
<link type="guide" xref="beginner.js#display-widgets"/>
|
|
Packit |
1470ea |
<revision version="0.1" date="2012-06-10" status="draft"/>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<credit type="author copyright">
|
|
Packit |
1470ea |
<name>Taryn Fox</name>
|
|
Packit |
1470ea |
<email its:translate="no">jewelfox@fursona.net</email>
|
|
Packit |
1470ea |
<years>2012</years>
|
|
Packit |
1470ea |
</credit>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<desc>Mostrar notificaciones en una barra de estado dedicada</desc>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
|
|
Packit |
1470ea |
<mal:name>Daniel Mustieles</mal:name>
|
|
Packit |
1470ea |
<mal:email>daniel.mustieles@gmail.com</mal:email>
|
|
Packit |
1470ea |
<mal:years>2011 - 2017</mal:years>
|
|
Packit |
1470ea |
</mal:credit>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
|
|
Packit |
1470ea |
<mal:name>Nicolás Satragno</mal:name>
|
|
Packit |
1470ea |
<mal:email>nsatragno@gmail.com</mal:email>
|
|
Packit |
1470ea |
<mal:years>2012 - 2013</mal:years>
|
|
Packit |
1470ea |
</mal:credit>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<mal:credit xmlns:mal="http://projectmallard.org/1.0/" type="translator copyright">
|
|
Packit |
1470ea |
<mal:name>Jorge González</mal:name>
|
|
Packit |
1470ea |
<mal:email>jorgegonz@svn.gnome.org</mal:email>
|
|
Packit |
1470ea |
<mal:years>2011</mal:years>
|
|
Packit |
1470ea |
</mal:credit>
|
|
Packit |
1470ea |
</info>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<title>Statusbar</title>
|
|
Packit |
1470ea |
<media type="image" mime="image/png" src="media/statusbar2.png"/>
|
|
Packit |
1470ea |
Esta barra de estado registra cuántas veces se pulsó un botón. Las aplicaciones como <link href="http://projects.gnome.org/gedit/">gedit</link> usan barras de estado para mostrar información a simple vista, y mostrar notificaciones sin interrumpir al usuario.
|
|
Packit |
1470ea |
Los mensajes que se muestran en una barra de estado van a la parte superior de su pila, y pueden extraerse para mostrar el siguiente más reciente. También puede limpiar todos los mensajes de un tipo específico de una vez. Esta aplicación de ejemplo demuestra estas funciones.
|
|
Packit |
1470ea |
<links type="section"/>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<section id="imports">
|
|
Packit |
1470ea |
<title>Bibliotecas que importar</title>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
#!/usr/bin/gjs
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
const Gio = imports.gi.Gio;
|
|
Packit |
1470ea |
const Gtk = imports.gi.Gtk;
|
|
Packit |
1470ea |
const Lang = imports.lang;
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
Estas son las bibliotecas que necesita importar para que esta aplicación se ejecute. Recuerde que la línea que le dice a GNOME que está usando Gjs siempre tiene que ir al principio.
|
|
Packit |
1470ea |
</section>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<section id="applicationwindow">
|
|
Packit |
1470ea |
<title>Crear la ventana de la aplicación</title>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
const StatusbarExample = new Lang.Class({
|
|
Packit |
1470ea |
Name: 'Statusbar Example',
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Create the application itself
|
|
Packit |
1470ea |
_init: function() {
|
|
Packit |
1470ea |
this.application = new Gtk.Application({
|
|
Packit |
1470ea |
application_id: 'org.example.jsstatusbar',
|
|
Packit |
1470ea |
flags: Gio.ApplicationFlags.FLAGS_NONE
|
|
Packit |
1470ea |
});
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Connect 'activate' and 'startup' signals to the callback functions
|
|
Packit |
1470ea |
this.application.connect('activate', Lang.bind(this, this._onActivate));
|
|
Packit |
1470ea |
this.application.connect('startup', Lang.bind(this, this._onStartup));
|
|
Packit |
1470ea |
},
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Callback function for 'activate' signal presents window when active
|
|
Packit |
1470ea |
_onActivate: function() {
|
|
Packit |
1470ea |
this._window.present();
|
|
Packit |
1470ea |
},
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Callback function for 'startup' signal builds the UI
|
|
Packit |
1470ea |
_onStartup: function() {
|
|
Packit |
1470ea |
this._buildUI ();
|
|
Packit |
1470ea |
},
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
Todo el código de este ejemplo va en la clase «StatusBarExample». El código anterior crea una <link href="http://www.roojs.com/seed/gir-1.2-gtk-3.0/gjs/Gtk.Application.html">Gtk.Application</link> para que vayan los widgets y la ventana.
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Build the application's UI
|
|
Packit |
1470ea |
_buildUI: function() {
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Create the application window
|
|
Packit |
1470ea |
this._window = new Gtk.ApplicationWindow({
|
|
Packit |
1470ea |
application: this.application,
|
|
Packit |
1470ea |
window_position: Gtk.WindowPosition.CENTER,
|
|
Packit |
1470ea |
default_height: 120,
|
|
Packit |
1470ea |
default_width: 300,
|
|
Packit |
1470ea |
title: "Button Clicker"});
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Create a paned interface
|
|
Packit |
1470ea |
this._panes = new Gtk.Paned ({
|
|
Packit |
1470ea |
orientation: Gtk.Orientation.VERTICAL });
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
La función «_buildUI» es donde se pone todo el código para crear la interfaz de usuario de la aplicación. El primer paso es crear una <link href="GtkApplicationWindow.js.page">Gtk.ApplicationWindow</link> nueva para poner dentro todos los widgets. El siguiente paso es crear una interfaz «Gtk.Paned» orientada verticalmente, para dividir la ventana en dos secciones. De esta manera la barra de estado se parece a aquellas usadas en otras aplicaciones, y permanece en la parte inferior de la ventana, incluso si el usuario la redimensiona.
|
|
Packit |
1470ea |
</section>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<section id="buttons">
|
|
Packit |
1470ea |
<title>Crear los botones</title>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Create the main button
|
|
Packit |
1470ea |
this._clickMe = new Gtk.Button ({
|
|
Packit |
1470ea |
label: "Click Me!" });
|
|
Packit |
1470ea |
this._clickMe.connect ("clicked", Lang.bind (this, this._clicked));
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Create the back button
|
|
Packit |
1470ea |
this._backButton = new Gtk.Button ({
|
|
Packit |
1470ea |
label: "gtk-go-back",
|
|
Packit |
1470ea |
use_stock: true });
|
|
Packit |
1470ea |
this._backButton.connect ("clicked", Lang.bind (this, this._back));
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Create the clear button
|
|
Packit |
1470ea |
this._clearButton = new Gtk.Button ({
|
|
Packit |
1470ea |
label: "gtk-clear",
|
|
Packit |
1470ea |
use_stock: true });
|
|
Packit |
1470ea |
this._clearButton.connect ("clicked", Lang.bind (this, this._clear));
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
Este código crea los tres <link href="button.js.page">Gtk.Buttons</link> que se usarán para empujar un mensaje nuevo a la barra de tareas, extraer el último, y limpiar todos los mensajes existentes. Los botones «back» y «clear» son <link href="https://developer.gnome.org/gtk3/3.4/gtk3-Stock-Items.html">botones del almacén</link>, que se traducen automáticamente a cualquier idioma que GNOME soporte.
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Put the buttons in a grid
|
|
Packit |
1470ea |
this._grid = new Gtk.Grid ({
|
|
Packit |
1470ea |
halign: Gtk.Align.CENTER,
|
|
Packit |
1470ea |
valign: Gtk.Align.CENTER });
|
|
Packit |
1470ea |
this._grid.attach (this._backButton, 0, 0, 1, 1);
|
|
Packit |
1470ea |
this._grid.attach_next_to (this._clickMe, this._backButton, Gtk.PositionType.RIGHT, 1, 1);
|
|
Packit |
1470ea |
this._grid.attach_next_to (this._clearButton, this._clickMe, Gtk.PositionType.RIGHT, 1, 1);
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Put the grid in a large frame that fills most of the window
|
|
Packit |
1470ea |
this._topFrame = new Gtk.Frame ({
|
|
Packit |
1470ea |
border_width: 20,
|
|
Packit |
1470ea |
height_request: 90,
|
|
Packit |
1470ea |
width_request: 300});
|
|
Packit |
1470ea |
this._topFrame.add (this._grid);
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
Este código crea la <link href="grid.js.page">Gtk.Grid</link> que se usará para organizar los botones, y le adjunta los botones en orden. Después crea un <link href="paned.js.page">Gtk.Frame</link> que ocupará la mayor parte de la ventana y que tiene bastante relleno alrededor de los botones, y añade la rejilla al cuadro. Tenga en cuenta que todavía se necesita poner el cuadro en la interfaz con paneles, y después añadirlo a la «ApplicationWindow».
|
|
Packit |
1470ea |
</section>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<section id="statusbar">
|
|
Packit |
1470ea |
<title>Crear la barra de estado</title>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Create the statusbar
|
|
Packit |
1470ea |
this._statusbar = new Gtk.Statusbar();
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Keep track of the number of times the button has been clicked
|
|
Packit |
1470ea |
this.Clicks = 0;
|
|
Packit |
1470ea |
this.ContextID = this._statusbar.get_context_id ("Number of Clicks");
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Give the statusbar an initial message
|
|
Packit |
1470ea |
this._statusbar.push (this.ContextID, "Number of clicks: " + this.Clicks);
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Put the statusbar in its own frame at the bottom
|
|
Packit |
1470ea |
this._barFrame = new Gtk.Frame ({
|
|
Packit |
1470ea |
height_request: 30 });
|
|
Packit |
1470ea |
this._barFrame.add (this._statusbar);
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
Aquí se crea la «Gtk.Statusbar», y se le empuja un mensaje para comenzar. Después se le da su propio cuadro estrecho en la parte inferior de la ventana.
|
|
Packit |
1470ea |
Cada mensaje necesita tener un ID de contexto, que es un valor entero que puede obtener de la barra de estado con la función «get_context_id()». Su único parámetro es el valor de la cadena que usa para describir ese ID de contexto particular. Normalmente, obtendría un ID de contexto nuevo para distintos tipos de mensajes, para que pueda usar la función «remove()» para eliminar un mensaje específico y no sólo el más reciente de la pila. Sin embargo, este es un ejemplo simple con sólo un tipo de mensaje, por lo que sólo se usa uno para todo.
|
|
Packit |
1470ea |
Se usa la función «push()» para empujar un mensaje nuevo a la pila. Su primer parámetro es el ID de contexto, y el segundo es el mensaje.
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Assemble the frames into the paned interface
|
|
Packit |
1470ea |
this._panes.pack1 (this._topFrame, true, false);
|
|
Packit |
1470ea |
this._panes.pack2 (this._barFrame, false, false);
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Put the panes into the window
|
|
Packit |
1470ea |
this._window.add (this._panes);
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Show the window and all child widgets
|
|
Packit |
1470ea |
this._window.show_all();
|
|
Packit |
1470ea |
},
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
Este código termina de crear la ventana, empaquetando los marcos en el panel, añadiéndolo a la ventana, y diciéndole a la ventana que muestre todos los widgets hijos.
|
|
Packit |
1470ea |
</section>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<section id="functions">
|
|
Packit |
1470ea |
<title>Funciones para interactuar con la barra de estado</title>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
_clicked: function() {
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Increment the number of clicks by 1
|
|
Packit |
1470ea |
this.Clicks++;
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Update the statusbar with the new number of clicks
|
|
Packit |
1470ea |
this._statusbar.push (this.ContextID, "Number of clicks: " + this.Clicks);
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
},
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
_back: function () {
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// If there have been any clicks, decrement by 1 and remove last statusbar update
|
|
Packit |
1470ea |
if (this.Clicks > 0 ) {
|
|
Packit |
1470ea |
this.Clicks--;
|
|
Packit |
1470ea |
this._statusbar.pop (this.ContextID);
|
|
Packit |
1470ea |
};
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
},
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
_clear: function () {
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Reset the number of clicks
|
|
Packit |
1470ea |
this.Clicks = 0;
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Wipe out all the messages pushed to the statusbar
|
|
Packit |
1470ea |
this._statusbar.remove_all (this.ContextID);
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Reset the statusbar's message
|
|
Packit |
1470ea |
this._statusbar.push (this.ContextID, "Number of clicks: " + this.Clicks);
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
});
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
Aquí están funciones que muestran cómo empujar un mensaje a la pila, extraer el que está arriba de todo, y limpiar todos los mensajes de un ID de contexto particular. La función «pop()» sólo toma un parámetro, que es el ID de contexto para el tipo de mensaje del que quiere extraer el más reciente. La función «remove_all()» funciona de la misma manera, excepto que elimina todos los mensajes de ese tipo de la pila.
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Run the application
|
|
Packit |
1470ea |
let app = new StatusbarExample ();
|
|
Packit |
1470ea |
app.application.run (ARGV);
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
Finalmente, se crea una instancia nueva de la clase «StatusbarExample» terminada, y se ejecuta la aplicación.
|
|
Packit |
1470ea |
</section>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<section id="complete">
|
|
Packit |
1470ea |
<title>Código de ejemplo completo</title>
|
|
Packit |
1470ea |
#!/usr/bin/gjs
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
imports.gi.versions.Gtk = '3.0';
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
const Gio = imports.gi.Gio;
|
|
Packit |
1470ea |
const Gtk = imports.gi.Gtk;
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
class StatusbarExample {
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Create the application itself
|
|
Packit |
1470ea |
constructor() {
|
|
Packit |
1470ea |
this.application = new Gtk.Application({
|
|
Packit |
1470ea |
application_id: 'org.example.jsstatusbar',
|
|
Packit |
1470ea |
flags: Gio.ApplicationFlags.FLAGS_NONE
|
|
Packit |
1470ea |
});
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Connect 'activate' and 'startup' signals to the callback functions
|
|
Packit |
1470ea |
this.application.connect('activate', this._onActivate.bind(this));
|
|
Packit |
1470ea |
this.application.connect('startup', this._onStartup.bind(this));
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Callback function for 'activate' signal presents window when active
|
|
Packit |
1470ea |
_onActivate() {
|
|
Packit |
1470ea |
this._window.present();
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Callback function for 'startup' signal builds the UI
|
|
Packit |
1470ea |
_onStartup() {
|
|
Packit |
1470ea |
this._buildUI();
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Build the application's UI
|
|
Packit |
1470ea |
_buildUI() {
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Create the application window
|
|
Packit |
1470ea |
this._window = new Gtk.ApplicationWindow({
|
|
Packit |
1470ea |
application: this.application,
|
|
Packit |
1470ea |
window_position: Gtk.WindowPosition.CENTER,
|
|
Packit |
1470ea |
default_height: 120,
|
|
Packit |
1470ea |
default_width: 300,
|
|
Packit |
1470ea |
title: "Button Clicker"});
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Create a paned interface
|
|
Packit |
1470ea |
this._panes = new Gtk.Paned ({
|
|
Packit |
1470ea |
orientation: Gtk.Orientation.VERTICAL });
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Create the main button
|
|
Packit |
1470ea |
this._clickMe = new Gtk.Button ({
|
|
Packit |
1470ea |
label: "Click Me!" });
|
|
Packit |
1470ea |
this._clickMe.connect ("clicked", this._clicked.bind(this));
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Create the back button
|
|
Packit |
1470ea |
this._backButton = new Gtk.Button ({
|
|
Packit |
1470ea |
label: "gtk-go-back",
|
|
Packit |
1470ea |
use_stock: true });
|
|
Packit |
1470ea |
this._backButton.connect ("clicked", this._back.bind(this));
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Create the clear button
|
|
Packit |
1470ea |
this._clearButton = new Gtk.Button ({
|
|
Packit |
1470ea |
label: "gtk-clear",
|
|
Packit |
1470ea |
use_stock: true });
|
|
Packit |
1470ea |
this._clearButton.connect ("clicked", this._clear.bind(this));
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Put the buttons in a grid
|
|
Packit |
1470ea |
this._grid = new Gtk.Grid ({
|
|
Packit |
1470ea |
halign: Gtk.Align.CENTER,
|
|
Packit |
1470ea |
valign: Gtk.Align.CENTER });
|
|
Packit |
1470ea |
this._grid.attach (this._backButton, 0, 0, 1, 1);
|
|
Packit |
1470ea |
this._grid.attach_next_to (this._clickMe, this._backButton, Gtk.PositionType.RIGHT, 1, 1);
|
|
Packit |
1470ea |
this._grid.attach_next_to (this._clearButton, this._clickMe, Gtk.PositionType.RIGHT, 1, 1);
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Put the grid in a large frame that fills most of the window
|
|
Packit |
1470ea |
this._topFrame = new Gtk.Frame ({
|
|
Packit |
1470ea |
border_width: 20,
|
|
Packit |
1470ea |
height_request: 90,
|
|
Packit |
1470ea |
width_request: 300});
|
|
Packit |
1470ea |
this._topFrame.add (this._grid);
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Create the statusbar
|
|
Packit |
1470ea |
this._statusbar = new Gtk.Statusbar();
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Keep track of the number of times the button has been clicked
|
|
Packit |
1470ea |
this.Clicks = 0;
|
|
Packit |
1470ea |
this.ContextID = this._statusbar.get_context_id ("Number of Clicks");
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Give the statusbar an initial message
|
|
Packit |
1470ea |
this._statusbar.push (this.ContextID, "Number of clicks: " + this.Clicks);
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Put the statusbar in its own frame at the bottom
|
|
Packit |
1470ea |
this._barFrame = new Gtk.Frame ({
|
|
Packit |
1470ea |
height_request: 30 });
|
|
Packit |
1470ea |
this._barFrame.add (this._statusbar);
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Assemble the frames into the paned interface
|
|
Packit |
1470ea |
this._panes.pack1 (this._topFrame, true, false);
|
|
Packit |
1470ea |
this._panes.pack2 (this._barFrame, false, false);
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Put the panes into the window
|
|
Packit |
1470ea |
this._window.add (this._panes);
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Show the window and all child widgets
|
|
Packit |
1470ea |
this._window.show_all();
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
_clicked() {
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Increment the number of clicks by 1
|
|
Packit |
1470ea |
this.Clicks++;
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Update the statusbar with the new number of clicks
|
|
Packit |
1470ea |
this._statusbar.push (this.ContextID, "Number of clicks: " + this.Clicks);
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
_back() {
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// If there have been any clicks, decrement by 1 and remove last statusbar update
|
|
Packit |
1470ea |
if (this.Clicks > 0 ) {
|
|
Packit |
1470ea |
this.Clicks--;
|
|
Packit |
1470ea |
this._statusbar.pop (this.ContextID);
|
|
Packit |
1470ea |
};
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
_clear() {
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Reset the number of clicks
|
|
Packit |
1470ea |
this.Clicks = 0;
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Wipe out all the messages pushed to the statusbar
|
|
Packit |
1470ea |
this._statusbar.remove_all (this.ContextID);
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Reset the statusbar's message
|
|
Packit |
1470ea |
this._statusbar.push (this.ContextID, "Number of clicks: " + this.Clicks);
|
|
Packit |
1470ea |
}
|
|
Packit |
1470ea |
};
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
// Run the application
|
|
Packit |
1470ea |
let app = new StatusbarExample ();
|
|
Packit |
1470ea |
app.application.run (ARGV);
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
</section>
|
|
Packit |
1470ea |
|
|
Packit |
1470ea |
<section id="in-depth">
|
|
Packit |
1470ea |
<title>Documentación en profundidad</title>
|
|
Packit |
1470ea |
<list>
|
|
Packit |
1470ea |
<item><link href="http://www.roojs.com/seed/gir-1.2-gtk-3.0/gjs/Gtk.Application.html">Gtk.Application</link> </item>
|
|
Packit |
1470ea |
<item><link href="http://developer.gnome.org/gtk3/stable/GtkApplicationWindow.html">Gtk.ApplicationWindow</link> </item>
|
|
Packit |
1470ea |
<item><link href="http://www.roojs.org/seed/gir-1.2-gtk-3.0/gjs/Gtk.Button.html">Gtk.Button</link> </item>
|
|
Packit |
1470ea |
<item><link href="http://www.roojs.org/seed/gir-1.2-gtk-3.0/gjs/Gtk.Frame.html">Gtk.Frame</link> </item>
|
|
Packit |
1470ea |
<item><link href="http://www.roojs.org/seed/gir-1.2-gtk-3.0/gjs/Gtk.Paned.html">Gtk.Paned</link> </item>
|
|
Packit |
1470ea |
<item><link href="http://www.roojs.org/seed/gir-1.2-gtk-3.0/gjs/Gtk.Statusbar.html">Gtk.Statusbar</link> </item>
|
|
Packit |
1470ea |
</list>
|
|
Packit |
1470ea |
</section>
|
|
Packit |
1470ea |
</page>
|