Class: ManabuDesktop::Screens::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/screens/base.rb

Direct Known Subclasses

Login, MainMenu, Roster, Student::Registration, ToolBox

Constant Summary collapse

@@gtk_initialized =
false
@@gtk_main_quit_set =
false

Instance Attribute Summary collapse

Instance Method Summary collapse

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 |_widget|
      #@window.destroy()
      ManabuDesktop::Windows.destroy_all()
      Gtk.main_quit()
    end
    @@gtk_main_quit_set = true
  end
end

Instance Attribute Details

#builderObject

Returns the value of attribute builder.



8
9
10
# File 'lib/screens/base.rb', line 8

def builder
  @builder
end

#windowObject

Returns the value of attribute window.



8
9
10
# File 'lib/screens/base.rb', line 8

def window
  @window
end

Instance Method Details

#_showObject



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