Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2007-03-13 17:39:22 (GMT)
committer Dan Williams <dcbw@redhat.com>2007-03-13 17:39:22 (GMT)
commit6c1d173f7bbd419d4a30430bf05e2cd23c00b2f2 (patch)
tree70ba507e843b547a3dd90d8b8ead0bc6d96dff91
parente3f57526ae5d6b43e532e79b362b650ef6a598a1 (diff)
Move document open logic out of toolbar
-rw-r--r--XbookActivity.py38
-rw-r--r--xbooktoolbar.py19
2 files changed, 38 insertions, 19 deletions
diff --git a/XbookActivity.py b/XbookActivity.py
index c730742..43e8f01 100644
--- a/XbookActivity.py
+++ b/XbookActivity.py
@@ -1,18 +1,40 @@
+# Copyright (C) 2007, Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
import logging
from gettext import gettext as _
import gtk
import evince
import hippo
+import os
from sugar.activity import activity
from xbooktoolbar import XbookToolbar
+DOCUMENTS_DIR = os.path.join(os.path.expanduser("~"), "Documents")
+
class XbookActivity(activity.Activity):
def __init__(self, handle):
activity.Activity.__init__(self, handle)
self._document = None
+ if not os.path.exists(DOCUMENTS_DIR):
+ os.makedirs(DOCUMENTS_DIR)
+
logging.debug('Starting xbook...')
self.set_title(_('Read Activity'))
@@ -49,5 +71,17 @@ class XbookActivity(activity.Activity):
self._view.set_document(self._document)
self._toolbar.set_document(self._document)
- def _open_document_cb(self, widget, fname):
- self._load_document(fname)
+ def _open_document_cb(self, widget):
+ filt = gtk.FileFilter()
+ filt.add_mime_type("application/pdf")
+ filt.add_mime_type("application/x-pdf")
+ chooser = gtk.FileChooserDialog(_("Open a document to read"), \
+ buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
+ chooser.set_filter(filt)
+ chooser.set_current_folder(DOCUMENTS_DIR)
+ resp = chooser.run()
+ fname = chooser.get_filename()
+ chooser.hide()
+ chooser.destroy()
+ if resp == gtk.RESPONSE_ACCEPT and fname:
+ self._load_document(fname)
diff --git a/xbooktoolbar.py b/xbooktoolbar.py
index 669d042..8903d7c 100644
--- a/xbooktoolbar.py
+++ b/xbooktoolbar.py
@@ -17,8 +17,6 @@
import logging
import hippo
-import gtk
-from gettext import gettext as _
import gobject
from sugar.graphics import font
@@ -33,9 +31,7 @@ class XbookToolbar(Toolbar):
__gsignals__ = {
'open-document': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
- ([gobject.TYPE_STRING])),
- 'save-document': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
- ([gobject.TYPE_STRING]))
+ ([]))
}
def __init__(self, evince_view):
@@ -142,15 +138,4 @@ class XbookToolbar(Toolbar):
self._next.props.active = self._evince_view.can_find_next()
def _open_cb(self, button):
- filt = gtk.FileFilter()
- filt.add_mime_type("application/pdf")
- filt.add_mime_type("application/x-pdf")
- chooser = gtk.FileChooserDialog(_("Open a document to read"), \
- buttons=(gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT, gtk.STOCK_OK, gtk.RESPONSE_ACCEPT))
- chooser.set_filter(filt)
- resp = chooser.run()
- fname = chooser.get_filename()
- chooser.hide()
- chooser.destroy()
- if resp == gtk.RESPONSE_ACCEPT and fname:
- self.emit('open-document', fname)
+ self.emit('open-document')