lib/screens/base.rb in manabu-desktop-0.0.2 vs lib/screens/base.rb in manabu-desktop-0.0.3

- old
+ new

@@ -1,13 +1,17 @@ require_relative '../tools' +require_relative '../windows' require 'gtk3' module ManabuDesktop module Screens class Base attr_accessor :window, :builder + @@gtk_initialized = false + @@gtk_main_quit_set = false + def initialize(layout, locale = :c) @builder = Gtk::Builder.new() @builder.add_from_file("#{__dir__}/../../layouts/#{layout}.glade") @builder.connect_signals do |handler| @@ -17,19 +21,27 @@ puts "#{handler} not yet implemented!" method('not_yet_implemented') end end - @window = builder.get_object("#{layout}.window") - @window.signal_connect('delete-event') do |_widget| - @window.destroy() - Gtk.main_quit() + @window = builder.get_object("#{layout}.Window") + @window.set_title(I18n.t("#{layout}.title")) + unless @@gtk_main_quit_set + @window.signal_connect('delete-event') do |_widget| + #@window.destroy() + ManabuDesktop::Windows.destroy_all() + Gtk.main_quit() + end + @@gtk_main_quit_set = true end end def _show() @window.show() - Gtk.main() + unless @@gtk_initialized + Gtk.main() + @@gtk_initialized = true + end end end end end