Save state of volume when shutdown and reboot fix for #3652
This commit is contained in:
parent
0a53813064
commit
e3f97b042f
1
NEWS
1
NEWS
@ -1,3 +1,4 @@
|
|||||||
|
* #3652 Save state of volume when shutdown (erikos)
|
||||||
* #3378 Support changes in activity scope (incomplete!) (smcv, marco)
|
* #3378 Support changes in activity scope (incomplete!) (smcv, marco)
|
||||||
* #3081, #3497, #3485 Fix palette sizing and widget placement (benzea)
|
* #3081, #3497, #3485 Fix palette sizing and widget placement (benzea)
|
||||||
* #2211 New XRestop interface style in Developer Console (edsiper)
|
* #2211 New XRestop interface style in Developer Console (edsiper)
|
||||||
|
@ -21,6 +21,8 @@ import gst
|
|||||||
import gst.interfaces
|
import gst.interfaces
|
||||||
|
|
||||||
from hardware.nmclient import NMClient
|
from hardware.nmclient import NMClient
|
||||||
|
from sugar.profile import get_profile
|
||||||
|
from sugar import env
|
||||||
|
|
||||||
_HARDWARE_MANAGER_INTERFACE = 'org.laptop.HardwareManager'
|
_HARDWARE_MANAGER_INTERFACE = 'org.laptop.HardwareManager'
|
||||||
_HARDWARE_MANAGER_SERVICE = 'org.laptop.HardwareManager'
|
_HARDWARE_MANAGER_SERVICE = 'org.laptop.HardwareManager'
|
||||||
@ -80,6 +82,17 @@ class HardwareManager(object):
|
|||||||
logging.error('Cannot mute the audio channel')
|
logging.error('Cannot mute the audio channel')
|
||||||
self._mixer.set_mute(self._master, mute)
|
self._mixer.set_mute(self._master, mute)
|
||||||
|
|
||||||
|
def startup(self):
|
||||||
|
if env.is_emulator() is False:
|
||||||
|
profile = get_profile()
|
||||||
|
self.set_volume(profile.sound_volume)
|
||||||
|
|
||||||
|
def shutdown(self):
|
||||||
|
if env.is_emulator() is False:
|
||||||
|
profile = get_profile()
|
||||||
|
profile.sound_volume = self.get_volume()
|
||||||
|
profile.save()
|
||||||
|
|
||||||
def set_dcon_freeze(self, frozen):
|
def set_dcon_freeze(self, frozen):
|
||||||
if not self._service:
|
if not self._service:
|
||||||
return
|
return
|
||||||
|
@ -147,6 +147,9 @@ if __name__ == '__main__':
|
|||||||
|
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
hw_manager = hardwaremanager.get_manager()
|
||||||
|
hw_manager.startup()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
gtk.main()
|
gtk.main()
|
||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
|
@ -24,6 +24,7 @@ import gtk
|
|||||||
import hippo
|
import hippo
|
||||||
import dbus
|
import dbus
|
||||||
|
|
||||||
|
from hardware import hardwaremanager
|
||||||
from sugar.graphics import style
|
from sugar.graphics import style
|
||||||
from sugar.graphics.xocolor import XoColor
|
from sugar.graphics.xocolor import XoColor
|
||||||
from sugar.graphics.palette import Palette, CanvasInvoker
|
from sugar.graphics.palette import Palette, CanvasInvoker
|
||||||
@ -169,6 +170,9 @@ class HomeMyIcon(MyIcon):
|
|||||||
|
|
||||||
pm = self._get_power_manager()
|
pm = self._get_power_manager()
|
||||||
|
|
||||||
|
hw_manager = hardwaremanager.get_manager()
|
||||||
|
hw_manager.shutdown()
|
||||||
|
|
||||||
if env.is_emulator():
|
if env.is_emulator():
|
||||||
self._close_emulator()
|
self._close_emulator()
|
||||||
else:
|
else:
|
||||||
@ -180,6 +184,9 @@ class HomeMyIcon(MyIcon):
|
|||||||
|
|
||||||
pm = self._get_power_manager()
|
pm = self._get_power_manager()
|
||||||
|
|
||||||
|
hw_manager = hardwaremanager.get_manager()
|
||||||
|
hw_manager.shutdown()
|
||||||
|
|
||||||
if env.is_emulator():
|
if env.is_emulator():
|
||||||
self._close_emulator()
|
self._close_emulator()
|
||||||
else:
|
else:
|
||||||
|
@ -25,6 +25,7 @@ from sugar import util
|
|||||||
from sugar.graphics.xocolor import XoColor
|
from sugar.graphics.xocolor import XoColor
|
||||||
|
|
||||||
DEFAULT_JABBER_SERVER = 'olpc.collabora.co.uk'
|
DEFAULT_JABBER_SERVER = 'olpc.collabora.co.uk'
|
||||||
|
DEFAULT_VOLUME = 81
|
||||||
|
|
||||||
_profile = None
|
_profile = None
|
||||||
|
|
||||||
@ -93,6 +94,8 @@ class Profile(object):
|
|||||||
|
|
||||||
_set_key(cp, 'Jabber', 'Registered', self.jabber_registered)
|
_set_key(cp, 'Jabber', 'Registered', self.jabber_registered)
|
||||||
|
|
||||||
|
_set_key(cp, 'Sound', 'Volume', self.sound_volume)
|
||||||
|
|
||||||
f = open(self._config_path, 'w')
|
f = open(self._config_path, 'w')
|
||||||
cp.write(f)
|
cp.write(f)
|
||||||
f.close()
|
f.close()
|
||||||
@ -115,6 +118,10 @@ class Profile(object):
|
|||||||
self.jabber_registered = True
|
self.jabber_registered = True
|
||||||
if cp.has_option('Server', 'Backup1'):
|
if cp.has_option('Server', 'Backup1'):
|
||||||
self.backup1 = cp.get('Server', 'Backup1')
|
self.backup1 = cp.get('Server', 'Backup1')
|
||||||
|
if cp.has_option('Sound', 'Volume'):
|
||||||
|
self.sound_volume = float(cp.get('Sound', 'Volume'))
|
||||||
|
else:
|
||||||
|
self.sound_volume = DEFAULT_VOLUME
|
||||||
|
|
||||||
del cp
|
del cp
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user