2006-10-15 01:24:45 +02:00
|
|
|
# Copyright (C) 2006, Red Hat, Inc.
|
|
|
|
#
|
|
|
|
# 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-07-12 13:20:41 +02:00
|
|
|
import os
|
2006-07-12 14:02:29 +02:00
|
|
|
import gtk
|
2006-08-12 01:29:55 +02:00
|
|
|
|
2006-09-15 13:23:21 +02:00
|
|
|
from view.Shell import Shell
|
2006-09-15 12:52:37 +02:00
|
|
|
from model.ShellModel import ShellModel
|
2006-09-04 21:49:58 +02:00
|
|
|
from sugar import env
|
|
|
|
from sugar import logger
|
2006-08-20 12:10:12 +02:00
|
|
|
|
2006-09-10 02:35:53 +02:00
|
|
|
from sugar.session.Process import Process
|
|
|
|
from sugar.session.DbusProcess import DbusProcess
|
|
|
|
from sugar.session.MatchboxProcess import MatchboxProcess
|
2006-07-19 20:58:29 +02:00
|
|
|
|
2006-09-15 13:23:21 +02:00
|
|
|
from view.FirstTimeDialog import FirstTimeDialog
|
2006-09-10 02:35:53 +02:00
|
|
|
import conf
|
2006-07-12 13:20:41 +02:00
|
|
|
|
2006-09-08 05:28:01 +02:00
|
|
|
class DBusMonitorProcess(Process):
|
|
|
|
def __init__(self):
|
|
|
|
Process.__init__(self, "dbus-monitor --session")
|
|
|
|
|
|
|
|
def get_name(self):
|
|
|
|
return 'dbus-monitor'
|
|
|
|
|
2006-07-12 13:20:41 +02:00
|
|
|
class Session:
|
|
|
|
"""Takes care of running the shell and all the sugar processes"""
|
2006-09-04 21:49:58 +02:00
|
|
|
|
|
|
|
def _check_profile(self):
|
|
|
|
profile = conf.get_profile()
|
|
|
|
|
2006-09-26 22:52:45 +02:00
|
|
|
name = profile.get_nick_name()
|
|
|
|
if not name or not len(name):
|
2006-09-04 21:49:58 +02:00
|
|
|
dialog = FirstTimeDialog()
|
|
|
|
dialog.run()
|
|
|
|
profile.save()
|
|
|
|
|
|
|
|
env.setup_user(profile)
|
|
|
|
|
2006-07-12 13:20:41 +02:00
|
|
|
def start(self):
|
|
|
|
"""Start the session"""
|
2006-09-04 21:49:58 +02:00
|
|
|
process = MatchboxProcess()
|
2006-08-23 11:52:18 +02:00
|
|
|
process.start()
|
|
|
|
|
2006-09-04 21:49:58 +02:00
|
|
|
self._check_profile()
|
|
|
|
|
|
|
|
process = DbusProcess()
|
2006-07-12 13:20:41 +02:00
|
|
|
process.start()
|
2006-07-23 06:56:40 +02:00
|
|
|
|
2006-09-08 18:03:40 +02:00
|
|
|
if os.environ.has_key('SUGAR_DBUS_MONITOR'):
|
2006-09-08 05:28:01 +02:00
|
|
|
dbm = DBusMonitorProcess()
|
|
|
|
dbm.start()
|
|
|
|
|
2006-09-15 12:40:22 +02:00
|
|
|
model = ShellModel()
|
|
|
|
shell = Shell(model)
|
2006-07-12 13:20:41 +02:00
|
|
|
|
2006-08-17 18:02:29 +02:00
|
|
|
from sugar import TracebackUtils
|
|
|
|
tbh = TracebackUtils.TracebackHelper()
|
2006-07-12 13:20:41 +02:00
|
|
|
try:
|
|
|
|
gtk.main()
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
print 'Ctrl+C pressed, exiting...'
|
2006-08-17 18:02:29 +02:00
|
|
|
del tbh
|