Module: MultimediaParadise::GUI::Gtk::WidgetIncreaseOrDecreaseAudioModule
- Includes:
- Gtk::BaseModule
- Included in:
- WidgetIncreaseOrDecreaseAudio
- Defined in:
- lib/multimedia_paradise/gui/shared_code/widget_increase_or_decrease_audio/widget_increase_or_decrease_audio_module.rb
Constant Summary collapse
- NAMESPACE =
#
NAMESPACE
#
inspect
- WIDTH =
#
WIDTH
#
'35%'
- HEIGHT =
#
HEIGHT
#
'25%'
- USE_THIS_FONT =
#
USE_THIS_FONT
#
:hack_20
- REGEX_TO_USE_FOR_THE_CURRENT_VOLUME_PERCENTAGE_VALUE =
/\[(\d+%)\]/
Class Method Summary collapse
-
.[](i = '') ⇒ Object
# === MultimediaParadise::GUI::Gtk::WidgetIncreaseOrDecreaseAudio.new[] ========================================================================= #.
-
.run ⇒ Object
# === MultimediaParadise::GUI::Gtk::WidgetIncreaseOrDecreaseAudio.run ========================================================================= #.
Instance Method Summary collapse
-
#connect_skeleton ⇒ Object
# === connect_skeleton ========================================================================= #.
-
#create_buttons ⇒ Object
# === create_buttons ========================================================================= #.
-
#create_skeleton ⇒ Object
# === create_skeleton ========================================================================= #.
-
#create_volume_percentage_label ⇒ Object
# === create_volume_percentage_label ========================================================================= #.
-
#decrease_audio_by_n_percent ⇒ Object
# === decrease_audio_by_n_percent ========================================================================= #.
-
#determine_the_current_volume_percentage_value ⇒ Object
# === determine_the_current_volume_percentage_value ========================================================================= #.
-
#handle_CSS_rules ⇒ Object
# === handle_CSS_rules (CSS tag) ========================================================================= #.
-
#increase_audio_by_n_percent ⇒ Object
# === increase_audio_by_n_percent ========================================================================= #.
-
#initialize(commandline_arguments = nil, run_already = true) ⇒ Object
# === initialize ========================================================================= #.
-
#n_percent_changes? ⇒ Boolean
(also: #n_percent?)
# === n_percent_changes? ========================================================================= #.
-
#reset ⇒ Object
# === reset (reset tag) ========================================================================= #.
-
#return_cmd_to_run_for_the_audio_decrease ⇒ Object
# === return_cmd_to_run_for_the_audio_decrease ========================================================================= #.
-
#return_cmd_to_run_for_the_audio_increase ⇒ Object
# === return_cmd_to_run_for_the_audio_increase ========================================================================= #.
-
#return_inferred_position(use_this_offset = 200) ⇒ Object
# === return_inferred_position ========================================================================= #.
-
#run ⇒ Object
# === run (run tag) ========================================================================= #.
Class Method Details
.[](i = '') ⇒ Object
#
MultimediaParadise::GUI::Gtk::WidgetIncreaseOrDecreaseAudio.new[]
#
297 298 299 |
# File 'lib/multimedia_paradise/gui/shared_code/widget_increase_or_decrease_audio/widget_increase_or_decrease_audio_module.rb', line 297 def self.[](i = '') new(i) end |
.run ⇒ Object
#
MultimediaParadise::GUI::Gtk::WidgetIncreaseOrDecreaseAudio.run
#
285 286 287 288 289 290 291 292 |
# File 'lib/multimedia_paradise/gui/shared_code/widget_increase_or_decrease_audio/widget_increase_or_decrease_audio_module.rb', line 285 def self.run require 'gtk_paradise/run' _ = MultimediaParadise::GUI::Gtk::WidgetIncreaseOrDecreaseAudio.new(ARGV) r = ::Gtk.run r << _ r.set_size_request(_.width?, _.height?) r.top_left_then_run end |
Instance Method Details
#connect_skeleton ⇒ Object
#
connect_skeleton
#
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/multimedia_paradise/gui/shared_code/widget_increase_or_decrease_audio/widget_increase_or_decrease_audio_module.rb', line 127 def connect_skeleton # ======================================================================= # # Pack these two buttons into a horizontal-hbox next: # ======================================================================= # # middle_pane = gtk_draggable_vpane vbox_left = gtk_vbox # ======================================================================= # # === eventbox_image_audio_volume_high # ======================================================================= # eventbox_image_audio_volume_high = gtk_eventbox(image_audio_volume_high) eventbox_image_audio_volume_high.clear_background eventbox_image_audio_volume_high.css_class('fancy_button') eventbox_image_audio_volume_high.on_clicked { increase_audio_by_n_percent } vbox_left.minimal(eventbox_image_audio_volume_high) vbox_left.minimal(@array_buttons[0]) # middle_pane.add(hbox_left) vbox_right = gtk_vbox # ======================================================================= # # === eventbox_image_audio_volume_low # ======================================================================= # eventbox_image_audio_volume_low = gtk_eventbox(image_audio_volume_low) eventbox_image_audio_volume_low.clear_background eventbox_image_audio_volume_low.css_class('fancy_button') eventbox_image_audio_volume_low.on_clicked { decrease_audio_by_n_percent } vbox_right.minimal(eventbox_image_audio_volume_low) vbox_right.minimal(@array_buttons[1]) # middle_pane.add(hbox_right) # middle_pane.position = return_inferred_position grid = default_grid grid.left(vbox_left) grid.middle(vbox_right) alignment = gtk_alignment(0.5, 1.0, 1, 1) alignment.add(@volume_percentage_label) grid.middle(alignment) minimal(grid, 2) determine_the_current_volume_percentage_value end |
#create_buttons ⇒ Object
#
create_buttons
#
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 210 211 212 213 214 215 |
# File 'lib/multimedia_paradise/gui/shared_code/widget_increase_or_decrease_audio/widget_increase_or_decrease_audio_module.rb', line 181 def # === button_increase_audio = ("_Increase audio by +#{@n_percent_changes}%") .tooltip_markup = 'Increase the audio by +<b>'+@n_percent_changes.to_s+'%</b>'+ "\n\nThe command that will be run here is:\n\n "\ "<b>#{return_cmd_to_run_for_the_audio_increase}</b>\n" .on_clicked { increase_audio_by_n_percent } = ("_Decrease audio by -#{@n_percent_changes}%") .tooltip_markup = ' Decrease the audio by -<b>'+@n_percent_changes.to_s+'%</b> '+ "\n\nThe command that will be run here is:\n\n "\ "<b>#{return_cmd_to_run_for_the_audio_decrease}</b>\n" .on_clicked { decrease_audio_by_n_percent } # ======================================================================= # # Style both buttons uniformly. # ======================================================================= # @array_buttons = [ , ] @array_buttons.each {|| # this_button.background_colour = :lightblue # this_button.hover_colour = :paleturquoise .set_name('button1') # Old CSS rule was: 'BG_paleturquoise_and_black' .set_size_request(120, 40) .disallow_resizing } end |
#create_skeleton ⇒ Object
#
create_skeleton
#
220 221 222 223 |
# File 'lib/multimedia_paradise/gui/shared_code/widget_increase_or_decrease_audio/widget_increase_or_decrease_audio_module.rb', line 220 def create_skeleton create_volume_percentage_label end |
#create_volume_percentage_label ⇒ Object
#
create_volume_percentage_label
#
228 229 230 231 232 233 234 |
# File 'lib/multimedia_paradise/gui/shared_code/widget_increase_or_decrease_audio/widget_increase_or_decrease_audio_module.rb', line 228 def create_volume_percentage_label # ======================================================================= # # === @volume_percentage_label # ======================================================================= # @volume_percentage_label = gtk_label @volume_percentage_label.justify = ::Gtk::Justification::CENTER end |
#decrease_audio_by_n_percent ⇒ Object
#
decrease_audio_by_n_percent
#
270 271 272 273 |
# File 'lib/multimedia_paradise/gui/shared_code/widget_increase_or_decrease_audio/widget_increase_or_decrease_audio_module.rb', line 270 def decrease_audio_by_n_percent system return_cmd_to_run_for_the_audio_decrease determine_the_current_volume_percentage_value end |
#determine_the_current_volume_percentage_value ⇒ Object
#
determine_the_current_volume_percentage_value
#
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/multimedia_paradise/gui/shared_code/widget_increase_or_decrease_audio/widget_increase_or_decrease_audio_module.rb', line 239 def determine_the_current_volume_percentage_value result = `amixer sget Master` if result.include? "\n" result = result.split("\n").last.strip end # ======================================================================= # # result may look like this now: # # Mono: Playback 56 [88%] [-8.00dB] [on] # # ======================================================================= # percentage_value = result.scan( REGEX_TO_USE_FOR_THE_CURRENT_VOLUME_PERCENTAGE_VALUE ).flatten.first @volume_percentage_label.set_text( percentage_value.to_s. rjust(5, ' ') ) end |
#handle_CSS_rules ⇒ Object
#
handle_CSS_rules (CSS tag)
#
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/multimedia_paradise/gui/shared_code/widget_increase_or_decrease_audio/widget_increase_or_decrease_audio_module.rb', line 86 def handle_CSS_rules use_the_gtk_paradise_css_file more_CSS_then_apply_it ' #BG_paleturquoise_and_black { color: black; background: paleturquoise; } .fancy_button:hover { transition: 2000ms linear; background-color: tomato; } ' end |
#increase_audio_by_n_percent ⇒ Object
#
increase_audio_by_n_percent
#
262 263 264 265 |
# File 'lib/multimedia_paradise/gui/shared_code/widget_increase_or_decrease_audio/widget_increase_or_decrease_audio_module.rb', line 262 def increase_audio_by_n_percent system return_cmd_to_run_for_the_audio_increase determine_the_current_volume_percentage_value end |
#initialize(commandline_arguments = nil, run_already = true) ⇒ Object
#
initialize
#
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/multimedia_paradise/gui/shared_code/widget_increase_or_decrease_audio/widget_increase_or_decrease_audio_module.rb', line 50 def initialize( commandline_arguments = nil, run_already = true ) super(:horizontal) reset set_commandline_arguments( commandline_arguments ) run if run_already end |
#n_percent_changes? ⇒ Boolean Also known as: n_percent?
#
n_percent_changes?
#
106 107 108 |
# File 'lib/multimedia_paradise/gui/shared_code/widget_increase_or_decrease_audio/widget_increase_or_decrease_audio_module.rb', line 106 def n_percent_changes? @n_percent_changes end |
#reset ⇒ Object
#
reset (reset tag)
#
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/multimedia_paradise/gui/shared_code/widget_increase_or_decrease_audio/widget_increase_or_decrease_audio_module.rb', line 65 def reset reset_the_internal_variables # ======================================================================= # # === @configuration # ======================================================================= # @configuration = [true, __dir__, NAMESPACE] width_height_font(WIDTH, HEIGHT, USE_THIS_FONT) # ======================================================================= # # === @n_percent_changes # # This variable denotes how many steps we may take "up" or "down" when # changing the audio-volume. # ======================================================================= # @n_percent_changes = 3 handle_CSS_rules infer_the_size_automatically end |
#return_cmd_to_run_for_the_audio_decrease ⇒ Object
#
return_cmd_to_run_for_the_audio_decrease
#
120 121 122 |
# File 'lib/multimedia_paradise/gui/shared_code/widget_increase_or_decrease_audio/widget_increase_or_decrease_audio_module.rb', line 120 def return_cmd_to_run_for_the_audio_decrease "amixer set Master #{n_percent?}%-" end |
#return_cmd_to_run_for_the_audio_increase ⇒ Object
#
return_cmd_to_run_for_the_audio_increase
#
113 114 115 |
# File 'lib/multimedia_paradise/gui/shared_code/widget_increase_or_decrease_audio/widget_increase_or_decrease_audio_module.rb', line 113 def return_cmd_to_run_for_the_audio_increase 'amixer set Master '+n_percent?.to_s+'%+' end |
#return_inferred_position(use_this_offset = 200) ⇒ Object
#
return_inferred_position
#
172 173 174 175 176 |
# File 'lib/multimedia_paradise/gui/shared_code/widget_increase_or_decrease_audio/widget_increase_or_decrease_audio_module.rb', line 172 def return_inferred_position( use_this_offset = 200 ) (width? / 2)+use_this_offset end |
#run ⇒ Object
#
run (run tag)
#
278 279 280 |
# File 'lib/multimedia_paradise/gui/shared_code/widget_increase_or_decrease_audio/widget_increase_or_decrease_audio_module.rb', line 278 def run create_skeleton_then_connect_skeleton end |