Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Narvaez <dwnarvaez@gmail.com>2012-12-14 11:58:28 (GMT)
committer Daniel Narvaez <dwnarvaez@gmail.com>2012-12-14 13:36:46 (GMT)
commitde4a186f9b221996cab96daf6a754eeb8dd5a212 (patch)
treebe77aeed017356f283f214c8d97a815b174a2db4
parent110ca319bc0dedb258584cb9200b8755c71bd713 (diff)
Move metacity invocation into the python code
So that the sugar script only setup environment variables and all the rest is in main.py. This avoids the confusion about putting stuff in the one or the other script. Ideally we would get rid of the bash script completely, but it would not be possible to source the debug and i18n files from python.
-rw-r--r--bin/sugar.in1
-rwxr-xr-xsrc/jarabe/main.py55
2 files changed, 44 insertions, 12 deletions
diff --git a/bin/sugar.in b/bin/sugar.in
index 2de0c15..606057d 100644
--- a/bin/sugar.in
+++ b/bin/sugar.in
@@ -47,6 +47,5 @@ if [ -f ~/.sugar/debug ]; then
fi
echo Xcursor.theme: sugar | xrdb -merge
-metacity --no-force-fullscreen -d $DISPLAY &
exec python -m jarabe.main
diff --git a/src/jarabe/main.py b/src/jarabe/main.py
index 9d504a0..8b6cec3 100755
--- a/src/jarabe/main.py
+++ b/src/jarabe/main.py
@@ -67,6 +67,10 @@ from jarabe.intro.window import IntroWindow
from jarabe import frame
from jarabe.view.service import UIService
+_metacity_process = None
+_window_manager_started = False
+_starting_desktop = False
+
def _unfreeze_dcon_cb():
logging.debug('STARTUP: unfreeze_dcon_cb')
screen.set_dcon_freeze(0)
@@ -93,13 +97,21 @@ def _window_manager_changed_cb(screen):
def _check_for_window_manager(screen):
wm_name = screen.get_window_manager_name()
- if wm_name is not None:
- screen.disconnect_by_func(_window_manager_changed_cb)
- _bootstrap()
+ if wm_name is None:
+ return
+
+ screen.disconnect_by_func(_window_manager_changed_cb)
-def _bootstrap():
_setup_window_manager()
+ global window_manager_started
+ window_manager_started = True
+
+ global _starting_desktop
+ if _starting_desktop:
+ _complete_desktop_startup()
+
+def _complete_desktop_startup():
launcher.setup()
frame_view = frame.get_view()
@@ -131,7 +143,24 @@ def _setup_theme():
icons_path = os.path.join(config.data_path, 'icons')
Gtk.IconTheme.get_default().append_search_path(icons_path)
-def _start_home():
+def _start_window_manager():
+ global _metacity_process
+
+ _metacity_process = subprocess.Popen(["metacity", "--no-force-fullscreen"])
+
+ screen = Wnck.Screen.get_default()
+ screen.connect('window-manager-changed', _window_manager_changed_cb)
+
+ _check_for_window_manager(screen)
+
+def _stop_window_manager():
+ global _metacity_process
+ _metacity_process.terminate()
+
+def _begin_desktop_startup():
+ global _starting_desktop
+ _starting_desktop = True
+
ui_service = UIService()
session_manager = get_session_manager()
@@ -141,12 +170,12 @@ def _start_home():
home_window = homewindow.get_instance()
home_window.show()
- screen = Wnck.Screen.get_default()
- screen.connect('window-manager-changed', _window_manager_changed_cb)
- _check_for_window_manager(screen)
-
def _intro_window_done_cb(window):
- _start_home()
+ _begin_desktop_startup()
+
+ global window_manager_started
+ if window_manager_started:
+ _complete_desktop_startup()
def _cleanup_temporary_files():
try:
@@ -190,6 +219,8 @@ def _main():
_cleanup_temporary_files()
+ _start_window_manager()
+
_setup_locale()
_setup_mouse()
_setup_fonts()
@@ -209,11 +240,13 @@ def _main():
win.connect("done", _intro_window_done_cb)
win.show_all()
else:
- _start_home()
+ _begin_desktop_startup()
try:
Gtk.main()
except KeyboardInterrupt:
print 'Ctrl+C pressed, exiting...'
+ _stop_window_manager()
+
_main()