Class: TECSCDE::Preferences
Instance Attribute Summary collapse
-
#selected_paper ⇒ Object
Returns the value of attribute selected_paper.
Instance Method Summary collapse
- #apply ⇒ Object
-
#initialize(control) ⇒ Preferences
constructor
A new instance of Preferences.
- #run ⇒ Object
- #setup ⇒ Object
- #setup_combo_box ⇒ Object
Constructor Details
#initialize(control) ⇒ Preferences
Returns a new instance of Preferences.
9 10 11 12 13 14 15 16 |
# File 'lib/tecscde/preferences.rb', line 9 def initialize(control) @control = control @builder = Gtk::Builder.new @builder.add_from_file(File.join(__dir__, "preferences.glade")) @selected_paper = nil @changed = false setup end |
Instance Attribute Details
#selected_paper ⇒ Object
Returns the value of attribute selected_paper.
7 8 9 |
# File 'lib/tecscde/preferences.rb', line 7 def selected_paper @selected_paper end |
Instance Method Details
#apply ⇒ Object
40 41 42 |
# File 'lib/tecscde/preferences.rb', line 40 def apply @control.change_preferences(paper: @selected_paper) end |
#run ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/tecscde/preferences.rb', line 31 def run dialog = @builder["preferences"] response = dialog.run if response == Gtk::ResponseType::APPLY apply end dialog.destroy end |
#setup ⇒ Object
18 19 20 |
# File 'lib/tecscde/preferences.rb', line 18 def setup setup_combo_box end |
#setup_combo_box ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/tecscde/preferences.rb', line 22 def setup_combo_box combo = @builder["paper-size"] combo.signal_connect("changed") do @selected_paper = combo.active_text @changed = true end combo.active = @control.preferences[:paper].index end |