bar.title = "app.nit" # TODO offer a portable API to name windows
bar.show_close_button = true
- # TODO add back button
+ bar.add back_button.native
return bar
end
return stack
end
+ # Button on the header bar to go back
+ var back_button = new BackButton is lazy
+
# On GNU/Linux, we go through all the callbacks once,
# there is no complex life-cycle.
redef fun run
app.on_start
app.on_resume
- native_window.show_all
gtk_main
app.on_pause
# improved with GTK 3.18 and interpolate_size.
native_window.resizable = false
+ native_window.show_all
+
super
+
+ if window.enable_back_button then
+ back_button.native.show
+ else back_button.native.hide
end
end
init do native.signal_connect("clicked", self, null)
end
+# Button to go back between windows
+class BackButton
+ super Button
+
+ # TODO i18n
+ redef fun text=(value) do super(value or else "Back")
+
+ redef fun signal(sender, data)
+ do
+ super
+
+ app.window.on_back_button
+ end
+end
+
redef class Label
redef type NATIVE: GtkLabel
redef var native = new GtkLabel("")