pdf_paradise 0.1.66

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of pdf_paradise might be problematic. Click here for more details.

Files changed (110) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +705 -0
  3. data/bin/automatic_pdf_title +7 -0
  4. data/bin/combine_these_pdf_pages +7 -0
  5. data/bin/compress_via_hexapdf +7 -0
  6. data/bin/convert_markdown_to_pdf +7 -0
  7. data/bin/convert_pdf_to_text +7 -0
  8. data/bin/delete_first_page_of_this_pdf_file +7 -0
  9. data/bin/merge_then_open +7 -0
  10. data/bin/n_pages +10 -0
  11. data/bin/open_main_pdf +7 -0
  12. data/bin/pdf_paradise +9 -0
  13. data/bin/set_main_book +7 -0
  14. data/bin/set_title_of_this_pdf_file +15 -0
  15. data/doc/README.gen +662 -0
  16. data/doc/todo/todo.md +7 -0
  17. data/lib/pdf_paradise/base/base.rb +239 -0
  18. data/lib/pdf_paradise/base/colours.rb +36 -0
  19. data/lib/pdf_paradise/commandline/commandline.rb +101 -0
  20. data/lib/pdf_paradise/commandline/help.rb +73 -0
  21. data/lib/pdf_paradise/commandline/menu.rb +142 -0
  22. data/lib/pdf_paradise/compress/compress_via_hexapdf.rb +27 -0
  23. data/lib/pdf_paradise/compress_this_pdf_file.rb +87 -0
  24. data/lib/pdf_paradise/constants/constants.rb +76 -0
  25. data/lib/pdf_paradise/convert_text_to_pdf.rb +94 -0
  26. data/lib/pdf_paradise/css/project.css +17 -0
  27. data/lib/pdf_paradise/djvu_to_pdf.rb +85 -0
  28. data/lib/pdf_paradise/gui/README.md +6 -0
  29. data/lib/pdf_paradise/gui/fox/split_pdf_file.rb +77 -0
  30. data/lib/pdf_paradise/gui/gtk2/delete_the_first_or_the_last_page_of_this_pdf_file/delete_the_first_or_the_last_page_of_this_pdf_file.rb +39 -0
  31. data/lib/pdf_paradise/gui/gtk2/pdf_viewer/pdf_viewer.rb +34 -0
  32. data/lib/pdf_paradise/gui/gtk2/split_pdf_file/split_pdf_file.rb +34 -0
  33. data/lib/pdf_paradise/gui/gtk2/statistics_widget/statistics_widget.rb +34 -0
  34. data/lib/pdf_paradise/gui/gtk2/to_pdf/to_pdf.rb +32 -0
  35. data/lib/pdf_paradise/gui/gtk3/controller/controller.rb +212 -0
  36. data/lib/pdf_paradise/gui/gtk3/convert_pdf_to_text/convert_pdf_to_text.rb +34 -0
  37. data/lib/pdf_paradise/gui/gtk3/delete_the_first_or_the_last_page_of_this_pdf_file/delete_the_first_or_the_last_page_of_this_pdf_file.rb +39 -0
  38. data/lib/pdf_paradise/gui/gtk3/pdf_viewer/pdf_viewer.rb +34 -0
  39. data/lib/pdf_paradise/gui/gtk3/split_pdf_file/split_pdf_file.rb +34 -0
  40. data/lib/pdf_paradise/gui/gtk3/statistics_widget/statistics_widget.rb +34 -0
  41. data/lib/pdf_paradise/gui/gtk3/to_pdf/to_pdf.rb +32 -0
  42. data/lib/pdf_paradise/gui/libui/extract_all_images_from_this_pdf_file/extract_all_images_from_this_pdf_file.rb +223 -0
  43. data/lib/pdf_paradise/gui/libui/statistics_widget/statistics_widget.rb +233 -0
  44. data/lib/pdf_paradise/gui/shared_code/convert_pdf_to_text/convert_pdf_to_text_module.rb +277 -0
  45. data/lib/pdf_paradise/gui/shared_code/delete_the_first_or_the_last_page_of_this_pdf_file/delete_the_first_or_the_last_page_of_this_pdf_file_module.rb +443 -0
  46. data/lib/pdf_paradise/gui/shared_code/pdf_viewer/pdf_viewer.css +5 -0
  47. data/lib/pdf_paradise/gui/shared_code/pdf_viewer/pdf_viewer_module.rb +284 -0
  48. data/lib/pdf_paradise/gui/shared_code/split_pdf_file/split_pdf_file.css +0 -0
  49. data/lib/pdf_paradise/gui/shared_code/split_pdf_file/split_pdf_file_module.rb +294 -0
  50. data/lib/pdf_paradise/gui/shared_code/statistics_widget/statistics_widget_module.rb +349 -0
  51. data/lib/pdf_paradise/gui/shared_code/to_pdf/to_pdf_module.rb +281 -0
  52. data/lib/pdf_paradise/hexapdf/001_rainbow_pattern_example.rb +0 -0
  53. data/lib/pdf_paradise/hexapdf/hexapdf.rb +123 -0
  54. data/lib/pdf_paradise/images/PDF_PARADISE_LOGO.png +0 -0
  55. data/lib/pdf_paradise/main_pdf/main_pdf.rb +444 -0
  56. data/lib/pdf_paradise/merge_pdf/menu.rb +63 -0
  57. data/lib/pdf_paradise/merge_pdf/merge_pdf.rb +306 -0
  58. data/lib/pdf_paradise/merge_pdf_namespace.rb +9 -0
  59. data/lib/pdf_paradise/merge_then_open/merge_then_open.rb +105 -0
  60. data/lib/pdf_paradise/pdf_file_n_total_pages.rb +249 -0
  61. data/lib/pdf_paradise/prawn_addons/README.md +2 -0
  62. data/lib/pdf_paradise/prawn_addons/prawn_addons.rb +17 -0
  63. data/lib/pdf_paradise/project/project.rb +22 -0
  64. data/lib/pdf_paradise/remove_pdf_password.rb +391 -0
  65. data/lib/pdf_paradise/requires/batch_require_toplevel_files.rb +22 -0
  66. data/lib/pdf_paradise/requires/colours.rb +7 -0
  67. data/lib/pdf_paradise/requires/colours_and_esystem_and_save_file_and_fileutils_and_opn.rb +11 -0
  68. data/lib/pdf_paradise/requires/esystem_and_colours.rb +10 -0
  69. data/lib/pdf_paradise/requires/esystem_and_opn_and_colours.rb +8 -0
  70. data/lib/pdf_paradise/requires/require_the_whole_project.rb +28 -0
  71. data/lib/pdf_paradise/requires/require_utility_scripts.rb +9 -0
  72. data/lib/pdf_paradise/set_main_book.rb +156 -0
  73. data/lib/pdf_paradise/set_pdf_title.rb +220 -0
  74. data/lib/pdf_paradise/sinatra/embeddable_interface.rb +318 -0
  75. data/lib/pdf_paradise/toplevel_methods/automatic_pdf_title.rb +55 -0
  76. data/lib/pdf_paradise/toplevel_methods/convert_epub_to_pdf.rb +27 -0
  77. data/lib/pdf_paradise/toplevel_methods/convert_markdown_to_pdf.rb +45 -0
  78. data/lib/pdf_paradise/toplevel_methods/convert_ppt_to_pdf.rb +35 -0
  79. data/lib/pdf_paradise/toplevel_methods/e.rb +16 -0
  80. data/lib/pdf_paradise/toplevel_methods/esystem.rb +19 -0
  81. data/lib/pdf_paradise/toplevel_methods/misc.rb +76 -0
  82. data/lib/pdf_paradise/toplevel_methods/number_pages.rb +38 -0
  83. data/lib/pdf_paradise/toplevel_methods/opened_pdf_files.rb +221 -0
  84. data/lib/pdf_paradise/toplevel_methods/query_pdf_title.rb +191 -0
  85. data/lib/pdf_paradise/toplevel_methods/reduce_size_of_this_pdf_file.rb +46 -0
  86. data/lib/pdf_paradise/toplevel_methods/roebe.rb +17 -0
  87. data/lib/pdf_paradise/toplevel_methods/rotate_pdf_file.rb +143 -0
  88. data/lib/pdf_paradise/toplevel_methods/to_pdf.rb +38 -0
  89. data/lib/pdf_paradise/utility_scripts/README.md +3 -0
  90. data/lib/pdf_paradise/utility_scripts/combine_these_pdf_pages.rb +118 -0
  91. data/lib/pdf_paradise/utility_scripts/convert_pdf_to_text.rb +175 -0
  92. data/lib/pdf_paradise/utility_scripts/delete_first_page_of_this_pdf_file.rb +221 -0
  93. data/lib/pdf_paradise/utility_scripts/delete_last_page_of_this_pdf_file.rb +180 -0
  94. data/lib/pdf_paradise/utility_scripts/delete_this_page_of_this_pdf_file.rb +329 -0
  95. data/lib/pdf_paradise/utility_scripts/extract_all_images_from_this_pdf_file.rb +129 -0
  96. data/lib/pdf_paradise/utility_scripts/extract_pdf_page.rb +283 -0
  97. data/lib/pdf_paradise/utility_scripts/pdf_optimizer.rb +111 -0
  98. data/lib/pdf_paradise/utility_scripts/pdf_statistics.rb +148 -0
  99. data/lib/pdf_paradise/utility_scripts/pdf_to_html.rb +75 -0
  100. data/lib/pdf_paradise/utility_scripts/remove_images.rb +110 -0
  101. data/lib/pdf_paradise/utility_scripts/split_pdf.rb +340 -0
  102. data/lib/pdf_paradise/utility_scripts/to_qdf.rb +82 -0
  103. data/lib/pdf_paradise/version/version.rb +19 -0
  104. data/lib/pdf_paradise/www/README.md +2 -0
  105. data/lib/pdf_paradise/www/sinatra/app.rb +276 -0
  106. data/lib/pdf_paradise/yaml/working_on_these_pdf_files.yml +4 -0
  107. data/lib/pdf_paradise.rb +5 -0
  108. data/pdf_paradise.gemspec +61 -0
  109. data/test/testing_pdf_paradise.rb +9 -0
  110. metadata +219 -0
@@ -0,0 +1,284 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === PdfParadise::GUI::Gtk::PdfViewerModule
6
+ #
7
+ # This widget can be used to "view" a .pdf file. Right now we will
8
+ # convert it to a .pdf file, then simply display the text.
9
+ # =========================================================================== #
10
+ # require 'pdf_paradise/gui/shared_code/pdf_viewer/pdf_viewer_module.rb'
11
+ # include ::PdfParadise::GUI::Gtk::PdfViewerModule
12
+ # =========================================================================== #
13
+ module PdfParadise
14
+
15
+ module GUI
16
+
17
+ module Gtk
18
+
19
+ module PdfViewerModule
20
+
21
+ require 'gtk_paradise/requires/require_the_base_module.rb'
22
+ include ::Gtk::BaseModule
23
+
24
+ # ========================================================================= #
25
+ # === NAMESPACE
26
+ # ========================================================================= #
27
+ NAMESPACE = inspect
28
+
29
+ # ========================================================================= #
30
+ # === TITLE
31
+ # ========================================================================= #
32
+ TITLE = 'View .pdf files'
33
+
34
+ # ========================================================================= #
35
+ # === WIDTH
36
+ # ========================================================================= #
37
+ WIDTH = 1600
38
+
39
+ # ========================================================================= #
40
+ # === HEIGHT
41
+ # ========================================================================= #
42
+ HEIGHT = 600
43
+
44
+ # ========================================================================= #
45
+ # === initialize
46
+ # ========================================================================= #
47
+ def initialize(
48
+ commandline_arguments = ARGV,
49
+ run_already = true
50
+ )
51
+ super(:vertical)
52
+ reset
53
+ set_commandline_arguments(
54
+ commandline_arguments
55
+ )
56
+ run if run_already
57
+ end
58
+
59
+ # ========================================================================= #
60
+ # === reset
61
+ # ========================================================================= #
62
+ def reset
63
+ reset_the_internal_variables
64
+ # ======================================================================= #
65
+ # === @configuration
66
+ # ======================================================================= #
67
+ @configuration = [true, __dir__, NAMESPACE]
68
+ # ======================================================================= #
69
+ # === @parent_widget
70
+ # ======================================================================= #
71
+ @parent_widget = nil
72
+ # ======================================================================= #
73
+ # === @title
74
+ # ======================================================================= #
75
+ @title = TITLE
76
+ # ======================================================================= #
77
+ # === @width
78
+ # ======================================================================= #
79
+ set_width(WIDTH)
80
+ # ======================================================================= #
81
+ # === @height
82
+ # ======================================================================= #
83
+ set_height(HEIGHT)
84
+ set_use_this_font(:dejavu_condensed_23)
85
+ use_project_css_file
86
+ infer_the_size_automatically
87
+ end
88
+
89
+ # ========================================================================= #
90
+ # === padding?
91
+ # ========================================================================= #
92
+ def padding?
93
+ 2
94
+ end
95
+
96
+ # ========================================================================= #
97
+ # === border_size?
98
+ # ========================================================================= #
99
+ def border_size?
100
+ 2
101
+ end
102
+
103
+ # ========================================================================= #
104
+ # === create_skeleton
105
+ # ========================================================================= #
106
+ def create_skeleton
107
+ @text_buffer = gtk_text_buffer
108
+ create_the_text_view
109
+ create_the_buttons
110
+ create_the_scrolled_window
111
+ end
112
+
113
+ # ========================================================================= #
114
+ # === create_the_scrolled_window
115
+ # ========================================================================= #
116
+ def create_the_scrolled_window
117
+ @scrolled_window = gtk_scrolled_window(@text_view) { :always_show_the_scrollbars }
118
+ @scrolled_window.css_class('bblack1')
119
+ end
120
+
121
+ # ========================================================================= #
122
+ # === create_the_text_view
123
+ # ========================================================================= #
124
+ def create_the_text_view
125
+ @text_view = gtk_text_view(@text_buffer)
126
+ end
127
+
128
+ # ========================================================================= #
129
+ # === do_the_conversion
130
+ #
131
+ # This method will do the actual file-conversion.
132
+ # ========================================================================= #
133
+ def do_the_conversion(
134
+ i = @entry_this_is_the_pdf_file.text.to_s
135
+ )
136
+ if File.exist? i
137
+ location_of_the_newly_generated_file = '/Depot/j/converted_pdf_file.md'
138
+ # ===================================================================== #
139
+ # Next, do the conversion.
140
+ # ===================================================================== #
141
+ `pdftotext #{i} #{location_of_the_newly_generated_file}`
142
+ if File.exist? location_of_the_newly_generated_file
143
+ dataset = File.read(location_of_the_newly_generated_file).to_s
144
+ set_text_in_the_main_buffer(dataset)
145
+ else
146
+ e 'No file exists at '+location_of_the_newly_generated_file+'.'
147
+ end
148
+ else
149
+ e 'No file exists at '+::Colours.sfile(i)+'.'
150
+ end
151
+ end; alias trigger_the_conversion do_the_conversion # === trigger_the_conversion
152
+
153
+ # ========================================================================= #
154
+ # === create_the_buttons
155
+ # ========================================================================= #
156
+ def create_the_buttons
157
+ @button_view_this_pdf_file = gtk_button('View this .pdf file')
158
+ @button_view_this_pdf_file.set_name('button1')
159
+ @button_view_this_pdf_file.hint = 'Click on '\
160
+ 'this button to view the content of the .pdf file.'
161
+ @button_view_this_pdf_file.on_clicked {
162
+ do_the_conversion(@entry_this_is_the_pdf_file.text.to_s)
163
+ }
164
+ @button_clear = gtk_button('Clear')
165
+ @button_clear.hint = 'Click this button '\
166
+ 'to clear the buffer shown below.'
167
+ @button_clear.on_clicked {
168
+ @text_buffer.clear
169
+ }
170
+ @button_file_picker = gtk_button('_Pick a file')
171
+ @button_file_picker.hint = 'Pick a local .pdf file.'
172
+ @button_file_picker.on_clicked {
173
+ do_pick_a_file
174
+ }
175
+ end
176
+
177
+ # ========================================================================= #
178
+ # === connect_skeleton (connect tag)
179
+ # ========================================================================= #
180
+ def connect_skeleton
181
+ abort_on_exception
182
+ # ======================================================================= #
183
+ # === @entry_this_is_the_pdf_file
184
+ # ======================================================================= #
185
+ @entry_this_is_the_pdf_file = gtk_entry(
186
+ '/Depot/j/test.pdf'
187
+ )
188
+ @entry_this_is_the_pdf_file.yellow_background
189
+ top_hbox = gtk_hbox
190
+ top_hbox.maximal(@entry_this_is_the_pdf_file, 3)
191
+ top_hbox.maximal(@button_view_this_pdf_file, 3)
192
+ top_hbox.minimal(@button_file_picker, 3)
193
+ top_hbox.minimal(@button_clear, 3)
194
+ minimal(top_hbox)
195
+ maximal(@scrolled_window)
196
+ end
197
+
198
+ # ========================================================================= #
199
+ # === set_parent_widget
200
+ # ========================================================================= #
201
+ def set_parent_widget(i)
202
+ @parent_widget = i
203
+ end
204
+
205
+ # ========================================================================= #
206
+ # === set_text_in_the_main_buffer
207
+ # ========================================================================= #
208
+ def set_text_in_the_main_buffer(i)
209
+ i = i.to_s.dup.strip
210
+ i.delete!('® ') # Do a bit ad-hoc deletion.
211
+ @text_buffer.set_text(i.to_s.dup)
212
+ GC.start
213
+ end
214
+
215
+ # ========================================================================= #
216
+ # === set_this_as_the_active_pdf_file
217
+ # ========================================================================= #
218
+ def set_this_as_the_active_pdf_file(i)
219
+ i = i.to_s.dup
220
+ @entry_this_is_the_pdf_file.set_text(i)
221
+ end
222
+
223
+ # ========================================================================= #
224
+ # === do_pick_a_file
225
+ # ========================================================================= #
226
+ def do_pick_a_file
227
+ filename = ::Gtk.select_file(@parent_widget) {{
228
+ current_folder: '/Depot/j/',
229
+ show_hidden: true,
230
+ add_these_shortcut_folders: ['/Depot/j/'],
231
+ use_this_file_filter: '*.pdf'
232
+ }}
233
+ if File.exist? filename
234
+ set_this_as_the_active_pdf_file_then_trigger_the_conversion(filename)
235
+ end
236
+ end
237
+
238
+ # ========================================================================= #
239
+ # === set_this_as_the_active_pdf_file_then_trigger_the_conversion
240
+ # ========================================================================= #
241
+ def set_this_as_the_active_pdf_file_then_trigger_the_conversion(
242
+ filename
243
+ )
244
+ set_this_as_the_active_pdf_file(filename)
245
+ trigger_the_conversion
246
+ end
247
+
248
+ # ========================================================================= #
249
+ # === run
250
+ # ========================================================================= #
251
+ def run
252
+ create_skeleton_then_connect_skeleton
253
+ menu
254
+ end
255
+
256
+ # ========================================================================= #
257
+ # === menu (menu tag)
258
+ # ========================================================================= #
259
+ def menu(
260
+ i = commandline_arguments?
261
+ )
262
+ if i.is_a? Array
263
+ i.each {|entry| menu(entry) }
264
+ else
265
+ if File.exist? i
266
+ set_this_as_the_active_pdf_file_then_trigger_the_conversion(i)
267
+ end
268
+ end
269
+ end
270
+
271
+ # ========================================================================= #
272
+ # === PdfParadise::GUI::Gtk::PdfViewerModule.run
273
+ # ========================================================================= #
274
+ def self.run
275
+ require 'gtk_paradise/run'
276
+ _ = ::PdfParadise::GUI::Gtk::PdfViewer.new
277
+ r = ::Gtk.run
278
+ _.set_parent_widget(r)
279
+ r << _
280
+ r.automatic_title_and_size
281
+ r.top_left_then_run
282
+ end
283
+
284
+ end; end; end; end
@@ -0,0 +1,294 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === PdfParadise::GUI::Gtk::SplitPdfFileModule
6
+ #
7
+ # This is a simple gtk-GUI wrapper over the split-pdf functionality
8
+ # of the PdfParadise project. The main box is a VBox (vertical box).
9
+ # =========================================================================== #
10
+ # require 'pdf_paradise/gui/shared_code/split_pdf_file/split_pdf_file_module.rb'
11
+ # include ::PdfParadise::GUI::Gtk::SplitPdfFileModule
12
+ # =========================================================================== #
13
+ module PdfParadise
14
+
15
+ module GUI
16
+
17
+ module Gtk
18
+
19
+ module SplitPdfFileModule
20
+
21
+ require 'gtk_paradise/requires/require_the_base_module.rb'
22
+ include ::Gtk::BaseModule
23
+
24
+ require 'pdf_paradise/utility_scripts/split_pdf.rb'
25
+
26
+ begin
27
+ require 'colours'
28
+ include Colours
29
+ rescue LoadError; end
30
+
31
+ # ========================================================================= #
32
+ # === NAMESPACE
33
+ # ========================================================================= #
34
+ NAMESPACE = inspect
35
+
36
+ # ========================================================================= #
37
+ # === TITLE
38
+ # ========================================================================= #
39
+ TITLE = 'Split .pdf files'
40
+
41
+ # ========================================================================= #
42
+ # === WIDTH
43
+ # ========================================================================= #
44
+ WIDTH = 1400
45
+
46
+ # ========================================================================= #
47
+ # === HEIGHT
48
+ # ========================================================================= #
49
+ HEIGHT = 700
50
+
51
+ # ========================================================================= #
52
+ # === ARRAY_ADD_THESE_SHORTCUT_FOLDERS
53
+ # ========================================================================= #
54
+ ARRAY_ADD_THESE_SHORTCUT_FOLDERS = [
55
+ # "C:\\",
56
+ # "C:\\ingrid",
57
+ # '/ingrid'
58
+ ]
59
+
60
+ # ========================================================================= #
61
+ # === initialize
62
+ # ========================================================================= #
63
+ def initialize(
64
+ optional_file = nil,
65
+ run_already = true
66
+ )
67
+ super(:vertical)
68
+ reset
69
+ run if run_already
70
+ end
71
+
72
+ # ========================================================================= #
73
+ # === reset
74
+ # ========================================================================= #
75
+ def reset
76
+ reset_the_internal_variables
77
+ # ======================================================================= #
78
+ # === @configuration
79
+ # ======================================================================= #
80
+ @configuration = [true, __dir__, NAMESPACE]
81
+ set_use_this_font(:dejavu_condensed_24)
82
+ # ======================================================================= #
83
+ # === @title
84
+ # ======================================================================= #
85
+ @title = TITLE
86
+ # ======================================================================= #
87
+ # === @width
88
+ # ======================================================================= #
89
+ set_width(WIDTH)
90
+ # ======================================================================= #
91
+ # === @height
92
+ # ======================================================================= #
93
+ set_height(HEIGHT)
94
+ use_project_css_file
95
+ end
96
+
97
+ # ========================================================================= #
98
+ # === add_the_split_pdf_file_button
99
+ # ========================================================================= #
100
+ def add_the_split_pdf_file_button
101
+ minimal(
102
+ @button_split_the_pdf_file, 2
103
+ )
104
+ end
105
+
106
+ # ========================================================================= #
107
+ # === padding?
108
+ # ========================================================================= #
109
+ def padding?
110
+ 2
111
+ end
112
+
113
+ # ========================================================================= #
114
+ # === border_size?
115
+ # ========================================================================= #
116
+ def border_size?
117
+ 2
118
+ end
119
+
120
+ # ========================================================================= #
121
+ # === create_skeleton
122
+ # ========================================================================= #
123
+ def create_skeleton
124
+ @hbox1 = gtk_vbox
125
+ create_buttons
126
+ create_gtk_entries
127
+ end
128
+
129
+ # ========================================================================= #
130
+ # === create_gtk_entries (entries tag)
131
+ # ========================================================================= #
132
+ def create_gtk_entries
133
+ @entry_for_the_path_to_the_pdf_file = gtk_entry('')
134
+ @entry_for_the_path_to_the_pdf_file.on_click_event {
135
+ :highlight_text
136
+ }
137
+ # ======================================================================= #
138
+ # Determine where the individual .pdf files are to be kept:
139
+ # ======================================================================= #
140
+ _ = return_pwd
141
+ _ = '/Depot/j/'.dup if File.directory? '/Depot/j/'
142
+ @entry_for_the_directory_where_we_will_generate_the_individual_pdf_files_into = gtk_entry(
143
+ _
144
+ )
145
+ end
146
+
147
+ # ========================================================================= #
148
+ # === create_buttons (buttons tag)
149
+ #
150
+ # This method can be used to create all buttons in this small application.
151
+ # ========================================================================= #
152
+ def create_buttons
153
+ @button_file_chooser = gtk_button('Choose a file')
154
+ @button_file_chooser.lightgreen
155
+ @button_file_chooser.on_clicked {
156
+ open_file_chooser_dialog
157
+ }
158
+ @button_file_chooser.fancy_tooltip = 'Select this to <b>choose</b> '\
159
+ ' a local .pdf file.'
160
+ @button_split_the_pdf_file = gtk_button('Split the pdf file')
161
+ @button_split_the_pdf_file.lightgreen
162
+ @button_split_the_pdf_file.fancy_tooltip =
163
+ 'Click on this button to actually <b>split the .pdf file</b> at hand.'
164
+ @button_split_the_pdf_file.on_clicked {
165
+ do_split_the_pdf_file
166
+ }
167
+ end
168
+
169
+ # ========================================================================= #
170
+ # === do_split_the_pdf_file
171
+ #
172
+ # This is the main action of this class.
173
+ # ========================================================================= #
174
+ def do_split_the_pdf_file
175
+ target_file = @entry_for_the_path_to_the_pdf_file.text.to_s
176
+ if File.exist?(target_file)
177
+ e 'Now splitting the .pdf file'
178
+ PdfParadise.split_this_pdf_file(
179
+ target_file, :default, store_in_which_directory?
180
+ )
181
+ else
182
+ e 'No file was found at the location '+target_file+'.'
183
+ end
184
+ end
185
+
186
+ # ========================================================================= #
187
+ # === store_in_which_directory?
188
+ #
189
+ # This method must return a String, hence why the method .text is used.
190
+ # ========================================================================= #
191
+ def store_in_which_directory?
192
+ @entry_for_the_directory_where_we_will_generate_the_individual_pdf_files_into.text
193
+ end
194
+
195
+ # ========================================================================= #
196
+ # === open_file_chooser_dialog
197
+ # ========================================================================= #
198
+ def open_file_chooser_dialog
199
+ @file_chooser_dialog = gtk_file_chooser_dialog('Open File',
200
+ self,
201
+ ::Gtk::FileChooser::ACTION_OPEN, nil,
202
+ [::Gtk::Stock::CANCEL, ::Gtk::Dialog::RESPONSE_CANCEL],
203
+ [::Gtk::Stock::OPEN, ::Gtk::Dialog::RESPONSE_ACCEPT]
204
+ )
205
+ if File.directory? '/Depot/j/'
206
+ @file_chooser_dialog.current_folder = '/Depot/j/'
207
+ else
208
+ @file_chooser_dialog.current_folder = return_pwd
209
+ end
210
+ # @file_chooser_dialog.add_shortcut_folder(return_pwd)
211
+ # ^^^ already exists as shortcut.
212
+ begin
213
+ ARRAY_ADD_THESE_SHORTCUT_FOLDERS.each {|this_directory|
214
+ @file_chooser_dialog.add_shortcut_folder(this_directory)
215
+ }
216
+ rescue; end
217
+ if File.directory? '/home/Temp/'
218
+ @file_chooser_dialog.add_directory('/home/Temp/')
219
+ end
220
+ @file_chooser_dialog.show_hidden = true # Do show hidden files.
221
+ @extra_button = gtk_button('_Extra button')
222
+ @extra_button.signal_connect(:clicked) { e ' > Extra button was clicked' }
223
+ @file_chooser_dialog.extra_widget = @extra_button
224
+ case @file_chooser_dialog.run
225
+ when ::Gtk::Dialog::RESPONSE_ACCEPT
226
+ filename = @file_chooser_dialog.filename.to_s
227
+ @entry_for_the_path_to_the_pdf_file.set_text(filename)
228
+ end
229
+ @file_chooser_dialog.destroy
230
+ end
231
+
232
+ # ========================================================================= #
233
+ # === connect_skeleton
234
+ # ========================================================================= #
235
+ def connect_skeleton
236
+ abort_on_exception
237
+ end
238
+
239
+ # ========================================================================= #
240
+ # === run
241
+ # ========================================================================= #
242
+ def run
243
+ create_skeleton
244
+ connect_skeleton
245
+ gtk_text_for_the_gtk_entry_denoting_into_which_directory_we_will_generate_the_pdf_files = gtk_label(
246
+ 'Set the path to the directory where these .pdf files will be kept below:'
247
+ )
248
+ gtk_text = gtk_label(
249
+ 'Set the path to the .pdf file below this text.'
250
+ ) {{
251
+ tooltip: 'You need to supply the path to the .pdf file '\
252
+ 'into the input field on the right side.'
253
+ }}
254
+ @hbox1.minimal(gtk_text)
255
+ @hbox1.maximal(@entry_for_the_path_to_the_pdf_file)
256
+ # ======================================================================= #
257
+ # And add the file-chooser button:
258
+ # ======================================================================= #
259
+ @hbox1.minimal(@button_file_chooser)
260
+ maximal(@hbox1, 1)
261
+
262
+ @vbox_denoting_where_the_individual_pdf_files_are_kept = gtk_vbox
263
+ @vbox_denoting_where_the_individual_pdf_files_are_kept.minimal(
264
+ gtk_text_for_the_gtk_entry_denoting_into_which_directory_we_will_generate_the_pdf_files,
265
+ 1
266
+ )
267
+ @vbox_denoting_where_the_individual_pdf_files_are_kept.minimal(
268
+ @entry_for_the_directory_where_we_will_generate_the_individual_pdf_files_into,
269
+ 1
270
+ )
271
+ minimal(
272
+ @vbox_denoting_where_the_individual_pdf_files_are_kept, 0
273
+ )
274
+ add_the_split_pdf_file_button
275
+ show_all
276
+ end
277
+
278
+ # ========================================================================= #
279
+ # === PdfParadise::GUI::Gtk::SplitPdfFileModule.run
280
+ # ========================================================================= #
281
+ def self.run
282
+ require 'gtk_paradise/run'
283
+ _ = ::PdfParadise::GUI::Gtk::SplitPdfFile.new
284
+ r = ::Gtk.run
285
+ r << _
286
+ r.set_size_request(
287
+ _.width?,
288
+ _.height?
289
+ )
290
+ r.enable_quick_exit
291
+ r.top_left_then_run
292
+ end
293
+
294
+ end; end; end; end