Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@tomeuvizoso.net>2007-06-25 10:48:21 (GMT)
committer Tomeu Vizoso <tomeu@tomeuvizoso.net>2007-06-25 10:48:21 (GMT)
commit811a7d8411f8bea383497cd24ed3836645a55c48 (patch)
tree786f51f4c1f4a401a2efbb3e18fbc3a4c505ff9d
parent400cbc29e52f4824d78d329cc105409f0ac3500e (diff)
Implement shutdown.
-rw-r--r--shell/view/home/HomeBox.py29
1 files changed, 23 insertions, 6 deletions
diff --git a/shell/view/home/HomeBox.py b/shell/view/home/HomeBox.py
index ba0cb1d..e7625da 100644
--- a/shell/view/home/HomeBox.py
+++ b/shell/view/home/HomeBox.py
@@ -14,18 +14,22 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+import os
+import signal
import math
from gettext import gettext as _
import gobject
import gtk
import hippo
+import dbus
from sugar.graphics import units
from sugar.graphics import color
from sugar.graphics.xocolor import XoColor
from sugar.graphics.palette import Palette, CanvasInvoker
from sugar import profile
+from sugar import env
from view.home.activitiesdonut import ActivitiesDonut
from view.devices import deviceview
@@ -43,7 +47,7 @@ class HomeBox(hippo.CanvasBox, hippo.CanvasItem):
box_height=units.grid_to_pixels(6))
self.append(self._donut)
- self._my_icon = HomeMyIcon(units.XLARGE_ICON_SCALE)
+ self._my_icon = HomeMyIcon(shell, units.XLARGE_ICON_SCALE)
self.append(self._my_icon, hippo.PACK_FIXED)
shell_model = shell.get_model()
@@ -82,11 +86,11 @@ class HomeBox(hippo.CanvasBox, hippo.CanvasItem):
if self._donut:
self.remove(self._donut)
self._donut = None
- self._my_icon.props.stroke_color = color.BUTTON_INACTIVE
+ self._my_icon.props.stroke_color = color.ICON_STROKE_INACTIVE
self._my_icon.props.fill_color = \
- color.BUTTON_INACTIVE_BACKGROUND
+ color.ICON_FILL_INACTIVE
self._my_icon.props.background_color = \
- color.BUTTON_INACTIVE_BACKGROUND
+ color.ICON_FILL_INACTIVE.get_int()
def do_allocate(self, width, height, origin_changed):
hippo.CanvasBox.do_allocate(self, width, height, origin_changed)
@@ -124,9 +128,10 @@ class HomeBox(hippo.CanvasBox, hippo.CanvasItem):
class HomeMyIcon(MyIcon):
_POPUP_PALETTE_DELAY = 100
- def __init__(self, scale):
+ def __init__(self, shell, scale):
MyIcon.__init__(self, scale)
+ self._shell = shell
self._palette = Palette()
self._palette.set_primary_state(profile.get_nick_name())
self._palette.props.invoker = CanvasInvoker(self)
@@ -188,5 +193,17 @@ class HomeMyIcon(MyIcon):
return False
def _shutdown_activate_cb(self, menuitem):
- pass
+ model = self._shell.get_model()
+ model.props.state = ShellModel.STATE_SHUTDOWN
+
+ if env.is_emulator():
+ if os.environ.has_key('SUGAR_EMULATOR_PID'):
+ pid = int(os.environ['SUGAR_EMULATOR_PID'])
+ os.kill(pid, signal.SIGTERM)
+ else:
+ bus = dbus.SystemBus()
+ proxy = bus.get_object('org.freedesktop.Hal',
+ '/org/freedesktop/Hal/devices/computer')
+ mgr = dbus.Interface(proxy, 'org.freedesktop.Hal.Device.SystemPowerManagement')
+ mgr.Shutdown()