Class: Smartdict::Gui::LangComboBox

Inherits:
Gtk::ComboBox
  • Object
show all
Extended by:
Forwardable
Includes:
Smartdict::Gui
Defined in:
lib/smartdict/gui/lang_combo_box.rb

Constant Summary

Constants included from Smartdict::Gui

LEFT_BOX_BUTTON_HEIGHT, VERSION

Instance Method Summary collapse

Methods included from Smartdict::Gui

#root_dir, #run

Constructor Details

#initialize(controller, active_lang_code, &on_change_block) ⇒ LangComboBox

Returns a new instance of LangComboBox.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/smartdict/gui/lang_combo_box.rb', line 7

def initialize(controller, active_lang_code, &on_change_block)
  super(true)
  @controller = controller
  @on_change_block = on_change_block

  config.lang_names.each {|name| append_text(name) }
  active_index = config.langs.index(active_lang_code)
  set_active(active_index)

  signal_connect("changed") do |comb_box|
    lang_code = config.langs[active]
    @on_change_block.call(lang_code)
  end

  set_size_request(100, LEFT_BOX_BUTTON_HEIGHT)
end