Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@member.fsf.org>2009-03-01 18:37:02 (GMT)
committer Aleksey Lim <alsroot@member.fsf.org>2009-03-02 06:32:19 (GMT)
commit513d8cb45a8fc24383268a8c8bb5b67379bab625 (patch)
treef88766ebe396a0070b1c4534aa907afb22a3c1db
parent50e18027a1d605ef04e90d004601ca2cb88582a8 (diff)
Reflect to last .xol changes in sugar
-rw-r--r--GUI_Components/Compound_Widgets/bookview.py10
-rw-r--r--book.py57
-rw-r--r--library.py4
-rw-r--r--xol.py14
4 files changed, 47 insertions, 38 deletions
diff --git a/GUI_Components/Compound_Widgets/bookview.py b/GUI_Components/Compound_Widgets/bookview.py
index 5192a9d..e18ae2a 100644
--- a/GUI_Components/Compound_Widgets/bookview.py
+++ b/GUI_Components/Compound_Widgets/bookview.py
@@ -130,7 +130,7 @@ class BookView(gtk.VBox):
cell.props.editable = True
self.tree.insert_column_with_attributes(1, '', cell, text=1)
- for i in self.book.map:
+ for i in self.book.index:
self.store.append((i['ready'], i['title']))
# scrolled tree
@@ -205,15 +205,15 @@ class BookView(gtk.VBox):
elif new_index >= len(self.store):
new_index = 0
- self.book.map[old_index], self.book.map[new_index] = \
- self.book.map[new_index], self.book.map[old_index]
+ self.book.index[old_index], self.book.index[new_index] = \
+ self.book.index[new_index], self.book.index[old_index]
self.store.swap(self.tree.props.model.get_iter(old_index),
self.tree.props.model.get_iter(new_index))
def _check_toggled_cb(self, widget):
for i, entry in enumerate(self.store):
entry[PUBLISH] = widget.props.active
- self.book.map[i]['ready'] = widget.props.active
+ self.book.index[i]['ready'] = widget.props.active
self._check.props.inconsistent = False
def _update_check(self, value):
@@ -227,7 +227,7 @@ class BookView(gtk.VBox):
def _cell_toggled_cb(self, cell, index):
value = not self.store[index][PUBLISH]
self.store[index][PUBLISH] = value
- self.book.map[int(index)]['ready'] = value
+ self.book.index[int(index)]['ready'] = value
self._update_check(value)
def _cursor_changed_cb(self, widget):
diff --git a/book.py b/book.py
index 01b9740..ee61538 100644
--- a/book.py
+++ b/book.py
@@ -47,7 +47,7 @@ class Book(gobject.GObject):
return
logger.debug('set_article: %s' % title)
- self.sync()
+ self.sync_article()
if title is None:
return
@@ -73,7 +73,7 @@ class Book(gobject.GObject):
getter=get_article, setter=set_article)
# save current article
- def sync(self):
+ def sync_article(self):
if not self._article:
return
@@ -100,50 +100,55 @@ class Book(gobject.GObject):
self._article = None
shutil.rmtree(os.path.join(self.root, entry['uid']), True)
- del self.map[index]
- self.save_map()
+ del self.index[index]
+ self.sync_index()
self.emit('article-deleted', title)
def find(self, title):
- for i, entry in enumerate(self.map):
+ for i, entry in enumerate(self.index):
if entry['title'] == title:
return (i, entry)
return (None, None)
def find_by_uuid(self, uid):
- for i in self.map:
+ for i in self.index:
if i['uid'] == uid:
return i
return None
- def save_map(self):
- data = { 'uid': self.uid,
- 'map': self.map }
+ def sync_index(self):
+ data = { 'uid' : self.uid,
+ 'index' : self.index,
+ 'revision' : self.revision }
- mapfile = file(os.path.join(self.root, 'map'), 'w')
- mapfile.write(cjson.encode(data))
- mapfile.close()
+ index = file(os.path.join(self.root, 'index'), 'w')
+ index.write(cjson.encode(data))
+ index.close()
def __init__(self, preinstalled, dirname):
gobject.GObject.__init__(self)
self.root = os.path.join(get_activity_root(), dirname)
- self.map = []
+ self.index = []
self.uid = None
+ self.revision = 0
self._article = None
if os.path.exists(self.root):
try:
- mapfile = file(os.path.join(self.root, 'map'), 'r')
- data = cjson.decode(mapfile.read())
+ index = file(os.path.join(self.root, 'index'), 'r')
+ data = cjson.decode(index.read())
self.uid = data['uid']
- self.map = data['map']
- if self.map:
- self.props.article = self.map[0]['title']
+ self.index = data['index']
+ self.revision = data['revision']
+ if self.index:
+ self.props.article = self.index[0]['title']
except:
- logger.debug('cannot find map file; use empty')
- else:
+ logger.debug('cannot find index file; use empty')
+
+ if not self.uid:
self.uid = str(uuid.uuid1())
+ self.revision = 1
os.makedirs(self.root, 0777)
for i in preinstalled:
@@ -157,11 +162,11 @@ class Book(gobject.GObject):
logger.debug("install library: saving page %s" % i[0])
self.create(i[0], contents)
logger.debug("install library: save successful")
- self.save_map()
+ self.sync_index()
def _create(self, title, uid):
entry = { 'title': title, 'uid': str(uid), 'ready': False }
- self.map.append(entry)
+ self.index.append(entry)
self.emit('article-added', title)
return entry
@@ -216,7 +221,7 @@ def init():
custom = CustomBook()
def teardown():
- wiki.props.article = None
- wiki.save_map()
- custom.props.article = None
- custom.save_map()
+ wiki.sync_article()
+ wiki.sync_index()
+ custom.sync_article()
+ custom.sync_index()
diff --git a/library.py b/library.py
index 4288993..360ae4b 100644
--- a/library.py
+++ b/library.py
@@ -140,7 +140,7 @@ class View(gtk.EventBox):
if not article:
return
- if not abook.map:
+ if not abook.index:
notebooks[0].set_current_page(0)
return
@@ -152,7 +152,7 @@ class View(gtk.EventBox):
article_widget.textbox.set_article(article)
def _article_deleted_cb(self, abook, article, notebooks):
- if not abook.map:
+ if not abook.index:
notebooks[0].set_current_page(0)
self.activity.set_edit_sensitive(False)
diff --git a/xol.py b/xol.py
index 23b3040..eee2549 100644
--- a/xol.py
+++ b/xol.py
@@ -19,7 +19,7 @@ import book
logger = logging.getLogger('infoslicer')
def publish(activity, force=False):
- if not [i for i in book.custom.map if i['ready']]:
+ if not [i for i in book.custom.index if i['ready']]:
alert = NotifyAlert(
title=_('Nothing to publich'),
msg=_('Mark arcticles from "Custom" panel and try again.'))
@@ -71,11 +71,15 @@ def publish(activity, force=False):
'To view these articles, open the \'Browse\' Activity.\n' \
'Go to \'Books\', and select \'%s\'.' % (title, title)
- book.custom.sync()
+ book.custom.sync_article()
+ book.custom.revision += 1
+
jobject.metadata['title'] = title
_publish(title, jobject)
jobject.destroy()
+ book.custom.sync_index()
+
"""
@author: Matthew Bailey
@@ -113,7 +117,7 @@ def _dita_management(zip, uid, title):
images = {}
- for entry in book.custom.map:
+ for entry in book.custom.index:
if not entry['ready']:
continue
@@ -170,10 +174,10 @@ def _info_file(zip, uid, title):
"""
libraryfile = ['[Library]',\
'name = %s' % uid,\
- 'bundle_id = info.slice.%s' % uid,\
+ 'bundle_class = %s' % uid,\
'global_name = info.slice.%s' % uid,\
'long_name = %s' % title,\
- 'library_version = 1',\
+ 'library_version = %d' % book.custom.revision,\
'host_version = 1',\
'l10n = false',\
'locale = en',\