Class: GamesAndRpgParadise::GUI::Gtk::CardCollection

Inherits:
Gtk::Box
  • Object
show all
Includes:
MagicTheGathering::CardCollectionModule, Gtk::BaseModule
Defined in:
lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/card_collection/card_collection.rb

Overview

GamesAndRpgParadise::GUI::Gtk::CardCollection

Constant Summary collapse

NAMESPACE =
#

NAMESPACE

#
inspect

Constants included from MagicTheGathering::CardCollectionModule

MagicTheGathering::CardCollectionModule::ARRAY_CONTAINING_INFORMATION_ABOUT_ALL_CARDS, MagicTheGathering::CardCollectionModule::ARRAY_RARITY, MagicTheGathering::CardCollectionModule::BLANK_IMAGE, MagicTheGathering::CardCollectionModule::COLOUR_FOR_THE_LABEL_SHOWING_THE_CORRECT_DATE, MagicTheGathering::CardCollectionModule::DIRECTORY_CONTAINING_THE_INDIVIDUAL_CARDS_BELONGING_TO_A_THEME, MagicTheGathering::CardCollectionModule::HEIGHT, MagicTheGathering::CardCollectionModule::LOG_DIR, MagicTheGathering::CardCollectionModule::SMALLER_FONT, MagicTheGathering::CardCollectionModule::SMALLEST_FONT, MagicTheGathering::CardCollectionModule::SUPER_SMALL_FONT, MagicTheGathering::CardCollectionModule::TITLE, MagicTheGathering::CardCollectionModule::USE_THIS_FONT, MagicTheGathering::CardCollectionModule::WIDTH

Constants included from CommonExtensions

CommonExtensions::CONTROL_C_CODE, CommonExtensions::N

Class Method Summary collapse

Instance Method Summary collapse

Methods included from MagicTheGathering::CardCollectionModule

#base_dir?, #border_size?, #cost?, #create_the_buttons, #create_the_combo_box, #create_the_labels, #create_the_small_spinner, #current_theme?, #delay_show_the_guessed_image, #determine_the_rarity_based_on_this_mouse_movement, #determine_whether_the_current_theme_is_available_locally_or_not, #do_all_actions_associated_with_the_main_combo_box_containing_the_themes, #do_change_to_use_another_model_for_the_main_entry, #do_delete_the_yaml_dataset, #do_open_the_remote_profile, #do_open_the_remote_webpage_for_the_current_card, #do_save_the_information, #do_save_this_dataset_into_the_yaml_file, #do_set_the_correct_completion_model_for_entry1, #do_show_the_modal_popover_containing_all_local_images_belonging_to_the_current_theme, #do_startup_related_tasks, #do_update_the_correct_date_entry, #does_the_yaml_file_exist?, #entry1?, #entry4?, #entry_for_the_cost?, #entry_for_the_theme?, #foil_yes_or_no?, #handle_the_action_of_the_event_box_containing_the_image_with_the_graphical_checkbox_for_determining_local_images_availability, #handle_the_combo_box_on_changed_event, #how_many_images_are_available_locally_in_the_current_theme?, #largest_font?, #main_combobox?, #main_font?, #n_cards?, #n_cards_registered?, #n_cards_registered_in_total?, #name_of_the_card?, #padding?, #rarity?, #reset_the_shared_module, #return_all_cards_belonging_to_this_theme, #return_all_themes?, #return_all_yaml_theme_files, #return_amount_of_the_card, #return_cost_of_the_card, #return_entry_for_the_amount_of_the_card, #return_entry_for_the_cost_of_the_card, #return_entry_for_the_name_of_the_card, #return_entry_for_the_rarity_of_the_card, #return_entry_for_the_theme_of_the_card, #return_euro_symbol, #return_name_of_the_card, #return_rarity_of_the_card, #return_string_n_cards_registered_in_total, #return_the_URL_for_cardmarket_based_on_the_entries, #return_the_assumed_local_path_to_the_directory_containing_the_images, #return_the_assumed_local_path_to_the_image, #return_the_checkbox_to_foil_or_not_to_foil, #return_the_dynamic_tooltip_for_the_image_containing_the_graphical_checkbox_for_determining_local_images_availability, #return_the_fifth_row, #return_the_foil_card_text, #return_the_icon_showing_the_theme_symbols, #return_the_sixth_row, #return_the_up_and_down_spinner, #return_theme_of_the_card, #return_up_and_down_arrows_for_the_rarity_entry, #sanitize_the_entry_for_the_cost, #sanitize_the_entry_for_the_name_of_the_card, #sanitize_the_entry_for_the_rarity_of_the_card, #small_spinner?, #smaller_font?, #smallest_font?, #super_small_font?, #the_current_theme_is_available_locally_as_well, #the_current_theme_is_not_available_locally, #theme?, #try_to_match_the_entry_onto_the_main_image_that_is_shown, #try_to_show_the_correct_theme_icon, #use_this_image_as_the_new_card_image, #yaml_file?

Methods included from Base::Extensions::CommandlineArguments

#commandline_arguments?, #filter_away_commandline_arguments, #first_argument?, #first_non_hyphened_argument?, #set_commandline_arguments

Methods included from CommonExtensions

#cat, #cd, #cliner, #copy_file, #delete, #dirname_but_retains_the_trailing_slash, #disable_colours, #ensure_that_the_log_directory_exists, #esystem, #get_user_input, #infer_the_namespace, #is_on_roebe?, #log_dir?, #mkdir, #mkdir_then_cd_into_it, #mv, #namespace?, #opne, #opnn, #project_base_directory?, #project_image_directory?, #project_yaml_directory?, #rds, #register_sigint, #remove_this_directory, #rename_file, #reset_the_internal_hash, #return_pwd, #return_today, #touch_file, #wrap, #write_what_into

Constructor Details

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

#

initialize

#


44
45
46
47
48
49
50
51
52
53
54
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/card_collection/card_collection.rb', line 44

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

#

GamesAndRpgParadise::GUI::Gtk::CardCollection.run

#


685
686
687
688
689
690
691
692
693
694
695
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/card_collection/card_collection.rb', line 685

def self.run(
    i = ARGV
  )
  require 'gtk_paradise/run'
  _ = ::GamesAndRpgParadise::GUI::Gtk::CardCollection.new(i)
  r = ::Gtk.run
  r << _
  r.automatic_size_then_automatic_title
  r.set_background_colour(:white)
  r.top_left_then_run
end

Instance Method Details

#connect_skeletonObject

#

connect_skeleton (connect tag)

#


96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/card_collection/card_collection.rb', line 96

def connect_skeleton
  abort_on_exception
  # ======================================================================= #
  # === @information_widget
  # ======================================================================= #
  @information_widget = GamesAndRpgParadise::GUI::Gtk::InformationWidget.new
  @widget_right = drag_via_up_and_down_movement(
    @information_widget,
    @view_card_widget
  )
  @widget_right.padding(8)
  # ======================================================================= #
  # Next add the vbox that can be dragged via left and right movement.
  # ======================================================================= #
  lower_draggable = drag_via_left_and_right_movement(
    @grid,
    @widget_right
  )
  upper_draggable = drag_via_up_and_down_movement(
    @header_bar,
    lower_draggable
  )
  handle_the_combo_box_on_changed_event
  handle_the_scale_up_entry_on_changed_event
  minimal(upper_draggable, 2)
end

#create_skeletonObject

#

create_skeleton (create tag, skeleton tag)

#


642
643
644
645
646
647
648
649
650
651
652
653
654
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/card_collection/card_collection.rb', line 642

def create_skeleton
  create_the_images
  create_the_entries          # Must come before we create the spinner.
  create_the_view_card_widget # Must come after the entries were created.
  create_the_small_spinner    # Create the spinner very early on.
  create_the_header_bar
  create_the_labels
  create_the_buttons
  create_the_combo_box # This must come before we create the grid.
  create_the_grid
  create_the_settings
  create_the_about_dialog
end

#create_the_about_dialogObject

#

create_the_about_dialog (about tag)

#


659
660
661
662
663
664
665
666
667
668
669
670
671
672
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/card_collection/card_collection.rb', line 659

def create_the_about_dialog
  # ======================================================================= #
  # === @about_dialog
  # ======================================================================= #
  @about_dialog = gtk_about_dialog
  @about_dialog.author = 'Robert Heiler'
  @about_dialog.comments = 'This GUI can help keep your magic '\
    'cards managed.'
  @about_dialog.copyright = 'Copyright (C) 2022 and onwards'
  @about_dialog.use_this_font = USE_THIS_FONT
  @about_dialog.signal_connect(:response) {
    @about_dialog.hide
  }
end

#create_the_entriesObject

#

create_the_entries (entries tag, entry tag)

#


232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/card_collection/card_collection.rb', line 232

def create_the_entries
  # ======================================================================= #
  # === @entry_scale_by_n_percent
  # ======================================================================= #
  @entry_scale_by_n_percent = gtk_entry('8')
  @entry_scale_by_n_percent.center
  @entry_scale_by_n_percent.bblack2
  @entry_scale_by_n_percent.very_light_yellowish_background
  @entry_scale_by_n_percent.hint =
    "Scale the image size by n percent.\n\n"\
    "If set to 0% then no scaling will occur."
  @entry_scale_by_n_percent.enable_scroll_events

  @entry_scale_by_n_percent.signal_connect(:event) { |widget, event|
    if scroll_up_event?(event)
      old_value = @entry_scale_by_n_percent.text?.to_i
      old_value +=1
      old_value = 200 if old_value > 200
      @entry_scale_by_n_percent.set_text(old_value.to_s)
    elsif scroll_down_event?(event)
      old_value = @entry_scale_by_n_percent.text?.to_i
      old_value -=1
      old_value = 0 if old_value < 0
      @entry_scale_by_n_percent.set_text(old_value.to_s)
    end
  }
  # ======================================================================= #
  # === @entry_use_this_browser
  # ======================================================================= #
  @entry_use_this_browser = gtk_entry('firefox')
  @entry_use_this_browser.center
  @entry_use_this_browser.bblack2
  @entry_use_this_browser.very_light_yellowish_background
  @entry_use_this_browser.hint = 'Denote which browser you wish '\
                                 'to use here.'
  # ======================================================================= #
  # === @entry1
  # ======================================================================= #
  @entry1 = return_entry_for_the_name_of_the_card
  # ======================================================================= #
  # === @entry2
  # ======================================================================= #
  @entry2 = return_entry_for_the_theme_of_the_card # Define our entry for the theme here.
  # ======================================================================= #
  # === @entry3
  # ======================================================================= #
  @entry3 = return_entry_for_the_amount_of_the_card
  # ======================================================================= #
  # === @entry4
  # ======================================================================= #
  @entry4 = return_entry_for_the_rarity_of_the_card
  # ======================================================================= #
  # === @entry5
  # ======================================================================= #
  @entry5 = return_entry_for_the_cost_of_the_card
end

#create_the_gridObject

#

create_the_grid

#


126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/card_collection/card_collection.rb', line 126

def create_the_grid
  # ======================================================================= #
  # === @grid
  # ======================================================================= #
  @grid = default_grid
  @grid.columnspacing = 10
  # ======================================================================= #
  # This is the first row.
  # ======================================================================= #
  @grid.left(return_name_of_the_card)
  @grid.right(@entry1)
  # ======================================================================= #
  # This is the second row.
  # ======================================================================= #
  @grid.left(return_theme_of_the_card)
  hbox = gtk_hbox
  hbox.minimal(@entry2,    1)
  @image_containing_the_theme_symbols = return_the_icon_showing_the_theme_symbols
  hbox.minimal(@image_containing_the_theme_symbols, 4)
  # ======================================================================= #
  # The next line can only possibly work if the combo-box has been
  # created already.
  # ======================================================================= #
  hbox.maximal(main_combo_box?, 1)
  @grid.right(hbox)
  # ======================================================================= #
  # === "Amount:"
  # This is the third row, containing the up-and-down spinner.
  # ======================================================================= #
  @grid.left(return_amount_of_the_card)
  hbox = gtk_hbox
  hbox.minimal(@entry3)
  hbox.minimal(small_spinner?, 2)
  hbox.minimal(@label_for_the_correct_date_entry_aka_the_year, 8)
  hbox.minimal(gtk_vertical_separator, 2)
  @n_local_cards_text = gtk_text
  hbox.minimal(@n_local_cards_text, 2)
  @event_box_containing_the_image_with_the_graphical_checkbox_for_determining_local_images_availability =
    gtk_event_box(
      @image_containing_the_graphical_checkbox_for_determining_local_images_availability
    )
  hbox.pack_end(
    @event_box_containing_the_image_with_the_graphical_checkbox_for_determining_local_images_availability, padding: 8
  )
  handle_the_action_of_the_event_box_containing_the_image_with_the_graphical_checkbox_for_determining_local_images_availability
  @grid.right(hbox)
  # ======================================================================= #
  # === "Rarity:"
  # This is the fourth row.
  # ======================================================================= #
  @grid.left(return_rarity_of_the_card)
  hbox = gtk_hbox
  hbox.maximal(@entry4)
  hbox.minimal(return_up_and_down_arrows_for_the_rarity_entry)
  @grid.right(hbox)
  # ======================================================================= #
  # === "Cost:"
  # This is the fifth row.
  # ======================================================================= #
  @grid.left(return_cost_of_the_card)
  hbox = gtk_hbox
  hbox.maximal(@entry5)
  hbox.minimal(return_euro_symbol, 5)
  @grid.right(hbox)
  # ======================================================================= #
  # === The foil row                        (which is the sixth row, row 6)
  # ======================================================================= #
  @grid.left(return_the_foil_card_text)
  @checkbox_to_foil_or_not_to_foil = return_the_checkbox_to_foil_or_not_to_foil
  @grid.right(@checkbox_to_foil_or_not_to_foil)
  small_hbox = gtk_hbox
  small_hbox.minimal(@button_save_the_information)
  small_hbox.hjustify
  @grid.full_row(small_hbox)
end

#create_the_header_barObject

#

create_the_header_bar (header bar tag)

#


461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/card_collection/card_collection.rb', line 461

def create_the_header_bar
  @header_bar = default_header_bar
  @header_bar.title = 'Card Collection'
  @header_bar.bblack2
  @header_bar.set_name('header_bar')
  @header_bar.spacing = 8
  @header_bar.set_border_width(14)
  # ======================================================================= #
  # === button_show_information_about_the_yaml_file
  # ======================================================================= #
  button_show_information_about_the_yaml_file = button_with_image(:dialog_information)
  button_show_information_about_the_yaml_file.hint =
    "Use this button to show the content of the current <b>.yml</b> file.\n\n"\
    "This file will normally reside at: <b>#{location_to_the_yaml_file?}</b>"
  button_show_information_about_the_yaml_file.on_clicked {
    do_show_information_about_the_yaml_file
  }
  @header_bar.place_left(
    button_show_information_about_the_yaml_file
  )
  # ======================================================================= #
  # === button_show_the_settings
  # ======================================================================= #
  button_show_the_settings = gtk_button('Settings')
  button_show_the_settings.set_name('button1')
  button_show_the_settings.hint = 'This button allows you to change a few '\
                                  'settings of this application, such as '\
                                  'how much zoom-increase on-hover actions '\
                                  'over a card will use.'
  button_show_the_settings.use_this_font = 'Rubik 18'
  button_show_the_settings.on_clicked {
    do_popup_the_settings_widget
  }
  @header_bar.place_left(
    button_show_the_settings
  )
  # ======================================================================= #
  # === Add an about-dialog option next
  # ======================================================================= #
  button_for_the_about_dialog = button('_About')
  button_for_the_about_dialog.make_bold
  button_for_the_about_dialog.use_this_font = smallest_font?
  button_for_the_about_dialog.hint = 'Show general '\
    'information about this application.'
  button_for_the_about_dialog.on_clicked {
    @about_dialog.show
  }
  @header_bar.place_right(
    button_for_the_about_dialog
  )
  # ======================================================================= #
  # === button_delete_the_yaml_dataset
  # ======================================================================= #
  button_delete_the_yaml_dataset = button_with_image(:edit_delete)
  button_delete_the_yaml_dataset.hint =
    "Use this button to <b>delete the .yml file</b>. That way you "\
    "can resume from scratch.\n\nOnly use this if you are sure "\
    "you want to delete the .yml file."
  button_delete_the_yaml_dataset.on_clicked {
    do_delete_the_yaml_dataset
  }
  @header_bar.place_right(
    button_delete_the_yaml_dataset
  )
  # ======================================================================= #
  # === button_open_the_profile_via_the_browser
  # ======================================================================= #
  if is_on_roebe?
    button_open_the_profile_via_the_browser = button_with_image('web-browser-symbolic.symbolic')
    button_open_the_profile_via_the_browser.hint =
      "Click this button to open the link at "\
      "<b>https://www.cardmarket.com/en/Magic/Account</b>."
    button_open_the_profile_via_the_browser.on_clicked {
      do_open_the_remote_profile
    }
    @header_bar.place_right(
      button_open_the_profile_via_the_browser
    )
  end
  # ======================================================================= #
  # === button_lookup_remote_webpage
  # ======================================================================= #
  button_lookup_remote_webpage = button_with_image(:face_glasses)
  button_lookup_remote_webpage.hint =
    "<b>Click</b> on this button to look up information about the "\
    "card at <b>https://www.cardmarket.com/</b>.\n\n"\
    "Note that this will only work properly if you filled in "\
    "the entries below prior to clicking this button.\n"
  button_lookup_remote_webpage.on_clicked {
    do_look_up_remote_webpage_and_then_display_information_about_it
  }
  @header_bar.place_right(
    button_lookup_remote_webpage
  )
  # ======================================================================= #
  # === button_open_the_remote_webpage_for_the_current_card
  # ======================================================================= #
  button_open_the_remote_webpage_for_the_current_card = button_with_image(
    'media-playlist-consecutive-symbolic.symbolic'
  )
  button_open_the_remote_webpage_for_the_current_card.hint =
    "This button can be used to open the remote webpage for the "\
    "card at hand. This requires that the user has designated the "\
    "name and the theme in the input formular below.\n\n"\
    "As browser firefox will be used - this is hardcoded right now."
  button_open_the_remote_webpage_for_the_current_card.on_clicked {
    do_open_the_remote_webpage_for_the_current_card
  }
  @header_bar.place_right(
    button_open_the_remote_webpage_for_the_current_card
  )
  @header_bar.place_right(
    @entry_use_this_browser
  )
end

#create_the_imagesObject

#

create_the_images

#


205
206
207
208
209
210
211
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/card_collection/card_collection.rb', line 205

def create_the_images
  # ======================================================================= #
  # === @image_containing_the_graphical_checkbox_for_determining_local_images_availability
  # ======================================================================= #
  @image_containing_the_graphical_checkbox_for_determining_local_images_availability = gtk_image
  update_the_tooltip_belonging_to_the_image_containing_the_graphical_checkbox_for_determining_local_images_availability
end

#create_the_settingsObject

#

create_the_settings

#


363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/card_collection/card_collection.rb', line 363

def create_the_settings
  # ======================================================================= #
  # === @settings_vbox
  # ======================================================================= #
  @settings_vbox = gtk_vbox
  # ======================================================================= #
  # Style this vbox a bit:
  # ======================================================================= #
  @settings_vbox.pad5px
  @settings_vbox.set_border_width(20)
  @settings_vbox.use_this_font = smaller_font?
  _ = text("Settings\n")
  _.use_this_font = largest_font?
  @settings_vbox.add(_)
  @settings_vbox.add_hspacer
  hbox = gtk_hbox
  hbox.minimal(left_aligned_text('Scale image size by n percent: '), 2)
  hbox.minimal(@entry_scale_by_n_percent)
  @settings_vbox << hbox
  @settings_vbox.add_hspacer
  @settings_vbox.use_this_font = smallest_font?
  @settings_vbox.width_height(800, 300)
  @settings_vbox.show_all
end

#create_the_view_card_widgetObject

#

create_the_view_card_widget

#


85
86
87
88
89
90
91
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/card_collection/card_collection.rb', line 85

def create_the_view_card_widget
  # ======================================================================= #
  # === @view_card_widget
  # ======================================================================= #
  @view_card_widget = GamesAndRpgParadise::GUI::Gtk::ViewCard.new
  @view_card_widget.set_scale_up_by_n_percent(@entry_scale_by_n_percent.text?) # 8% scale up.
end

#do_look_up_remote_webpage_and_then_display_information_about_itObject

#

do_look_up_remote_webpage_and_then_display_information_about_it

#


391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/card_collection/card_collection.rb', line 391

def do_look_up_remote_webpage_and_then_display_information_about_it
  # ======================================================================= #
  # First build up the remote String. This should look like so:
  #
  #   https://www.cardmarket.com/en/Magic/Products/Singles/Tempest/Eladamri-Lord-of-Leaves
  #
  # ======================================================================= #
  remote_URL_to_use = return_the_URL_for_cardmarket_based_on_the_entries
  e 'Looking up the remote website at `'+
    ::Colours.steelblue(remote_URL_to_use)+'` now ...'
  n_available_items = GamesAndRpgParadise::MagicTheGathering.available_items_in_this_URL(
    remote_URL_to_use
  )
  # ======================================================================= #
  # The above method already downloaded the remote dataset, so we do
  # not have to do it again for the following method call. This is
  # why we use the second parameter.
  # ======================================================================= #
  price_trend = GamesAndRpgParadise::MagicTheGathering.price_trend_in_this_URL(
    remote_URL_to_use
  )

  vbox = gtk_vbox
  # ======================================================================= #
  # Style this vbox a bit:
  # ======================================================================= #
  vbox.pad5px
  vbox.set_border_width(6)
  vbox.use_this_font = :hack_17 # smaller_font?
  vbox.add(
    text(
      "Information about the card named "\
      "`<b>#{@entry1.text?}</b>`:\n"
    )
  )
  vbox.add_hspacer
  vbox.add(
    left_aligned_text('n available cards for sale: <b>'+n_available_items.to_s+'</b>')
  )
  vbox.add_hspacer
  vbox.add(
    left_aligned_text('Price trend:                 <b>'+price_trend.to_s+'</b> Euro')
  )
  vbox.add_hspacer
  vbox.width_height(680, 480)
  scrolled_window = gtk_scrolled_window(vbox)
  scrolled_window.pad8px
  scrolled_window.css_class('mar5px')
  scrolled_window.border_width = 6
  scrolled_window.bblack1
  scrolled_window.width_height(550, 340)
  scrolled_window.use_this_font = smallest_font?
  scrolled_window.show_all
  pop_up_widget(
    over_this_widget: main_content?,
    custom_widget: scrolled_window
  ).popup
end

#do_popup_the_settings_widgetObject

#

do_popup_the_settings_widget

#


580
581
582
583
584
585
586
587
588
589
590
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/card_collection/card_collection.rb', line 580

def do_popup_the_settings_widget
  if @settings_popover.nil?
    @settings_popover = return_popover(
      '',
      main_content?, # This is the header bar actually.
      :default_padding, # This is the default padding to use.
      @settings_vbox
    )
  end
  @settings_popover.popup
end

#do_show_information_about_the_yaml_fileObject

#

do_show_information_about_the_yaml_file

#


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
342
343
344
345
346
347
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/card_collection/card_collection.rb', line 292

def do_show_information_about_the_yaml_file
  vbox = gtk_vbox
  # ======================================================================= #
  # Style this vbox a bit:
  # ======================================================================= #
  vbox.pad5px
  vbox.set_border_width(20)
  vbox.use_this_font = smaller_font?
  vbox.add(
    text("Information about the registered cards:\n")
  )
  vbox.add_hspacer
  vbox.add(
    left_aligned_text('n cards registered: <b>'+n_cards_registered?.to_s+'</b>')
  )
  vbox.add_hspacer
  vbox.width_height(600, 300)
  vbox.use_this_font = smallest_font?
  text_view = gtk_text_view
  vbox_containing_the_clickable_buttons = gtk_vbox
  # ======================================================================= #
  # Query whether the .yml file exists or whether it does not
  # ======================================================================= #
  if does_the_yaml_file_exist?
    YAML.load_file(yaml_file?).each_pair {|name_of_the_card, inner_hash|
      button = GamesAndRpgParadise::GUI::Gtk::ButtonContainingInformationAboutASingleCard.new
      button.set_text(name_of_the_card)
      button.append_entries_from_this_hash(inner_hash)
      button.set_parent_widget(self)
      vbox_containing_the_clickable_buttons.minimal(button, 2)
    }
    file_content = File.read(yaml_file?)
    file_content = '' if file_content.start_with? '--- {}' # Empty Hash.
    text_view.set_text(file_content)
  end
  scrolled_window = gtk_scrolled_window(text_view)
  scrolled_window.pad6px
  scrolled_window.css_class('mar5px')
  scrolled_window.border_width = 8
  scrolled_window.width_height(420, 420)
  scrolled_window.use_this_font = smallest_font?

  scrolled_window_containing_the_clickable_buttons = gtk_scrolled_window(
    vbox_containing_the_clickable_buttons
  )
  scrolled_window_containing_the_clickable_buttons.width_height(420, 420)
  the_first_vbox = gtk_vbox
  the_first_vbox.add(scrolled_window_containing_the_clickable_buttons)
  vbox.add(the_first_vbox)
  vbox.add(scrolled_window)
  vbox.show_all
  pop_up_widget(
    over_this_widget: main_content?,
    custom_widget:    vbox
  ).popup
end

#handle_CSS_rulesObject

#

handle_CSS_rules (CSS tag)

#


602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/card_collection/card_collection.rb', line 602

def handle_CSS_rules
  use_gtk_paradise_project_css_file
  custom_CSS_then_apply_it '
.header_bar {
margin: 1px;
}

spinbutton entry {
background-color: rgb(248, 247, 224);
border: 1px solid black;
}

popover {
padding: 5px;
border: 2px solid royalblue;
}

#button1 {
border: 1px dotted steelblue;
}

/*
 * Style the tooltip next:
 */
tooltip {
background-image: none;
border: 3px solid darkblue;
padding:     15px;
margin:      6px 6px 6px 6px;
font-size:   32px;
color: black;
}


'
end

#handle_the_scale_up_entry_on_changed_eventObject

#

handle_the_scale_up_entry_on_changed_event

#


352
353
354
355
356
357
358
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/card_collection/card_collection.rb', line 352

def handle_the_scale_up_entry_on_changed_event
  @entry_scale_by_n_percent.on_changed {
    new_value = @entry_scale_by_n_percent.text?.to_s # Adjust it here.
    new_value = 100 if new_value.to_i > 100 # Prevent users being wild.
    @view_card_widget.set_scale_up_by_n_percent(new_value)
  }
end

#header_bar?Boolean

#

header_bar?

#

Returns:

  • (Boolean)


78
79
80
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/card_collection/card_collection.rb', line 78

def header_bar?
  @header_bar
end

#main_content?Boolean

#

main_content?

#

Returns:

  • (Boolean)


595
596
597
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/card_collection/card_collection.rb', line 595

def main_content?
  header_bar? # Could be the outer vbox too, if we'd like to.
end

#resetObject

#

reset (reset tag)

#


59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/card_collection/card_collection.rb', line 59

def reset
  reset_the_internal_variables
  # ======================================================================= #
  # === @configuration
  # ======================================================================= #
  @configuration = [true, __dir__, NAMESPACE]
  set_use_this_font(USE_THIS_FONT)
  # ======================================================================= #
  # === @settings_popover
  # ======================================================================= #
  @settings_popover = nil
  handle_CSS_rules
  infer_the_size_automatically
  reset_the_shared_module
end

#runObject

#

run (run tag)

#


677
678
679
680
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/card_collection/card_collection.rb', line 677

def run
  super()
  do_startup_related_tasks
end

#update_the_n_local_cards_text_labelObject

#

update_the_n_local_cards_text_label

#


216
217
218
219
220
221
222
223
224
225
226
227
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/card_collection/card_collection.rb', line 216

def update_the_n_local_cards_text_label
  _ = "n local images:\n".dup
  _ << '<b>'.dup
  name_of_the_theme = entry2?.text?.downcase.tr(' ','_')
  name_of_the_theme.delete!(':') if name_of_the_theme.include? ':'
  target = LOG_DIR+name_of_the_theme+'/'
  _ << "     #{Dir[target+'*png'].size.to_s}"
  _ << '</b>'
  @n_local_cards_text.set_text(_)
  @n_local_cards_text.use_this_font = super_small_font?
  @n_local_cards_text.markify
end

#update_the_tooltip_belonging_to_the_image_containing_the_graphical_checkbox_for_determining_local_images_availabilityObject

#

update_the_tooltip_belonging_to_the_image_containing_the_graphical_checkbox_for_determining_local_images_availability

#


453
454
455
456
# File 'lib/games_and_rpg_paradise/gui/gtk3/magic_the_gathering/card_collection/card_collection.rb', line 453

def update_the_tooltip_belonging_to_the_image_containing_the_graphical_checkbox_for_determining_local_images_availability
  @image_containing_the_graphical_checkbox_for_determining_local_images_availability.hint =
    return_the_dynamic_tooltip_for_the_image_containing_the_graphical_checkbox_for_determining_local_images_availability
end