Hi Daniel,

the new module is this one [1] I presume. We currently have the emulator packaged for Fedora qit a Desktop file so there is an easy way to launch Sugar from within another Desktop. I guess this would then be a separate package based on sugar-runner.

Regards,
   Simon

[1] http://git.sugarlabs.org/sugar-runner
[2] http://koji.fedoraproject.org/koji/rpminfo?rpmID=3585350



On 12/16/2012 12:24 AM, Daniel Narvaez wrote:
From: Daniel Narvaez <dwnarv...@gmail.com>

Replaced by the sugar-runner module.

Rationale:

* sugar-runner is similar in concept to sugar-emulator but it
provides a better user experience. It runs also from a text
console (into a standard X server). It works around Xephyr
issues like international keyboards and multiple outputs.
It tries to work out of the box everywhere, for example
by offering to tweak Xwrapper.config where necessary.
* sugar-runner is better tested with recent sugar code and
recent distributions. It also integrates with sugar-build.
* A separate module make sense here because most users will
never run this code. It's largely a collection of hacks
which are not necessary when running as a normal desktop
environment.

Why now:

* We are starting to use GSettings, which requires to setup
the xdg directories to avoid conflicts with GNOME. Thus we
would require to make changes to sugar-emulator to setup
these properly. Maintaining two separate implementation of
basically the same thing is a waste of resources.
* We are at the beginning of the cycle, the best time for
potentially disruptive changes.
---
  README                         |    1 -
  bin/Makefile.am                |    1 -
  bin/sugar-emulator             |   14 ---
  configure.ac                   |    1 -
  data/Makefile.am               |    3 -
  data/sugar-emulator.desktop.in |   10 ---
  src/jarabe/model/session.py    |   15 +---
  src/jarabe/model/sound.py      |   10 +--
  src/jarabe/util/Makefile.am    |    1 -
  src/jarabe/util/emulator.py    |  194 ----------------------------------------
  src/jarabe/view/keyhandler.py  |    5 --
  11 files changed, 5 insertions(+), 250 deletions(-)
  delete mode 100755 bin/sugar-emulator
  delete mode 100644 data/sugar-emulator.desktop.in
  delete mode 100644 src/jarabe/util/emulator.py

diff --git a/README b/README
index 1f89810..cfc196e 100644
--- a/README
+++ b/README
@@ -38,7 +38,6 @@ Alt+r  Rotate the screen
  Alt+o  Toggle overlay visibility
  Alt+=  Open the developer console
  Alt+0  Open the developer console
-Alt+q  Quit the emulator

  Ctrl+s Activate sketch mode in chat

diff --git a/bin/Makefile.am b/bin/Makefile.am
index cb671da..bd38323 100644
--- a/bin/Makefile.am
+++ b/bin/Makefile.am
@@ -1,6 +1,5 @@
  python_scripts =              \
        sugar-control-panel     \
-       sugar-emulator          \
        sugar-install-bundle    \
        sugar-launch

diff --git a/bin/sugar-emulator b/bin/sugar-emulator
deleted file mode 100755
index 308aac7..0000000
--- a/bin/sugar-emulator
+++ /dev/null
@@ -1,14 +0,0 @@
-#!/bin/sh
-
-if [ "$(id -u)" -eq 0 -o "$(id -ru)" -eq 0 ] ; then
-       echo Refusing to run as root.
-       exit 3
-fi
-
-# Source debug definitions
-if [ -f ~/.sugar/debug ]; then
-        . ~/.sugar/debug
-fi
-
-# Start emulator
-python -c "import sys; from jarabe.util import emulator; sys.argv[0]='$0'; 
emulator.main()" "$@"
diff --git a/configure.ac b/configure.ac
index 137e53a..9eae29e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -48,7 +48,6 @@ bin/Makefile
  bin/sugar
  data/icons/Makefile
  data/Makefile
-data/sugar-emulator.desktop
  extensions/cpsection/aboutcomputer/Makefile
  extensions/cpsection/aboutme/Makefile
  extensions/cpsection/datetime/Makefile
diff --git a/data/Makefile.am b/data/Makefile.am
index 6a62d23..39bdb35 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -23,9 +23,6 @@ GTKRC_FILES =         \
  xsessionsdir = $(datadir)/xsessions
  xsessions_DATA = sugar.desktop

-applicationsdir = $(datadir)/applications
-applications_DATA = sugar-emulator.desktop
-
  mime_xml_in_files = sugar.xml.in
  mime_xml_files = $(mime_xml_in_files:.xml.in=.xml)
  @INTLTOOL_XML_RULE@
diff --git a/data/sugar-emulator.desktop.in b/data/sugar-emulator.desktop.in
deleted file mode 100644
index 6247bd7..0000000
--- a/data/sugar-emulator.desktop.in
+++ /dev/null
@@ -1,10 +0,0 @@
-[Desktop Entry]
-Encoding=UTF-8
-Name=Sugar
-GenericName=Sugar Emulator
-Comment=The emulator for the Sugar Desktop Environment
-Exec=@prefix@/bin/sugar-emulator
-Terminal=false
-Type=Application
-Icon=sugar-xo
-Categories=Education;Teaching;
diff --git a/src/jarabe/model/session.py b/src/jarabe/model/session.py
index a5cd4a4..a708633 100644
--- a/src/jarabe/model/session.py
+++ b/src/jarabe/model/session.py
@@ -54,9 +54,7 @@ class SessionManager(session.SessionManager):
          self.initiate_shutdown()

      def shutdown_completed(self):
-        if env.is_emulator():
-            self._close_emulator()
-        elif self._logout_mode != self.MODE_LOGOUT:
+        if self._logout_mode != self.MODE_LOGOUT:
              bus = dbus.SystemBus()
              if have_systemd():
                  try:
@@ -93,17 +91,6 @@ class SessionManager(session.SessionManager):
          session.SessionManager.shutdown_completed(self)
          Gtk.main_quit()

-    def _close_emulator(self):
-        Gtk.main_quit()
-
-        if 'SUGAR_EMULATOR_PID' in os.environ:
-            pid = int(os.environ['SUGAR_EMULATOR_PID'])
-            os.kill(pid, signal.SIGTERM)
-
-        # Need to call this ASAP so the atexit handlers get called before we
-        # get killed by the X (dis)connection
-        sys.exit()
-

  def get_session_manager():
      global _session_manager
diff --git a/src/jarabe/model/sound.py b/src/jarabe/model/sound.py
index 851228d..02ad04d 100644
--- a/src/jarabe/model/sound.py
+++ b/src/jarabe/model/sound.py
@@ -54,12 +54,10 @@ def set_muted(new_state):


  def save():
-    if env.is_emulator() is False:
-        client = GConf.Client.get_default()
-        client.set_int('/desktop/sugar/sound/volume', get_volume())
+    client = GConf.Client.get_default()
+    client.set_int('/desktop/sugar/sound/volume', get_volume())


  def restore():
-    if env.is_emulator() is False:
-        client = GConf.Client.get_default()
-        set_volume(client.get_int('/desktop/sugar/sound/volume'))
+    client = GConf.Client.get_default()
+    set_volume(client.get_int('/desktop/sugar/sound/volume'))
diff --git a/src/jarabe/util/Makefile.am b/src/jarabe/util/Makefile.am
index 3054b5a..17b9253 100644
--- a/src/jarabe/util/Makefile.am
+++ b/src/jarabe/util/Makefile.am
@@ -4,5 +4,4 @@ SUBDIRS =               \
  sugardir = $(pythondir)/jarabe/util
  sugar_PYTHON =          \
        __init__.py         \
-       emulator.py         \
        normalize.py
diff --git a/src/jarabe/util/emulator.py b/src/jarabe/util/emulator.py
deleted file mode 100644
index 72b0d26..0000000
--- a/src/jarabe/util/emulator.py
+++ /dev/null
@@ -1,194 +0,0 @@
-# Copyright (C) 2006-2008, 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 os
-import signal
-import subprocess
-import sys
-import time
-from optparse import OptionParser
-from gettext import gettext as _
-
-from gi.repository import Gtk
-from gi.repository import Gdk
-from gi.repository import GObject
-
-from sugar3 import env
-
-
-ERROR_NO_DISPLAY = 30
-ERROR_NO_SERVER = 31
-default_dimensions = (800, 600)
-
-
-def _run_xephyr(display, dpi, dimensions, fullscreen):
-    cmd = ['Xephyr']
-    cmd.append(':%d' % display)
-    cmd.append('-ac')
-    cmd += ['-title', _('Sugar in a window')]
-
-    screen_size = (Gdk.Screen.width(), Gdk.Screen.height())
-
-    if (not dimensions) and (fullscreen is None) and \
-       (screen_size <= default_dimensions):
-        # no forced settings, screen too small => fit screen
-        fullscreen = True
-    elif not dimensions:
-        # screen is big enough or user has en/disabled fullscreen manually
-        # => use default size (will get ignored for fullscreen)
-        dimensions = '%dx%d' % default_dimensions
-
-    if not dpi:
-        dpi = Gtk.Settings.get_default().get_property('gtk-xft-dpi') / 1024
-
-    if fullscreen:
-        cmd.append('-fullscreen')
-
-    if dimensions:
-        cmd.append('-screen')
-        cmd.append(dimensions)
-
-    if dpi:
-        cmd.append('-dpi')
-        cmd.append('%d' % dpi)
-
-    cmd.append('-noreset')
-
-    try:
-        pipe = subprocess.Popen(cmd)
-
-    except OSError, exc:
-        sys.stderr.write('Error executing server: %s\n' % (exc, ))
-        return None
-
-    return pipe
-
-
-def _check_server(display):
-    result = subprocess.call(['xdpyinfo', '-display', ':%d' % display],
-                             stdout=open(os.devnull, 'w'),
-                             stderr=open(os.devnull, 'w'))
-    return result == 0
-
-
-def _kill_pipe(pipe):
-    """Terminate and wait for child process."""
-    try:
-        os.kill(pipe.pid, signal.SIGTERM)
-    except OSError:
-        pass
-
-    pipe.wait()
-
-
-def _start_xephyr(dpi, dimensions, fullscreen):
-    for display in range(30, 40):
-        if not _check_server(display):
-            pipe = _run_xephyr(display, dpi, dimensions, fullscreen)
-            if pipe is None:
-                return None, None
-
-            for i_ in range(10):
-                if _check_server(display):
-                    return pipe, display
-
-                time.sleep(0.1)
-
-            _kill_pipe(pipe)
-
-    return None, None
-
-
-def _start_window_manager():
-    cmd = ['metacity']
-
-    cmd.extend(['--no-force-fullscreen'])
-
-    GObject.spawn_async(cmd, flags=GObject.SPAWN_SEARCH_PATH)
-
-
-def _setup_env(display, scaling, emulator_pid):
-    # We need to remove the environment related to gnome-keyring-daemon,
-    # so a new instance of gnome-keyring-daemon can be started and
-    # registered properly.
-    for variable in ['GPG_AGENT_INFO', 'SSH_AUTH_SOCK',
-                     'GNOME_KEYRING_CONTROL', 'GNOME_KEYRING_PID']:
-        if variable in os.environ:
-            del os.environ[variable]
-
-    os.environ['SUGAR_EMULATOR'] = 'yes'
-    os.environ['GABBLE_LOGFILE'] = os.path.join(
-            env.get_profile_path(), 'logs', 'telepathy-gabble.log')
-    os.environ['SALUT_LOGFILE'] = os.path.join(
-            env.get_profile_path(), 'logs', 'telepathy-salut.log')
-    os.environ['MC_LOGFILE'] = os.path.join(
-            env.get_profile_path(), 'logs', 'mission-control.log')
-    os.environ['STREAM_ENGINE_LOGFILE'] = os.path.join(
-            env.get_profile_path(), 'logs', 'telepathy-stream-engine.log')
-    os.environ['DISPLAY'] = ':%d' % (display)
-    os.environ['SUGAR_EMULATOR_PID'] = emulator_pid
-    os.environ['MC_ACCOUNT_DIR'] = os.path.join(
-            env.get_profile_path(), 'accounts')
-
-    if scaling:
-        os.environ['SUGAR_SCALING'] = scaling
-
-
-def main():
-    """Script-level operations"""
-
-    parser = OptionParser()
-    parser.add_option('-d', '--dpi', dest='dpi', type='int',
-                      help='Emulator dpi')
-    parser.add_option('-s', '--scaling', dest='scaling',
-                      help='Sugar scaling in %')
-    parser.add_option('-i', '--dimensions', dest='dimensions',
-                      help='Emulator dimensions (ex. 1200x900)')
-    parser.add_option('-f', '--fullscreen', dest='fullscreen',
-                      action='store_true', default=None,
-                      help='Run emulator in fullscreen mode')
-    parser.add_option('-F', '--no-fullscreen', dest='fullscreen',
-                      action='store_false',
-                      help='Do not run emulator in fullscreen mode')
-    (options, args) = parser.parse_args()
-
-    if not os.environ.get('DISPLAY'):
-        sys.stderr.write('DISPLAY not set, cannot connect to host X server.\n')
-        return ERROR_NO_DISPLAY
-
-    server, display = _start_xephyr(options.dpi, options.dimensions,
-                                    options.fullscreen)
-    if server is None:
-        sys.stderr.write('Failed to start server. Please check output above'
-            ' for any error message.\n')
-        return ERROR_NO_SERVER
-
-    _setup_env(display, options.scaling, str(server.pid))
-
-    command = ['dbus-launch', '--exit-with-session']
-
-    if not args:
-        command.append('sugar')
-    else:
-        _start_window_manager()
-
-        if args[0].endswith('.py'):
-            command.append('python')
-
-        command.append(args[0])
-
-    subprocess.call(command)
-    _kill_pipe(server)
diff --git a/src/jarabe/view/keyhandler.py b/src/jarabe/view/keyhandler.py
index cb47d17..d96a88c 100644
--- a/src/jarabe/view/keyhandler.py
+++ b/src/jarabe/view/keyhandler.py
@@ -57,9 +57,7 @@ _actions_table = {
      '<alt><shift>Tab': 'previous_window',
      '<alt>Escape': 'close_window',
      'XF86WebCam': 'open_search',
-# the following are intended for emulator users
      '<alt><shift>f': 'frame',
-    '<alt><shift>q': 'quit_emulator',
      'XF86Search': 'open_search',
      '<alt><shift>o': 'open_search'
  }
@@ -156,9 +154,6 @@ class KeyHandler(object):
      def handle_frame(self, event_time):
          self._frame.notify_key_press()

-    def handle_quit_emulator(self, event_time):
-        session.get_session_manager().shutdown()
-
      def handle_open_search(self, event_time):
          journalactivity.get_journal().show_journal()



_______________________________________________
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel

Reply via email to