[gnome-utils] screenshot: unlink the temporary file when the pixbuf is loaded
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-utils] screenshot: unlink the temporary file when the pixbuf is loaded
- Date: Mon, 26 Sep 2011 21:05:17 +0000 (UTC)
commit 81c187207421ebc68528f9a6b5307eb34451b22c
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Mon Sep 26 17:04:33 2011 -0400
screenshot: unlink the temporary file when the pixbuf is loaded
Pick a random name for the temporary file, then unlink it immediately
after it has been loaded into memory.
gnome-screenshot/screenshot-utils.c | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/gnome-screenshot/screenshot-utils.c b/gnome-screenshot/screenshot-utils.c
index 1eb5626..21e3851 100644
--- a/gnome-screenshot/screenshot-utils.c
+++ b/gnome-screenshot/screenshot-utils.c
@@ -562,14 +562,16 @@ screenshot_get_pixbuf (GdkWindow *window,
GdkRectangle *rectangle)
{
GdkPixbuf *screenshot;
- gchar *path, *filename;
+ gchar *path, *filename, *tmpname;
const gchar *method_name;
GVariant *method_params;
GError *error = NULL;
path = g_build_filename (g_get_user_cache_dir (), "gnome-screenshot", NULL);
g_mkdir_with_parents (path, 0700);
- filename = g_build_filename (path, "tmp.png", NULL);
+
+ tmpname = g_strdup_printf ("scr-%d.png", g_random_int ());
+ filename = g_build_filename (path, tmpname, NULL);
if (screenshot_config->take_window_shot)
{
@@ -624,9 +626,15 @@ screenshot_get_pixbuf (GdkWindow *window,
screenshot = screenshot_get_pixbuf_fallback (window, rectangle);
}
+ else
+ {
+ /* remove the temporary file created by the shell */
+ g_unlink (filename);
+ }
}
g_free (path);
+ g_free (tmpname);
g_free (filename);
return screenshot;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]