2007-06-24 14:45:05 +02:00
|
|
|
# Copyright (C) 2006-2007 Red Hat, Inc.
|
2006-10-15 01:24:45 +02:00
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
|
2006-10-31 13:10:34 +01:00
|
|
|
import os
|
|
|
|
|
2007-07-02 14:53:50 +02:00
|
|
|
import wnck
|
2007-01-11 11:20:08 +01:00
|
|
|
import gobject
|
|
|
|
|
2007-04-09 20:40:56 +02:00
|
|
|
from sugar.presence import presenceservice
|
2006-09-15 16:19:56 +02:00
|
|
|
from model.Friends import Friends
|
2006-09-25 16:01:11 +02:00
|
|
|
from model.MeshModel import MeshModel
|
2006-12-24 14:35:02 +01:00
|
|
|
from model.homemodel import HomeModel
|
2006-09-15 12:52:37 +02:00
|
|
|
from model.Owner import ShellOwner
|
2007-02-20 11:48:03 +01:00
|
|
|
from model.devices.devicesmodel import DevicesModel
|
2006-11-05 18:14:00 +01:00
|
|
|
from sugar import env
|
2006-09-15 12:40:46 +02:00
|
|
|
|
2007-01-11 11:20:08 +01:00
|
|
|
class ShellModel(gobject.GObject):
|
|
|
|
STATE_STARTUP = 0
|
|
|
|
STATE_RUNNING = 1
|
|
|
|
STATE_SHUTDOWN = 2
|
|
|
|
|
2007-07-02 14:34:41 +02:00
|
|
|
ZOOM_MESH = 0
|
|
|
|
ZOOM_FRIENDS = 1
|
|
|
|
ZOOM_HOME = 2
|
|
|
|
ZOOM_ACTIVITY = 3
|
|
|
|
|
2007-01-11 11:20:08 +01:00
|
|
|
__gproperties__ = {
|
2007-07-02 14:53:50 +02:00
|
|
|
'state' : (int, None, None,
|
|
|
|
0, 2, STATE_RUNNING,
|
|
|
|
gobject.PARAM_READWRITE),
|
|
|
|
'zoom-level' : (int, None, None,
|
|
|
|
0, 3, ZOOM_HOME,
|
|
|
|
gobject.PARAM_READABLE)
|
2007-01-11 11:20:08 +01:00
|
|
|
}
|
|
|
|
|
2006-12-04 20:12:24 +01:00
|
|
|
def __init__(self):
|
2007-01-11 11:20:08 +01:00
|
|
|
gobject.GObject.__init__(self)
|
|
|
|
|
2006-12-04 20:12:24 +01:00
|
|
|
self._current_activity = None
|
2007-01-11 11:20:08 +01:00
|
|
|
self._state = self.STATE_RUNNING
|
2007-07-02 14:53:50 +02:00
|
|
|
self._zoom_level = self.ZOOM_HOME
|
2007-09-14 13:58:59 +02:00
|
|
|
self._showing_desktop = True
|
2006-09-15 12:40:46 +02:00
|
|
|
|
2007-04-09 20:40:56 +02:00
|
|
|
self._pservice = presenceservice.get_instance()
|
2006-09-15 12:40:46 +02:00
|
|
|
|
2006-12-04 20:12:24 +01:00
|
|
|
self._owner = ShellOwner()
|
2006-10-29 19:05:09 +01:00
|
|
|
|
2006-12-04 20:12:24 +01:00
|
|
|
self._friends = Friends()
|
2007-02-21 17:53:44 +01:00
|
|
|
self._mesh = MeshModel()
|
|
|
|
self._home = HomeModel()
|
2007-02-20 11:48:03 +01:00
|
|
|
self._devices = DevicesModel()
|
2006-10-31 13:10:34 +01:00
|
|
|
|
2007-07-02 14:53:50 +02:00
|
|
|
self._screen = wnck.screen_get_default()
|
|
|
|
self._screen.connect('showing-desktop-changed',
|
|
|
|
self._showing_desktop_changed_cb)
|
|
|
|
|
|
|
|
def set_zoom_level(self, level):
|
|
|
|
self._zoom_level = level
|
2007-07-02 15:00:55 +02:00
|
|
|
self.notify('zoom-level')
|
2007-07-02 14:53:50 +02:00
|
|
|
|
|
|
|
def get_zoom_level(self):
|
|
|
|
if self._screen.get_showing_desktop():
|
|
|
|
return self._zoom_level
|
|
|
|
else:
|
|
|
|
return self.ZOOM_ACTIVITY
|
|
|
|
|
2007-01-11 11:20:08 +01:00
|
|
|
def do_set_property(self, pspec, value):
|
|
|
|
if pspec.name == 'state':
|
|
|
|
self._state = value
|
|
|
|
|
|
|
|
def do_get_property(self, pspec):
|
|
|
|
if pspec.name == 'state':
|
|
|
|
return self._state
|
2007-07-02 14:53:50 +02:00
|
|
|
elif pspec.name == 'zoom-level':
|
|
|
|
return self.get_zoom_level()
|
2007-01-11 11:20:08 +01:00
|
|
|
|
2006-12-04 20:12:24 +01:00
|
|
|
def get_mesh(self):
|
|
|
|
return self._mesh
|
2006-09-15 12:40:46 +02:00
|
|
|
|
2006-12-04 20:12:24 +01:00
|
|
|
def get_friends(self):
|
|
|
|
return self._friends
|
2006-09-15 12:40:46 +02:00
|
|
|
|
2006-12-04 20:12:24 +01:00
|
|
|
def get_invites(self):
|
|
|
|
return self._owner.get_invites()
|
2006-09-15 12:40:46 +02:00
|
|
|
|
2006-12-24 14:35:02 +01:00
|
|
|
def get_home(self):
|
|
|
|
return self._home
|
|
|
|
|
2006-12-04 20:12:24 +01:00
|
|
|
def get_owner(self):
|
|
|
|
return self._owner
|
2007-02-20 11:48:03 +01:00
|
|
|
|
|
|
|
def get_devices(self):
|
|
|
|
return self._devices
|
2007-07-02 14:53:50 +02:00
|
|
|
|
|
|
|
def _showing_desktop_changed_cb(self, screen):
|
2007-09-14 13:58:59 +02:00
|
|
|
showing_desktop = self._screen.get_showing_desktop()
|
|
|
|
if self._showing_desktop != showing_desktop:
|
|
|
|
self._showing_desktop = showing_desktop
|
|
|
|
self.notify('zoom-level')
|