Class: Gtk::RadioButtonWindow

Inherits:
Box
  • Object
show all
Defined in:
lib/gtk_paradise/examples/gtk3/055_radio_button_window.rb

Overview

Gtk::RadioButtonWindow

Constant Summary collapse

TITLE =
#

TITLE

#
'RadioButton Demo'
VERTICAL_OR_HORIZONTAL =
#

VERTICAL_OR_HORIZONTAL

#
:vertical

Instance Method Summary collapse

Methods inherited from Box

#add_space, #left_aligned_text, #text

Constructor Details

#initialize(run_already = true) ⇒ RadioButtonWindow

#

initialize

#


34
35
36
37
38
39
40
# File 'lib/gtk_paradise/examples/gtk3/055_radio_button_window.rb', line 34

def initialize(
    run_already = true
  )
  super(VERTICAL_OR_HORIZONTAL, 6)
  reset
  run if run_already
end

Instance Method Details

#connect_skeletonObject

#

connect_skeleton

#


76
77
78
79
80
# File 'lib/gtk_paradise/examples/gtk3/055_radio_button_window.rb', line 76

def connect_skeleton
  pack_start(@button1)
  pack_start(@button2)
  pack_start(@button3)
end

#create_skeletonObject

#

create_skeleton

#


62
63
64
65
66
67
68
69
70
71
# File 'lib/gtk_paradise/examples/gtk3/055_radio_button_window.rb', line 62

def create_skeleton
  @button1 = ::Gtk::RadioButton.new(label: '_Austria', use_underline: true)
  @button1.signal_connect(:toggled) { |b| on_button_toggled(b, 1) }

  @button2 = ::Gtk::RadioButton.new(member: @button1, label: '_Germany', use_underline: true)
  @button2.signal_connect(:toggled) { |b| on_button_toggled(b, 2) }

  @button3 = ::Gtk::RadioButton.new(member: @button1, label: 'Fr_ance', use_underline: true)
  @button3.signal_connect(:toggled) { |b| on_button_toggled(b, 3) }
end

#on_button_toggled(button, name) ⇒ Object

#

on_button_toggled

#


53
54
55
56
57
# File 'lib/gtk_paradise/examples/gtk3/055_radio_button_window.rb', line 53

def on_button_toggled(button, name)
  active_or_not_active = button.active? ? 'on' : 'off'
  e "Button #{name} was turned #{active_or_not_active} - "\
    "its text is: #{button.label}"
end

#resetObject

#

reset

#


45
46
47
48
# File 'lib/gtk_paradise/examples/gtk3/055_radio_button_window.rb', line 45

def reset
  set_title(TITLE) if respond_to? :set_title
  set_border_width(15)
end

#runObject

#

run

#


85
86
87
88
# File 'lib/gtk_paradise/examples/gtk3/055_radio_button_window.rb', line 85

def run
  create_skeleton
  connect_skeleton
end