Class: PdfParadise::GUI::UniversalWidgets::StatisticsWidget
- Inherits:
-
Base
- Object
- Base
- PdfParadise::GUI::UniversalWidgets::StatisticsWidget
show all
- Includes:
- UniversalWidgets::BaseModule
- Defined in:
- lib/pdf_paradise/gui/universal_widgets/statistics_widget/statistics_widget.rb
Overview
Constant Summary
collapse
- TITLE =
'Show statistics about the .pdf file at hand'
- FONT_SIZE =
18
- USE_THIS_FONT =
"Liberation serif #{FONT_SIZE}"
- USE_THIS_FONT_FOR_THE_DISPLAY_AREA =
#
USE_THIS_FONT_FOR_THE_DISPLAY_AREA
#
'DejaVu Sans Mono 18'
- WIDTH =
'95% or minimum 1820px'
- HEIGHT =
'35% or minimum 840px'
- LARGER_FONT =
:hack_24
- SMALLER_FONT =
:hack_28
Constants inherited
from Base
Base::NAMESPACE
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#basename, #be_verbose?, #change_directory, #commandline_arguments?, #copy_file, #delete_file, #e, #ecomment, #esystem, #first_argument?, #gold, #infer_the_namespace, #input_without_leading_hyphens?, #internal_hash?, #is_an_image_file?, #is_on_roebe?, #lightsteelblue, #log_dir?, #mkdir, #mv, #n_pages?, #namespace?, #no_file_at, #opne, #opnn, #orange, #reset_the_internal_hash, #return_commandline_arguments_starting_with_hyphens, #return_files_from_the_commandline_arguments, #return_pwd, #rev, #set_be_quiet, #set_commandline_arguments, #steelblue, #try_to_ensure_that_this_directory_exists, #write_what_into
Constructor Details
#initialize(commandline_arguments = nil, run_already = true) ⇒ StatisticsWidget
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/pdf_paradise/gui/universal_widgets/statistics_widget/statistics_widget.rb', line 74
def initialize(
commandline_arguments = nil,
run_already = true
)
super(:vertical) if use_gtk3?
determine_the_GUI_to_be_used(commandline_arguments) reset
set_commandline_arguments(
commandline_arguments
)
run if run_already
end
|
Class Method Details
.[](i = ARGV) ⇒ Object
377
378
379
|
# File 'lib/pdf_paradise/gui/universal_widgets/statistics_widget/statistics_widget.rb', line 377
def self.[](i = ARGV)
new(i)
end
|
.run(i = ARGV) ⇒ Object
362
363
364
365
366
367
368
369
370
371
372
|
# File 'lib/pdf_paradise/gui/universal_widgets/statistics_widget/statistics_widget.rb', line 362
def self.run(
i = ARGV
)
require 'gtk_paradise/run'
_ = ::PdfParadise::GUI::Gtk::StatisticsWidget.new(i)
r = ::Gtk.run
r << _
r.automatic_size
r.automatic_title
r.top_left_then_run
end
|
Instance Method Details
#border_size? ⇒ Boolean
348
349
350
|
# File 'lib/pdf_paradise/gui/universal_widgets/statistics_widget/statistics_widget.rb', line 348
def border_size?
2
end
|
#connect_the_skeleton ⇒ Object
#
connect_the_skeleton (connect tag)
#
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
|
# File 'lib/pdf_paradise/gui/universal_widgets/statistics_widget/statistics_widget.rb', line 221
def connect_the_skeleton
abort_on_exception
outer_vbox = create_vbox
_ = top_bar
_.add(@button_auto_title)
_.add(@button_open_via_a_pdf_reader)
outer_vbox.minimal(_)
outer_vbox.minimal(
left_aligned_label(
'This small widget will show some information about '\
'the .pdf file at hand.'
), 8
)
outer_vbox.minimal(@hbox_containing_the_entry, 8)
button_box = button_box(
@button_choose_file,
@button_analyse
) {{ layout: :horizontal,
padding: 2 }}
button_box.spacing = 2
button_box.layout = :expand
outer_vbox.minimal(button_box, 4)
outer_vbox.minimal(@label, 4)
window = create_window_or_runner(
widget: outer_vbox,
width: width?,
height: height?,
title: title?,
font: font?
)
window.set_padding(padding?)
window.set_border_size(border_size?)
window.show_all
Thread.new {
sleep 0.001
main_entry?.do_focus
}
run_main
end
|
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
# File 'lib/pdf_paradise/gui/universal_widgets/statistics_widget/statistics_widget.rb', line 166
def create_the_buttons
@button_choose_file = file_chooser_button
@button_choose_file.hint = 'Click on this button to open a '\
'local <b>.pdf</b> file.'
@button_choose_file.on_hover(:lightgreen)
@button_choose_file.on_clicked {
do_create_a_new_file_chooser_dialog_and_then_set_the_main_entry_to(main_file?)
}
@button_analyse = button('_Analyse the .pdf file')
@button_analyse.on_hover(:lightgreen)
@button_analyse.hint =
'Click this button to obtain some information about '\
'the .pdf file at hand.'
@button_analyse.on_clicked {
do_analyse_the_pdf_file
}
@button_auto_title = button('Automatic Title')
@button_auto_title.hint = 'Click on this button to automatically '\
'determine the title for this .pdf file, based on the filename.'
@button_auto_title.on_clicked {
do_automatically_determine_the_title_for_the_pdf_file_at_hand
}
@button_open_via_a_pdf_reader = button('_Open via a pdf-reader', self, :use_mnemonics) {
:do_open_the_local_pdf_file_in_the_pdf_reader
}
@button_open_via_a_pdf_reader.hint = 'This will open the '\
'.pdf file in a pdf-reader.'
return_all_buttons.each {|this_button|
this_button.bblack1
}
@button_auto_title.bblack3
end
|
#create_the_entries ⇒ Object
268
269
270
271
272
273
274
275
276
277
278
279
280
|
# File 'lib/pdf_paradise/gui/universal_widgets/statistics_widget/statistics_widget.rb', line 268
def create_the_entries
@gtk_entry = create_entry
@gtk_entry.yellow_background
@gtk_entry.bblack1
@gtk_entry.css_class('pad4px')
@gtk_entry.enable_all_events
@gtk_entry.on_the_enter_key_was_pressed {
do_analyse_the_pdf_file
}
end
|
#create_the_skeleton ⇒ Object
#
create_skeleton (create tag, skeleton tag)
#
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
# File 'lib/pdf_paradise/gui/universal_widgets/statistics_widget/statistics_widget.rb', line 131
def create_the_skeleton
create_the_entries
create_the_buttons
@label = left_aligned_label
@label.set_font(USE_THIS_FONT_FOR_THE_DISPLAY_AREA)
@label.make_selectable
@hbox_containing_the_entry = create_hbox
@arrow_right = emoji(:arrow_right)
@event_box_arrow_right = create_eventbox(@arrow_right)
@event_box_arrow_right.on_clicked {
do_create_a_new_file_chooser_dialog_and_then_set_the_main_entry_to(main_file?)
}
@hbox_containing_the_entry.minimal(
@event_box_arrow_right
)
@hbox_containing_the_entry.maximal(@gtk_entry)
end
|
#do_analyse_the_pdf_file ⇒ Object
#
do_analyse_the_pdf_file
This is the method that will analyse the .pdf file at hand.
#
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
|
# File 'lib/pdf_paradise/gui/universal_widgets/statistics_widget/statistics_widget.rb', line 287
def do_analyse_the_pdf_file
this_pdf_file = main_entry?.text.to_s
_ = ''.dup
_ << "This .pdf file has the following characteristics:\n\n"
_ << ' <b>n pages</b>: '+::PdfParadise.n_pages?(this_pdf_file).to_s
_ << "\n"
use_this_title = ::PdfParadise.title?(this_pdf_file).to_s
if use_this_title.empty?
use_this_title = '(This .pdf file has no title)'
end
_ << " <b>title</b>: #{use_this_title}"
_ << "\n"
@label.set_text(_)
@label.do_markify
end
|
#do_automatically_determine_the_title_for_the_pdf_file_at_hand ⇒ Object
#
do_automatically_determine_the_title_for_the_pdf_file_at_hand
#
306
307
308
309
310
311
312
313
314
315
316
317
318
|
# File 'lib/pdf_paradise/gui/universal_widgets/statistics_widget/statistics_widget.rb', line 306
def do_automatically_determine_the_title_for_the_pdf_file_at_hand
this_pdf_file = main_entry?.text.to_s
if this_pdf_file and !this_pdf_file.empty?
::PdfParadise.automatic_pdf_title(this_pdf_file)
do_analyse_the_pdf_file
else
(
main_entry?,
'Please first assign a .pdf file, before '\
'this functionality can be used.'
)
end
end
|
#do_create_a_new_file_chooser_dialog_and_then_set_the_main_entry_to(i = main_file?.to_s) ⇒ Object
#
do_create_a_new_file_chooser_dialog_and_then_set_the_main_entry_to
#
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
# File 'lib/pdf_paradise/gui/universal_widgets/statistics_widget/statistics_widget.rb', line 113
def do_create_a_new_file_chooser_dialog_and_then_set_the_main_entry_to(
i = main_file?.to_s
)
create_a_new_file_chooser_dialog(parent_widget?) {{
filter: '.pdf',
additional_folders: '/Depot/j/',
start_directory: '/Depot/'
}}
_ = assigned_main_file?.to_s
if _ and !_.empty?
main_entry?.set_text(_)
do_analyse_the_pdf_file
end
end
|
#do_open_the_local_pdf_file_in_the_pdf_reader ⇒ Object
#
do_open_the_local_pdf_file_in_the_pdf_reader
#
323
324
325
326
327
328
329
330
331
332
333
334
335
336
|
# File 'lib/pdf_paradise/gui/universal_widgets/statistics_widget/statistics_widget.rb', line 323
def do_open_the_local_pdf_file_in_the_pdf_reader
this_pdf_file = main_entry?.text.to_s
if this_pdf_file and !this_pdf_file.empty?
Thread.new {
esystem("evince #{this_pdf_file}")
}
else
(
main_entry?,
'Please first assign a .pdf file, before '\
'this functionality can be used.'
)
end
end
|
#main_entry? ⇒ Boolean
214
215
216
|
# File 'lib/pdf_paradise/gui/universal_widgets/statistics_widget/statistics_widget.rb', line 214
def main_entry?
@gtk_entry
end
|
#padding? ⇒ Boolean
341
342
343
|
# File 'lib/pdf_paradise/gui/universal_widgets/statistics_widget/statistics_widget.rb', line 341
def padding?
0
end
|
159
160
161
|
# File 'lib/pdf_paradise/gui/universal_widgets/statistics_widget/statistics_widget.rb', line 159
def parent_widget?
@commandline_arguments.first
end
|
#reset ⇒ Object
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
|
# File 'lib/pdf_paradise/gui/universal_widgets/statistics_widget/statistics_widget.rb', line 90
def reset
super() if respond_to?(:super)
reset_the_base_module
reset_the_internal_variables
infer_the_namespace
@configuration = [true, __dir__, namespace?]
title_width_height_font(TITLE, WIDTH, HEIGHT, USE_THIS_FONT)
if use_gtk3?
append_project_css_file
use_gtk_paradise_project_css_file
end
infer_the_size_automatically
end
|
#run ⇒ Object
355
356
357
|
# File 'lib/pdf_paradise/gui/universal_widgets/statistics_widget/statistics_widget.rb', line 355
def run
run_super
end
|