Commit ffdacaa5 authored by James Cameron's avatar James Cameron
Browse files

Add Gio.Settings for home-page - move XML file to source

Do not use get_bundle_path() to locate the XML source file, instead
place it inside the Python file.

For compatibility with activities that instantiate the WebActivity
class.

Fixes a Wikipedia activity traceback;

Traceback (most recent call last):
  File "/usr/bin/sugar-activity", line 219, in <module>
    main()
  File "/usr/bin/sugar-activity", line 214, in main
    instance = create_activity_instance(activity_constructor, activity_handle)
  File "/usr/bin/sugar-activity", line 48, in create_activity_instance
    activity = constructor(handle)
  File "/usr/share/sugar/activities/SimpleEnglishWikipedia.activity/activity.py", line 78, in __init__
    webactivity.WebActivity.__init__(self, handle)
  File "/usr/share/sugar/activities/Browse.activity/webactivity.py", line 192, in __init__
    self._tabbed_view = TabbedView(self)
  File "/usr/share/sugar/activities/Browse.activity/browser.py", line 133, in __init__
    self.settings = _get_local_settings(activity)
  File "/usr/share/sugar/activities/Browse.activity/browser.py", line 109, in _get_local_settings
    lines = open(os.path.join(get_bundle_path(), src), 'r').readlines()
IOError: [Errno 2] No such file or directory: '/usr/share/sugar/activities/SimpleEnglishWikipedia.activity/org.laptop.WikipediaActivitySimpleEN.gschema.xml'
parent 920550b2
......@@ -106,7 +106,21 @@ def _get_local_settings(activity):
compiled = os.path.join(path, 'gschemas.compiled')
if not os.access(compiled, os.R_OK):
src = '%s.gschema.xml' % activity.get_bundle_id()
lines = open(os.path.join(get_bundle_path(), src), 'r').readlines()
lines = \
[
'<?xml version="1.0" encoding="UTF-8"?>',
'<schemalist>',
'<schema id="org.laptop.WebActivity" '
'path="/org/laptop/WebActivity/">',
'<key name="home-page" type="s">',
"<default>''</default>",
'<summary>Home page URL</summary>',
'<description>URL to show as default or when home button '
'is pressed.</description>',
'</key>',
'</schema>',
'</schemalist>',
]
open(os.path.join(path, src), 'w').writelines(lines)
os.system('glib-compile-schemas %s' % path)
os.remove(os.path.join(path, src))
......
<?xml version="1.0" encoding="UTF-8"?>
<schemalist>
<schema id="org.laptop.WebActivity" path="/org/laptop/WebActivity/">
<key name="home-page" type="s">
<default>''</default>
<summary>Home page URL</summary>
<description>URL to show as default or when home buttin is pressed.</description>
</key>
</schema>
</schemalist>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment