From 29cc73ae18d467a9fb2534db430f12a6cf0ad05b Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Wed, 25 Feb 2009 15:09:06 +0000 Subject: Let activities provide their own implementation of get_preview() #152 --- (limited to 'src') diff --git a/src/sugar/activity/activity.py b/src/sugar/activity/activity.py index 66dcbd1..deca79d 100644 --- a/src/sugar/activity/activity.py +++ b/src/sugar/activity/activity.py @@ -713,8 +713,14 @@ class Activity(Window, gtk.Container): self._jobject.destroy() self._jobject = None - def _get_preview(self): + def get_preview(self): + """Returns an image representing the state of the activity. Generally + this is what the user is seeing in this moment. + Activities can override this method, which should return a str with the + binary content of a png image with a width of 300 and a height of 225 + pixels. + """ if self.canvas is None or not hasattr(self.canvas, 'get_snapshot'): return None pixmap = self.canvas.get_snapshot((-1, -1, 0, 0)) @@ -770,7 +776,7 @@ class Activity(Window, gtk.Container): self.metadata['buddies_id'] = cjson.encode(buddies_dict.keys()) self.metadata['buddies'] = cjson.encode(self._get_buddies()) - preview = self._get_preview() + preview = self.get_preview() if preview is not None: self.metadata['preview'] = dbus.ByteArray(preview) -- cgit v0.9.1