[Sugar-devel] [PATCH sugar] Rework how we select the Xcursor theme

Daniel Narvaez dwnarvaez at gmail.com
Mon Dec 10 17:32:47 EST 2012


From: Daniel Narvaez <dwnarvaez at gmail.com>

Metacity reads the default theme from gsettings and we was trying
to override it at lower level, causing race conditions. Now we are
just setting the cursor-theme gsetting, so that metacity setup the
sugar theme for us.

Distributions which are shipping both GNOME and sugar should make
sure to set XDG_CONFIG_HOME for either of the desktops to point
to a non default location, so that the settings are not conflicting.
It's necessary in this case if you don't want to get the sugar
cursors in GNOME, but it seems like a sane approach in general. We
are sharing several components with GNOME which are (or might in
the future) be using GNOME gsettings.

This also moves metacity into the python code. I wanted to do that
anyway, 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.
---
 bin/sugar.in       |    3 ---
 src/jarabe/main.py |   42 ++++++++++++++++++++++++++----------------
 2 files changed, 26 insertions(+), 19 deletions(-)

diff --git a/bin/sugar.in b/bin/sugar.in
index 2de0c15..440e3b3 100644
--- a/bin/sugar.in
+++ b/bin/sugar.in
@@ -46,7 +46,4 @@ if [ -f ~/.sugar/debug ]; then
         . ~/.sugar/debug
 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 c379361..20304c1 100755
--- a/src/jarabe/main.py
+++ b/src/jarabe/main.py
@@ -43,6 +43,7 @@ from gi.repository import Gtk
 from gi.repository import Gdk
 from gi.repository import GObject
 from gi.repository import Gst
+from gi.repository import Gio
 import dbus.glib
 from gi.repository import Wnck
 
@@ -67,6 +68,8 @@ from jarabe.intro.window import IntroWindow
 from jarabe import frame
 from jarabe.view.service import UIService
 
+_metacity_process = None
+
 def _check_software_updates():
     logging.debug('STARTUP: check_software_updates')
     if os.path.isfile(os.path.expanduser('~/.sugar-update')):
@@ -84,6 +87,23 @@ def _setup_window_manager():
                        shell=True):
         logging.warning('Can not disable metacity mouse button modifiers')
 
+def _start_window_manager():
+    global _metacity_process
+
+    settings = Gio.Settings.new("org.gnome.desktop.interface")
+    settings.set_string("cursor-theme", "sugar")
+
+    _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 _window_manager_changed_cb(screen):
     _check_for_window_manager(screen)
 
@@ -136,10 +156,6 @@ 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()
 
@@ -166,17 +182,6 @@ def _setup_locale():
     if timezone is not None and timezone:
         os.environ['TZ'] = timezone
 
-def _setup_mouse():
-    client = GConf.Client.get_default()
-    client.set_string('/apps/metacity/general/mouse_button_modifier',
-                      '<Super>')
-
-    cursortracker.setup()
-    # make sure we have the correct cursor in the intro screen
-    # TODO #3204
-    if subprocess.call(["xsetroot", "-cursor_name", "left_ptr"]):
-        logging.warning('Can not reset cursor')
-
 def _main():
     GLib.threads_init()
     Gdk.threads_init()
@@ -188,14 +193,17 @@ def _main():
     screen.set_dcon_freeze(0)
 
     _setup_locale()
-    _setup_mouse()
     _setup_fonts()
     _setup_theme()
 
+    cursortracker.setup()
+
     sound.restore()
 
     sys.path.append(config.ext_path)
 
+    _start_window_manager()
+
     if not intro.check_profile():
         win = IntroWindow()
         win.connect("done", _intro_window_done_cb)
@@ -208,4 +216,6 @@ def _main():
     except KeyboardInterrupt:
         print 'Ctrl+C pressed, exiting...'
 
+    _metacity_process.terminate()
+
 _main()
-- 
1.7.10.4



More information about the Sugar-devel mailing list