diff --git a/browser/sugar-browser.cpp b/browser/sugar-browser.cpp index 273cea8f..df5769b2 100644 --- a/browser/sugar-browser.cpp +++ b/browser/sugar-browser.cpp @@ -65,6 +65,8 @@ #include #include +#define SUGAR_PATH "SUGAR_PATH" + enum { PROP_0, PROP_PROGRESS, @@ -161,9 +163,11 @@ sugar_browser_startup(const char *profile_path, const char *profile_name) NS_ENSURE_TRUE(prefService, FALSE); /* Read our predefined default prefs */ + nsCString pathToPrefs(g_getenv(SUGAR_PATH)); + pathToPrefs.Append("/data/gecko-prefs.js"); + nsCOMPtr file; - NS_NewNativeLocalFile(nsCString(SHARE_DIR"/gecko-prefs.js"), - PR_TRUE, getter_AddRefs(file)); + NS_NewNativeLocalFile(pathToPrefs, PR_TRUE, getter_AddRefs(file)); NS_ENSURE_TRUE(file, FALSE); rv = prefService->ReadUserPrefs (file); @@ -176,7 +180,10 @@ sugar_browser_startup(const char *profile_path, const char *profile_name) prefService->GetBranch ("", getter_AddRefs(pref)); NS_ENSURE_TRUE(pref, FALSE); - pref->SetCharPref ("helpers.private_mime_types_file", SHARE_DIR"/mime.types"); + nsCString pathToMimeTypes(g_getenv(SUGAR_PATH)); + pathToMimeTypes.Append("/data/mime.types"); + + pref->SetCharPref ("helpers.private_mime_types_file", pathToMimeTypes.get()); rv = prefService->ReadUserPrefs (nsnull); if (NS_FAILED(rv)) { diff --git a/data/Makefile.am b/data/Makefile.am index 3ff222b9..8e99b34f 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -1,6 +1,7 @@ sugardir = $(pkgdatadir)/data sugar_DATA = \ - gtkrc \ + sugar.gtkrc \ + sugar-xo.gtkrc \ gecko-prefs.js \ mime.types diff --git a/data/gtkrc b/data/gtkrc deleted file mode 100644 index cb635362..00000000 --- a/data/gtkrc +++ /dev/null @@ -1,6 +0,0 @@ -gtk-theme-name = "sugar" -gtk-icon-theme-name = "olpc" -gtk-font-name = "Bitstream Vera Sans 7" -gtk-icon-sizes = "gtk-menu=32,32:gtk-button=32,32" -gtk-cursor-theme-name = "olpc" -gtk-cursor-theme-size = 48 diff --git a/data/mime.types b/data/mime.types index 0f76f396..a6ffcb2b 100644 --- a/data/mime.types +++ b/data/mime.types @@ -1,2 +1,3 @@ application/x-squeak-project pr application/x-abiword abw +application/vnd.olpc-x-sugar xo diff --git a/data/sugar-xo.gtkrc b/data/sugar-xo.gtkrc new file mode 100644 index 00000000..6c6a1a66 --- /dev/null +++ b/data/sugar-xo.gtkrc @@ -0,0 +1,7 @@ +gtk-theme-name = "sugar-xo" +gtk-icon-theme-name = "sugar" +gtk-font-name = "Sans Serif 7" +gtk-icon-sizes = "gtk-menu=32,32:gtk-button=32,32" +gtk-cursor-theme-name = "sugar" +gtk-cursor-theme-size = 48 +gtk-toolbar-style = GTK_TOOLBAR_ICONS diff --git a/data/sugar.gtkrc b/data/sugar.gtkrc new file mode 100644 index 00000000..d7420268 --- /dev/null +++ b/data/sugar.gtkrc @@ -0,0 +1,5 @@ +gtk-theme-name = "sugar" +gtk-icon-theme-name = "sugar" +gtk-font-name = "Sans Serif 11" +gtk-cursor-theme-name = "sugar" +gtk-toolbar-style = GTK_TOOLBAR_ICONS diff --git a/services/clipboard/typeregistry.py b/services/clipboard/typeregistry.py index 88bdf607..0cab0e9c 100644 --- a/services/clipboard/typeregistry.py +++ b/services/clipboard/typeregistry.py @@ -237,6 +237,26 @@ class UriListFileType(FileType): return mime_type in cls._types matches_mime_type = classmethod(matches_mime_type) +class XoFileType(FileType): + + _types = set(['application/vnd.olpc-x-sugar']) + + def get_name(self): + return _('Activity package') + + def get_icon(self): + return 'theme:stock-missing' + + def get_preview(self): + return '' + + def get_activity(self): + return '' + + def matches_mime_type(cls, mime_type): + return mime_type in cls._types + matches_mime_type = classmethod(matches_mime_type) + class UnknownFileType(FileType): def get_name(self): return _('Object') @@ -267,6 +287,7 @@ class TypeRegistry: self._types.append(AbiwordFileType) self._types.append(TextFileType) self._types.append(SqueakProjectFileType) + self._types.append(XoFileType) def get_type(self, formats): for file_type in self._types: diff --git a/sugar-emulator b/sugar-emulator index c1fb6a3e..29b02603 100755 --- a/sugar-emulator +++ b/sugar-emulator @@ -72,6 +72,14 @@ def _start_xephyr(): os.environ['DISPLAY'] = ":%d" % (display) os.environ['SUGAR_EMULATOR_PID'] = str(pid) +def _start_matchbox(): + cmd = ['matchbox-window-manager'] + + cmd.extend(['-use_titlebar', 'no']) + cmd.extend(['-theme', 'olpc']) + + gobject.spawn_async(cmd, flags=gobject.SPAWN_SEARCH_PATH) + def _setup_env(): os.environ['SUGAR_EMULATOR'] = 'yes' @@ -87,11 +95,17 @@ _start_xephyr() from sugar import env -os.environ['GTK2_RC_FILES'] = env.get_data_path('gtkrc') +if env.is_emulator(): + gtkrc_filename = 'sugar.gtkrc' +else: + gtkrc_filename = 'sugar-xo.gtkrc' + +os.environ['GTK2_RC_FILES'] = env.get_data_path(gtkrc_filename) if len(sys.argv) == 1: program = 'sugar-shell' else: + _start_matchbox() program = sys.argv[1] os.execlp('dbus-launch', 'dbus-launch', '--exit-with-session', program) diff --git a/sugar/graphics2/Makefile.am b/sugar/graphics2/Makefile.am new file mode 100644 index 00000000..f5bde18a --- /dev/null +++ b/sugar/graphics2/Makefile.am @@ -0,0 +1,5 @@ +sugardir = $(pythondir)/sugar/graphics2 +sugar_PYTHON = \ + __init__.py \ + window.py \ + toolbox.py diff --git a/sugar/graphics2/__init__.py b/sugar/graphics2/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/sugar/graphics2/toolbox.py b/sugar/graphics2/toolbox.py new file mode 100644 index 00000000..be7e5e09 --- /dev/null +++ b/sugar/graphics2/toolbox.py @@ -0,0 +1,32 @@ +# Copyright (C) 2007, Red Hat, Inc. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library 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 +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +import gtk + +class Toolbox(gtk.VBox): + __gtype_name__ = 'SugarToolbox' + def __init__(self): + gtk.VBox.__init__(self) + + self._notebook = gtk.Notebook() + self._notebook.set_tab_pos(gtk.POS_BOTTOM) + self._notebook.set_show_border(False) + self.pack_start(self._notebook) + self._notebook.show() + + def add_toolbar(self, name, toolbar): + self._notebook.append_page(toolbar, gtk.Label(name)) diff --git a/sugar/graphics2/window.py b/sugar/graphics2/window.py new file mode 100644 index 00000000..d03788b0 --- /dev/null +++ b/sugar/graphics2/window.py @@ -0,0 +1,49 @@ +# Copyright (C) 2007, Red Hat, Inc. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. +# +# This library 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 +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the +# Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +import gtk +import hippo + +from sugar.graphics2.toolbox import Toolbox + +class Window(gtk.Window): + def __init__(self): + gtk.Window.__init__(self) + + vbox = gtk.VBox() + self.add(vbox) + + self.toolbox = Toolbox() + vbox.pack_start(self.toolbox, False) + self.toolbox.show() + + self._canvas_box = gtk.VBox() + vbox.pack_start(self._canvas_box) + self._canvas_box.show() + + self.canvas = hippo.Canvas() + self._canvas_box.pack_start(self.canvas) + self.canvas.show() + + vbox.show() + + def set_canvas(self, canvas): + if self.canvas: + self._canvas_box.remove(self.canvas) + + self._canvas_box.add(canvas) + self.canvas = canvas diff --git a/tests/test-ui.py b/tests/test-ui.py index 6c1f6676..26f3d127 100755 --- a/tests/test-ui.py +++ b/tests/test-ui.py @@ -18,13 +18,81 @@ import gtk -class Window(gtk.Window): +from sugar.graphics2.window import Window + +class ActivityToolbar(gtk.Toolbar): def __init__(self): - gtk.Window.__init__(self) - self.set_default_size(800, 600) - + gtk.Toolbar.__init__(self) + +class EditToolbar(gtk.Toolbar): + def __init__(self): + gtk.Toolbar.__init__(self) + +class TextToolbar(gtk.Toolbar): + def __init__(self): + gtk.Toolbar.__init__(self) + + button = gtk.ToolButton() + button.set_icon_name('text-format-bold') + self.insert(button, -1) + button.show() + +class ImageToolbar(gtk.Toolbar): + def __init__(self): + gtk.Toolbar.__init__(self) + +class TableToolbar(gtk.Toolbar): + def __init__(self): + gtk.Toolbar.__init__(self) + +class FormatToolbar(gtk.Toolbar): + def __init__(self): + gtk.Toolbar.__init__(self) + +class ViewToolbar(gtk.Toolbar): + def __init__(self): + gtk.Toolbar.__init__(self) + window = Window() window.connect("destroy", lambda w: gtk.main_quit()) + +activity_toolbar = ActivityToolbar() +window.toolbox.add_toolbar('Activity', activity_toolbar) +activity_toolbar.show() + +edit_toolbar = EditToolbar() +window.toolbox.add_toolbar('Edit', edit_toolbar) +edit_toolbar.show() + +text_toolbar = TextToolbar() +window.toolbox.add_toolbar('Text', text_toolbar) +text_toolbar.show() + +image_toolbar = ImageToolbar() +window.toolbox.add_toolbar('Image', image_toolbar) +image_toolbar.show() + +table_toolbar = TableToolbar() +window.toolbox.add_toolbar('Table', table_toolbar) +table_toolbar.show() + +format_toolbar = FormatToolbar() +window.toolbox.add_toolbar('Format', format_toolbar) +format_toolbar.show() + +view_toolbar = ViewToolbar() +window.toolbox.add_toolbar('View', view_toolbar) +view_toolbar.show() + +scrolled_window = gtk.ScrolledWindow() +scrolled_window.set_policy(gtk.POLICY_NEVER, gtk.POLICY_ALWAYS) +window.set_canvas(scrolled_window) +scrolled_window.show() + +text_view = gtk.TextView() +scrolled_window.add(text_view) +text_view.show() + window.show() gtk.main()