Save state of volume when shutdown and reboot fix for #3652

This commit is contained in:
Simon Schampijer 2007-09-24 18:00:36 +02:00
parent 0a53813064
commit e3f97b042f
5 changed files with 31 additions and 0 deletions

1
NEWS
View File

@ -1,3 +1,4 @@
* #3652 Save state of volume when shutdown (erikos)
* #3378 Support changes in activity scope (incomplete!) (smcv, marco)
* #3081, #3497, #3485 Fix palette sizing and widget placement (benzea)
* #2211 New XRestop interface style in Developer Console (edsiper)

View File

@ -21,6 +21,8 @@ import gst
import gst.interfaces
from hardware.nmclient import NMClient
from sugar.profile import get_profile
from sugar import env
_HARDWARE_MANAGER_INTERFACE = 'org.laptop.HardwareManager'
_HARDWARE_MANAGER_SERVICE = 'org.laptop.HardwareManager'
@ -80,6 +82,17 @@ class HardwareManager(object):
logging.error('Cannot mute the audio channel')
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):
if not self._service:
return

View File

@ -147,6 +147,9 @@ if __name__ == '__main__':
main()
hw_manager = hardwaremanager.get_manager()
hw_manager.startup()
try:
gtk.main()
except KeyboardInterrupt:

View File

@ -24,6 +24,7 @@ import gtk
import hippo
import dbus
from hardware import hardwaremanager
from sugar.graphics import style
from sugar.graphics.xocolor import XoColor
from sugar.graphics.palette import Palette, CanvasInvoker
@ -169,6 +170,9 @@ class HomeMyIcon(MyIcon):
pm = self._get_power_manager()
hw_manager = hardwaremanager.get_manager()
hw_manager.shutdown()
if env.is_emulator():
self._close_emulator()
else:
@ -180,6 +184,9 @@ class HomeMyIcon(MyIcon):
pm = self._get_power_manager()
hw_manager = hardwaremanager.get_manager()
hw_manager.shutdown()
if env.is_emulator():
self._close_emulator()
else:

View File

@ -25,6 +25,7 @@ from sugar import util
from sugar.graphics.xocolor import XoColor
DEFAULT_JABBER_SERVER = 'olpc.collabora.co.uk'
DEFAULT_VOLUME = 81
_profile = None
@ -93,6 +94,8 @@ class Profile(object):
_set_key(cp, 'Jabber', 'Registered', self.jabber_registered)
_set_key(cp, 'Sound', 'Volume', self.sound_volume)
f = open(self._config_path, 'w')
cp.write(f)
f.close()
@ -115,6 +118,10 @@ class Profile(object):
self.jabber_registered = True
if cp.has_option('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