Module: PdfParadise::GUI::Gtk::SplitPdfFileModule
- Includes:
- Gtk::BaseModule
- Included in:
- SplitPdfFile
- Defined in:
- lib/pdf_paradise/gui/shared_code/split_pdf_file/split_pdf_file_module.rb
Constant Summary collapse
- NAMESPACE =
#
NAMESPACE
#
inspect
- TITLE =
#
TITLE
#
'Split .pdf files'
- WIDTH =
#
WIDTH
#
1400
- HEIGHT =
#
HEIGHT
#
700
- ARRAY_ADD_THESE_SHORTCUT_FOLDERS =
#
ARRAY_ADD_THESE_SHORTCUT_FOLDERS
#
[ # "C:\\", # "C:\\ingrid", # '/ingrid' ]
Class Method Summary collapse
-
.run ⇒ Object
# === PdfParadise::GUI::Gtk::SplitPdfFileModule.run ========================================================================= #.
Instance Method Summary collapse
-
#add_the_split_pdf_file_button ⇒ Object
# === add_the_split_pdf_file_button ========================================================================= #.
-
#border_size? ⇒ Boolean
# === border_size? ========================================================================= #.
-
#connect_skeleton ⇒ Object
# === connect_skeleton ========================================================================= #.
-
#create_buttons ⇒ Object
# === create_buttons (buttons tag).
-
#create_skeleton ⇒ Object
# === create_skeleton ========================================================================= #.
-
#create_the_entries ⇒ Object
# === create_the_entries (entries tag) ========================================================================= #.
-
#do_split_the_pdf_file ⇒ Object
# === do_split_the_pdf_file (split tag).
-
#initialize(optional_file = nil, run_already = true) ⇒ Object
# === initialize ========================================================================= #.
-
#open_file_chooser_dialog ⇒ Object
# === open_file_chooser_dialog ========================================================================= #.
-
#padding? ⇒ Boolean
# === padding? ========================================================================= #.
-
#reset ⇒ Object
# === reset ========================================================================= #.
-
#run ⇒ Object
# === run ========================================================================= #.
-
#store_in_which_directory? ⇒ Boolean
# === store_in_which_directory?.
Class Method Details
.run ⇒ Object
#
PdfParadise::GUI::Gtk::SplitPdfFileModule.run
#
282 283 284 285 286 287 288 289 290 291 292 293 |
# File 'lib/pdf_paradise/gui/shared_code/split_pdf_file/split_pdf_file_module.rb', line 282 def self.run require 'gtk_paradise/run' _ = ::PdfParadise::GUI::Gtk::SplitPdfFile.new r = ::Gtk.run r << _ r.set_size_request( _.width?, _.height? ) r.enable_quick_exit r.top_left_then_run end |
Instance Method Details
#add_the_split_pdf_file_button ⇒ Object
#
add_the_split_pdf_file_button
#
100 101 102 103 104 |
# File 'lib/pdf_paradise/gui/shared_code/split_pdf_file/split_pdf_file_module.rb', line 100 def minimal( , 2 ) end |
#border_size? ⇒ Boolean
#
border_size?
#
116 117 118 |
# File 'lib/pdf_paradise/gui/shared_code/split_pdf_file/split_pdf_file_module.rb', line 116 def border_size? 2 end |
#connect_skeleton ⇒ Object
#
connect_skeleton
#
236 237 238 |
# File 'lib/pdf_paradise/gui/shared_code/split_pdf_file/split_pdf_file_module.rb', line 236 def connect_skeleton abort_on_exception end |
#create_buttons ⇒ Object
#
create_buttons (buttons tag)
This method can be used to create all buttons in this small application.
#
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/pdf_paradise/gui/shared_code/split_pdf_file/split_pdf_file_module.rb', line 152 def = ('Choose a file') .on_hover(:lightgreen) .on_clicked { open_file_chooser_dialog } .fancy_tooltip = 'Select this to <b>choose</b> '\ ' a local .pdf file.' = ('_Split the pdf file') .clear_background .on_hover(:lightgreen) .hint = 'Click on this button to actually <b>split the .pdf file</b> at hand.' .on_clicked { do_split_the_pdf_file } end |
#create_skeleton ⇒ Object
#
create_skeleton
#
123 124 125 126 127 |
# File 'lib/pdf_paradise/gui/shared_code/split_pdf_file/split_pdf_file_module.rb', line 123 def create_skeleton @hbox1 = create_vbox create_the_entries end |
#create_the_entries ⇒ Object
#
create_the_entries (entries tag)
#
132 133 134 135 136 137 138 139 140 141 142 143 144 145 |
# File 'lib/pdf_paradise/gui/shared_code/split_pdf_file/split_pdf_file_module.rb', line 132 def create_the_entries @entry_for_the_path_to_the_pdf_file = create_entry('') @entry_for_the_path_to_the_pdf_file.on_click_event { :highlight_text } # ======================================================================= # # Determine where the individual .pdf files are to be kept: # ======================================================================= # _ = return_pwd _ = '/Depot/j/'.dup if File.directory? '/Depot/j/' @entry_for_the_directory_where_we_will_generate_the_individual_pdf_files_into = gtk_entry( _ ) end |
#do_split_the_pdf_file ⇒ Object
#
do_split_the_pdf_file (split tag)
This is the main action of this class.
#
175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/pdf_paradise/gui/shared_code/split_pdf_file/split_pdf_file_module.rb', line 175 def do_split_the_pdf_file target_file = @entry_for_the_path_to_the_pdf_file.text? if File.exist?(target_file) e 'Now splitting the .pdf file' PdfParadise.split_this_pdf_file( target_file, :default, store_in_which_directory? ) else e 'No file was found at the location '+target_file+'.' end end |
#initialize(optional_file = nil, run_already = true) ⇒ Object
#
initialize
#
63 64 65 66 67 68 69 70 |
# File 'lib/pdf_paradise/gui/shared_code/split_pdf_file/split_pdf_file_module.rb', line 63 def initialize( optional_file = nil, run_already = true ) super(:vertical) reset run if run_already end |
#open_file_chooser_dialog ⇒ Object
#
open_file_chooser_dialog
#
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
# File 'lib/pdf_paradise/gui/shared_code/split_pdf_file/split_pdf_file_module.rb', line 199 def open_file_chooser_dialog @file_chooser_dialog = create_file_chooser_dialog('Open File', self, ::Gtk::FileChooser::ACTION_OPEN, nil, [::Gtk::Stock::CANCEL, ::Gtk::Dialog::RESPONSE_CANCEL], [::Gtk::Stock::OPEN, ::Gtk::Dialog::RESPONSE_ACCEPT] ) if File.directory? '/Depot/j/' @file_chooser_dialog.current_folder = '/Depot/j/' else @file_chooser_dialog.current_folder = return_pwd end # @file_chooser_dialog.add_shortcut_folder(return_pwd) # ^^^ already exists as shortcut. begin ARRAY_ADD_THESE_SHORTCUT_FOLDERS.each {|this_directory| @file_chooser_dialog.add_shortcut_folder(this_directory) } rescue; end if File.directory? '/home/Temp/' @file_chooser_dialog.add_directory('/home/Temp/') end @file_chooser_dialog.show_hidden = true # Do show hidden files. = ('_Extra button') .signal_connect(:clicked) { e ' > Extra button was clicked' } @file_chooser_dialog. = case @file_chooser_dialog.run when ::Gtk::Dialog::RESPONSE_ACCEPT filename = @file_chooser_dialog.filename.to_s @entry_for_the_path_to_the_pdf_file.set_text(filename) end @file_chooser_dialog.destroy end |
#padding? ⇒ Boolean
#
padding?
#
109 110 111 |
# File 'lib/pdf_paradise/gui/shared_code/split_pdf_file/split_pdf_file_module.rb', line 109 def padding? 2 end |
#reset ⇒ Object
#
reset
#
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/pdf_paradise/gui/shared_code/split_pdf_file/split_pdf_file_module.rb', line 75 def reset reset_the_internal_variables # ======================================================================= # # === @configuration # ======================================================================= # @configuration = [true, __dir__, NAMESPACE] set_use_this_font(:dejavu_condensed_24) # ======================================================================= # # === @title # ======================================================================= # @title = TITLE # ======================================================================= # # === @width # ======================================================================= # set_width(WIDTH) # ======================================================================= # # === @height # ======================================================================= # set_height(HEIGHT) use_project_css_file end |
#run ⇒ Object
#
run
#
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 |
# File 'lib/pdf_paradise/gui/shared_code/split_pdf_file/split_pdf_file_module.rb', line 243 def run create_skeleton connect_skeleton gtk_text_for_the_gtk_entry_denoting_into_which_directory_we_will_generate_the_pdf_files = gtk_label( 'Set the path to the directory where these .pdf files will be kept below:' ) gtk_text = create_label( 'Set the path to the .pdf file below this text.' ) {{ tooltip: 'You need to supply the path to the .pdf file '\ 'into the input field on the right side.' }} @hbox1.minimal(gtk_text) @hbox1.maximal(@entry_for_the_path_to_the_pdf_file) # ======================================================================= # # And add the file-chooser button: # ======================================================================= # @hbox1.minimal() maximal(@hbox1, 1) @vbox_denoting_where_the_individual_pdf_files_are_kept = gtk_vbox @vbox_denoting_where_the_individual_pdf_files_are_kept.minimal( gtk_text_for_the_gtk_entry_denoting_into_which_directory_we_will_generate_the_pdf_files, 1 ) @vbox_denoting_where_the_individual_pdf_files_are_kept.minimal( @entry_for_the_directory_where_we_will_generate_the_individual_pdf_files_into, 1 ) minimal( @vbox_denoting_where_the_individual_pdf_files_are_kept, 0 ) show_all end |
#store_in_which_directory? ⇒ Boolean
#
store_in_which_directory?
This method must return a String, hence why the method .text is used.
#
192 193 194 |
# File 'lib/pdf_paradise/gui/shared_code/split_pdf_file/split_pdf_file_module.rb', line 192 def store_in_which_directory? @entry_for_the_directory_where_we_will_generate_the_individual_pdf_files_into.text end |