Class: PdfParadise::GUI::LibUI::ExtractAllImagesFromThisPdfFile
- Inherits:
-
Object
- Object
- PdfParadise::GUI::LibUI::ExtractAllImagesFromThisPdfFile
- Includes:
- LibuiParadise::Extensions
- Defined in:
- lib/pdf_paradise/gui/libui/extract_all_images_from_this_pdf_file/extract_all_images_from_this_pdf_file.rb
Overview
PdfParadise::GUI::LibUI::ExtractAllImagesFromThisPdfFile
Constant Summary collapse
- TITLE =
#
TITLE
#
'Extract all images from this .pdf file'
- WIDTH =
#
WIDTH
#
800
- HEIGHT =
#
HEIGHT
#
680
Instance Method Summary collapse
-
#create_skeleton ⇒ Object
# === create_skeleton (create tag, skeleton tag) ========================================================================= #.
-
#create_the_entries ⇒ Object
# === create_the_entries ========================================================================= #.
-
#do_extract_the_pdf_file(this_pdf_file = @entry_work_on_this_pdf_file.text?) ⇒ Object
# === do_extract_the_pdf_file ========================================================================= #.
-
#do_parse_the_commandline_arguments ⇒ Object
# === do_parse_the_commandline_arguments ========================================================================= #.
-
#initialize(optional_commandline_arguments = [], run_already = true) ⇒ ExtractAllImagesFromThisPdfFile
constructor
# === initialize.
-
#main_entry? ⇒ Boolean
# === main_entry? ========================================================================= #.
-
#reset ⇒ Object
# === reset (reset tag) ========================================================================= #.
-
#return_the_file_open_button ⇒ Object
# === return_the_file_open_button ========================================================================= #.
-
#run ⇒ Object
# === run ========================================================================= #.
-
#set_work_on_this_file(i) ⇒ Object
# === set_work_on_this_file ========================================================================= #.
Constructor Details
#initialize(optional_commandline_arguments = [], run_already = true) ⇒ ExtractAllImagesFromThisPdfFile
#
initialize
This class will not make use of ARGV by default, so you have to pass it in on your own.
#
48 49 50 51 52 53 54 55 |
# File 'lib/pdf_paradise/gui/libui/extract_all_images_from_this_pdf_file/extract_all_images_from_this_pdf_file.rb', line 48 def initialize( optional_commandline_arguments = [], run_already = true ) reset @commandline_arguments = [optional_commandline_arguments].flatten.compact run if run_already end |
Instance Method Details
#create_skeleton ⇒ Object
#
create_skeleton (create tag, skeleton tag)
#
71 72 73 74 75 76 77 |
# File 'lib/pdf_paradise/gui/libui/extract_all_images_from_this_pdf_file/extract_all_images_from_this_pdf_file.rb', line 71 def create_skeleton # ======================================================================= # # === @window # ======================================================================= # @window = ui_padded_main_window(title?, width?, height?, 0) create_the_entries end |
#create_the_entries ⇒ Object
#
create_the_entries
#
82 83 84 85 86 87 |
# File 'lib/pdf_paradise/gui/libui/extract_all_images_from_this_pdf_file/extract_all_images_from_this_pdf_file.rb', line 82 def create_the_entries # ======================================================================= # # === @entry_work_on_this_pdf_file # ======================================================================= # @entry_work_on_this_pdf_file = entry end |
#do_extract_the_pdf_file(this_pdf_file = @entry_work_on_this_pdf_file.text?) ⇒ Object
#
do_extract_the_pdf_file
#
208 209 210 211 212 213 214 215 216 217 |
# File 'lib/pdf_paradise/gui/libui/extract_all_images_from_this_pdf_file/extract_all_images_from_this_pdf_file.rb', line 208 def do_extract_the_pdf_file( this_pdf_file = @entry_work_on_this_pdf_file.text? ) @_.do_extract_the_pdf_file(this_pdf_file) LibuiParadise.( 'If everything went fine then you should now be able '\ 'to see all extracted images in the '\ 'directory `'+return_pwd+'`.' ) end |
#do_parse_the_commandline_arguments ⇒ Object
#
do_parse_the_commandline_arguments
#
187 188 189 190 191 192 193 194 195 196 |
# File 'lib/pdf_paradise/gui/libui/extract_all_images_from_this_pdf_file/extract_all_images_from_this_pdf_file.rb', line 187 def do_parse_the_commandline_arguments _ = @commandline_arguments if _ and _.is_a?(Array) and !_.empty? _.each {|entry| if File.exist? entry set_work_on_this_file(entry) end } end end |
#main_entry? ⇒ Boolean
#
main_entry?
#
92 93 94 |
# File 'lib/pdf_paradise/gui/libui/extract_all_images_from_this_pdf_file/extract_all_images_from_this_pdf_file.rb', line 92 def main_entry? @entry_work_on_this_pdf_file end |
#reset ⇒ Object
#
reset (reset tag)
#
60 61 62 63 64 65 66 |
# File 'lib/pdf_paradise/gui/libui/extract_all_images_from_this_pdf_file/extract_all_images_from_this_pdf_file.rb', line 60 def reset title_width_height(TITLE, WIDTH, HEIGHT) # ======================================================================= # # === @_ # ======================================================================= # @_ = PdfParadise::ExtractAllImagesFromThisPdfFile.new(:do_not_run_yet) end |
#return_the_file_open_button ⇒ Object
#
return_the_file_open_button
#
99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/pdf_paradise/gui/libui/extract_all_images_from_this_pdf_file/extract_all_images_from_this_pdf_file.rb', line 99 def = ('Open file') .on_clicked { begin filename = ui_open_file(@window).to_s # This is the part that will open a local file. if filename and !filename.empty? filename = File.absolute_path(filename) main_entry?.set_text(filename) end rescue Exception end } return end |
#run ⇒ Object
#
run
#
117 118 119 120 121 122 123 124 125 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 |
# File 'lib/pdf_paradise/gui/libui/extract_all_images_from_this_pdf_file/extract_all_images_from_this_pdf_file.rb', line 117 def run log_dir = PdfParadise.log_dir? unless File.directory? log_dir begin FileUtils.mkdir_p(log_dir) rescue LoadError; end end PdfParadise.cd_to_the_log_directory create_skeleton_then_connect_skeleton outer_vbox = padded_vbox # ======================================================================= # # First add the two buttons on top: # ======================================================================= # = ('Extract the images') .on_clicked { do_extract_the_pdf_file } outer_vbox.add_hsep grid = ui_padded_grid # widget, left, top, xspan, yspan, hexpand, halign, vexpand, valign grid.ui_grid_append(text('Work on this .pdf file → '), 0, 0, 1, 1, 0, 0.5, 0, 0) grid.ui_grid_append(main_entry?, 1, 0, 2, 1, 1, 0.5, 0, 0) grid.hash_grid( , left: 0, top: 1, xspan: 1, yspan: 1, hexpand: 0, halign: 0.5, vexpand: 0, valign: 0 ) grid.hash_grid( , left: 1, top: 1, xspan: 1, yspan: 1, hexpand: 0, halign: 0.5, vexpand: 0, valign: 0 ) grid.hash_grid( text('Current working directory: '+return_pwd), left: 2, top: 1, xspan: 1, yspan: 1, hexpand: 0, halign: 0.5, vexpand: 0, valign: 0 ) outer_vbox.minimal(grid, 0) outer_vbox.add_hsep outer_vbox.minimal() outer_vbox.add_hsep ::LibuiParadise.set_main_window(@window) do_parse_the_commandline_arguments @window.add(outer_vbox) @window.intelligent_exit end |
#set_work_on_this_file(i) ⇒ Object
#
set_work_on_this_file
#
201 202 203 |
# File 'lib/pdf_paradise/gui/libui/extract_all_images_from_this_pdf_file/extract_all_images_from_this_pdf_file.rb', line 201 def set_work_on_this_file(i) @entry_work_on_this_pdf_file.set_text(i) end |