diff options
author | Marco Pesenti Gritti <mpgritti@gmail.com> | 2008-10-06 08:34:50 (GMT) |
---|---|---|
committer | Marco Pesenti Gritti <mpgritti@gmail.com> | 2008-10-06 08:34:50 (GMT) |
commit | 8dbc090d4cf70a4171543d60ebba3f9a2d2affdd (patch) | |
tree | 197065f654e01ca5501957d09bf244c0ab934090 /bin/sugar-session | |
parent | 0b558e98d4275e8a3052290ec1584ec25d348073 (diff) |
Rename sugar-shell to sugar-session to avoid confusion with
the model meaning of shell.
Diffstat (limited to 'bin/sugar-session')
-rw-r--r-- | bin/sugar-session | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/bin/sugar-session b/bin/sugar-session new file mode 100644 index 0000000..0f3025a --- /dev/null +++ b/bin/sugar-session @@ -0,0 +1,124 @@ +#!/usr/bin/env python +# 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 + +import sys +import os +import gettext +import logging +import time +import shutil + +import gtk +import gobject +import dbus.glib + +gtk.gdk.threads_init() +dbus.glib.threads_init() + +from sugar import logger +from sugar.profile import get_profile +from sugar.datastore import datastore +from sugar import env + +from jarabe.shellservice import ShellService +from jarabe.session import get_session_manager +from jarabe.nmservice import NMService +from jarabe.model import sound +from jarabe.model import screen +from jarabe.journal import journalactivity +from jarabe.view import launcher +from jarabe import intro +from jarabe import logsmanager +from jarabe import config + +def _shell_started_cb(home_window): + screen.set_dcon_freeze(0) + + if os.path.isfile(os.path.expanduser('~/.sugar-update')): + home_window.get_home_box().show_software_updates_alert() + + # Mount the datastore in internal flash + ds_path = env.get_profile_path('datastore') + try: + datastore.mount(ds_path, [], timeout=120) + except Exception, e: + # Don't explode if there's corruption; move the data out of the way + # and attempt to create a store from scratch. + logging.error(e) + shutil.move(ds_path, os.path.abspath(ds_path) + str(time.time())) + datastore.mount(ds_path, [], timeout=120) + + journalactivity.start() + +def main(): + try: + logsmanager.setup() + except Exception, e: + # logs setup is not critical; it should not prevent sugar from + # starting if (for example) the disk is full or read-only. + print 'Log setup failed: %s' % e + + logger.start('shell') + + sys.path.append(config.ext_path) + + gettext.bindtextdomain('sugar', config.locale_path) + gettext.textdomain('sugar') + + icons_path = os.path.join(config.data_path, 'icons') + gtk.icon_theme_get_default().append_search_path(icons_path) + + intro.check_profile() + + # set timezone + if get_profile().timezone is not None: + os.environ['TZ'] = get_profile().timezone + + from jarabe.frame import frame + frame = frame.get_instance() + + from jarabe.view.keyhandler import KeyHandler + key_handler = KeyHandler(frame) + + from jarabe.desktop.homewindow import HomeWindow + home_window = HomeWindow() + home_window.show() + + ShellService() + + launcher.setup() + + session_manager = get_session_manager() + session_manager.start() + + try: + nm_service = NMService() + except dbus.DBusException: + logging.error("Network manager is already running.") + + sound.restore() + + gobject.idle_add(_shell_started_cb, home_window) + + try: + gtk.main() + except KeyboardInterrupt: + print 'Ctrl+C pressed, exiting...' + + sound.save() + +main() |