Class: Roebe::GUI::UniversalWidgets::WorldCapitals
- Inherits:
-
Base
- Object
- Base
- Roebe::GUI::UniversalWidgets::WorldCapitals
show all
- Includes:
- UniversalWidgets::BaseModule
- Defined in:
- lib/roebe/gui/universal_widgets/world_capitals/world_capitals.rb
Overview
Constant Summary
collapse
- TITLE =
'World Capitals'
- WIDTH =
'88% or minimum 1280px'
- HEIGHT =
'30% or minimum 880px'
- USE_THIS_FONT =
'Sans Bold 25'
- DEFAULT_FONT =
:dejavu_condensed_18 # or :hack_23
USE_THIS_FONT
- LARGER_FONT =
:hack_25
- SMALLER_FONT =
:hack_20
- FILE_WORLD_CAPITALS =
#
FILE_WORLD_CAPITALS
Where we store stuff.
bl $ROEBE_YAML/world_capitals.yml
#
'/home/x/programming/ruby/src/roebe/lib/roebe/yaml/world_capitals/world_capitals.yml'
Constants inherited
from Base
Base::COLOURS, Base::HOME_DIRECTORY_OF_USER_X, Base::N, Base::NAMESPACE
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#actions, #append_this_onto_that_file, #append_what_into, #be_silent, #be_verbose?, #beautiful_url, #burlywood, #call_next, #chdir, #cheerful_guy, #cliner, #complex_esystem, #convert_global_env, #copy_directory, #copy_file, #cornflowerblue, #create_directory, #crimson, #current_month?, #current_time?, #current_year?, #cyan, #darkcyan, #darkgreen, #darkkhaki, #darkslateblue, #deeppink, #delete_symlink, #do_not_use_the_base_colours, #do_use_the_base_colours, #e, #ecomment, #editor_to_use?, #efancy, #eimp, #emphasis, #ensure_main_encoding, #ensure_utf_encoding, #eparse, #erev, #esteelblue, #etomato, #ewarn, #exit_program, #firebrick, #get_current_day, #get_current_month, #get_files_and_directories, #get_files_from, #get_german_name_for_this_weekday, #gold, #green, #grey, #hh_mm_ss, #hh_mm_ss_day_month_year, #home_dir?, #home_directory_of_user_x?, #infer_the_namespace, #internal_hash?, #is_a_directory?, #is_a_file?, #is_a_jpg_file?, #is_an_image_file?, #is_archive?, #is_audio_file?, #is_in_studium_dir?, #is_multimedia_file?, #is_on_roebe?, #is_on_windows?, #is_studium_available?, #is_symlink?, #is_this_a_ruby_file?, #is_video_file?, #iso_encoding?, #le, #left_colour, #lightblue, #lightgreen, #lightseagreen, #lightsteelblue, #lime, #limegreen, #localhost_to_data, #log_directory?, #main_encoding?, #mediumorchid, #mediumpurple, #mediumseagreen, #mediumslateblue, #mediumspringgreen, #mediumturquoise, #mkdir_p, #mv, #n_days_in_this_month, #n_pages_in_this_pdf_file?, #namespace?, #no_file_exists_at, #ogrey, #olive, #olivedrab, #open_in_browser, #opne, #opnesystem, #opnn, #orange, #orchid, #orev, #palegoldenrod, #palevioletred, #pink, #powderblue, #programs_dir?, #project_base_dir?, #random_html_colour, #rds, #read_file_in_iso_encoding, #read_file_via_the_default_encoding, #read_lines_via_iso_encoding, #readlines_with_main_encoding, #red, #register_sigint, #remove, #remove_directory, #remove_file, #rename_kde_konsole_tab, #replace_localhost_with_data, #report_pwd, #require_rescue, #reset_the_internal_hash, #return_all_directories_from_this_directory, #return_all_files_from_this_directory, #return_current_directory, #return_dd_mm_yyyy, #return_file_or_directory_of, #return_files_from_pwd, #return_last_part_of_the_current_directory, #return_utc, #rev, #right_arrow?, #right_colour, #roebe_log_directory?, #rosybrown, #royalblue, #ruby_base_directory?, #run_in_background, #run_rcfiles_then_run_ata_via_qdbus, #sandybrown, #sdir, #seagreen, #set_be_verbose, #set_xorg_buffer, #sfancy, #sfile, #show_help, #silent_redirection?, #simp, #simple_esystem, #skyblue, #slateblue, #slategray, #springgreen, #steelblue, #string_italic, #swarn, #symlink, #teal, #temp_dir?, #to_camelcase, #to_counted_hash, #tomato, #touch, #try_to_require_the_beautiful_url_gem, #try_to_require_the_html_template, #try_to_require_the_open_gem, #try_to_require_the_program_information_gem, #try_to_require_the_xorg_buffer, #use_colours?, #verbose_truth, #weekday?, #word_wrap, #write_what_into, #yellow
#append_onto_the_commandline_arguments, #clear_commandline_arguments, #commandline_arguments?, #commandline_arguments_as_string?, #commandline_arguments_without_leading_hyphens?, #first_argument?, #first_argument_without_leading_hyphens?, #has_an_argument_been_passed?, #remove_hyphened_arguments_from_the_commandline_arguments, #return_commandline_arguments_with_leading_hyphens, #second_argument?, #set_commandline_arguments
Constructor Details
#initialize(commandline_arguments = nil, run_already = true) ⇒ WorldCapitals
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/roebe/gui/universal_widgets/world_capitals/world_capitals.rb', line 74
def initialize(
commandline_arguments = nil,
run_already = true
)
super(:vertical) if use_gtk3?
determine_the_GUI_to_be_used(commandline_arguments) reset
set_commandline_arguments(
commandline_arguments
)
on_delete_event_quit_the_application
run if run_already
end
|
Class Method Details
.[](i = ARGV) ⇒ Object
361
362
363
|
# File 'lib/roebe/gui/universal_widgets/world_capitals/world_capitals.rb', line 361
def self.[](i = ARGV)
new(i)
end
|
.run(i = ARGV) ⇒ Object
#
Roebe::GUI::Gtk::WorldCapitals.run
#
343
344
345
346
347
348
349
350
351
352
353
354
355
356
|
# File 'lib/roebe/gui/universal_widgets/world_capitals/world_capitals.rb', line 343
def self.run(
i = ARGV
)
require 'gtk_paradise/run'
_ = ::Roebe::GUI::Gtk::WorldCapitals.new(i)
r = ::Gtk.run
_.set_parent_widget(r) r << _
r.automatic_size_then_automatic_title
r.enable_quick_exit
r.set_background :white
r.maximize
r.top_left_then_run
end
|
Instance Method Details
#activate_this_tab(i = 1) ⇒ Object
Also known as:
focus_on_tab
226
227
228
|
# File 'lib/roebe/gui/universal_widgets/world_capitals/world_capitals.rb', line 226
def activate_this_tab(i = 1)
@notebook.focus_on_this_tab(i.to_i - 1)
end
|
#border_size? ⇒ Boolean
249
250
251
|
# File 'lib/roebe/gui/universal_widgets/world_capitals/world_capitals.rb', line 249
def border_size?
2
end
|
#connect_the_skeleton ⇒ Object
#
connect_the_skeleton (connect tag)
#
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
|
# File 'lib/roebe/gui/universal_widgets/world_capitals/world_capitals.rb', line 256
def connect_the_skeleton
abort_on_exception
vbox = create_vbox
vbox.maximal(@scrolled_window)
vbox.minimal(create_the_reset_button_and_the_hide_all_button)
window << vbox
properly_prepare_this_window(window,
{
title: title?,
font: font?,
width: width?,
height: height?,
padding: padding?,
border_size: border_size?
}
)
create_the_reset_button_and_the_hide_all_button
window.show_all
window.top_left
run_main
end
|
#create_left_aligned_label(string, make_font_larger = false) ⇒ Object
#
create_left_aligned_label
#
119
120
121
122
123
124
125
126
127
128
129
130
|
# File 'lib/roebe/gui/universal_widgets/world_capitals/world_capitals.rb', line 119
def create_left_aligned_label(
string,
make_font_larger = false
)
_ = create_label(string)
_.align_left
_.set_alignment(0, 1)
if make_font_larger
_.use_this_font = FONT_TYPE
end
return _
end
|
#create_the_paned_hboxes ⇒ Object
#
create_the_paned_hboxes
#
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
# File 'lib/roebe/gui/universal_widgets/world_capitals/world_capitals.rb', line 135
def create_the_paned_hboxes
vbox1 = create_vbox
vbox1.spacing = 2
vbox2 = create_vbox
vbox2.spacing = 2
@array_vboxes << vbox1
@array_vboxes << vbox2
hpaned_widget = create_hpaned(@array_vboxes[0], @array_vboxes[1])
@hbox = create_paned_hbox(
hpaned_widget
)
end
|
#
This method will add the big reset-button, and the hide-button.
#
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
# File 'lib/roebe/gui/universal_widgets/world_capitals/world_capitals.rb', line 162
def create_the_reset_button_and_the_hide_all_button
@button_reset = button('_Reset')
@button_reset.on_clicked { |w|
@array_vboxes[1].each { |b| b.set_empty } }
@button_reset.modify_background(:normal, :grey)
@button_reset.prelight_colour :slateblue
button_hide_all = button('_Hide all elements')
button_hide_all.on_clicked { |w|
@array_vboxes[1].each { |b| b.set_empty } }
button_hide_all.modify_background(:normal, :grey)
button_hide_all.prelight_colour :slateblue
hbox = create_hbox(@button_reset, button_hide_all)
return hbox
end
|
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
|
# File 'lib/roebe/gui/universal_widgets/world_capitals/world_capitals.rb', line 283
def create_the_scrolled_window
sorted_keys = return_a_sorted_list_of_the_capitals
sorted_keys.each { |key|
capital = key.dup.delete('[]').to_s.strip country = @hash_yaml_file_capitals.invert[key].to_s.strip
if country.include? ' ('
country = country[
0 .. country.index(' (')
]
end
_ = create_left_aligned_label(capital)
event_box1 = ::Roebe::GUI::Gtk::CapitalEventBox.new(
_, capital, :do_not_allow_for_toggle_events
)
@array_vboxes[0].maximal(event_box1, 1)
_ = create_left_aligned_label(country)
_.make_bold
event_box2 = ::Roebe::GUI::Gtk::CapitalEventBox.new(
_, country, :we_may_toggle
) if key.include? '[]'
event_box2.toggle
end
@array_vboxes[1].maximal(event_box2, 1)
}
if ::Gtk.use_gtk2?
@hbox.modify_font(DEFAULT_FONT)
else
@hbox.override_font(DEFAULT_FONT)
end
@scrolled_window = create_scrolled_window(@hbox)
end
|
#create_the_skeleton ⇒ Object
#
create_the_skeleton (create tag, skeleton tag)
#
328
329
330
331
|
# File 'lib/roebe/gui/universal_widgets/world_capitals/world_capitals.rb', line 328
def create_the_skeleton
create_the_scrolled_window
create_the_paned_hboxes
end
|
#handle_CSS_rules ⇒ Object
#
handle_CSS_rules (CSS tag)
#
214
215
216
217
218
219
220
221
|
# File 'lib/roebe/gui/universal_widgets/world_capitals/world_capitals.rb', line 214
def handle_CSS_rules
use_gtk_paradise_project_css_file
append_project_css_file
more_CSS_then_apply_it '
'
end
|
#padding? ⇒ Boolean
242
243
244
|
# File 'lib/roebe/gui/universal_widgets/world_capitals/world_capitals.rb', line 242
def padding?
0
end
|
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
# File 'lib/roebe/gui/universal_widgets/world_capitals/world_capitals.rb', line 91
def reset
super() if respond_to?(:super)
reset_the_shared_module reset_the_base_module
reset_the_internal_variables
infer_the_namespace
@configuration = [true, __dir__, namespace?]
title_width_height_font(TITLE, WIDTH, HEIGHT, USE_THIS_FONT)
if use_gtk3?
handle_CSS_rules
end
infer_the_size_automatically
@array_vboxes = []
try_to_load_the_dataset_from_the_file_world_capitals
end
|
#reset_the_shared_module ⇒ Object
#
reset_the_shared_module
This method can be used for ruby-gtk3 and ruby-libui, among other toolkits.
#
236
237
|
# File 'lib/roebe/gui/universal_widgets/world_capitals/world_capitals.rb', line 236
def reset_the_shared_module
end
|
#return_a_sorted_list_of_the_capitals ⇒ Object
#
return_a_sorted_list_of_the_capitals
#
186
187
188
|
# File 'lib/roebe/gui/universal_widgets/world_capitals/world_capitals.rb', line 186
def return_a_sorted_list_of_the_capitals
@hash_yaml_file_capitals.values.sort end
|
336
337
338
|
# File 'lib/roebe/gui/universal_widgets/world_capitals/world_capitals.rb', line 336
def run
run_super
end
|
#smaller_font? ⇒ Boolean
207
208
209
|
# File 'lib/roebe/gui/universal_widgets/world_capitals/world_capitals.rb', line 207
def smaller_font?
SMALLER_FONT
end
|
#try_to_load_the_dataset_from_the_file_world_capitals(this_file = FILE_WORLD_CAPITALS) ⇒ Object
#
try_to_load_the_dataset_from_the_file_world_capitals
#
193
194
195
196
197
198
199
200
201
202
|
# File 'lib/roebe/gui/universal_widgets/world_capitals/world_capitals.rb', line 193
def try_to_load_the_dataset_from_the_file_world_capitals(
this_file = FILE_WORLD_CAPITALS
)
if File.exist? this_file
@hash_yaml_file_capitals = YAML.load_file(this_file)
else
@hash_yaml_file_capitals = {}
e 'No file at '+FILE_WORLD_CAPITALS+' exists.'
end
end
|