Class: MultimediaParadise::GUI::UniversalWidgets::SimplePlayWidget
- Inherits:
-
Base
- Object
- Base
- MultimediaParadise::GUI::UniversalWidgets::SimplePlayWidget
show all
- Includes:
- MultimediaParadise::GUI, UniversalWidgets::BaseModule
- Defined in:
- lib/multimedia_paradise/gui/universal_widgets/simple_play_widget/simple_play_widget.rb
Overview
Constant Summary
collapse
- TITLE =
'Simple Play Widget'
- WIDTH =
'95% or minimum 850px'
- HEIGHT =
'80% or minimum 500px'
- FONT_SIZE =
18
- USE_THIS_FONT =
"Liberation serif #{FONT_SIZE}"
- LARGER_FONT =
"Liberation serif #{FONT_SIZE+6}"
- SLIGHTLY_SMALLER_FONT =
#
SLIGHTLY_SMALLER_FONT
#
"Liberation serif #{FONT_SIZE-2}"
- SMALLEST_FONT =
"Liberation serif #{FONT_SIZE-4}"
ISO, MAIN_FONT_TO_USE, N, MultimediaParadise::GUI::UTF, VIDEO_COLLECTION
Constants inherited
from Base
Base::ERROR, Base::ERROR_LINE, Base::NAMESPACE, Base::USE_THIS_NAMESPACE_FOR_THE_COLOURS, Base::USE_THIS_NAMESPACE_FOR_THE_CORE_COLOURS
Class Method Summary
collapse
Instance Method Summary
collapse
#esystem, #populate_the_dataset_with_this_array, #set_gtk_font_to_use
Methods inherited from Base
#actions, #append_what_into, #be_silent, #be_verbose?, #beautiful_url, #cartoons_directory?, #clear_the_internal_hash, #cliner, #cliner_with_time_stamp, #colourized_comment, #copy_file, #crimson, #dataset_from_file_video_collection, #dd_mm_yyyy, #debug?, #default_readlines, #directory_to_realvids?, #do_not_use_opn, #dodgerblue, #does_the_video_player_support_this_commandline?, #e, #ecomment, #ecrimson, #efancy, #enable_debug, #ensure_main_encoding, #ensure_that_the_output_directory_exists, #eparse, #erev, #esystem, #ewarn, #file_video_collection?, #filter_for_audio_files, #filter_for_video_files, #forestgreen, #gold, #grey, #hh_mm_ss, #home_x_video?, #indianred, #infer_the_namespace, #internal_hash?, #is_audio_file?, #is_mkv?, #is_mp3?, #is_mp4?, #is_multimedia_file?, #is_on_roebe?, #is_video_file?, #konsole_colour_peru, #lightblue, #lightgreen, #load_yaml, #local_audio_directory?, #log_dir?, #map_symbol_to_locally_existing_file, #mediumorchid, #mediumpurple, #mediumslateblue, #mkdir, #move_file, #namespace?, #no_file_exists, #no_file_exists_at, #olive, #olivedrab, #opne, #opnecomment, #opnn, #orange, #palegoldenrod, #palegreen, #powderblue, #project_base_directory?, #rds, #register_sigint, #remove_file, #report_pwd, #reset_the_internal_hash, #return_all_video_files, #return_pwd, #return_random_video, #rev, #royalblue, #save_what_into, #sdir, #seagreen, #seconds_to_time_format, #select_only_video_files_from, #set_be_verbose, #set_use_colours, #sfancy, #sfile, #simp, #skyblue, #slateblue, #springgreen, #steelblue, #swarn, #teal, #time_right_now, #to_hh_mm_ss, #tomato, #true_rev, #try_to_rename_kde_konsole_tab, #ucliner, #use_colours?, #use_opn?, #use_which_video_player?, #verbose_truth, #video_collection?, #violet, #yaml_directory?, #yel
#all_input_starts_with_a_number?, #commandline_arguments?, #commandline_arguments_as_a_string, #first_argument?, #first_non_hyphened_commandline_argument?, #set_commandline_arguments
Constructor Details
#initialize(commandline_arguments = nil, run_already = true) ⇒ SimplePlayWidget
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/multimedia_paradise/gui/universal_widgets/simple_play_widget/simple_play_widget.rb', line 84
def initialize(
commandline_arguments = nil,
run_already = true
)
determine_the_GUI_to_be_used(commandline_arguments) reset
set_commandline_arguments(
commandline_arguments
)
on_delete_event_quit_the_application
run if run_already
end
|
Class Method Details
.[](i = ARGV) ⇒ Object
384
385
386
|
# File 'lib/multimedia_paradise/gui/universal_widgets/simple_play_widget/simple_play_widget.rb', line 384
def self.[](i = ARGV)
new(i)
end
|
.run(i = ARGV) ⇒ Object
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
|
# File 'lib/multimedia_paradise/gui/universal_widgets/simple_play_widget/simple_play_widget.rb', line 352
def self.run(
i = ARGV
)
require 'gtk_paradise/run'
_ = ::MultimediaParadise::GUI::Gtk::SimplePlayWidget.new(i)
r = ::Gtk.run
_.set_parent_widget(r) r << _
r.automatic_size_then_automatic_title
r.shortcuts {[
[1, 'click_on_button_number(0)', :alt],
[2, 'click_on_button_number(1)', :alt],
[3, 'click_on_button_number(2)', :alt],
[4, 'click_on_button_number(3)', :alt],
[5, 'click_on_button_number(4)', :alt],
[6, 'click_on_button_number(5)', :alt],
[7, 'click_on_button_number(6)', :alt],
[8, 'click_on_button_number(7)', :alt],
[9, 'click_on_button_number(8)', :alt]
]}
r.enable_simple_exit
r.set_background :white
r.maximize
r.top_left_then_run
end
|
Instance Method Details
#border_size? ⇒ Boolean
187
188
189
|
# File 'lib/multimedia_paradise/gui/universal_widgets/simple_play_widget/simple_play_widget.rb', line 187
def border_size?
2
end
|
#connect_the_skeleton ⇒ Object
#
connect_the_skeleton (connect tag)
#
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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
|
# File 'lib/multimedia_paradise/gui/universal_widgets/simple_play_widget/simple_play_widget.rb', line 237
def connect_the_skeleton
abort_on_exception
outer_vbox = create_vbox
@scrolled_window = create_scrolled_window(@main_vbox) { :automatic_scrollbars }
@dataset.each_with_index {|entry, index| index += 1
padded_index = index.to_s.rjust(3, ' ')
name_of_the_song = File.basename(entry).
sub(/#{File.extname(entry)}$/,'').
tr('_',' ')
button1 = bold_button(
label: name_of_the_song
)
button1.tooltip_markup = ""\
"<span weight=\"bold\">#{padded_index}</span> "\
"#{name_of_the_song} 🎵️\n → "\
"<span weight=\"bold\" foreground=\"#{@use_this_colour_for_the_tooltip}\">#{entry}</span>"
button1.lightgreen
button1.on_clicked {
do_perform_the_default_actions(button, index)
}
@array_buttons << button1
index_button = create_button(padded_index)
index_button.make_bold
index_button.on_clicked {
do_perform_the_default_actions(button, index)
}
index_button.limegreen
@array_buttons << index_button
mini_hbox = create_hbox
mini_hbox.minimal(index_button)
mini_hbox.maximal(button)
@main_vbox.minimal(mini_hbox, 1)
}
hbox_center_aligned = hbox
hbox_center_aligned.set_border_width(1)
hbox_center_aligned.maximal(
return_widget_increase_or_decrease_audio
)
center_aligned_box = create_alignment(0.5, 0.5, 0.5, 0.5)
center_aligned_box.add(hbox_center_aligned)
_ = draggable_hpane(
@scrolled_window,
center_aligned_box
)
n_percent_to_use = 50.0
use_this_vertical_position = ( (height?.to_i * n_percent_to_use) / 100.0 ).to_i
_.position = use_this_vertical_position
outer_vbox.maximal(_, 0)
window = create_window_or_runner(nil, width?, height?, title?)
window << outer_vbox
properly_prepare_this_window(window,
{
title: title?,
font: font?,
width: width?,
height: height?,
padding: padding?,
border_size: border_size?
}
)
window.show_all
window.top_left
window.set_size(width?, height?)
do_all_startup_related_actions
handle_CSS_rules if use_gtk3?
run_main
end
|
#create_the_skeleton ⇒ Object
330
331
332
|
# File 'lib/multimedia_paradise/gui/universal_widgets/simple_play_widget/simple_play_widget.rb', line 330
def create_the_skeleton
@main_vbox = create_vbox
end
|
323
324
325
|
# File 'lib/multimedia_paradise/gui/universal_widgets/simple_play_widget/simple_play_widget.rb', line 323
def do_all_startup_related_actions
populate_the_dataset_with_this_array
end
|
337
338
339
340
|
# File 'lib/multimedia_paradise/gui/universal_widgets/simple_play_widget/simple_play_widget.rb', line 337
def do_perform_the_default_actions(button, index = 0)
this_song = @dataset[index - 1]
play_this_song_via_mpv(this_song)
end
|
#handle_CSS_rules ⇒ Object
#
handle_CSS_rules (CSS tag)
This is currently only in use if gtk3 is in use.
#
169
170
171
172
173
174
175
|
# File 'lib/multimedia_paradise/gui/universal_widgets/simple_play_widget/simple_play_widget.rb', line 169
def handle_CSS_rules
use_gtk_paradise_project_css_file
append_project_css_file
more_CSS_then_apply_it '
'
end
|
#large_font_in_use? ⇒ Boolean
#
large_font_in_use?
This is like the main font, but a bit larger.
#
196
197
198
|
# File 'lib/multimedia_paradise/gui/universal_widgets/simple_play_widget/simple_play_widget.rb', line 196
def large_font_in_use?
LARGER_FONT
end
|
#main_font? ⇒ Boolean
Also known as:
normal_font?
203
204
205
|
# File 'lib/multimedia_paradise/gui/universal_widgets/simple_play_widget/simple_play_widget.rb', line 203
def main_font?
USE_THIS_FONT
end
|
#padding? ⇒ Boolean
180
181
182
|
# File 'lib/multimedia_paradise/gui/universal_widgets/simple_play_widget/simple_play_widget.rb', line 180
def padding?
4
end
|
#play_this_song_via_mpv(this_song) ⇒ Object
#
play_this_song_via_mpv
#
217
218
219
220
221
222
223
224
225
|
# File 'lib/multimedia_paradise/gui/universal_widgets/simple_play_widget/simple_play_widget.rb', line 217
def play_this_song_via_mpv(this_song)
e
e "Next playing #{::Colours.steelblue(this_song)} via mpv."
e
@array_threads << Thread.new {
pid = Process.spawn("mpv #{this_song}")
@array_pids << pid
}
end
|
#reset ⇒ Object
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
# File 'lib/multimedia_paradise/gui/universal_widgets/simple_play_widget/simple_play_widget.rb', line 100
def reset
super() if respond_to?(:super)
reset_the_shared_module 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)
infer_the_size_automatically
@array_buttons = []
@array_threads = []
@array_pids = []
@dataset = []
@font_size_to_use = 20
@use_this_colour_for_the_tooltip = :lightblue
end
|
#reset_the_shared_module ⇒ Object
#
reset_the_shared_module
This method can be used for ruby-gtk3 and ruby-libui, among other toolkits.
#
147
148
|
# File 'lib/multimedia_paradise/gui/universal_widgets/simple_play_widget/simple_play_widget.rb', line 147
def reset_the_shared_module
end
|
#run ⇒ Object
345
346
347
|
# File 'lib/multimedia_paradise/gui/universal_widgets/simple_play_widget/simple_play_widget.rb', line 345
def run
run_super
end
|
#slightly_smaller_font? ⇒ Boolean
#
slightly_smaller_font?
#
210
211
212
|
# File 'lib/multimedia_paradise/gui/universal_widgets/simple_play_widget/simple_play_widget.rb', line 210
def slightly_smaller_font?
SLIGHTLY_SMALLER_FONT
end
|
#smaller_font? ⇒ Boolean
153
154
155
|
# File 'lib/multimedia_paradise/gui/universal_widgets/simple_play_widget/simple_play_widget.rb', line 153
def smaller_font?
SMALLER_FONT
end
|
#smallest_font? ⇒ Boolean
160
161
162
|
# File 'lib/multimedia_paradise/gui/universal_widgets/simple_play_widget/simple_play_widget.rb', line 160
def smallest_font?
SMALLEST_FONT
end
|