Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ImageViewerActivity.py18
-rw-r--r--ProgressDialog.py26
2 files changed, 43 insertions, 1 deletions
diff --git a/ImageViewerActivity.py b/ImageViewerActivity.py
index 7c88048..0096b22 100644
--- a/ImageViewerActivity.py
+++ b/ImageViewerActivity.py
@@ -17,6 +17,8 @@
# The sharing bits have been taken from ReadEtexts
+from __future__ import division
+
from sugar.activity import activity
import logging
@@ -37,6 +39,7 @@ import dbus
import ImageView
import ImageViewerToolbar
+import ProgressDialog
_logger = logging.getLogger('imageviewer-activity')
@@ -91,6 +94,7 @@ class ImageViewerActivity(activity.Activity):
self._object_id = handle.object_id
self.view = ImageView.ImageViewer()
+ self.progressdialog = None
toolbox = activity.ActivityToolbox(self)
self._view_toolbar = ImageViewerToolbar.ViewToolbar(self.view)
@@ -217,6 +221,9 @@ class ImageViewerActivity(activity.Activity):
_logger.debug("Got document %s (%s) from tube %u",
tempfile, suggested_name, tube_id)
+
+ self.progressdialog.destroy()
+
gobject.idle_add(self.__set_file_idle_cb, tempfile)
self.save()
@@ -229,7 +236,11 @@ class ImageViewerActivity(activity.Activity):
_logger.debug("Downloaded %u bytes from tube %u...",
bytes_downloaded, tube_id)
total = self._download_content_length
- # gtk.main_iteration()
+
+ fraction = bytes_downloaded/total
+ self.progressdialog.set_fraction(fraction)
+
+ #gtk.main_iteration()
def _download_error_cb(self, getter, err, tube_id):
_logger.debug("Error getting document from tube %u: %s",
@@ -267,6 +278,7 @@ class ImageViewerActivity(activity.Activity):
getter.start(path)
self._download_content_length = getter.get_content_length()
self._download_content_type = getter.get_content_type()
+
return False
def _get_document(self):
@@ -299,6 +311,10 @@ class ImageViewerActivity(activity.Activity):
Get the shared document from another participant.
"""
self.watch_for_tubes()
+
+ self.progressdialog = ProgressDialog.ProgressDialog(self)
+ self.progressdialog.show_all()
+
gobject.idle_add(self._get_document)
def _share_document(self):
diff --git a/ProgressDialog.py b/ProgressDialog.py
new file mode 100644
index 0000000..bf92502
--- /dev/null
+++ b/ProgressDialog.py
@@ -0,0 +1,26 @@
+import gtk
+from gettext import gettext as _
+
+class ProgressDialog(gtk.Dialog):
+ def __init__(self, parent):
+ gtk.Dialog.__init__(self, _('Downloading...'), parent, \
+ gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, \
+ (gtk.STOCK_CANCEL, gtk.RESPONSE_REJECT))
+
+ self._activity = parent
+
+ self.connect('response', self._response_cb)
+
+ self._pb = gtk.ProgressBar()
+ self._pb.set_text(_('Retrieving shared image, please wait...'))
+ self.vbox.add(self._pb)
+
+ def _response_cb(self, dialog, response_id):
+ if response_id == gtk.RESPONSE_REJECT:
+ self._activity.close()
+ else:
+ pass
+
+ def set_fraction(self, fraction):
+ self._pb.set_fraction(fraction)
+