Class: ManabuDesktop::Screens::Base
- Inherits:
-
Object
- Object
- ManabuDesktop::Screens::Base
- Defined in:
- lib/screens/base.rb
Direct Known Subclasses
Constant Summary collapse
- @@gtk_initialized =
false
- @@gtk_main_quit_set =
false
Instance Attribute Summary collapse
-
#builder ⇒ Object
Returns the value of attribute builder.
-
#window ⇒ Object
Returns the value of attribute window.
Instance Method Summary collapse
- #_show ⇒ Object
-
#initialize(layout, locale = :c, opts = {}) ⇒ Base
constructor
opts: icon_path: path to an icon image for the window icon.
Constructor Details
#initialize(layout, locale = :c, opts = {}) ⇒ Base
opts:
icon_path: path to an icon image for the window icon
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 |
# File 'lib/screens/base.rb', line 15 def initialize(layout, locale = :c, opts = {}) @builder = Gtk::Builder.new() @builder.add_from_file("#{__dir__}/../../layouts/#{layout}.glade") @builder.connect_signals do |handler| begin method(handler) rescue puts "#{handler} not yet implemented!" method('not_yet_implemented') end end @window = builder.get_object("#{layout}.Window") @window.set_title(I18n.t("#{layout}.title")) if opts.include? :icon_path begin @window.set_icon(opts[:icon_path]) rescue @window.set_icon("#{__dir__}/../../layouts/img/gaku-logo-128.png") end else @window.set_icon("#{__dir__}/../../layouts/img/gaku-logo-128.png") end unless @@gtk_main_quit_set @window.signal_connect('delete-event') do || #@window.destroy() ManabuDesktop::Windows.destroy_all() Gtk.main_quit() end @@gtk_main_quit_set = true end end |
Instance Attribute Details
#builder ⇒ Object
Returns the value of attribute builder.
8 9 10 |
# File 'lib/screens/base.rb', line 8 def builder @builder end |
#window ⇒ Object
Returns the value of attribute window.
8 9 10 |
# File 'lib/screens/base.rb', line 8 def window @window end |
Instance Method Details
#_show ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/screens/base.rb', line 49 def _show() @window.show() unless @@gtk_initialized Gtk.main() @@gtk_initialized = true end end |