class ImageParadise::GUI::Gtk::CfdgWidget

Constants

HEIGHT
#

HEIGHT

#
IMG_DIRECTORY
#

IMG_DIRECTORY

This constant only works for my home setup.

#
NAMESPACE
#

NAMESPACE

#
POSSIBLE_RESOLUTIONS
#

POSSIBLE_RESOLUTIONS

The first entry should be the default variant.

#
SMALLER_FONT
#

SMALLER_FONT

#
TITLE
#

TITLE

#
TOOLTIP_EDITOR
#

TOOLTIP_EDITOR

#
USE_THIS_FONT
#

USE_THIS_FONT

#
WIDTH
#

WIDTH

#
YOUR_FAVOURITE_EDITOR
#

YOUR_FAVOURITE_EDITOR

Easier constant “alias” to the editor in use.

#

Public Class Methods

new( commandline_arguments = ARGV, run_already = true ) click to toggle source
#

initialize

#
Calls superclass method
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 106
def initialize(
    commandline_arguments = ARGV,
    run_already           = true
  )
  super(:vertical)
  reset
  set_commandline_arguments(
    commandline_arguments
  )
  run if run_already
end
run( i = ARGV ) click to toggle source
#

ImageParadise::GUI::Gtk::CfdgWidgetModule.run

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 1028
def self.run(
    i = ARGV
  )
  require 'gtk_paradise/app/app'
  _ = ::ImageParadise::GUI::Gtk::CfdgWidget.new(i)
  r = ::Gtk.app
  r << _
  r.enable_context_menu
  r.on_button_press_event { |widget, event|
    if ::Gtk.right_mouse_click?(event) # right mouse click event.
      _.context_menu?.popup_based_on_this_event(event)
    end
  }
  r.automatic_size_and_automatic_title
  r.middle_of_the_screen_then_run
end

Public Instance Methods

border_size?() click to toggle source
#

border_size?

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 179
def border_size?
  2
end
clear_buffer() click to toggle source
#

clear_buffer

This method clears the buffer.

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 793
def clear_buffer
  @text_buffer.text = ''
end
connect_skeleton() click to toggle source
#

connect_skeleton (connect tag)

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 233
def connect_skeleton
  abort_on_exception
  @text_buffer = gtk_text_buffer
  use_this_cfdg_file(@show_this_cfdg_file)
  @text_view = gtk_text_view(@text_buffer)
  mini_hbox_containing_the_numbered_lines_and_the_text_view = gtk_hbox
  _ = @numbered_lines
  _.set_use_this_font(USE_THIS_FONT) # Sync the font in use here.
  mini_hbox_containing_the_numbered_lines_and_the_text_view.minimal(
    _
  )
  mini_hbox_containing_the_numbered_lines_and_the_text_view.maximal(@text_view)
  @scrolled_window1 = gtk_scrolled_window(
    mini_hbox_containing_the_numbered_lines_and_the_text_view
  ) { :always }
  @scrolled_window1.width_height(400, 800)
  @scrolled_window1.bblack1
  @scrolled_window1.css_class('pad2px')
  # ======================================================================= #
  # === @image1
  # ======================================================================= #
  @image1 = gtk_image
  @image1.bblack1
  @image1.css_class('mar8px')
  # ======================================================================= #
  # Put that image into the second scrolled window.
  # ======================================================================= #
  vbox = gtk_vbox
  small_hbox = padded_hbox
  small_hbox.minimal(return_the_spinner_on_top, 5)
  small_hbox.maximal(@button_render_again)
  vbox.minimal(small_hbox)
  vbox.maximal(@image1)
  @scrolled_window2 = gtk_scrolled_window(vbox) { :always }
  @scrolled_window2.width_height(300, 300)
  @scrolled_window2.css_class('pad5px')
  pane_top_to_bottom = gtk_pane_top_to_bottom(
    @scrolled_window1,
    @scrolled_window2
  )
  pane_top_to_bottom.position = 900
  small_vbox = gtk_vbox
  small_vbox.minimal(@label_file_name_top)

  pane_top_to_bottom_and_scrolled_widget = gtk_hbox
  # ======================================================================= #
  # Add the widget containing each .cfdg file as a button.
  # ======================================================================= #
  pane_top_to_bottom_and_scrolled_widget.maximal(pane_top_to_bottom)
  pane_top_to_bottom_and_scrolled_widget.minimal(
    return_scrolled_window_widget_containing_each_cfdg_file_as_a_button,
    2
  )

  small_vbox.maximal(pane_top_to_bottom_and_scrolled_widget)
  # ======================================================================= #
  # Add the widget with lots of buttons, via the method called
  # .return_button_widget(). This one is on the very right side.
  # ======================================================================= #
  _ = gtk_pane_top_to_bottom(small_vbox, return_button_widget)
  minimal(_)
  _.position = 1520
  do_style_all_the_buttons_uniformly
end
context_menu?() click to toggle source
#

context_menu?

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 977
def context_menu?
  @context_menu
end
create_combo_box() click to toggle source
#

create_combo_box

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 361
def create_combo_box
  @combo_box = gtk_combo_box_text
  @combo_box.bblack1
  POSSIBLE_RESOLUTIONS.each { |entry|
    @combo_box.append_text(entry)
  }
  @combo_box.active = 0
  # @combo_box.set_halign(::Gtk::Align::CENTER)
  # @combo_box.set_hexpand(true)
end
create_skeleton() click to toggle source
#

create_skeleton (create tag)

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 219
def create_skeleton
  create_the_context_menu
  create_combo_box
  create_the_checkboxes
  create_the_event_box_for_the_browser
  create_the_buttons
  create_the_label_file_name_on_top
  create_the_entries
  create_the_event_box_for_the_bluefish_editor
end
create_the_buttons() click to toggle source
#

create_the_buttons (buttons tag)

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 733
def create_the_buttons
  # ======================================================================= #
  # === @button_render_again
  # ======================================================================= #
  @button_render_again = button('_Render again')
  @button_render_again.hint = 'Click this button to render the .cfdg '\
    'file (on the left) again. The new image will then be displayed '\
    'in the image-box below this button.'
  @button_render_again.on_clicked {
    do_render_again
  }
  # ======================================================================= #
  # === @button_open_in_the_browser
  # ======================================================================= #
  @button_open_in_the_browser = gtk_button('Open in the browser')
  @button_open_in_the_browser.hint = 'Click on this button '\
    'if you want to open the image in a browser-tab.'
  @button_open_in_the_browser.set_font(SMALLER_FONT)
  @button_open_in_the_browser.on_clicked {
    do_open_the_current_image_in_the_browser
  }
end
create_the_checkboxes() click to toggle source
#

create_the_checkboxes

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 726
def create_the_checkboxes
  @checkbox_automatically_render_this_cfdg = gtk_checkbox { :is_checked }
end
create_the_context_menu() click to toggle source
#

create_the_context_menu

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 953
def create_the_context_menu
  # ======================================================================= #
  # === @context_menu
  # ======================================================================= #
  @context_menu = create_context_menu(self) {{
    actions: {
      '• Render again':              :do_render_again,
      '• Render a random cfdg file': :do_use_a_new_random_cfdg_file
    }
  }}
  @context_menu.use_this_font = main_font?
  @context_menu.css_class('bblack3_and_padding')
end
create_the_entries() click to toggle source
#

create_the_entries (entries tag, entry tag)

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 321
def create_the_entries
  # ======================================================================= #
  # @entry_width is on the top.
  # ======================================================================= #
  @entry_width = gtk_entry
  @entry_width.set_max_length(8)
  @entry_width.center
  @entry_width.on_click_select_everything
  @entry_width.lightgreen_background
  @entry_width.bblack1
  @entry_width.set_text(
    ::ImageParadise::ConfreeGenerator::DEFAULT_WIDTH.to_s
  )
  @entry_width.on_changed { |widget, event|
    @entry_height.text = @entry_width.text if @button_check_coupled.active?
  }
  # ======================================================================= #
  # === @entry_height
  #
  # The height entry comes next.
  # ======================================================================= #
  @entry_height = gtk_entry
  @entry_height.set_max_length(8)
  @entry_height.center
  @entry_height.on_click_select_everything
  @entry_height.lightgreen_background
  @entry_height.bblack1
  @entry_height.set_text(
    ::ImageParadise::ConfreeGenerator::DEFAULT_HEIGHT.to_s
  )
  @entry_height.on_changed { |w,event|
    if @button_check_coupled.active?
      @entry_width.text = @entry_height.text
    end
  }
end
create_the_event_box_for_the_bluefish_editor() click to toggle source
#

create_the_event_box_for_the_bluefish_editor

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 819
def create_the_event_box_for_the_bluefish_editor
  image_bluefish = gtk_image # Will be "filled" lateron.
  target_file = IMG_DIRECTORY+'/PC/EDITORS/BLUEFISH/BLUEFISH.png'
  if File.exist? target_file
    image_bluefish.set_from_file(target_file)
  else
    # ===================================================================== #
    # In this case we will use a custom image from the stock-items.
    # ===================================================================== #
    # image_bluefish.set(image_document_open, 25,25)
    image_bluefish.set_pixbuf(
      icon_theme_default(:document_open, 25), 25, 25
    )
  end
  @event_box_for_the_bluefish_editor = gtk_event_box
  @event_box_for_the_bluefish_editor.add(image_bluefish)
  @event_box_for_the_bluefish_editor.hint = TOOLTIP_EDITOR
  @event_box_for_the_bluefish_editor.on_clicked {
    open_file_in_editor
  }
end
create_the_event_box_for_the_browser() click to toggle source
#

create_the_event_box_for_the_browser

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 375
def create_the_event_box_for_the_browser
  _ = IMG_DIRECTORY+'firefox/FIREFOX_FAVICON.png'
  if File.exist? _
    @event_box_for_firefox = gtk_event_box
    firefox_image = gtk_image_from_file(_)
    firefox_image.hint = 'Opens a tab in the browser.'
    @event_box_for_firefox.add(firefox_image) # Add the firefox image here.
    @event_box_for_firefox.on_button_press_event {
      do_open_the_current_image_in_the_browser
    }
  end
end
create_the_label_file_name_on_top( i = @show_this_cfdg_file ) click to toggle source
#

create_the_label_file_name_on_top

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 884
def create_the_label_file_name_on_top(
    i = @show_this_cfdg_file
  )
  @label_file_name_top = gtk_label
  @label_file_name_top.css_class('royalblue')
  @label_file_name_top.set_font(:hack_20)
  @label_file_name_top.make_bold
  @label_file_name_top.left_align
  @label_file_name_top.hint = 'This text will show the current '\
    'active .cfdg file assigned. The text-view widget below '\
    'this text holds the content of the .cfdg file.'
  @label_file_name_top.set_text(
    File.basename(i).to_s
  )
end
current_buffer?() click to toggle source
#

current_buffer?

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 768
def current_buffer?
  @text_buffer.text?
end
do_create_a_new_file_chooser_dialog_and_then_set_the_main_entry_to( i = main_file?.to_s ) click to toggle source
#

do_create_a_new_file_chooser_dialog_and_then_set_the_main_entry_to

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 1011
def do_create_a_new_file_chooser_dialog_and_then_set_the_main_entry_to(
    i = main_file?.to_s
  )
  create_a_new_file_chooser_dialog(self) {{
    filter:             '.cfdg',
    additional_folders: ::ImageParadise.project_base_directory?+'cfdg/',
    start_dir:          ::ImageParadise.project_base_directory?+'cfdg/'
  }}
  _ = ::Gtk.main_file?
  if _ and File.exist?(_)
    use_this_cfdg_file(_)
  end
end
do_create_the_image( i = nil )
do_generate_all_cfdg_images() click to toggle source
#

do_generate_all_cfdg_images

This is the batch-generation part.

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 697
def do_generate_all_cfdg_images
  ::ImageParadise::ConfreeGenerator.batch_generate_all_images    
end
Also aliased as: create_batch_gallery
do_open_the_current_image_in_the_browser( _ = @output_file_location ) click to toggle source
#

do_open_the_current_image_in_the_browser

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 775
def do_open_the_current_image_in_the_browser(
    _ = @output_file_location
  ) 
  require 'open'
  if _ and !_.empty?
    e "Opening the image at #{_} next."
    Open.in_browser(_)
  else
    e 'You first have to create a new image file. Click '\
      'the run-button to generate a new image.'
  end
end
Also aliased as: open_firefox_tab
do_randomize_all_hue_entries() click to toggle source
#

do_randomize_all_hue_entries

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 1073
def do_randomize_all_hue_entries
  old_content = text_buffer?.text?.dup
  if old_content.include? 'hue '
    regex = /(hue \d{1,3})/ # See: https://rubular.com/r/nLkepmPs8U8WRe
    scanned_results = old_content.scan(regex)
    # The results may look like this:
    #
    #  [["hue 270"], ["hue 75"]]
    #
    scanned_results.flatten.each {|this_hue_related_entry| # "hue 270"
      number = this_hue_related_entry.split(' ').last.to_i
      case rand(2)
      when 0 # For minus.
        number = number - rand(number)
        number = 1 if number < 0
      when 1 # For upper.
        number = number + rand(250)
        number = 255 if number > 255
      end
      old_content.gsub!(/#{this_hue_related_entry}/, 'hue '+number.to_s)
    }
    @text_buffer.set_text(old_content)
    render_anew # This may be commented out at some later point in time.
  end
end
do_render_again() click to toggle source
#

do_render_again

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 1102
def do_render_again
  render_the_cfdg_file_again(:make_use_of_the_spinner_as_well)
end
Also aliased as: render_anew
do_render_the_cfdg_file( i = nil )
do_scramble_the_cfdg_content() click to toggle source
#

do_scramble_the_cfdg_content

This will randomly “scramble” the cfdg content, then run the cfdg binary.

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 856
def do_scramble_the_cfdg_content
  _ = @text_buffer.text?.dup
  _.gsub!(/260/,'268')
  _.gsub!(/100/,'105')
  _.gsub!(/110/,'115')
  _.gsub!(/#{rand(300)}/,"#{rand(300)}")
  _.gsub!(/#{rand(300)}/,"#{rand(300)}")
  _.gsub!(/#{rand(300)}/,"#{rand(300)}")
  _.gsub!(/#{rand(300)}/,"#{rand(300)}")
  _.gsub!(/#{rand(300)}/,"#{rand(300)}")
  _.gsub!(/#{rand(300)}/,"#{rand(300)}")
  _.gsub!(/#{rand(300)}/,"#{rand(300)}")
  _.gsub!(/#{rand(300)}/,"#{rand(300)}")
  _.gsub!(/90/,(95+rand(60)).to_s)
  _.gsub!(/80/,(85+rand(50)).to_s)
  _.gsub!(/70/,(70+rand(40)).to_s)
  _.gsub!(/240/,(220+rand(40)).to_s)
  _.gsub!(
    /0.15/,
    (0.10 + ( rand(100) /100.0 ) ).to_s
  )
  set_source_buffer(_)
  do_run
end
do_style_all_the_buttons_uniformly() click to toggle source
#

do_style_all_the_buttons_uniformly

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 759
def do_style_all_the_buttons_uniformly
  return_all_buttons.each {|this_button|
    this_button.bblack1
  }
end
do_use_a_new_random_cfdg_file() click to toggle source
#

do_use_a_new_random_cfdg_file

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 1000
def do_use_a_new_random_cfdg_file
  random_file = return_random_cfdg_file
  use_this_cfdg_file(random_file)
  if @checkbox_automatically_render_this_cfdg.is_checked?
    do_render_the_cfdg_file
  end
end
do_use_the_current_buffer_for_creating_a_new_image_file( i = nil ) click to toggle source
#

do_use_the_current_buffer_for_creating_a_new_image_file

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 1109
def do_use_the_current_buffer_for_creating_a_new_image_file(
    i = nil
  )
  _ = current_buffer?
  # ======================================================================= #
  # We will create a new file and use that.
  # ======================================================================= #
  @home_dir = ENV['HOME'].to_s+'/image_paradise/'
  ::ImageParadise.mkdir(@home_dir) unless File.directory?(@home_dir)
  @into = @home_dir+'default_cfdg_file.cfdg'
  ::ImageParadise.write_what_into(_, @into)
  # ======================================================================= #
  # We need to use a consistent output-file here, as an image.
  # ======================================================================= #
  @output_file_location = @home_dir+'output.png'
  Thread.new {
    case i
    when :make_use_of_the_spinner_as_well
      the_spinner_is_now_active
    end
    result = ::ImageParadise.confreegenerator(@into) {{
      output_location:     @output_file_location,
      open_in_browser_tab: false,
      width:               @entry_width.text?,
      height:              @entry_height.text?
    }}
    if result.was_an_error_encountered?
      notify_the_user_that_the_text_view_contains_an_error
    end
    update_the_main_image_with_this_path(@output_file_location)
    case i
    # === :make_use_of_the_spinner_as_well
    when :make_use_of_the_spinner_as_well
      the_spinner_is_now_inactive
    end
  }
end
favicon?() click to toggle source
#

favicon?

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 800
def favicon?
  '/home/x/data/images/ART/NEURONAL_HAND.png'
end
main_buffer?() click to toggle source
#

main_buffer?

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 1048
def main_buffer?
  @text_buffer
end
Also aliased as: text_buffer?
main_font?() click to toggle source
#

main_font?

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 970
def main_font?
  USE_THIS_FONT
end
menu( i = commandline_arguments? ) click to toggle source
#

menu (menu tag)

#
notify_the_user_that_the_text_view_contains_an_error() click to toggle source
#

notify_the_user_that_the_text_view_contains_an_error

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 1153
def notify_the_user_that_the_text_view_contains_an_error
  popup_over_this_widget(
    text_view?,
    'The buffer (text content) contains some error. Have a '\
    'look at it and correct the error, if possible.'
  ).popup
end
open_a_random_cfdg_file() click to toggle source
#

open_a_random_cfdg_file

Open a random cfdg file here. This method will then invoke the method open_this_file().

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 987
def open_a_random_cfdg_file
  random_file = return_random_cfdg_file
  use_this_cfdg_file(random_file)
  e "Loading this `#{sfile(random_file)}` random file now."
  open_file_in_editor(random_file)
  if @checkbox_automatically_render_this_cfdg.is_checked?
    do_render_the_cfdg_file
  end
end
open_file_in_editor( this_file = @show_this_cfdg_file ) click to toggle source
#

open_file_in_editor

This method opens the cfdg file in your designated editor.

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 809
def open_file_in_editor(
    this_file = @show_this_cfdg_file
  )
  _ = "#{YOUR_FAVOURITE_EDITOR} #{this_file}"
  esystem _
end
open_firefox_tab( _ = @output_file_location )
padding?() click to toggle source
#

padding?

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 172
def padding?
  2
end
path_to_the_cfdg_directory() click to toggle source
#

path_to_the_cfdg_directory

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 165
def path_to_the_cfdg_directory
  ::ImageParadise.project_base_directory?+'cfdg/'
end
program_exists?(this_program) click to toggle source
#

program_exists?

Find out whether a program exists or not.

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 713
def program_exists?(this_program)
  does_program_exist = false # default is false
  array_available_paths = [ ENV['SYSBIN'].to_s, '/usr/bin/']
  array_available_paths.each { |path|
    _ = path+'/'+this_program
    does_program_exist = true if File.exist? _
  }
  return does_program_exist
end
render_anew()
Alias for: do_render_again
render_the_cfdg_file_again( i = nil )
reset() click to toggle source
#

reset (reset tag)

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 121
def reset
  reset_the_internal_variables
  # ======================================================================= #
  # === @configuration
  # ======================================================================= #
  @configuration = [true, __dir__, NAMESPACE]
  # ======================================================================= #
  # === @title
  # ======================================================================= #
  set_title(TITLE)
  # ======================================================================= #
  # === @width
  # ======================================================================= #
  set_width(WIDTH)
  # ======================================================================= #
  # === @height
  # ======================================================================= #
  set_height(HEIGHT)
  set_use_this_font(USE_THIS_FONT)
  use_gtk_paradise_project_css_file
  infer_the_size_automatically
  # ======================================================================= #
  # === @numbered_lines
  # ======================================================================= #
  @numbered_lines = return_numbered_lines_widget
  # ======================================================================= #
  # === @output_file_location
  # ======================================================================= #
  @output_file_location = nil
  # ======================================================================= #
  # === @event_box_for_firefox
  #
  # The following event-box is only used on my home setup for now.
  # ======================================================================= #
  @event_box_for_firefox = nil
  # ======================================================================= #
  # === @show_this_cfdg_file
  # ======================================================================= #
  @show_this_cfdg_file = path_to_the_cfdg_directory+'water_ink.cfdg'
end
return_all_cfdg_files( i = path_to_the_cfdg_directory ) click to toggle source
#

return_all_cfdg_files

This method will try to get all .cfdg files, except for all entries we stored in our Array at the top.

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 906
def return_all_cfdg_files(
    i = path_to_the_cfdg_directory
  )
  Dir["#{i}*.cfdg"].sort
end
return_button_widget() click to toggle source
#

return_button_widget (buttons tag, button tag)

This is the button-widget on the right hand side of this widget.

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 408
def return_button_widget
  _ = gtk_vbox
  # ======================================================================= #
  # First the file-chooser dialog.
  # ======================================================================= #
  button_file_chooser = return_file_chooser_button
  button_file_chooser.on_clicked {
    do_create_a_new_file_chooser_dialog_and_then_set_the_main_entry_to(main_file?)
  }
  # ======================================================================= #
  # Next add the open-in-the-browser button
  # ======================================================================= #
  hbox = gtk_hbox
  hbox.maximal(@button_open_in_the_browser, 1)
  hbox.minimal(@event_box_for_firefox, 1) if @event_box_for_firefox
  _.minimal(hbox, 1)
  # ======================================================================= #
  # === @button_check_coupled
  # ======================================================================= #
  @button_check_coupled = gtk_check_button('Coupled')
  @button_check_coupled.set_active(false)

  # ======================================================================= #
  # === Add the "Open File" button
  # ======================================================================= #
  hbox = gtk_hbox
  event_box1 = gtk_event_box(document_open)
  event_box1.on_clicked {
    do_create_a_new_file_chooser_dialog_and_then_set_the_main_entry_to(main_file?)
  }
  hbox.minimal(event_box1, 1)
  hbox.maximal(button_file_chooser, 1)
  _.minimal(hbox, 1)
  @button_open_a_random_cfdg_file = gtk_button('_Open a random file')
  @button_open_a_random_cfdg_file.on_clicked {
    open_a_random_cfdg_file
  }
  hbox = gtk_hbox
  event_box = gtk_event_box(document_open)
  event_box.on_clicked {
    open_a_random_cfdg_file
  }
  hbox.minimal(event_box,                                1)
  hbox.maximal(@button_open_a_random_cfdg_file,          1)
  hbox.minimal(@checkbox_automatically_render_this_cfdg, 1)
  _.minimal(hbox, 1)
  _.minimal(@combo_box, 1)
  # ======================================================================= #
  # === Add the "Width:" text next:
  # ======================================================================= #
  label_width = text('Width:')
  label_width.width_height(100, 40)
  _.minimal(
    hbox(label_width, @entry_width), 1
  )
  # ======================================================================= #
  # === Add the "Height:" text next:
  # ======================================================================= #
  label_height = text('Height:')
  label_height.width_height(100, 40)
  _.minimal(
    hbox(label_height, @entry_height), 1
  )
  _.minimal(@button_check_coupled, 1)
  _.minimal(gtk_hseparator, 0)
  _.minimal(@event_box_for_the_bluefish_editor, 1)
  @button_scramble = gtk_button('_Scramble')
  @button_scramble.on_clicked { do_scramble_the_cfdg_content }
  _.minimal(@button_scramble, 1)

  # ======================================================================= #
  # == The clear-button
  # ======================================================================= #
  @button_clear = button('_Clear')
  @button_clear.on_clicked { clear_buffer }
  @button_clear.hint = 'Click this button to clear the content of '\
    'the text-view area on the left hand side. This is the area '\
    'where the content of a .cfdg file usually appears.'
  @button_clear.set_image(
    ::Gtk::Image.new(
      stock: ::Gtk::Stock::OK,
      size:  ::Gtk::IconSize::SMALL_TOOLBAR
    )
  )
  _.minimal(@button_clear, 1)

  # ======================================================================= #
  # === @button_batch_generate_all_cfdg_images
  # ======================================================================= #
  @button_batch_generate_all_cfdg_images = button(
    'Generate all cfdg-images'
  )
  @button_batch_generate_all_cfdg_images.hint = 'This '\
    'button can be used to <b>generate all images</b>. This '\
    'will take a while, though.'
  @button_batch_generate_all_cfdg_images.on_clicked {
    do_generate_all_cfdg_images
  }
  _.minimal(@button_batch_generate_all_cfdg_images, 1)

  # ======================================================================= #
  # == The quit-button                                 (exit tag, quit tag)
  # ======================================================================= #
  @button_quit = gtk_quit_button
  _.minimal(@button_quit, 1)

  # ======================================================================= #
  # === @button_run_cfdg
  # ======================================================================= #
  @button_run_cfdg = gtk_button('_Run cfdg')
  @button_run_cfdg.hint = 'Click on this button '\
    'to generate a new image from the .cfdg dataset '\
    'shown to the left side. Keep in mind that this may '\
    'take up to a few seconds, depending on how complex '\
    'the context-free rules are. Once the image was '\
    'generated, it will be shown to the left side '\
    'as well.' 
  @button_run_cfdg.on_clicked {
    do_use_the_current_buffer_for_creating_a_new_image_file
  }
  
  _.minimal(@button_run_cfdg, 1)
  # ======================================================================= #
  # Next add a frame
  # ======================================================================= #
  frame = gtk_frame
  # ======================================================================= #
  # This frame is for the various insert-buttons. These insert-buttons
  # will insert (or modify) lines at the current iter of the text-buffer.
  # ======================================================================= #
  frame.label = ' InsertButtons: '
  frame.label_widget.make_bold
  frame.set_border_width(2)
  frame.pad5px
  frame.hint = 'These small buttons allow you to insert '\
               'commands into the text-buffer.'

  small_hbox1 = gtk_hbox

  # ======================================================================= #
  # === :comment
  #
  # This method will insert a comment in the current iter.
  # ======================================================================= #
  button1 = button('A comment')
  button1.use_this_font = SMALLER_FONT
  button1.on_clicked {
    main_buffer?.insert_at_cursor(
      '# ============================================= #'+N
    )
    main_buffer?.insert_at_cursor('# '+N)
    main_buffer?.insert_at_cursor(
      '# ============================================= #'+N
    )
  }
  small_hbox1.minimal(button1, 0)

  # ======================================================================= #
  # === :rect
  # ======================================================================= #
  button2 = button('A rectangle')
  button2.use_this_font = SMALLER_FONT
  button2.on_clicked {
    main_buffer?.insert_at_cursor("RECT {}\n")
  }
  small_hbox1.minimal(button2, 0)

  # ======================================================================= #
  # === :triangle
  # ======================================================================= #
  button3 = button('A triangle')
  button3.use_this_font = SMALLER_FONT
  button3.on_clicked {
    main_buffer?.insert_at_cursor("TRIANGLE {}\n")
  }
  small_hbox1.minimal(button3, 0)

  small_hbox2 = gtk_hbox
  # ======================================================================= #
  # === :line
  # ======================================================================= #
  button4 = button('A line')
  button4.use_this_font = SMALLER_FONT
  button4.on_clicked {
    main_buffer?.insert_at_cursor("LINE {}\n")
  }
  small_hbox2.minimal(button4, 0)

  # ======================================================================= #
  # === :circle
  # ======================================================================= #
  button5 = button('A circle')
  button5.use_this_font = SMALLER_FONT
  button5.on_clicked {
    main_buffer?.insert_at_cursor("CIRCLE {}\n")
  }
  small_hbox2.minimal(button5, 0)

  # ======================================================================= #
  # === :hue
  # ======================================================================= #
  button6 = button('Hue setting')
  button6.use_this_font = SMALLER_FONT
  button6.on_clicked {
    main_buffer?.insert_at_cursor(" hue 10 ")
  }
  small_hbox2.minimal(button6, 0)

  small_hbox3 = gtk_hbox

  # ======================================================================= #
  # === :sat
  # ======================================================================= #
  button7 = button('Saturation setting')
  button7.use_this_font = SMALLER_FONT
  button7.on_clicked {
    main_buffer?.insert_at_cursor(' sat 0.995 ')
  }
  small_hbox3.minimal(button7, 0)

  # ======================================================================= #
  # === :bold
  # ======================================================================= #
  button8 = button('Bold')
  button8.use_this_font = SMALLER_FONT
  button8.on_clicked {
    main_buffer?.insert_at_cursor(' b 0.995 ')
  }
  small_hbox3.minimal(button8, 0)

  # ======================================================================= #
  # === :square
  # ======================================================================= #
  button9 = button('square')
  button9.use_this_font = SMALLER_FONT
  button9.on_clicked {
    main_buffer?.insert_at_cursor('SQUARE {}')
  }
  small_hbox3.minimal(button9, 0)

  # ======================================================================= #
  # === :background
  # ======================================================================= #
  button10 = button('background')
  button10.use_this_font = SMALLER_FONT
  button10.on_clicked {
    main_buffer?.insert_at_cursor('background { b -0.95 sat 1 hue 180 }')
  }
  small_hbox3.minimal(button10, 0)

  # ======================================================================= #
  # === :newline
  # ======================================================================= #
  button11 = button('newline')
  button11.use_this_font = SMALLER_FONT
  button11.on_clicked {
    main_buffer?.insert_at_cursor("\n")
  }
  small_hbox3.minimal(button11, 0)

  # ======================================================================= #
  # Colourize these buttons next:
  # ======================================================================= #
  [ button1,  button2, button3,
    button4,  button5, button6,
    button7,  button8, button9,
    button10, button11
  ].each {|this_button|
    this_button.clear_background
    this_button.modify_background(:normal,   :lightsteelblue)
    this_button.modify_background(:active,   :brown)
    this_button.modify_background(:prelight, :bisque)
  }

  frame_padded_vbox = padded_vbox
  frame_padded_vbox.minimal(small_hbox1, 4)
  frame_padded_vbox.minimal(small_hbox2, 4)
  frame_padded_vbox.minimal(small_hbox3, 4)
  frame.add(frame_padded_vbox)
  _.minimal(frame, 1)
  _.minimal(return_widget_containing_buttons_to_randomize_the_text_buffer, 1)
  return _
end
return_random_cfdg_file() click to toggle source
#

return_random_cfdg_file

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 704
def return_random_cfdg_file
  Dir[path_to_the_cfdg_directory+'*.cfdg'].sort.sample
end
return_scrolled_window_widget_containing_each_cfdg_file_as_a_button() click to toggle source
#

return_scrolled_window_widget_containing_each_cfdg_file_as_a_button

This method will create the widget that contains all .cfdg files as a button.

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 918
def return_scrolled_window_widget_containing_each_cfdg_file_as_a_button
  vbox = gtk_vbox
  vbox.set_font(:hack_10)
  vbox.width_height(50, 50)
  sorted_array = return_all_cfdg_files
  sorted_array.each_with_index {|this_cfdg_file, index| index += 1
    _ = File.basename(this_cfdg_file) # We want to use a shorter name.
    button = gtk_button(
      _.delete_suffix('.cfdg')
    )
    button.make_bold
    button.left_align
    button.width_height(50, 24)
    button.bblack1
    button.on_clicked {
      use_this_cfdg_file(this_cfdg_file)
      do_create_the_image
    }
    button.hint =
      'This button (file position <b>'+index.to_s+
      '</b>) will create the image described by <b>'+
      this_cfdg_file+'</b>.'
    vbox.minimal(button, 1)
  }
  scrolled_window = gtk_scrolled_window(vbox) { :only_top_down_bar }
  scrolled_window.width_height(80, 50)
  frame = gtk_frame(scrolled_window)
  frame.set_title('Available .cfdg files')
  frame.set_border_width(1)
  return frame
end
return_the_spinner_on_top() click to toggle source
#

return_the_spinner_on_top

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 1191
def return_the_spinner_on_top
  # ======================================================================= #
  # === @spinner_on_top
  # ======================================================================= #
  @spinner_on_top = gtk_spinner
  return @spinner_on_top
end
return_widget_containing_buttons_to_randomize_the_text_buffer() click to toggle source
#

return_widget_containing_buttons_to_randomize_the_text_buffer

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 1055
def return_widget_containing_buttons_to_randomize_the_text_buffer
  _ = gtk_vbox
  button1 = gtk_button('Randomize <b>hue</b>')
  button1.on_clicked {
    do_randomize_all_hue_entries
  }
  button1.do_markify
  button1.hint = 'Click this button to randomly change all <b>hue</b> '\
                 'entries in the text-buffer.'
  small_hbox1 = gtk_hbox
  small_hbox1.minimal(button1, 0)
  _.minimal(small_hbox1)
  return _
end
run() click to toggle source
#

run (run tag)

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 398
def run
  create_skeleton_then_connect_skeleton
  menu
end
set_file_location(i = nil)
Alias for: use_this_cfdg_file
set_source_buffer(i = '') click to toggle source
#

set_source_buffer

This simply sets the content for the @text_buffer variable.

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 846
def set_source_buffer(i = '')
  @text_buffer.text = i
end
text_buffer?()
Alias for: main_buffer?
text_view?() click to toggle source
#

text_view?

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 1164
def text_view?
  @text_view
end
the_spinner_is_now_active() click to toggle source
#

the_spinner_is_now_active

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 1171
def the_spinner_is_now_active
  @spinner_on_top.is_active
  # ======================================================================= #
  # Whenever the spinner is spinning, such as defined in the line above,
  # the render-again button becomes inactive (aka insensitive).
  # ======================================================================= #
  @button_render_again.is_inactive
end
the_spinner_is_now_inactive() click to toggle source
#

the_spinner_is_now_inactive

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 1183
def the_spinner_is_now_inactive
  @spinner_on_top.is_inactive
  @button_render_again.is_active
end
update_the_main_image_with_this_path(i) click to toggle source
#

update_the_main_image_with_this_path

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 391
def update_the_main_image_with_this_path(i)
  @image1.set_file(i)
end
use_this_cfdg_file(i = nil) click to toggle source
#

use_this_cfdg_file

#
# File lib/image_paradise/gui/gtk3/cfdg_widget/cfdg_widget.rb, line 186
def use_this_cfdg_file(i = nil)
  case i
  when nil, 'default'
    i = return_random_cfdg
  end
  if i and File.exist?(i)
    # ===================================================================== #
    # Update the @show_this_cfdg_file variable.
    # ===================================================================== #
    @show_this_cfdg_file = i
    opn; e 'A .cfdg file was found at: '+sfile(i)+'.'
    @label_file_name_top.set_text(File.basename(i))
    @label_file_name_top.is_selectable
    dataset = File.read(i)
    n_lines = dataset.split("\n").size
    if n_lines < @numbered_lines.n_entries?
      # =================================================================== #
      # Chop it down in this case. This has a bug right now; I may have
      # to improve on this at a later time.
      # =================================================================== #
      new_amount_of_lines = @numbered_lines.n_entries? - n_lines
      @numbered_lines.hide_the_last_n_lines(
        new_amount_of_lines
      )
      @numbered_lines.set_use_n_lines(n_lines)
    end
    @text_buffer.set_text(dataset) # Sync the content onto the main buffer as well.
  end
end
Also aliased as: set_file_location