From 1a2d68bace682f5065aa73c6efa47be364011cfe Mon Sep 17 00:00:00 2001
From: Manuel Kaufmann <humitos@gmail.com>
Date: Wed, 5 Dec 2012 10:11:53 -0300
Subject: [PATCH sugar] Screenshot (global key Alt+1) fixed SL #4104
Without this PATCH we were getting always the same screenshot (image
repeated) every time that we pressed Alt+1.
I realized that Browse takes screenshots for its Bookmark previews and
they always work. So, I copied the code from Browse to Sugar itself.
Actually, the code was really similar but for some reason it was not
working on Sugar.
Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
---
extensions/globalkey/screenshot.py | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/extensions/globalkey/screenshot.py b/extensions/globalkey/screenshot.py
index 5abf15b..a2ad363 100644
a
|
b
|
def handle_key_press(key): |
42 | 42 | window = Gdk.get_default_root_window() |
43 | 43 | width, height = window.get_width(), window.get_height() |
44 | 44 | |
45 | | window_cr = Gdk.cairo_create(window) |
46 | | window_surface = window_cr.get_target() |
47 | | screenshot_surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height) |
48 | | cr = cairo.Context(screenshot_surface) |
49 | | cr.set_source_surface(window_surface) |
| 45 | window_surface = Gdk.Window.create_similar_surface( |
| 46 | window, cairo.CONTENT_COLOR, width, height) |
| 47 | |
| 48 | cr = cairo.Context(window_surface) |
| 49 | Gdk.cairo_set_source_window(cr, window, 0, 0) |
50 | 50 | cr.paint() |
51 | | screenshot_surface.write_to_png(file_path) |
| 51 | window_surface.write_to_png(file_path) |
52 | 52 | |
53 | 53 | client = GConf.Client.get_default() |
54 | 54 | color = client.get_string('/desktop/sugar/user/color') |
… |
… |
def handle_key_press(key): |
81 | 81 | jobject.metadata['title'] = title |
82 | 82 | jobject.metadata['keep'] = '0' |
83 | 83 | jobject.metadata['buddies'] = '' |
84 | | jobject.metadata['preview'] = _get_preview_data(screenshot_surface) |
| 84 | jobject.metadata['preview'] = _get_preview_data(window_surface) |
85 | 85 | jobject.metadata['icon-color'] = color |
86 | 86 | jobject.metadata['mime_type'] = 'image/png' |
87 | 87 | jobject.file_path = file_path |