pdf_paradise 0.1.43
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.
- checksums.yaml +7 -0
- data/README.md +376 -0
- data/bin/automatic_pdf_title +7 -0
- data/bin/convert_markdown_to_pdf +7 -0
- data/bin/convert_pdf_to_text +7 -0
- data/bin/merge_then_open +7 -0
- data/bin/n_pages +10 -0
- data/bin/open_main_pdf +7 -0
- data/bin/pdf_paradise +7 -0
- data/bin/set_main_book +7 -0
- data/bin/set_title_of_this_pdf_file +15 -0
- data/doc/README.gen +348 -0
- data/doc/todo/todo.md +2 -0
- data/lib/pdf_paradise.rb +5 -0
- data/lib/pdf_paradise/base/base.rb +173 -0
- data/lib/pdf_paradise/commandline/help.rb +69 -0
- data/lib/pdf_paradise/commandline/menu.rb +160 -0
- data/lib/pdf_paradise/compress_this_pdf_file.rb +82 -0
- data/lib/pdf_paradise/constants/constants.rb +59 -0
- data/lib/pdf_paradise/convert_text_to_pdf.rb +94 -0
- data/lib/pdf_paradise/css/project.css +17 -0
- data/lib/pdf_paradise/djvu_to_pdf.rb +85 -0
- data/lib/pdf_paradise/gui/README.md +6 -0
- data/lib/pdf_paradise/gui/fox/split_pdf_file.rb +77 -0
- 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
- data/lib/pdf_paradise/gui/gtk2/pdf_viewer/pdf_viewer.rb +34 -0
- data/lib/pdf_paradise/gui/gtk2/split_pdf_file/split_pdf_file.rb +34 -0
- data/lib/pdf_paradise/gui/gtk2/statistics_widget/statistics_widget.rb +34 -0
- data/lib/pdf_paradise/gui/gtk2/to_pdf/to_pdf.rb +32 -0
- data/lib/pdf_paradise/gui/gtk3/controller/controller.rb +197 -0
- data/lib/pdf_paradise/gui/gtk3/convert_pdf_to_text/convert_pdf_to_text.rb +34 -0
- 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
- data/lib/pdf_paradise/gui/gtk3/pdf_viewer/pdf_viewer.rb +34 -0
- data/lib/pdf_paradise/gui/gtk3/split_pdf_file/split_pdf_file.rb +34 -0
- data/lib/pdf_paradise/gui/gtk3/statistics_widget/statistics_widget.rb +34 -0
- data/lib/pdf_paradise/gui/gtk3/to_pdf/to_pdf.rb +32 -0
- data/lib/pdf_paradise/gui/shared_code/convert_pdf_to_text/convert_pdf_to_text_module.rb +277 -0
- 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 +428 -0
- data/lib/pdf_paradise/gui/shared_code/pdf_viewer/pdf_viewer.css +5 -0
- data/lib/pdf_paradise/gui/shared_code/pdf_viewer/pdf_viewer_module.rb +284 -0
- data/lib/pdf_paradise/gui/shared_code/split_pdf_file/split_pdf_file.css +0 -0
- data/lib/pdf_paradise/gui/shared_code/split_pdf_file/split_pdf_file_module.rb +294 -0
- data/lib/pdf_paradise/gui/shared_code/statistics_widget/statistics_widget_module.rb +333 -0
- data/lib/pdf_paradise/gui/shared_code/to_pdf/to_pdf_module.rb +273 -0
- data/lib/pdf_paradise/main_pdf/main_pdf.rb +437 -0
- data/lib/pdf_paradise/merge_pdf/menu.rb +63 -0
- data/lib/pdf_paradise/merge_pdf/merge_pdf.rb +292 -0
- data/lib/pdf_paradise/merge_pdf_namespace.rb +9 -0
- data/lib/pdf_paradise/merge_then_open/merge_then_open.rb +105 -0
- data/lib/pdf_paradise/pdf_file_n_total_pages.rb +227 -0
- data/lib/pdf_paradise/project/project_base_directory.rb +22 -0
- data/lib/pdf_paradise/remove_pdf_password.rb +392 -0
- data/lib/pdf_paradise/requires/batch_require_toplevel_files.rb +22 -0
- data/lib/pdf_paradise/requires/colours.rb +7 -0
- data/lib/pdf_paradise/requires/colours_and_esystem_and_save_file_and_fileutils_and_opn.rb +11 -0
- data/lib/pdf_paradise/requires/esystem_and_colours.rb +10 -0
- data/lib/pdf_paradise/requires/esystem_and_opn_and_colours.rb +8 -0
- data/lib/pdf_paradise/requires/require_the_whole_project.rb +25 -0
- data/lib/pdf_paradise/requires/require_utility_scripts.rb +7 -0
- data/lib/pdf_paradise/rotate_pdf_file.rb +144 -0
- data/lib/pdf_paradise/set_main_book.rb +156 -0
- data/lib/pdf_paradise/set_pdf_title.rb +218 -0
- data/lib/pdf_paradise/sinatra/embeddable_interface.rb +315 -0
- data/lib/pdf_paradise/toplevel_methods/automatic_pdf_title.rb +55 -0
- data/lib/pdf_paradise/toplevel_methods/convert_epub_to_pdf.rb +27 -0
- data/lib/pdf_paradise/toplevel_methods/convert_markdown_to_pdf.rb +43 -0
- data/lib/pdf_paradise/toplevel_methods/convert_ppt_to_pdf.rb +35 -0
- data/lib/pdf_paradise/toplevel_methods/e.rb +16 -0
- data/lib/pdf_paradise/toplevel_methods/esystem.rb +19 -0
- data/lib/pdf_paradise/toplevel_methods/misc.rb +52 -0
- data/lib/pdf_paradise/toplevel_methods/number_pages.rb +38 -0
- data/lib/pdf_paradise/toplevel_methods/opened_pdf_files.rb +191 -0
- data/lib/pdf_paradise/toplevel_methods/query_pdf_title.rb +182 -0
- data/lib/pdf_paradise/toplevel_methods/reduce_size_of_this_pdf_file.rb +43 -0
- data/lib/pdf_paradise/toplevel_methods/roebe.rb +17 -0
- data/lib/pdf_paradise/toplevel_methods/to_pdf.rb +38 -0
- data/lib/pdf_paradise/utility_scripts/README.md +3 -0
- data/lib/pdf_paradise/utility_scripts/convert_pdf_to_text.rb +166 -0
- data/lib/pdf_paradise/utility_scripts/delete_first_page_of_this_pdf_file.rb +185 -0
- data/lib/pdf_paradise/utility_scripts/delete_last_page_of_this_pdf_file.rb +180 -0
- data/lib/pdf_paradise/utility_scripts/delete_this_page_of_this_pdf_file.rb +310 -0
- data/lib/pdf_paradise/utility_scripts/extract_pdf_page.rb +280 -0
- data/lib/pdf_paradise/utility_scripts/pdf_optimizer.rb +113 -0
- data/lib/pdf_paradise/utility_scripts/pdf_statistics.rb +150 -0
- data/lib/pdf_paradise/utility_scripts/remove_images.rb +110 -0
- data/lib/pdf_paradise/utility_scripts/split_pdf.rb +294 -0
- data/lib/pdf_paradise/utility_scripts/to_qdf.rb +82 -0
- data/lib/pdf_paradise/version/version.rb +19 -0
- data/lib/pdf_paradise/www/README.md +2 -0
- data/lib/pdf_paradise/www/sinatra/app.rb +276 -0
- data/pdf_paradise.gemspec +64 -0
- data/test/testing_pdf_paradise.rb +9 -0
- metadata +216 -0
File without changes
|
@@ -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
|
+
@width = WIDTH
|
90
|
+
# ======================================================================= #
|
91
|
+
# === @height
|
92
|
+
# ======================================================================= #
|
93
|
+
@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
|
@@ -0,0 +1,333 @@
|
|
1
|
+
#!/usr/bin/ruby -w
|
2
|
+
# Encoding: UTF-8
|
3
|
+
# frozen_string_literal: true
|
4
|
+
# =========================================================================== #
|
5
|
+
# === PdfParadise::GUI::Gtk::StatisticsWidgetModule
|
6
|
+
# =========================================================================== #
|
7
|
+
# require 'pdf_paradise/gui/shared_code/statistics_widget/statistics_widget_module.rb'
|
8
|
+
# include ::PdfParadise::GUI::Gtk::StatisticsWidgetModule
|
9
|
+
# =========================================================================== #
|
10
|
+
module PdfParadise
|
11
|
+
|
12
|
+
module GUI
|
13
|
+
|
14
|
+
module Gtk
|
15
|
+
|
16
|
+
module StatisticsWidgetModule
|
17
|
+
|
18
|
+
require 'gtk_paradise/requires/require_the_base_module.rb'
|
19
|
+
include ::Gtk::BaseModule
|
20
|
+
|
21
|
+
require 'pdf_paradise/pdf_file_n_total_pages.rb'
|
22
|
+
require 'pdf_paradise/toplevel_methods/automatic_pdf_title.rb'
|
23
|
+
require 'pdf_paradise/toplevel_methods/query_pdf_title.rb'
|
24
|
+
|
25
|
+
# ========================================================================= #
|
26
|
+
# === NAMESPACE
|
27
|
+
# ========================================================================= #
|
28
|
+
NAMESPACE = inspect
|
29
|
+
|
30
|
+
# ========================================================================= #
|
31
|
+
# === TITLE
|
32
|
+
# ========================================================================= #
|
33
|
+
TITLE = 'Show statistics about the .pdf file at hand'
|
34
|
+
|
35
|
+
# ========================================================================= #
|
36
|
+
# === FONT_SIZE
|
37
|
+
# ========================================================================= #
|
38
|
+
FONT_SIZE = 18
|
39
|
+
|
40
|
+
# ========================================================================= #
|
41
|
+
# === USE_THIS_FONT
|
42
|
+
# ========================================================================= #
|
43
|
+
USE_THIS_FONT = "Liberation serif #{FONT_SIZE}"
|
44
|
+
|
45
|
+
# ========================================================================= #
|
46
|
+
# === USE_THIS_FONT_FOR_THE_DISPLAY_AREA
|
47
|
+
# ========================================================================= #
|
48
|
+
USE_THIS_FONT_FOR_THE_DISPLAY_AREA = 'DejaVu Sans Mono 18' # :hack_18
|
49
|
+
|
50
|
+
# ========================================================================= #
|
51
|
+
# === WIDTH
|
52
|
+
# ========================================================================= #
|
53
|
+
WIDTH = 1820
|
54
|
+
|
55
|
+
# ========================================================================= #
|
56
|
+
# === HEIGHT
|
57
|
+
# ========================================================================= #
|
58
|
+
HEIGHT = 840
|
59
|
+
|
60
|
+
# ========================================================================= #
|
61
|
+
# === initialize
|
62
|
+
#
|
63
|
+
# The first argument is assumed to be the parent-widget.
|
64
|
+
# ========================================================================= #
|
65
|
+
def initialize(
|
66
|
+
commandline_arguments = nil,
|
67
|
+
run_already = true
|
68
|
+
)
|
69
|
+
super(:vertical) # Vertical box in style.
|
70
|
+
reset
|
71
|
+
set_commandline_arguments(
|
72
|
+
commandline_arguments
|
73
|
+
)
|
74
|
+
run if run_already
|
75
|
+
end
|
76
|
+
|
77
|
+
# ========================================================================= #
|
78
|
+
# === reset (reset tag)
|
79
|
+
# ========================================================================= #
|
80
|
+
def reset
|
81
|
+
abort_on_exception
|
82
|
+
reset_the_internal_variables
|
83
|
+
# ======================================================================= #
|
84
|
+
# === @configuration
|
85
|
+
# ======================================================================= #
|
86
|
+
@configuration = [true, __dir__, NAMESPACE]
|
87
|
+
# ======================================================================= #
|
88
|
+
# === @title
|
89
|
+
# ======================================================================= #
|
90
|
+
@title = TITLE
|
91
|
+
# ======================================================================= #
|
92
|
+
# === @width
|
93
|
+
# ======================================================================= #
|
94
|
+
@width = WIDTH
|
95
|
+
@height = HEIGHT
|
96
|
+
set_use_this_font(USE_THIS_FONT)
|
97
|
+
use_gtk_paradise_project_css_file
|
98
|
+
end
|
99
|
+
|
100
|
+
# ========================================================================= #
|
101
|
+
# === padding?
|
102
|
+
# ========================================================================= #
|
103
|
+
def padding?
|
104
|
+
0
|
105
|
+
end
|
106
|
+
|
107
|
+
# ========================================================================= #
|
108
|
+
# === parent_widget?
|
109
|
+
# ========================================================================= #
|
110
|
+
def parent_widget?
|
111
|
+
@commandline_arguments.first
|
112
|
+
end
|
113
|
+
|
114
|
+
# ========================================================================= #
|
115
|
+
# === main_entry?
|
116
|
+
# ========================================================================= #
|
117
|
+
def main_entry?
|
118
|
+
@gtk_entry
|
119
|
+
end
|
120
|
+
|
121
|
+
# ========================================================================= #
|
122
|
+
# === create_the_entries
|
123
|
+
# ========================================================================= #
|
124
|
+
def create_the_entries
|
125
|
+
@gtk_entry = gtk_entry
|
126
|
+
@gtk_entry.yellow_background
|
127
|
+
@gtk_entry.bblack1
|
128
|
+
@gtk_entry.css_class('pad4px')
|
129
|
+
end
|
130
|
+
|
131
|
+
# ========================================================================= #
|
132
|
+
# === create_the_buttons (buttons tag, button tag)
|
133
|
+
# ========================================================================= #
|
134
|
+
def create_the_buttons
|
135
|
+
# ======================================================================= #
|
136
|
+
# === @button_choose_file
|
137
|
+
# ======================================================================= #
|
138
|
+
@button_choose_file = gtk_file_chooser_button
|
139
|
+
@button_choose_file.hint = 'Click on this button to open a '\
|
140
|
+
'local <b>.pdf</b> file.'
|
141
|
+
@button_choose_file.lightgreen
|
142
|
+
@button_choose_file.on_clicked {
|
143
|
+
do_create_a_new_file_chooser_dialog_and_then_set_the_main_entry_to(main_file?)
|
144
|
+
}
|
145
|
+
# ======================================================================= #
|
146
|
+
# === @button_analyse
|
147
|
+
# ======================================================================= #
|
148
|
+
@button_analyse = gtk_button('_Analyse the .pdf file')
|
149
|
+
@button_analyse.lightgreen
|
150
|
+
@button_analyse.hint =
|
151
|
+
'Click this button to obtain some information about '\
|
152
|
+
'the .pdf file at hand.'
|
153
|
+
@button_analyse.on_clicked {
|
154
|
+
do_analyse_the_pdf_file
|
155
|
+
}
|
156
|
+
# ======================================================================= #
|
157
|
+
# === @button_auto_title
|
158
|
+
# ======================================================================= #
|
159
|
+
@button_auto_title = gtk_button('Automatic Title')
|
160
|
+
@button_auto_title.hint = 'Click on this button to automatically '\
|
161
|
+
'determine the title for this .pdf file, based on the filename.'
|
162
|
+
@button_auto_title.on_clicked {
|
163
|
+
do_automatically_determine_the_title_for_the_pdf_file_at_hand
|
164
|
+
}
|
165
|
+
@button_open_via_a_pdf_reader = gtk_button('Open via a pdf-reader')
|
166
|
+
@button_open_via_a_pdf_reader.hint = 'This will open the .pdf '\
|
167
|
+
'file in a pdf-reader.'
|
168
|
+
@button_open_via_a_pdf_reader.on_clicked {
|
169
|
+
do_open_the_local_pdf_file_in_the_pdf_reader
|
170
|
+
}
|
171
|
+
return_all_buttons.each {|this_button|
|
172
|
+
this_button.bblack1
|
173
|
+
}
|
174
|
+
@button_auto_title.bblack3
|
175
|
+
end
|
176
|
+
|
177
|
+
# ========================================================================= #
|
178
|
+
# === create_skeleton (create tag)
|
179
|
+
# ========================================================================= #
|
180
|
+
def create_skeleton
|
181
|
+
create_the_entries
|
182
|
+
create_the_buttons
|
183
|
+
@label = gtk_left_aligned_label
|
184
|
+
@label.set_font(USE_THIS_FONT_FOR_THE_DISPLAY_AREA)
|
185
|
+
|
186
|
+
@label.make_selectable
|
187
|
+
@hbox_containing_the_entry = gtk_hbox
|
188
|
+
|
189
|
+
@arrow_right = emoji(:arrow_right)
|
190
|
+
@event_box_arrow_right = gtk_eventbox(@arrow_right)
|
191
|
+
@event_box_arrow_right.on_clicked {
|
192
|
+
do_create_a_new_file_chooser_dialog_and_then_set_the_main_entry_to(main_file?)
|
193
|
+
}
|
194
|
+
@hbox_containing_the_entry.minimal(
|
195
|
+
@event_box_arrow_right
|
196
|
+
)
|
197
|
+
@hbox_containing_the_entry.maximal(@gtk_entry)
|
198
|
+
end
|
199
|
+
|
200
|
+
# ========================================================================= #
|
201
|
+
# === connect_skeleton (connect skeleton, connect tag)
|
202
|
+
# ========================================================================= #
|
203
|
+
def connect_skeleton
|
204
|
+
_ = top_bar
|
205
|
+
_.add(@button_auto_title)
|
206
|
+
_.add(@button_open_via_a_pdf_reader)
|
207
|
+
minimal(_)
|
208
|
+
minimal(
|
209
|
+
gtk_left_aligned_label(
|
210
|
+
'This small widget will show some information about the .pdf file at hand.'
|
211
|
+
), 4
|
212
|
+
)
|
213
|
+
minimal(@hbox_containing_the_entry, 4)
|
214
|
+
button_box = gtk_button_box(
|
215
|
+
@button_choose_file,
|
216
|
+
@button_analyse
|
217
|
+
) {{ layout: :horizontal,
|
218
|
+
padding: 2 }}
|
219
|
+
button_box.spacing = 2
|
220
|
+
button_box.layout = :expand
|
221
|
+
minimal(button_box, 4)
|
222
|
+
minimal(@label, 4)
|
223
|
+
end
|
224
|
+
|
225
|
+
# ========================================================================= #
|
226
|
+
# === do_create_a_new_file_chooser_dialog_and_then_set_the_main_entry_to
|
227
|
+
# ========================================================================= #
|
228
|
+
def do_create_a_new_file_chooser_dialog_and_then_set_the_main_entry_to(
|
229
|
+
i = main_file?.to_s
|
230
|
+
)
|
231
|
+
create_a_new_file_chooser_dialog(parent_widget?) {{
|
232
|
+
filter: '.pdf',
|
233
|
+
additional_folders: '/Depot/j/',
|
234
|
+
start_directory: '/Depot/'
|
235
|
+
}}
|
236
|
+
_ = assigned_main_file?.to_s
|
237
|
+
if _ and !_.empty?
|
238
|
+
main_entry?.set_text(_)
|
239
|
+
do_analyse_the_pdf_file
|
240
|
+
end
|
241
|
+
end
|
242
|
+
|
243
|
+
# ========================================================================= #
|
244
|
+
# === run (run tag)
|
245
|
+
# ========================================================================= #
|
246
|
+
def run
|
247
|
+
create_skeleton_then_connect_skeleton
|
248
|
+
show_all
|
249
|
+
Thread.new {
|
250
|
+
sleep 0.001
|
251
|
+
main_entry?.do_focus
|
252
|
+
}
|
253
|
+
end
|
254
|
+
|
255
|
+
# ========================================================================= #
|
256
|
+
# === do_analyse_the_pdf_file
|
257
|
+
#
|
258
|
+
# This is the method that will analyse the .pdf file at hand.
|
259
|
+
# ========================================================================= #
|
260
|
+
def do_analyse_the_pdf_file
|
261
|
+
this_pdf_file = main_entry?.text.to_s
|
262
|
+
_ = ''.dup
|
263
|
+
_ << "This .pdf file has the following characteristics:\n\n"
|
264
|
+
_ << ' <b>n pages</b>: '+::PdfParadise.n_pages?(this_pdf_file).to_s
|
265
|
+
_ << "\n"
|
266
|
+
use_this_title = ::PdfParadise.title?(this_pdf_file).to_s
|
267
|
+
if use_this_title.empty?
|
268
|
+
use_this_title = '(This .pdf file has no title)'
|
269
|
+
end
|
270
|
+
_ << " <b>title</b>: #{use_this_title}"
|
271
|
+
_ << "\n"
|
272
|
+
@label.set_text(_)
|
273
|
+
@label.do_markify
|
274
|
+
end
|
275
|
+
|
276
|
+
# ========================================================================= #
|
277
|
+
# === do_automatically_determine_the_title_for_the_pdf_file_at_hand
|
278
|
+
# ========================================================================= #
|
279
|
+
def do_automatically_determine_the_title_for_the_pdf_file_at_hand
|
280
|
+
this_pdf_file = main_entry?.text.to_s
|
281
|
+
if this_pdf_file and !this_pdf_file.empty?
|
282
|
+
::PdfParadise.automatic_pdf_title(this_pdf_file)
|
283
|
+
do_analyse_the_pdf_file
|
284
|
+
else
|
285
|
+
popup_over_this_widget(
|
286
|
+
main_entry?,
|
287
|
+
'Please first assign a .pdf file, before '\
|
288
|
+
'this functionality can be used.'
|
289
|
+
)
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
# ========================================================================= #
|
294
|
+
# === do_open_the_local_pdf_file_in_the_pdf_reader
|
295
|
+
# ========================================================================= #
|
296
|
+
def do_open_the_local_pdf_file_in_the_pdf_reader
|
297
|
+
this_pdf_file = main_entry?.text.to_s
|
298
|
+
if this_pdf_file and !this_pdf_file.empty?
|
299
|
+
Thread.new {
|
300
|
+
esystem("evince #{this_pdf_file}")
|
301
|
+
}
|
302
|
+
else
|
303
|
+
popup_over_this_widget(
|
304
|
+
main_entry?,
|
305
|
+
'Please first assign a .pdf file, before '\
|
306
|
+
'this functionality can be used.'
|
307
|
+
)
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
end; end; end
|
312
|
+
|
313
|
+
# =========================================================================== #
|
314
|
+
# === PdfParadise.start_gtk_gui_statistics_widget
|
315
|
+
# =========================================================================== #
|
316
|
+
def self.start_gtk_gui_statistics_widget
|
317
|
+
require 'gtk_paradise/run'
|
318
|
+
r = ::Gtk.run
|
319
|
+
_ = PdfParadise::GUI::Gtk::StatisticsWidget.new(r)
|
320
|
+
r << _
|
321
|
+
r.automatic_size
|
322
|
+
r.automatic_title
|
323
|
+
r.top_left_then_run
|
324
|
+
end
|
325
|
+
|
326
|
+
# =========================================================================== #
|
327
|
+
# === PdfParadise.return_widget_about_this_pdf_file
|
328
|
+
# =========================================================================== #
|
329
|
+
def self.return_widget_about_this_pdf_file
|
330
|
+
::PdfParadise::GUI::Gtk::StatisticsWidget.new
|
331
|
+
end
|
332
|
+
|
333
|
+
end
|