Simple profile support. First time dialog (ugly and only nick atm).

This commit is contained in:
Marco Pesenti Gritti 2006-08-22 16:15:34 +02:00
parent 3e51b086df
commit 511fec421f
7 changed files with 55 additions and 42 deletions

View File

@ -16,12 +16,6 @@ class ShellOwner(object):
self._nick = env.get_nick_name()
user_dir = env.get_user_dir()
try:
os.makedirs(user_dir)
except OSError, exc:
if exc[0] != 17: # file exists
print "Could not create user directory %s: (%d) %s" % (user_dir, exc[0], exc[1])
self._icon = None
for fname in os.listdir(user_dir):
if not fname.startswith("buddy-icon."):

View File

@ -11,11 +11,12 @@ from home.HomeWindow import HomeWindow
from home.HomeModel import HomeModel
from sugar import env
from Owner import ShellOwner
from sugar.presence.PresenceService import PresenceService
from sugar.presence import PresenceService
from ActivityHost import ActivityHost
from ChatController import ChatController
from sugar.activity import ActivityFactory
from sugar.activity import Activity
from FirstTimeDialog import FirstTimeDialog
from sugar import conf
import sugar.logger
@ -64,13 +65,33 @@ class Shell(gobject.GObject):
self._screen = wnck.screen_get_default()
self._hosts = {}
self._zoom_level = Shell.ZOOM_HOME
self._home_window = HomeWindow(self)
self._home_window.show()
self._screen.connect('window-opened', self.__window_opened_cb)
self._screen.connect('window-closed', self.__window_closed_cb)
self._screen.connect("showing_desktop_changed",
self.__showing_desktop_changed_cb)
if env.get_nick_name() == None:
dialog = FirstTimeDialog()
dialog.connect('destroy', self.__first_time_dialog_destroy_cb)
dialog.set_transient_for(self._home_window)
dialog.show()
else:
self.start()
def __first_time_dialog_destroy_cb(self, dialog):
self.start()
def start(self):
session_bus = dbus.SessionBus()
bus_name = dbus.service.BusName('com.redhat.Sugar.Shell', bus=session_bus)
ShellDbusService(self, bus_name)
PresenceService.start()
self._owner = ShellOwner()
self._owner.announce()
@ -78,13 +99,8 @@ class Shell(gobject.GObject):
self._chat_controller.listen()
home_model = HomeModel()
self._home_window = HomeWindow(self, home_model)
self._home_window.show()
self._screen.connect('window-opened', self.__window_opened_cb)
self._screen.connect('window-closed', self.__window_closed_cb)
self._screen.connect("showing_desktop_changed",
self.__showing_desktop_changed_cb)
self._home_window.set_model(home_model)
self._set_zoom_level(Shell.ZOOM_HOME)
def set_console(self, console):
self._console = console
@ -102,7 +118,7 @@ class Shell(gobject.GObject):
def __window_closed_cb(self, screen, window):
if window.get_window_type() == wnck.WINDOW_NORMAL:
xid = window.get_xid()
if self._hosts.has_key(xid):
host = self._hosts[xid]
self.emit('activity-closed', host)
@ -154,7 +170,7 @@ class Shell(gobject.GObject):
if activity:
activity.present()
else:
pservice = PresenceService()
pservice = PresenceService.PresenceService()
activity_ps = pservice.get_activity(activity_id)
if activity_ps:

View File

@ -9,8 +9,9 @@ class HomeWindow(gtk.Window):
FRIENDS_VIEW = 1
MESH_VIEW = 2
def __init__(self, shell, model):
def __init__(self, shell):
gtk.Window.__init__(self)
self._shell = shell
self.connect('realize', self.__realize_cb)
@ -18,24 +19,25 @@ class HomeWindow(gtk.Window):
self._nb.set_show_tabs(False)
self._nb.set_show_border(False)
home_view = HomeView(shell)
self.add(self._nb)
self._nb.show()
def set_model(self, model):
home_view = HomeView(self._shell)
self._nb.append_page(home_view)
self._setup_canvas(home_view)
home_view.show()
friends_view = FriendsView(shell, model.get_friends())
friends_view = FriendsView(self._shell, model.get_friends())
self._nb.append_page(friends_view)
self._setup_canvas(friends_view)
friends_view.show()
mesh_view = MeshView(shell, model.get_mesh())
mesh_view = MeshView(self._shell, model.get_mesh())
self._setup_canvas(mesh_view)
self._nb.append_page(mesh_view)
mesh_view.show()
self.add(self._nb)
self._nb.show()
def set_view(self, view):
self._nb.set_current_page(view)

View File

@ -4,7 +4,6 @@ import gobject
import time
import re
from sugar.presence import PresenceService
from Shell import Shell
from ConsoleWindow import ConsoleWindow
from session.Process import Process
@ -27,9 +26,6 @@ class Session:
"""Takes care of running the shell and all the sugar processes"""
def start(self):
"""Start the session"""
PresenceService.start()
process = MatchboxProcess()
process.start()
@ -38,7 +34,6 @@ class Session:
shell = Shell()
shell.set_console(console)
shell.start()
from sugar import TracebackUtils
tbh = TracebackUtils.TracebackHelper()

View File

@ -1,6 +1,11 @@
from sugar.conf.ActivityRegistry import ActivityRegistry
from sugar.conf.Profile import Profile
__registry = ActivityRegistry()
__profile = Profile()
def get_activity_registry():
return __registry
def get_profile():
return __profile

View File

@ -44,18 +44,19 @@ def setup():
registry = sugar.conf.get_activity_registry()
registry.scan_directory(get_activities_dir())
def get_user_dir():
if os.environ.has_key('SUGAR_NICK_NAME'):
nick = get_nick_name()
return os.path.expanduser('~/.sugar-%s/' % nick)
profile = sugar.conf.get_profile()
if os.environ.has_key('SUGAR_PROFILE'):
profile.read(os.environ['SUGAR_PROFILE'])
else:
return os.path.expanduser('~/.sugar')
profile.read('default')
def get_user_dir():
profile = sugar.conf.get_profile()
return profile.get_path()
def get_nick_name():
if os.environ.has_key('SUGAR_NICK_NAME'):
return os.environ['SUGAR_NICK_NAME']
else:
return pwd.getpwuid(os.getuid())[0]
profile = sugar.conf.get_profile()
return profile.get_nick_name()
def get_data_dir():
return sugar_data_dir