Class: Roebe::GUI::UniversalWidgets::ShowTenAliases

Inherits:
Base
  • Object
show all
Includes:
UniversalWidgets::BaseModule
Defined in:
lib/roebe/gui/universal_widgets/show_ten_aliases/show_ten_aliases.rb

Overview

Roebe::GUI::UniversalWidgets::ShowTenAliases

Constant Summary collapse

TITLE =
#

TITLE

#
'Show Ten Aliases'
WIDTH =
#

WIDTH

#
'42% or minimum 1280px'
HEIGHT =
#

HEIGHT

#
'30% or minimum 880px'
USE_THIS_FONT =
#

USE_THIS_FONT

#
:hack_23
LARGER_FONT =
#

LARGER_FONT

#
:hack_25
SMALLER_FONT =
#

SMALLER_FONT

#
:hack_20

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

Methods included from Base::CommandlineArguments

#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) ⇒ ShowTenAliases

#

initialize

#


68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/roebe/gui/universal_widgets/show_ten_aliases/show_ten_aliases.rb', line 68

def initialize(
    commandline_arguments = nil,
    run_already           = true
  )
  super(:vertical) if use_gtk3?
  determine_the_GUI_to_be_used(commandline_arguments) # This must come first, even before reset().
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  on_delete_event_quit_the_application
  run if run_already
end

Class Method Details

.[](i = ARGV) ⇒ Object

#

Roebe::GUI::UniversalWidgets::ShowTenAliases[]

#


388
389
390
# File 'lib/roebe/gui/universal_widgets/show_ten_aliases/show_ten_aliases.rb', line 388

def self.[](i = ARGV)
  new(i)
end

.run(i = ARGV) ⇒ Object

#

Roebe::GUI::Gtk::ShowTenAliases.run

#


372
373
374
375
376
377
378
379
380
381
382
383
# File 'lib/roebe/gui/universal_widgets/show_ten_aliases/show_ten_aliases.rb', line 372

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

Instance Method Details

#add_datastructureObject

#

add_datastructure

#


227
228
229
230
231
232
233
# File 'lib/roebe/gui/universal_widgets/show_ten_aliases/show_ten_aliases.rb', line 227

def add_datastructure
  @dataset = return_main_dataset
  @list_store.clear
  populate_this_list_store2(
    @list_store, return_dataset_as_array
  )
end

#border_size?Boolean

#

border_size?

#

Returns:

  • (Boolean)


163
164
165
# File 'lib/roebe/gui/universal_widgets/show_ten_aliases/show_ten_aliases.rb', line 163

def border_size?
  2
end

#connect_the_skeletonObject

#

connect_the_skeleton (connect tag)

#


192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# File 'lib/roebe/gui/universal_widgets/show_ten_aliases/show_ten_aliases.rb', line 192

def connect_the_skeleton
  abort_on_exception

  @vbox.maximal(@table2)

  window = create_window_or_runner(nil, width?, height?, title?)
  window << @vbox

  properly_prepare_this_window(window,
    {
      title:       title?,
      font:        font?,
      width:       width?,
      height:      height?,
      padding:     padding?,
      border_size: border_size?
    }
  )
  window.show_all
  window.top_left
  run_main
end

#create_table2_widgetObject

#

create_table2_widget

#


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
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
# File 'lib/roebe/gui/universal_widgets/show_ten_aliases/show_ten_aliases.rb', line 290

def create_table2_widget
 use_this_dataset = return_dataset_as_expanded_array
  _ = create_table2(
    use_this_dataset
  ) # {{ list_store: gtk_list_store(Integer, String) }}
  _.first.signal_connect(:button_press_event) { |widget, event|
    # ===================================================================== #
    # Handle double-click events next.
    # ===================================================================== #
    if is_a_mouse_double_click_event?(event)
      @selection = _.first.second_entry?.to_s # @selection will be a String past this point.
      # =================================================================== #
      # Make sure the parent widget allows external applications next.
      # =================================================================== #
      if @parent_widget and @parent_widget.respond_to?(:allow_external_applications?)
        # ================================================================= #
        # Trigger the call-back function. We have to find the corresponding
        # exam title.
        # ================================================================= #
        corresponding_exam_topic = ::Studium.find_corresponding_exam_topic(@selection)
        selection = corresponding_exam_topic
        # selection = ::Studium.find_corresponding_exam_title(
        #  corresponding_exam_topic
        #)
        use_this_widget = @parent_widget.entry_holding_all_exam_topics?
        if @parent_widget.respond_to? :clear_questions_buffer
          @parent_widget.clear_questions_buffer
        end
        if @parent_widget.respond_to? :clear_answers_buffer
          @parent_widget.clear_answers_buffer
        end
        use_this_widget.set_text(selection)
        # ================================================================= #
        # If we need to debug, the following could be used.
        # if is_on_roebe?
        #   e rev+'Debug from the file '+__FILE__+
        #     ': Trying to set '+::Colours.steelblue(selection)+' next.'
        # end
        # ================================================================= #
        if @parent_widget.respond_to? :sync_entry_holding_all_exam_topics_onto_the_combo_box
          @parent_widget.sync_entry_holding_all_exam_topics_onto_the_combo_box
        end
        if @parent_widget.respond_to? :one_two_three
          @parent_widget.one_two_three
        end
      end
    end
  }
  @table2 = _.first # This is an instance of Gtk::TreeView.
  @table2.the_headers_are_resizable
  @list_store = _.last
end

#create_the_skeletonObject

#

create_the_skeleton (create tag, skeleton tag)

#


277
278
279
280
281
282
283
284
285
# File 'lib/roebe/gui/universal_widgets/show_ten_aliases/show_ten_aliases.rb', line 277

def create_the_skeleton
  create_the_toolbar
  # ======================================================================= #
  # === @vbox
  # ======================================================================= #
  @vbox = create_vbox
  @vbox.minimal(@toolbar)
  create_table2_widget
end

#create_the_toolbarObject

#

create_the_toolbar

#


170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# File 'lib/roebe/gui/universal_widgets/show_ten_aliases/show_ten_aliases.rb', line 170

def create_the_toolbar
  # ======================================================================= #
  # Create a new Gtk::Toolbar here.
  # ======================================================================= #
  @toolbar = create_hbox
  @button_refresh = create_button('↺ Refresh')
  @button_refresh.set_name('button1')
  @button_refresh.css_class('bblack2')
  @button_refresh.on_clicked { do_refresh_the_main_widget }
  @button_refresh.hint = 'Click on this button in order to '\
                         'refresh the dataset displayed below.'
  @toolbar.append(@button_refresh, 2)
  @toolbar.add_space
  button_quit = create_quit_button(:use_image) # Use an image as well.
  button_quit.set_name('button1')
  @button_refresh.css_class('bblack2')
  @toolbar.append(button_quit, 2)
end

#do_refresh_the_main_widgetObject

#

do_refresh_the_main_widget

This is the method that can be used to refresh the main widget.

#


240
241
242
# File 'lib/roebe/gui/universal_widgets/show_ten_aliases/show_ten_aliases.rb', line 240

def do_refresh_the_main_widget
  add_datastructure
end

#handle_CSS_rulesObject

#

handle_CSS_rules

#


126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/roebe/gui/universal_widgets/show_ten_aliases/show_ten_aliases.rb', line 126

def handle_CSS_rules
  use_gtk_paradise_project_css_file
  append_project_css_file
  more_CSS_then_apply_it '/* this works

border: 20px solid darkblue;
 */

#button_css1 {
border-radius: 12px;
border-width:  3px;
border-color:  steelblue;
margin:        6px;
}

window {
background-color: white;
}
'
end

#padding?Boolean

#

padding?

#

Returns:

  • (Boolean)


156
157
158
# File 'lib/roebe/gui/universal_widgets/show_ten_aliases/show_ten_aliases.rb', line 156

def padding?
  2
end

#resetObject

#

reset (reset tag)

#


85
86
87
88
89
90
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/show_ten_aliases/show_ten_aliases.rb', line 85

def reset
  super() if respond_to?(:super)
  reset_the_base_module
  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)
  if use_gtk3?
    handle_CSS_rules
  end
  infer_the_size_automatically
  # ======================================================================= #
  # === @dataset
  # ======================================================================= #
  @dataset = return_main_dataset
  # ======================================================================= #
  # === @selection
  # ======================================================================= #
  @selection = nil
  # ======================================================================= #
  # === @parent_widget
  # ======================================================================= #
  @parent_widget = nil
end

#reset_the_shared_moduleObject

#

reset_the_shared_module

#


150
151
# File 'lib/roebe/gui/universal_widgets/show_ten_aliases/show_ten_aliases.rb', line 150

def reset_the_shared_module
end

#return_dataset_as_arrayObject

#

return_dataset_as_array

#


247
248
249
# File 'lib/roebe/gui/universal_widgets/show_ten_aliases/show_ten_aliases.rb', line 247

def return_dataset_as_array
  [*@dataset]
end

#return_dataset_as_expanded_arrayObject

#

return_dataset_as_expanded_array

The first two entries are the title of the column-table.

#


263
264
265
266
267
268
269
270
271
272
# File 'lib/roebe/gui/universal_widgets/show_ten_aliases/show_ten_aliases.rb', line 263

def return_dataset_as_expanded_array
  _ = return_dataset_as_array
  _.map! {|first, second|
    [first.to_s, second] # We need this as String, for better sorting.
  }
  # ======================================================================= #
  # Next we can modify the above dataset.
  # ======================================================================= #
  ['Position', 'Exam Topic', _]
end

#return_main_datasetObject

#

return_main_dataset

#


254
255
256
# File 'lib/roebe/gui/universal_widgets/show_ten_aliases/show_ten_aliases.rb', line 254

def return_main_dataset
  Roebe::ReturnTenAliases[] # This will return a Hash.
end

#return_random_entryObject

#

return_random_entry

#


218
219
220
221
222
# File 'lib/roebe/gui/universal_widgets/show_ten_aliases/show_ten_aliases.rb', line 218

def return_random_entry
  _ = []
  return_dataset_as_array.each {|a, b| _ << b }
  _.sample
end

#runObject

#

run (run tag)

#


365
366
367
# File 'lib/roebe/gui/universal_widgets/show_ten_aliases/show_ten_aliases.rb', line 365

def run
  run_super
end

#selection?Boolean

#

selection?

This will be “activated” when the user double-clicks on a row.

#

Returns:

  • (Boolean)


358
359
360
# File 'lib/roebe/gui/universal_widgets/show_ten_aliases/show_ten_aliases.rb', line 358

def selection?
  @selection
end

#set_parent_widget(i) ⇒ Object

#

set_parent_widget

This is optional; it exists so you can use a callback onto the main widget.

#


349
350
351
# File 'lib/roebe/gui/universal_widgets/show_ten_aliases/show_ten_aliases.rb', line 349

def set_parent_widget(i)
  @parent_widget = i
end

#smaller_font?Boolean

#

smaller_font?

#

Returns:

  • (Boolean)


119
120
121
# File 'lib/roebe/gui/universal_widgets/show_ten_aliases/show_ten_aliases.rb', line 119

def smaller_font?
  SMALLER_FONT
end