¿Cómo empaquetar un botón en un HeaderBar usando Genie?
Antecedentes
Mi objetivo es mejorar un pequeño editor de texto como ejercicio. Está funcionando bien después de que se agregó HeaderBar, sin embargo, no puedo encontrar una manera de empaquetar botones en él.
Códigouses
Granite.Widgets
Gtk
init
Gtk.init (ref args)
var app = new Application ()
app.show_all ()
Gtk.main ()
// This class holds all the elements from the GUI
class Application : Gtk.Window
_view:Gtk.TextView
construct ()
// Prepare Gtk.Window:
this.window_position = Gtk.WindowPosition.CENTER
this.destroy.connect (Gtk.main_quit)
this.set_default_size (400, 400)
// Headerbar definition
headerbar:Gtk.HeaderBar = new Gtk.HeaderBar()
headerbar.show_close_button = true
headerbar.set_title("My text editor")
// Headerbar buttons
var open_button = new ToolButton.from_stock(Stock.Open)
// Add everything to the toolbar
open_button.pack_start ()
show_all ()
this.set_titlebar(headerbar)
// Box:
box:Gtk.Box = new Gtk.Box (Gtk.Orientation.VERTICAL, 1)
this.add (box)
// A ScrolledWindow:
scrolled:Gtk.ScrolledWindow = new Gtk.ScrolledWindow (null, null)
box.pack_start (scrolled, true, true, 0)
// The TextView:
_view = new Gtk.TextView ()
_view.set_wrap_mode (Gtk.WrapMode.WORD)
_view.buffer.text = "Lorem Ipsum"
scrolled.add (_view)
// A Button:
button:Gtk.Button = new Gtk.Button.with_label ("Print content to
stdout")
box.pack_start (button, false, true, 0)
button.clicked.connect (clicked)
// This is a simple stub function to take care of the click
def clicked ()
stdout.puts (_view.buffer.text)
stdout.putc ('\n')
ErrorCuando se usa pack_start (ver más abajo), aparece el error:
text_editor-exercise_7_1.gs:136.3-136.39: error: Access to instance member `Gtk.HeaderBar.pack_start' denied
Se producen errores similares cuando uso HeaderBar.pack_start o button_name.pack_start.
Pregunta¿Me equivoco al creer que pack_start debería usarse con HeaderBars?Un segundo problema menor es el uso de los iconos de archivo. Por alguna razón no puedo acceder a Stock.Open.
Finalmente, ¿hay alguna otra fuente de información en HeaderBar? Valadoc es escaso en este tema (no hay ejemplos ni plantillas).