Class: Smartdict::Gui::MainWindow
- Inherits:
-
Gtk::Window
- Object
- Gtk::Window
- Smartdict::Gui::MainWindow
- Extended by:
- Forwardable
- Defined in:
- lib/smartdict/gui/main_window.rb
Instance Method Summary collapse
- #draw_window ⇒ Object
- #hide_visibility ⇒ Object
-
#initialize(controller) ⇒ MainWindow
constructor
A new instance of MainWindow.
- #show_visibility ⇒ Object
- #toggle_visibility ⇒ Object
Constructor Details
#initialize(controller) ⇒ MainWindow
Returns a new instance of MainWindow.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/smartdict/gui/main_window.rb', line 8 def initialize(controller) super("Smartdict") @controller = controller signal_connect("delete_event") { @controller.hide_visibility } signal_connect("destroy") { @controller.quit } signal_connect("focus_in_event") { @controller.focus_word_entry } set_default_size(720, 450) set_icon(Smartdict::Icons.logo) end |
Instance Method Details
#draw_window ⇒ Object
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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/smartdict/gui/main_window.rb', line 23 def draw_window vertical_span = 3 left_box_border = 3 main_box = Gtk::VBox.new. pack_start(, false, false, 0) main_hpaned = Gtk::HPaned.new left_scrolled_win = Gtk::ScrolledWindow.new. add(word_list). set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC) left_side_box = Gtk::VBox.new. pack_start(Gtk::VBox.new. pack_start(Gtk::HBox.new. pack_start(word_entry). set_border_width(vertical_span), false, false). pack_start(Gtk::HBox.new. pack_start(). set_border_width(vertical_span), false, false). pack_start(Gtk::HBox.new. pack_start(from_lang_combo_box). pack_start(). pack_start(to_lang_combo_box). set_border_width(vertical_span), false, false). set_border_width(left_box_border), false, false). pack_start(left_scrolled_win, true, true) right_scrolled_win = Gtk::ScrolledWindow.new. add(text_view). set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC) main_hpaned. add_child(Gtk::Builder.new, left_side_box). add_child(Gtk::Builder.new, right_scrolled_win) main_box.add(main_hpaned) main_box.pack_start(, false, false) add(main_box) end |
#hide_visibility ⇒ Object
83 84 85 86 |
# File 'lib/smartdict/gui/main_window.rb', line 83 def hide_visibility @prev_position = position hide_all end |
#show_visibility ⇒ Object
77 78 79 80 81 |
# File 'lib/smartdict/gui/main_window.rb', line 77 def show_visibility show_all move(*@prev_position) if @prev_position present end |
#toggle_visibility ⇒ Object
67 68 69 70 71 72 73 74 75 |
# File 'lib/smartdict/gui/main_window.rb', line 67 def toggle_visibility if visible? and active? hide_visibility elsif visible? and !active? present else show_visibility end end |