1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
<?xml version="1.0" encoding="utf-8"?>
<page xmlns="http://projectmallard.org/1.0/" type="guide" style="task" id="toolbar.js" xml:lang="es">
<info>
<link type="guide" xref="beginner.js#menu-combo-toolbar"/>
<revision version="0.1" date="2012-02-20" status="stub"/>
<credit type="author copyright">
<name>Susanna Huhtanen</name>
<email>ihmis.suski@gmail.com</email>
<years>2012</years>
</credit>
<desc>Un widget de barra de herramientas conectado a un widget de diálogo</desc>
</info>
<title>Widget de barra de herramientas</title>
<media type="image" mime="image/png" src="media/toolbar.png"/>
<p>La barra de herramientas es un widget que puede contener texto e iconos del almacén. En este ejemplo se usan iconos del almacén.</p>
<code mime="text/javascript" style="numbered"><![CDATA[
#!/usr/bin/gjs
Gtk = imports.gi.Gtk;
Gtk.init(null, 0);
myW = new Gtk.Window({type: Gtk.WindowType.TOPLEVEL, default_width: 200});
myW.title = "Toolbar";
myW.connect("destroy", function(){Gtk.main_quit()});
var grid = new Gtk.Grid({border_width:10});
myW.add(grid);
var toolbar = new Gtk.Toolbar();
toolbar.get_style_context().add_class(Gtk.STYLE_CLASS_PRIMARY_TOOLBAR);
toolbar.set_style(Gtk.ToolbarStyle.ICONS);
var buttonOpen = new Gtk.ToolButton.new_from_stock(Gtk.STOCK_OPEN);
toolbar.set_hexpand(true);
buttonOpen.connect("clicked", function() {
var dialog = new Gtk.Dialog({title:"Dialog", deletable: true});
dialog.add_button(Gtk.STOCK_OK, -7);
dialog.show_all();
dialog.run();
dialog.destroy();
});
toolbar.insert(buttonOpen, 0)
grid.attach(toolbar,1,1,1,1);
myW.show_all();
Gtk.main();]]></code>
<p>En este ejemplo se usan los siguientes widgets: <link href="http://www.roojs.com/seed/gir-1.2-gtk-3.0/gjs/Gtk.Window.html">Gtk.Window</link>, <link href="http://www.roojs.com/seed/gir-1.2-gtk-3.0/gjs/Gtk.Grid.html">Gtk.Grid</link>, <link href="http://www.roojs.com/seed/gir-1.2-gtk-3.0/gjs/Gtk.Toolbar.html">Gtk.Toolbar</link>, <link href="http://www.roojs.com/seed/gir-1.2-gtk-3.0/gjs/Gtk.ToolButton.html">Gtk.ToolButton</link>, <link href="http://www.roojs.com/seed/gir-1.2-gtk-3.0/gjs/Gtk.Dialog.html">Gtk.Dialog</link>.</p>
</page>
|