Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/shell/view/Shell.py
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@tomeuvizoso.net>2007-06-04 17:35:05 (GMT)
committer Tomeu Vizoso <tomeu@tomeuvizoso.net>2007-06-04 17:35:05 (GMT)
commita9600516fba87acb3cb319cc6a150a03e40a7440 (patch)
treea1a29cb92083cc277ae0698c920230f8b08b0103 /shell/view/Shell.py
parent283a3f4c9731ef5d6250cfe1db14ff063f299f7a (diff)
Take screenshot and save it to the journal (<alt>1).
Diffstat (limited to 'shell/view/Shell.py')
-rw-r--r--shell/view/Shell.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/shell/view/Shell.py b/shell/view/Shell.py
index 7624472..c682e2f 100644
--- a/shell/view/Shell.py
+++ b/shell/view/Shell.py
@@ -14,15 +14,22 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+from gettext import gettext as _
from sets import Set
import logging
+import tempfile
+import os
+import time
import gobject
+import gtk
import wnck
from sugar.activity.activityhandle import ActivityHandle
from sugar.graphics.popupcontext import PopupContext
from sugar.activity import activityfactory
+from sugar.datastore import datastore
+from sugar import profile
import sugar
from view.ActivityHost import ActivityHost
@@ -196,3 +203,27 @@ class Shell(gobject.GObject):
if not is_visible:
self._frame.do_slide_in()
act.chat_show(is_visible)
+
+ def take_screenshot(self):
+ file_path = os.path.join(tempfile.gettempdir(), '%i' % time.time())
+
+ window = gtk.gdk.get_default_root_window()
+ width, height = window.get_size();
+ x_orig, y_orig = window.get_origin();
+
+ screenshot = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, has_alpha=False,
+ bits_per_sample=8, width=width, height=height)
+ screenshot.get_from_drawable(window, window.get_colormap(), x_orig, y_orig, 0, 0,
+ width, height);
+ screenshot.save(file_path, "png")
+
+ jobject = datastore.create()
+ jobject.metadata['title'] = _('Screenshot')
+ jobject.metadata['keep'] = '0'
+ jobject.metadata['buddies'] = ''
+ jobject.metadata['preview'] = ''
+ jobject.metadata['icon-color'] = profile.get_color().to_string()
+ jobject.metadata['mime-type'] = 'image/png'
+ jobject.file_path = file_path
+ datastore.write(jobject)
+