Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@tomeuvizoso.net>2007-03-07 11:00:38 (GMT)
committer Tomeu Vizoso <tomeu@tomeuvizoso.net>2007-03-07 11:00:38 (GMT)
commit28caa6dbd23b51395a79460389d23c9aebd36fb9 (patch)
tree92a496acad200b88a8996c1592f8ff515be9ce17
parente2bc409d176c8704d6c5d23fd588c0405436a53f (diff)
Restored save and open buttons.
-rw-r--r--AbiWordActivity.py50
-rw-r--r--toolbar.py17
2 files changed, 18 insertions, 49 deletions
diff --git a/AbiWordActivity.py b/AbiWordActivity.py
index 2642b8a..2417688 100644
--- a/AbiWordActivity.py
+++ b/AbiWordActivity.py
@@ -55,56 +55,10 @@ class AbiWordActivity (activity.Activity):
# add the controls to our window
hippoCanvasBox.append(abiwordCanvasContainer, hippo.PACK_EXPAND)
- if handle.object_id:
- self._journal_handle = handle.object_id
- obj = datastore.read(handle.object_id)
- self.abiword_canvas.load_file('file://' + obj.get_file_path())
+ if handle.uri:
+ self.abiword_canvas.load_file('file://' + handle.uri)
else:
# open a blank file
self.abiword_canvas.load_file("")
self.abiword_canvas.show()
-
- self.connect('focus-out-event', self._focus_out_event_cb)
- self.connect('delete-event', self._delete_event_cb)
-
- def _focus_out_event_cb(self, widget, event):
- self._autosave()
-
- def _delete_event_cb(self, widget, event):
- self._autosave()
-
- def _autosave(self):
- text_content = self.abiword_canvas.get_content(".txt")[0]
- if not self._journal_handle:
- home_dir = os.path.expanduser('~')
- journal_dir = os.path.join(home_dir, "Journal")
- text = Text({'preview' : text_content[0:60],
- 'date' : str(time.time()),
- 'title' : text_content[0:30],
- 'icon' : 'theme:object-text',
- 'keep' : '0',
- 'buddies' : str([ { 'name' : profile.get_nick_name(),
- 'color': profile.get_color().to_string() }]),
- 'icon-color' : profile.get_color().to_string()})
- f = open(os.path.join(journal_dir, '%i.abw' % time.time()), 'w')
- try:
- f.write(self.abiword_canvas.get_content(".abw")[0])
- finally:
- f.close()
- text.set_file_path(f.name)
- self._journal_handle = datastore.write(text)
- elif text_content != self._last_saved_text:
- text = datastore.read(self._journal_handle)
- metadata = text.get_metadata()
- metadata['preview'] = text_content[0:60]
- metadata['title'] = text_content[0:30]
- metadata['date'] = str(time.time())
- f = open(text.get_file_path(), 'w')
- try:
- f.write(self.abiword_canvas.get_content(".abw")[0])
- finally:
- f.close()
- datastore.write(text)
-
- self._last_saved_text = text_content
diff --git a/toolbar.py b/toolbar.py
index 1231f1f..c55308d 100644
--- a/toolbar.py
+++ b/toolbar.py
@@ -28,7 +28,16 @@ class AbiToolbar(object):
hippoCanvasBox.append(toolbar)
self._abiword_canvas = abiword_canvas
-
+
+ self._open = IconButton(icon_name='theme:stock-open')
+ self._open.connect("activated", self._open_cb)
+ toolbar.append(self._open)
+
+ self._save = IconButton(icon_name='theme:stock-save')
+ self._save.connect("activated", self._save_cb)
+ self._abiword_canvas.connect("is-dirty", self._isDirty_cb)
+ toolbar.append(self._save)
+
# self._insert_separator()
self._undo = IconButton(icon_name='theme:stock-undo')
@@ -98,6 +107,12 @@ class AbiToolbar(object):
# button.set_active(b)
# button.handler_unblock(id)
+ def _open_cb(self, button):
+ self._abiword_canvas.file_open()
+
+ def _save_cb(self, button):
+ self._abiword_canvas.file_save()
+
def _isDirty_cb(self, abi, b):
print "isDirty",b
# self._save.set_sensitive(b)