Class: Roebe::GUI::Gtk::Capital

Inherits:
Gtk::BaseModuleBox
  • Object
show all
Defined in:
lib/roebe/gui/gtk3/guess_the_world_capitals/capital.rb

Overview

Roebe::GUI::Gtk::Capital

Constant Summary collapse

TITLE =
#

TITLE

#
'Capital Button'
WIDTH =
#

WIDTH

#
'15% or minimum 60px'
HEIGHT =
#

HEIGHT

#
'8% or minimum 20px'
USE_THIS_FONT =
#

USE_THIS_FONT

#
:dejavu_condensed_20
BACKGROUND_COLOUR =
#

BACKGROUND_COLOUR

#
'darkblue'

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(commandline_arguments = ARGV, run_already = true) ⇒ Capital

#

initialize

#


48
49
50
51
52
53
54
55
56
57
58
# File 'lib/roebe/gui/gtk3/guess_the_world_capitals/capital.rb', line 48

def initialize(
    commandline_arguments = ARGV,
    run_already           = true
  )
  super(:vertical)
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  run if run_already
end

Class Method Details

.run(i = ARGV) ⇒ Object

#

Roebe::GUI::Gtk::Capital.run

#


216
217
218
219
220
221
222
223
224
225
226
# File 'lib/roebe/gui/gtk3/guess_the_world_capitals/capital.rb', line 216

def self.run(
    i = ARGV
  )
  require 'gtk_paradise/run'
  _ = ::Roebe::GUI::Gtk::Capital.new(i)
  r = ::Gtk.run
  r << _
  r.automatic_size_then_automatic_title
  r.enable_quick_exit
  r.top_left_then_run
end

Instance Method Details

#border_size?Boolean

#

border_size?

#

Returns:

  • (Boolean)


111
112
113
# File 'lib/roebe/gui/gtk3/guess_the_world_capitals/capital.rb', line 111

def border_size?
  0
end

#connect_skeletonObject

#

connect_skeleton (connect tag)

#


196
197
198
199
200
201
202
203
204
# File 'lib/roebe/gui/gtk3/guess_the_world_capitals/capital.rb', line 196

def connect_skeleton
  abort_on_exception
  determine_the_label_from_the_commandline_arguments
  @event_box = create_event_box(@label)
  @event_box.on_clicked {
    toggle_the_status unless is_answered?
  }
  maximal(@event_box)
end

#create_skeletonObject

#

create_skeleton (create tag, skeleton tag)

#


118
119
120
# File 'lib/roebe/gui/gtk3/guess_the_world_capitals/capital.rb', line 118

def create_skeleton
  set_label(create_label)
end

#determine_the_label_from_the_commandline_argumentsObject

#

determine_the_label_from_the_commandline_arguments

#


134
135
136
137
138
139
140
# File 'lib/roebe/gui/gtk3/guess_the_world_capitals/capital.rb', line 134

def determine_the_label_from_the_commandline_arguments
  _ = first?.to_s
  if _ and !_.empty?
    set_the_raw_text(_)
    do_reveal_the_label
  end
end

#do_hide_the_labelObject Also known as: do_hide, hide_me, hide, set_empty

#

do_hide_the_label

#


179
180
181
# File 'lib/roebe/gui/gtk3/guess_the_world_capitals/capital.rb', line 179

def do_hide_the_label
  @label.set_text('')
end

#do_markifyObject

#

do_markify

#


172
173
174
# File 'lib/roebe/gui/gtk3/guess_the_world_capitals/capital.rb', line 172

def do_markify
  @label.do_markify
end

#do_reveal_the_labelObject Also known as: do_reveal_me, reveal_me

#

do_reveal_the_label

#


159
160
161
162
163
164
165
166
# File 'lib/roebe/gui/gtk3/guess_the_world_capitals/capital.rb', line 159

def do_reveal_the_label
  _ = @the_raw_text.sub(/\[\]/,'')
  if BACKGROUND_COLOUR
    _ = '<span weight="bold" foreground="'+BACKGROUND_COLOUR+'">'+_+'</span>'
  end
  @label.set_text(_)
  do_markify
end

#is_answered?Boolean

#

is_answered?

#

Returns:

  • (Boolean)


189
190
191
# File 'lib/roebe/gui/gtk3/guess_the_world_capitals/capital.rb', line 189

def is_answered?
  @the_raw_text.end_with?('[]')
end

#padding?Boolean

#

padding?

#

Returns:

  • (Boolean)


104
105
106
# File 'lib/roebe/gui/gtk3/guess_the_world_capitals/capital.rb', line 104

def padding?
  0
end

#resetObject

#

reset (reset tag)

#


63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/roebe/gui/gtk3/guess_the_world_capitals/capital.rb', line 63

def reset
  reset_the_internal_variables
  infer_the_namespace
  # ======================================================================= #
  # === @configuration
  # ======================================================================= #
  @configuration = [true, __dir__, namespace?]
  # ======================================================================= #
  # === Set the title, width, height and the font in use.
  # ======================================================================= #
  title_width_height_font(TITLE, WIDTH, HEIGHT, USE_THIS_FONT)
  use_gtk_paradise_project_css_file 
  infer_the_size_automatically
  # ======================================================================= #
  # === @the_raw_text
  # ======================================================================= #
  @the_raw_text = ''.dup
  # ======================================================================= #
  # === @is_hidden
  # ======================================================================= #
  @is_hidden = false
end

#runObject

#

run (run tag)

#


209
210
211
# File 'lib/roebe/gui/gtk3/guess_the_world_capitals/capital.rb', line 209

def run
  super()
end

#set_label(i) ⇒ Object

#

set_label

Setter-method for the @label variable.

#


127
128
129
# File 'lib/roebe/gui/gtk3/guess_the_world_capitals/capital.rb', line 127

def set_label(i)
  @label = i
end

#set_the_raw_text(i) ⇒ Object Also known as: set_string

#

set_the_raw_text

#


145
146
147
# File 'lib/roebe/gui/gtk3/guess_the_world_capitals/capital.rb', line 145

def set_the_raw_text(i)
  @the_raw_text = i
end

#the_raw_text?Boolean Also known as: raw_text?

#

the_raw_text?

#

Returns:

  • (Boolean)


152
153
154
# File 'lib/roebe/gui/gtk3/guess_the_world_capitals/capital.rb', line 152

def the_raw_text?
  @the_raw_text
end

#toggle_the_statusObject Also known as: toggle_label, toggle

#

toggle_the_status

#


89
90
91
92
93
94
95
96
97
98
# File 'lib/roebe/gui/gtk3/guess_the_world_capitals/capital.rb', line 89

def toggle_the_status
  case @is_hidden
  when true
    do_reveal_the_label
    @is_hidden = false
  when false
    do_hide_the_label
    @is_hidden = true
  end
end