Class: TECSCDE::Preferences

Inherits:
Object show all
Defined in:
lib/tecscde/preferences.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_paperObject

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

#applyObject



40
41
42
# File 'lib/tecscde/preferences.rb', line 40

def apply
  @control.change_preferences(paper: @selected_paper)
end

#runObject



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

#setupObject



18
19
20
# File 'lib/tecscde/preferences.rb', line 18

def setup
  setup_combo_box
end

#setup_combo_boxObject



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