From 4ca48ffd0977e023dcadc1a08b9c05bc3f2d7ba2 Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Thu, 19 Apr 2007 12:12:57 -0300 Subject: [PATCH 1/9] Look for gecko-prefs.js and mime.types in the correct location. --- browser/sugar-browser.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) 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)) { From 96b0bd1cfa97ff2e5f8eba0a1dbc9656acf27864 Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Thu, 19 Apr 2007 12:13:38 -0300 Subject: [PATCH 2/9] Recognize downloaded .xo as such. --- data/mime.types | 1 + services/clipboard/typeregistry.py | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) 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/services/clipboard/typeregistry.py b/services/clipboard/typeregistry.py index 88bdf607..8efcd610 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,10 +287,12 @@ 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: for format, data in formats.iteritems(): + logging.debug(format) if file_type.matches_mime_type(format): return file_type(formats) From 276d374b1ae6a0b7567979707d129aee7a6b2717 Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Thu, 19 Apr 2007 12:20:48 -0300 Subject: [PATCH 3/9] Remove debug message. --- services/clipboard/typeregistry.py | 1 - 1 file changed, 1 deletion(-) diff --git a/services/clipboard/typeregistry.py b/services/clipboard/typeregistry.py index 8efcd610..0cab0e9c 100644 --- a/services/clipboard/typeregistry.py +++ b/services/clipboard/typeregistry.py @@ -292,7 +292,6 @@ class TypeRegistry: def get_type(self, formats): for file_type in self._types: for format, data in formats.iteritems(): - logging.debug(format) if file_type.matches_mime_type(format): return file_type(formats) From cb997a5264bd78db73c558595126c89215718537 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Thu, 19 Apr 2007 18:53:55 +0200 Subject: [PATCH 4/9] More work on the new toolbars --- data/gtkrc | 1 + tests/test-ui.py | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/data/gtkrc b/data/gtkrc index cb635362..71c57bdb 100644 --- a/data/gtkrc +++ b/data/gtkrc @@ -4,3 +4,4 @@ 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 +gtk-toolbar-style = GTK_TOOLBAR_ICONS diff --git a/tests/test-ui.py b/tests/test-ui.py index 6c1f6676..ad324cc9 100755 --- a/tests/test-ui.py +++ b/tests/test-ui.py @@ -18,11 +18,29 @@ import gtk + +class Toolbar(gtk.Toolbar): + def __init__(self): + gtk.Toolbar.__init__(self) + + icon = gtk.ToolButton() + icon.set_icon_name('text-format-bold') + self.insert(icon, -1) + icon.show() + class Window(gtk.Window): def __init__(self): gtk.Window.__init__(self) self.set_default_size(800, 600) + box = gtk.VBox() + self.add(box) + box.show() + + toolbar = Toolbar() + box.pack_start(toolbar, False) + toolbar.show() + window = Window() window.connect("destroy", lambda w: gtk.main_quit()) window.show() From 23bf7d94c656804cc987a3f06d7ddd184048c6f1 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Thu, 19 Apr 2007 19:16:42 +0200 Subject: [PATCH 5/9] Rename themes to sugar --- data/gtkrc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/gtkrc b/data/gtkrc index 71c57bdb..840b7349 100644 --- a/data/gtkrc +++ b/data/gtkrc @@ -1,7 +1,7 @@ gtk-theme-name = "sugar" -gtk-icon-theme-name = "olpc" +gtk-icon-theme-name = "sugar" 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-name = "sugar" gtk-cursor-theme-size = 48 gtk-toolbar-style = GTK_TOOLBAR_ICONS From 2f858c02a3f613af043929da96fc1ba59d7a9eae Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Thu, 19 Apr 2007 21:13:55 +0200 Subject: [PATCH 6/9] Split the gtkrc in sugar and sugar-xo. Make them load the respective gtk theme. --- data/Makefile.am | 3 ++- data/{gtkrc => sugar.gtkrc} | 4 +--- sugar-emulator | 7 ++++++- 3 files changed, 9 insertions(+), 5 deletions(-) rename data/{gtkrc => sugar.gtkrc} (51%) 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/sugar.gtkrc similarity index 51% rename from data/gtkrc rename to data/sugar.gtkrc index 840b7349..d7420268 100644 --- a/data/gtkrc +++ b/data/sugar.gtkrc @@ -1,7 +1,5 @@ gtk-theme-name = "sugar" gtk-icon-theme-name = "sugar" -gtk-font-name = "Bitstream Vera Sans 7" -gtk-icon-sizes = "gtk-menu=32,32:gtk-button=32,32" +gtk-font-name = "Sans Serif 11" gtk-cursor-theme-name = "sugar" -gtk-cursor-theme-size = 48 gtk-toolbar-style = GTK_TOOLBAR_ICONS diff --git a/sugar-emulator b/sugar-emulator index c1fb6a3e..2d6b04f1 100755 --- a/sugar-emulator +++ b/sugar-emulator @@ -87,7 +87,12 @@ _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' From bf8dbeade5017140c7d95a2d9ca95ba5b30ea00c Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Thu, 19 Apr 2007 21:14:15 +0200 Subject: [PATCH 7/9] Forgot to add this --- data/sugar-xo.gtkrc | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 data/sugar-xo.gtkrc 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 From f6a93fd8e9f44acdcddf4a487f1483eca55ae805 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Fri, 20 Apr 2007 14:45:39 +0200 Subject: [PATCH 8/9] Some initial work on graphics2 --- sugar-emulator | 9 +++++++++ sugar/graphics2/Makefile.am | 5 +++++ sugar/graphics2/__init__.py | 0 sugar/graphics2/toolbox.py | 31 ++++++++++++++++++++++++++++++ sugar/graphics2/window.py | 38 +++++++++++++++++++++++++++++++++++++ tests/test-ui.py | 34 +++++++++++++++------------------ 6 files changed, 98 insertions(+), 19 deletions(-) create mode 100644 sugar/graphics2/Makefile.am create mode 100644 sugar/graphics2/__init__.py create mode 100644 sugar/graphics2/toolbox.py create mode 100644 sugar/graphics2/window.py diff --git a/sugar-emulator b/sugar-emulator index 2d6b04f1..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' @@ -97,6 +105,7 @@ 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..c3148b76 --- /dev/null +++ b/sugar/graphics2/toolbox.py @@ -0,0 +1,31 @@ +# 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.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..068d1770 --- /dev/null +++ b/sugar/graphics2/window.py @@ -0,0 +1,38 @@ +# 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 = hippo.Canvas() + vbox.pack_start(self.canvas) + self.canvas.show() + + vbox.show() diff --git a/tests/test-ui.py b/tests/test-ui.py index ad324cc9..e44828cd 100755 --- a/tests/test-ui.py +++ b/tests/test-ui.py @@ -17,32 +17,28 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import gtk +import hippo +from sugar.graphics2.window import Window -class Toolbar(gtk.Toolbar): +class TextToolbar(gtk.Toolbar): def __init__(self): gtk.Toolbar.__init__(self) - - icon = gtk.ToolButton() - icon.set_icon_name('text-format-bold') - self.insert(icon, -1) - icon.show() -class Window(gtk.Window): - def __init__(self): - gtk.Window.__init__(self) - self.set_default_size(800, 600) - - box = gtk.VBox() - self.add(box) - box.show() - - toolbar = Toolbar() - box.pack_start(toolbar, False) - toolbar.show() - + button = gtk.ToolButton() + button.set_icon_name('text-format-bold') + self.insert(button, -1) + button.show() + window = Window() window.connect("destroy", lambda w: gtk.main_quit()) + +text_toolbar = TextToolbar() +window.toolbox.add_toolbar('Text', text_toolbar) +text_toolbar.show() + +window.canvas.set_root(hippo.CanvasBox(background_color=0)) + window.show() gtk.main() From 76e375749addc130252116ea677250c38b117549 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Fri, 20 Apr 2007 15:38:34 +0200 Subject: [PATCH 9/9] Add more toolbars and a text area --- sugar/graphics2/toolbox.py | 1 + sugar/graphics2/window.py | 13 ++++++++- tests/test-ui.py | 58 ++++++++++++++++++++++++++++++++++++-- 3 files changed, 69 insertions(+), 3 deletions(-) diff --git a/sugar/graphics2/toolbox.py b/sugar/graphics2/toolbox.py index c3148b76..be7e5e09 100644 --- a/sugar/graphics2/toolbox.py +++ b/sugar/graphics2/toolbox.py @@ -24,6 +24,7 @@ class Toolbox(gtk.VBox): 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() diff --git a/sugar/graphics2/window.py b/sugar/graphics2/window.py index 068d1770..d03788b0 100644 --- a/sugar/graphics2/window.py +++ b/sugar/graphics2/window.py @@ -31,8 +31,19 @@ class Window(gtk.Window): 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() - vbox.pack_start(self.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 e44828cd..26f3d127 100755 --- a/tests/test-ui.py +++ b/tests/test-ui.py @@ -17,10 +17,17 @@ # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA import gtk -import hippo from sugar.graphics2.window import Window +class ActivityToolbar(gtk.Toolbar): + def __init__(self): + 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) @@ -30,14 +37,61 @@ class TextToolbar(gtk.Toolbar): 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() -window.canvas.set_root(hippo.CanvasBox(background_color=0)) +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()