Merge branch 'master' of git+ssh://dev.laptop.org/git/sugar
This commit is contained in:
commit
68b402cb86
@ -65,6 +65,8 @@
|
||||
#include <nsICommandManager.h>
|
||||
#include <nsIClipboardDragDropHooks.h>
|
||||
|
||||
#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<nsILocalFile> 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)) {
|
||||
|
@ -1,6 +1,7 @@
|
||||
sugardir = $(pkgdatadir)/data
|
||||
sugar_DATA = \
|
||||
gtkrc \
|
||||
sugar.gtkrc \
|
||||
sugar-xo.gtkrc \
|
||||
gecko-prefs.js \
|
||||
mime.types
|
||||
|
||||
|
@ -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
|
@ -1,2 +1,3 @@
|
||||
application/x-squeak-project pr
|
||||
application/x-abiword abw
|
||||
application/vnd.olpc-x-sugar xo
|
||||
|
7
data/sugar-xo.gtkrc
Normal file
7
data/sugar-xo.gtkrc
Normal file
@ -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
|
5
data/sugar.gtkrc
Normal file
5
data/sugar.gtkrc
Normal file
@ -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
|
@ -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:
|
||||
|
@ -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)
|
||||
|
5
sugar/graphics2/Makefile.am
Normal file
5
sugar/graphics2/Makefile.am
Normal file
@ -0,0 +1,5 @@
|
||||
sugardir = $(pythondir)/sugar/graphics2
|
||||
sugar_PYTHON = \
|
||||
__init__.py \
|
||||
window.py \
|
||||
toolbox.py
|
0
sugar/graphics2/__init__.py
Normal file
0
sugar/graphics2/__init__.py
Normal file
32
sugar/graphics2/toolbox.py
Normal file
32
sugar/graphics2/toolbox.py
Normal file
@ -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))
|
49
sugar/graphics2/window.py
Normal file
49
sugar/graphics2/window.py
Normal file
@ -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
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user