From cea67fa48d3ac9f4c9e5faa9ff7f781cad6cf67e Mon Sep 17 00:00:00 2001
From: Aleksey Lim <alsroot@member.fsf.org>
Date: Tue, 13 Oct 2009 14:51:13 +0000
Subject: Suppress race condition with Journal appearing on sugar startup #1373
---
bin/sugar-session | 54 ++++++++++++++++++++++++++++++++++----------
src/jarabe/model/shell.py | 18 ---------------
2 files changed, 41 insertions(+), 31 deletions(-)
mode change 100755 => 100644 bin/sugar-session
diff --git a/bin/sugar-session b/bin/sugar-session
old mode 100755
new mode 100644
index 427eeb8..7d8a96b
a
|
b
|
|
19 | 19 | import os |
20 | 20 | import sys |
21 | 21 | import time |
| 22 | import subprocess |
22 | 23 | |
23 | 24 | if os.environ.get('SUGAR_LOGGER_LEVEL', '') == 'debug': |
24 | 25 | print '%r STARTUP: Starting the shell' % time.time() |
… |
… |
import gconf |
31 | 32 | import gtk |
32 | 33 | import gobject |
33 | 34 | import dbus.glib |
| 35 | import wnck |
34 | 36 | |
35 | 37 | try: |
36 | 38 | import xklavier |
… |
… |
def setup_file_transfer_cb(): |
136 | 138 | from jarabe.model import filetransfer |
137 | 139 | filetransfer.init() |
138 | 140 | |
139 | | def setup_keyboard_cb(gconf_client): |
| 141 | def setup_keyboard_cb(): |
140 | 142 | logging.debug('STARTUP: setup_keyboard_cb') |
| 143 | |
| 144 | gconf_client = gconf.client_get_default() |
| 145 | |
141 | 146 | try: |
142 | 147 | display = gtk.gdk.display_get_default() |
143 | 148 | if display is not None: |
… |
… |
def setup_keyboard_cb(gconf_client): |
176 | 181 | except Exception: |
177 | 182 | logging.exception('Error during keyboard configuration') |
178 | 183 | |
| 184 | def setup_wm(): |
| 185 | logging.debug('STARTUP: wm') |
| 186 | |
| 187 | # have to reset cursor(metacity sets it on startup) |
| 188 | if subprocess.call('echo $DISPLAY; xsetroot -cursor_name left_ptr', shell=True): |
| 189 | logging.warning('Can not reset cursor') |
| 190 | |
| 191 | if subprocess.call('metacity-message disable-keybindings', |
| 192 | shell=True): |
| 193 | logging.warning('Can not disable metacity keybindings') |
| 194 | |
| 195 | def bootstrap(): |
| 196 | setup_wm() |
| 197 | launcher.setup() |
| 198 | |
| 199 | gobject.idle_add(unfreeze_dcon_cb) |
| 200 | gobject.idle_add(setup_frame_cb) |
| 201 | gobject.idle_add(setup_keyhandler_cb) |
| 202 | gobject.idle_add(setup_journal_cb) |
| 203 | gobject.idle_add(setup_notification_service_cb) |
| 204 | gobject.idle_add(setup_file_transfer_cb) |
| 205 | gobject.idle_add(show_software_updates_cb) |
| 206 | |
| 207 | if sys.modules.has_key('xklavier'): |
| 208 | gobject.idle_add(setup_keyboard_cb) |
| 209 | |
179 | 210 | def main(): |
180 | 211 | cleanup_logs() |
181 | 212 | logger.start('shell') |
… |
… |
def main(): |
200 | 231 | icons_path = os.path.join(config.data_path, 'icons') |
201 | 232 | gtk.icon_theme_get_default().append_search_path(icons_path) |
202 | 233 | |
203 | | launcher.setup() |
204 | | |
| 234 | # open homewindow before wm to let desktop appear fast |
205 | 235 | home_window = homewindow.get_instance() |
206 | 236 | home_window.show() |
207 | 237 | |
208 | | gobject.idle_add(unfreeze_dcon_cb) |
209 | | gobject.idle_add(setup_frame_cb) |
210 | | gobject.idle_add(setup_keyhandler_cb) |
211 | | gobject.idle_add(setup_journal_cb) |
212 | | gobject.idle_add(setup_notification_service_cb) |
213 | | gobject.idle_add(setup_file_transfer_cb) |
214 | | gobject.idle_add(show_software_updates_cb) |
215 | | |
216 | | if sys.modules.has_key('xklavier'): |
217 | | gobject.idle_add(setup_keyboard_cb, client) |
| 238 | screen = wnck.screen_get_default() |
| 239 | screen.connect('window-manager-changed', __window_manager_changed_cb) |
218 | 240 | |
219 | 241 | try: |
220 | 242 | gtk.main() |
221 | 243 | except KeyboardInterrupt: |
222 | 244 | print 'Ctrl+C pressed, exiting...' |
223 | 245 | |
| 246 | def __window_manager_changed_cb(screen): |
| 247 | wm_name = screen.get_window_manager_name() |
| 248 | if wm_name is not None: |
| 249 | screen.disconnect_by_func(__window_manager_changed_cb) |
| 250 | bootstrap() |
| 251 | |
224 | 252 | main() |
diff --git a/src/jarabe/model/shell.py b/src/jarabe/model/shell.py
index 8693e26..de5a66f 100644
a
|
b
|
|
17 | 17 | |
18 | 18 | import logging |
19 | 19 | import time |
20 | | import subprocess |
21 | 20 | |
22 | 21 | import gconf |
23 | 22 | import wnck |
… |
… |
class ShellModel(gobject.GObject): |
323 | 322 | self._screen.connect('window-closed', self._window_closed_cb) |
324 | 323 | self._screen.connect('active-window-changed', |
325 | 324 | self._active_window_changed_cb) |
326 | | self._screen.connect('window-manager-changed', |
327 | | self.__window_manager_changed_cb) |
328 | 325 | |
329 | 326 | self.zoom_level_changed = dispatch.Signal() |
330 | 327 | |
… |
… |
class ShellModel(gobject.GObject): |
594 | 591 | self.notify_launch_failed(activity_id) |
595 | 592 | return False |
596 | 593 | |
597 | | def __window_manager_changed_cb(self, screen): |
598 | | wm_name = screen.get_window_manager_name() |
599 | | if wm_name is not None: |
600 | | logging.debug('Setup %s wm', wm_name) |
601 | | self._setup_wm() |
602 | | |
603 | | def _setup_wm(self): |
604 | | # have to reset cursor(metacity sets it on startup) |
605 | | if subprocess.call('xsetroot -cursor_name left_ptr', shell=True): |
606 | | logging.warning('Can not reset cursor') |
607 | | |
608 | | if subprocess.call('metacity-message disable-keybindings', |
609 | | shell=True): |
610 | | logging.warning('Can not disable metacity keybindings') |
611 | | |
612 | 594 | |
613 | 595 | _model = None |
614 | 596 | |