Commit 11d195fb authored by Todd Weaver's avatar Todd Weaver
Browse files

Changing Volume Button (with subsequent click-to-adjust volume user-flow) in...

Changing Volume Button (with subsequent click-to-adjust volume user-flow) in favor of a direct mute and spinner button for volume control within the menu
parent 7bc79401
......@@ -28,6 +28,7 @@ class Menu(Gtk.PopoverMenu):
autoplay_toggle = Gtk.Template.Child()
volume = Gtk.Template.Child()
volume_icon = Gtk.Template.Child()
def __init__(self, app_window, **kwargs):
super().__init__(**kwargs)
......@@ -35,14 +36,25 @@ class Menu(Gtk.PopoverMenu):
self.app_window = app_window
@Gtk.Template.Callback()
def volume_change(self, event, data):
self.volume_slider(event.get_value())
def volume_change(self, event):
self.volume_setting(event.get_value())
def volume_slider(self, volume_value):
@Gtk.Template.Callback()
def mute_toggle(self, toggle_button):
if toggle_button.get_active():
self.volume_icon.set_property('icon-name', 'audio-volume-muted-symbolic')
self.volume_setting(0)
else:
self.volume_icon.set_property('icon-name', 'audio-volume-medium-symbolic')
self.volume_setting(self.volume.get_value())
def volume_setting(self, volume_value):
# gstreamer uses decimal 0.0 to 1.0 for volume
volume_decimal = volume_value / 100
list = self.app_window.get_scroller_list()
children = list.get_children()
for child in children:
child.get_child().player.set_property("volume", volume_value)
child.get_child().player.set_property("volume", volume_decimal)
@Gtk.Template.Callback()
def show_about(self, data):
......
......@@ -333,7 +333,7 @@ class ResultsBox(Gtk.Box):
# allow seeking
self.slider.set_sensitive(True)
app_volume = self.app_window.menu.volume.get_value()
app_volume = self.app_window.menu.volume.get_value() / 100
self.player.set_property("volume", app_volume)
# update slider to track video time in slider
......
......@@ -3,9 +3,10 @@
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkAdjustment" id="volume_adjustment">
<property name="upper">1</property>
<property name="step-increment">.05</property>
<property name="page-increment">.1</property>
<property name="upper">100</property>
<property name="value">90</property>
<property name="step-increment">5</property>
<property name="page-increment">10</property>
</object>
<template class="Menu" parent="GtkPopoverMenu">
<property name="can-focus">False</property>
......@@ -24,37 +25,43 @@
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkLabel">
<object class="GtkToggleButton" id="volume_button">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">start</property>
<property name="margin-left">6</property>
<property name="margin-start">6</property>
<property name="label" translatable="yes">Volume</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="tooltip-text" translatable="yes">Mute</property>
<signal name="clicked" handler="mute_toggle" swapped="no"/>
<child>
<object class="GtkImage" id="volume_icon">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">audio-volume-medium-symbolic</property>
<property name="icon_size">1</property>
</object>
</child>
<style>
<class name="image-button"/>
</style>
</object>
<packing>
<property name="expand">True</property>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkVolumeButton" id="volume">
<object class="GtkSpinButton" id="volume">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="focus-on-click">False</property>
<property name="halign">end</property>
<property name="margin-start">6</property>
<property name="max-length">3</property>
<property name="adjustment">volume_adjustment</property>
<property name="orientation">horizontal</property>
<property name="numeric">True</property>
<property name="value">90</property>
<signal name="value-changed" handler="volume_change" swapped="no"/>
<property name="value">0.90</property>
<property name="icons">audio-volume-muted-symbolic
audio-volume-high-symbolic
audio-volume-low-symbolic
audio-volume-medium-symbolic</property>
</object>
<packing>
<property name="expand">False</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
......
......@@ -317,16 +317,16 @@ class StreamWindow(Handy.ApplicationWindow):
def volume_up_keypress(self):
current_volume = self.menu.volume.get_value()
louder = 1.0
if current_volume <= 0.9:
louder = current_volume + 0.1
louder = 100
if current_volume <= 90:
louder = current_volume + 10
self.menu.volume.set_value(louder)
self.focus_child()
def volume_down_keypress(self):
current_volume = self.menu.volume.get_value()
quieter = 0
if current_volume >= 0.1:
quieter = current_volume - 0.1
if current_volume >= 10:
quieter = current_volume - 10
self.menu.volume.set_value(quieter)
self.focus_child()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment