class RBT::GUI::Gtk::RecipeMaker
Constants
- ARRAY_AVAILABLE_PROGRAMS
#¶ ↑
ARRAY_AVAILABLE_PROGRAMS
¶ ↑#¶ ↑
- ARRAY_WITH_PROGRAM_DIRS
#¶ ↑
ARRAY_WITH_PROGRAM_DIRS
¶ ↑#¶ ↑
- AUTHOR_NAME
#¶ ↑
AUTHOR_NAME
¶ ↑#¶ ↑
- DEBUG
#¶ ↑
DEBUG
¶ ↑#¶ ↑
- DEFAULT_FONT_SIZE
#¶ ↑
DEFAULT_FONT_SIZE
¶ ↑#¶ ↑
- GUESS_NAME
#¶ ↑
GUESS_NAME
¶ ↑#¶ ↑
- HEIGHT
#¶ ↑
HEIGHT
¶ ↑#¶ ↑
- TITLE
#¶ ↑
TITLE
¶ ↑#¶ ↑
- USE_OVERRIDE
#¶ ↑
USE_OVERRIDE
¶ ↑#¶ ↑
- USE_THIS_FONT
#¶ ↑
USE_THIS_FONT
¶ ↑#¶ ↑
- USE_THIS_MONOSPACED_FONT
#¶ ↑
USE_THIS_MONOSPACED_FONT
¶ ↑#¶ ↑
- VERSION_RECIPE_MAKER
#¶ ↑
VERSION_RECIPE_MAKER
¶ ↑#¶ ↑
- WIDTH
#¶ ↑
WIDTH
¶ ↑#¶ ↑
Public Class Methods
height?()
click to toggle source
new( commandline_arguments = ARGV, run_already = true )
click to toggle source
run( i = ARGV )
click to toggle source
#¶ ↑
RBT::GUI::Gtk::RecipeMaker.run
¶ ↑
#¶ ↑
# File lib/rbt/gui/gtk/recipe_maker/recipe_maker.rb, line 645 def self.run( i = ARGV ) require 'gtk_paradise/run' _ = ::RBT::GUI::Gtk::RecipeMaker.new(i) r = ::Gtk.run r << _ r.automatic_size r.automatic_title r.enable_quick_exit r.resizable = true # <- This line was added due to a possible prior .maximize action. r.start_in_the_middle end
Public Instance Methods
append(i, append_this_string = "\n")
click to toggle source
border_size?()
click to toggle source
colourize_the_buffer()
click to toggle source
#¶ ↑
colourize_the_buffer
¶ ↑
This method will colourize the buffer at hand.
#¶ ↑
# File lib/rbt/gui/gtk/recipe_maker/recipe_maker.rb, line 304 def colourize_the_buffer _ = @text_buffer.text? @text_buffer.clear iter = @text_buffer.start_iter _.split(N).each { |line| case line when /^ last_update:/i @text_buffer.insert(iter, line+N,tags: ['bold','tomato']) # ===================================================================== # # === name: # ===================================================================== # when /name:$/, /^#{program_name?}:$/ @text_buffer.insert(iter, line+N,tags: ['bold','seagreen']) # ===================================================================== # # === program_name # ===================================================================== # when /program_name/ @text_buffer.insert(iter, line+N,tags: ['bold','darkblue']) # ===================================================================== # # === description # ===================================================================== # when /description/ @text_buffer.insert(iter, line+N,tags: ['bold','darkgreen']) # ===================================================================== # # === required_deps # ===================================================================== # when /required_deps/ @text_buffer.insert(iter, line+N,tags: ['bold','slateblue']) # ===================================================================== # # === true # ===================================================================== # when /true/, / t$/ line.gsub!(/ true/,'') line.gsub!(/ t$/,'') if line =~ / t$/ @text_buffer.insert(iter, line) @text_buffer.insert(iter, ' yes'+N, tags: ['bold','red']) # ===================================================================== # # === false # ===================================================================== # when /false/, / f$/ line.gsub!(/ false/,'') line.gsub!(/ f$/,'') if line =~ / f$/ @text_buffer.insert(iter, line) @text_buffer.insert(iter, ' no'+N, tags: ['bold','red']) else @text_buffer.insert(iter, line+N) end } end
connect_skeleton()
click to toggle source
#¶ ↑
connect_skeleton
(connect tag)¶ ↑
#¶ ↑
# File lib/rbt/gui/gtk/recipe_maker/recipe_maker.rb, line 228 def connect_skeleton abort_on_exception _ = default_top_bar _.title = 'Recipe maker - create a new .yml file, a recipe' _.css_class('pad0px') # ======================================================================= # # === Create the open-file-button # ======================================================================= # @button_open_file = button('Open File') @button_open_file.bblack1 @button_open_file.hint = 'Click on this button in order to '\ 'select a local .cfdg file to open.' @button_open_file.on_clicked { do_open_a_local_recipe } _.pack_start(@button_open_file) # ======================================================================= # # Add the about-dialog next. # ======================================================================= # button_about_dialog = button('About') button_about_dialog.bblack1 button_about_dialog.on_clicked { create_a_new_gtk_about_dialog } _.pack_end(button_about_dialog) minimal(_) hbox_for_the_name_of_the_program = gtk_hbox hbox_for_the_name_of_the_program.minimal( text('Input the name of the program:', 2) ) @entry_name_of_the_program = entry('htop') @entry_name_of_the_program.default_entry @entry_name_of_the_program.pad8px @entry_name_of_the_program.on_click_select_everything @entry_name_of_the_program.width_height(250, 50) @entry_name_of_the_program.center # @entry_name_of_the_program.set_completion( # ARRAY_AVAILABLE_PROGRAMS # ) if @entry_name_of_the_program.respond_to? :set_completion @entry_name_of_the_program.do_focus @entry_name_of_the_program.on_enter { do_assign_data_from_this_program } hbox_for_the_name_of_the_program.minimal(@entry_name_of_the_program, 2) # === button_assign_data_to_the_buffer button_assign_data_to_the_buffer = button('_Assign') button_assign_data_to_the_buffer.hint = 'Click this button in '\ 'order to assign to the text view below this widget. Note that '\ 'this will only work if that program is registered in the '\ 'RBT project.' button_assign_data_to_the_buffer.bblack1 button_assign_data_to_the_buffer.on_clicked { do_assign_data_from_this_program(@entry_name_of_the_program.text?) } hbox_for_the_name_of_the_program.minimal(button_assign_data_to_the_buffer, 2) hbox_for_the_name_of_the_program.minimal(@button_clear, 2) hbox_for_the_name_of_the_program.minimal(@button_traditional, 2) hbox_for_the_name_of_the_program.minimal(@button_download, 2) hbox_for_the_name_of_the_program.minimal(@button_save, 2) minimal(hbox_for_the_name_of_the_program, 4) minimal(@outermost_vbox, 1) end
create_a_new_gtk_about_dialog()
click to toggle source
#¶ ↑
create_a_new_gtk_about_dialog
¶ ↑
This creates our about dialog.
#¶ ↑
# File lib/rbt/gui/gtk/recipe_maker/recipe_maker.rb, line 186 def create_a_new_gtk_about_dialog @about_dialog = gtk_about_dialog @about_dialog.artists = [ AUTHOR_NAME ] @about_dialog.authors = [ AUTHOR_NAME ] @about_dialog.comments = 'This Script creates recipe information '\ 'which will be stored in sources.yaml' @about_dialog.copyright = 'None' @about_dialog.documenters = [''] @about_dialog.license = 'This program is licenced under the same license '\ 'as Ruby. There is one additional license part - which simply '\ 'encourages you to send bug reports to '\ 'me so that I can improve the program. ;-)' @about_dialog.name = 'Ruby::Gtk::ReciperMaker' # @about_dialog.translator_credits = "Here you can insert the credits of the translator.\n" @about_dialog.version = VERSION_RECIPE_MAKER @about_dialog.website = 'https://rubygems.org/gems/rbt' @about_dialog.website_label = 'RBT on rubygems.org' _ = ENV['IMG'].to_s+'/STD/UHR.png' if File.exist? _ @about_dialog.logo = GdkPixbuf::Pixbuf.new(file: _) end @about_dialog.popup end
create_skeleton()
click to toggle source
create_text_buffer()
click to toggle source
#¶ ↑
create_text_buffer
¶ ↑
This method will create the textedit stuff.
#¶ ↑
# File lib/rbt/gui/gtk/recipe_maker/recipe_maker.rb, line 590 def create_text_buffer @outermost_vbox = gtk_vbox @text_buffer = gtk_text_buffer @text_buffer = ::Gtk::TextBufferTags.create_default_tags(@text_buffer) @text_view = gtk_text_view(@text_buffer) # @text_view.it_can_not_be_edited @text_view.use_this_font = USE_THIS_MONOSPACED_FONT hbox = gtk_hbox _ = return_widget_with_line_numbers {{ n_lines: 40 }} _.use_this_font = USE_THIS_MONOSPACED_FONT hbox.minimal(_) hbox.maximal(@text_view) another_scrolled_window = gtk_scrolled_window(hbox) { :always } another_scrolled_window.set_policy(:never, :always) another_scrolled_window.bblack3 another_scrolled_window.width_height(720, 520) another_scrolled_window.css_class('pad5px') @outermost_vbox.minimal(another_scrolled_window, 1) end
do_assign_data_from_this_program( this_program = @entry_name_of_the_program.text? )
click to toggle source
#¶ ↑
do_assign_data_from_this_program
¶ ↑
#¶ ↑
# File lib/rbt/gui/gtk/recipe_maker/recipe_maker.rb, line 628 def do_assign_data_from_this_program( this_program = @entry_name_of_the_program.text? ) # ======================================================================= # # We have to check whether the program is included in RBT or # whether it is not. # ======================================================================= # if ::RBT.is_this_program_included?(this_program) mass_append(return_hash_from_sanitize_cookbook(this_program)) else e "The program `#{this_program}` is not included." end end
Also aliased as: update_the_main_buffer, update_the_main_buffer
do_open_a_local_recipe()
click to toggle source
#¶ ↑
do_open_a_local_recipe
(open tag)¶ ↑
#¶ ↑
# File lib/rbt/gui/gtk/recipe_maker/recipe_maker.rb, line 213 def do_open_a_local_recipe create_a_new_file_chooser_dialog(self) {{ start_dir: ::RBT.project_base_directory?+'yaml/cookbooks/', additional_directories: ::RBT.project_base_directory?+'yaml/cookbooks/' }} _ = ::Gtk.main_file? if _ and File.exist?(_) @entry_name_of_the_program.set_text(File.basename(_).delete_suffix('.yml')) do_assign_data_from_this_program end end
do_process_the_commandline_arguments()
click to toggle source
#¶ ↑
do_process_the_commandline_arguments
¶ ↑
For now the first argument given is assumed to be a program.
#¶ ↑
# File lib/rbt/gui/gtk/recipe_maker/recipe_maker.rb, line 380 def do_process_the_commandline_arguments _ = commandline_arguments? if _ and !_.empty? set_handle_this_program(_.first) end end
do_save_the_buffer( what = main_buffer?.text.to_s )
click to toggle source
download_program( url = RBT.return_url1_of(handle_which_program?) )
click to toggle source
#¶ ↑
download_program
¶ ↑
This will download a program by using our Download module.
#¶ ↑
# File lib/rbt/gui/gtk/recipe_maker/recipe_maker.rb, line 509 def download_program( url = RBT.return_url1_of(handle_which_program?) ) e "Downloading #{url} next, into the directory at #{sfancy(Dir.pwd)}:" Cliner.cliner { Wget.download(url) } end
main_buffer?()
click to toggle source
main_entry?()
click to toggle source
main_text_view?()
click to toggle source
mass_append(hash)
click to toggle source
#¶ ↑
mass_append
¶ ↑
The first argument to this method must be a Hash that contains all relevant data.
Whenever this method is used, the old text-buffer is cleared.
#¶ ↑
# File lib/rbt/gui/gtk/recipe_maker/recipe_maker.rb, line 538 def mass_append(hash) @text_buffer.clear # Clear the old content first. append(hash[:short_name].to_s+':') # This entry is mandatory. append(' # blfs:') append(' # -') unless hash[:binaries].empty? append(' binaries:') append(' - ') end append( ' # program_name_and_program_version: '+hash[:program_name_and_program_version] ) append(' configure_options: |') append(' enable-shared') if hash.has_key? :short_description append(' short_description: |') append(' '+hash[:short_description].to_s) end append(' description: |') append( ' '+RBT.word_wrap(hash[:description], 60) ) append(' extra_information: |') append(' '+hash[:extra_information].to_s) append(' licence: '+hash[:licence].to_s) append(' url1: '+hash[:url1].to_s) append(' url1: '+hash[:url2].to_s) append(' homepage: '+hash[:homepage].to_s) append(' git_url: '+hash[:git_url].to_s) if hash[:git_url] append(' prefix: '+hash[:prefix].to_s) append(' use_autogen: '+hash[:use_autogen].to_s) append(' keep_extracted: '+hash[:keep_extracted].to_s) append(' use_build_directory: '+hash[:use_build_directory].to_s) if hash[:tags] and hash[:tags].is_a? Array append(' tags:') hash[:tags].each {|inner_entry| append(' - '+inner_entry.to_s) } end append(' required_deps_on:') hash[:required_deps_on].each {|this_dependency| append(' - '+this_dependency) } append(' last_update: '+hash[:last_update].to_s) colourize_the_buffer end
padding?()
click to toggle source
program_name?()
click to toggle source
#¶ ↑
program_name?¶ ↑
#¶ ↑
# File lib/rbt/gui/gtk/recipe_maker/recipe_maker.rb, line 498 def program_name? @entry_name_of_the_program.text? end
Also aliased as: compile_this_program?, handle_which_program?, compile_this_program?, handle_which_program?
reset()
click to toggle source
#¶ ↑
reset (reset tag)¶ ↑
#¶ ↑
# File lib/rbt/gui/gtk/recipe_maker/recipe_maker.rb, line 133 def reset reset_the_internal_variables infer_the_namespace # ======================================================================= # # === @configuration # ======================================================================= # @configuration = [true, __dir__, namespace?] title_width_height_font(TITLE, WIDTH, HEIGHT, USE_THIS_FONT) use_gtk_paradise_project_css_file infer_the_size_automatically end
return_hash_from_sanitize_cookbook( for_this_program = @entry_name_of_the_program.text? )
click to toggle source
#¶ ↑
return_hash_from_sanitize_cookbook
¶ ↑
#¶ ↑
# File lib/rbt/gui/gtk/recipe_maker/recipe_maker.rb, line 405 def return_hash_from_sanitize_cookbook( for_this_program = @entry_name_of_the_program.text? ) _ = RBT::Cookbooks::SanitizeCookbook.new(for_this_program) binaries = _.binaries? hash = { short_name: _.short_name?, binaries: binaries, program_name_and_program_version: _.program_name_and_program_version?, short_description: _.short_description?, description: _.description?, extra_information: _.extra_information?, licence: _.licence?, url1: _.url1?, url2: _.url2?, homepage: _.homepage?, git_url: _.git_url?, prefix: _.prefix?, use_autogen: _.use_autogen?, keep_extracted: _.keep_extracted?, use_build_directory: _.use_build_directory?, tags: _.tags?, required_deps_on: _.required_deps_on?, last_update: _.last_update? } return hash end
run()
click to toggle source
set_handle_this_program(i)
click to toggle source
update_the_main_buffer( this_program = @entry_name_of_the_program.text? )
Alias for: do_assign_data_from_this_program