[gnome-utils] screenshot: cleanup ICC profile code
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-utils] screenshot: cleanup ICC profile code
- Date: Mon, 26 Sep 2011 20:56:54 +0000 (UTC)
commit 8e266fff936ec6903b78747822d39bebcec6dcb7
Author: Cosimo Cecchi <cosimoc gnome org>
Date: Mon Sep 26 14:13:15 2011 -0400
screenshot: cleanup ICC profile code
gnome-screenshot/gnome-screenshot.c | 90 +++++++++++++++++++----------------
1 files changed, 49 insertions(+), 41 deletions(-)
---
diff --git a/gnome-screenshot/gnome-screenshot.c b/gnome-screenshot/gnome-screenshot.c
index 64c2a0b..2793bc7 100644
--- a/gnome-screenshot/gnome-screenshot.c
+++ b/gnome-screenshot/gnome-screenshot.c
@@ -396,6 +396,49 @@ out:
return icc_profile;
}
+static void
+screenshot_ensure_icc_profile (GdkWindow *window)
+{
+ char *icc_profile_filename;
+ guchar *icc_profile;
+ gsize icc_profile_size;
+ char *icc_profile_base64;
+ gboolean ret;
+ GError *error = NULL;
+
+ if (!screenshot_config->include_icc_profile)
+ return;
+
+ /* load ICC profile */
+ icc_profile_filename = get_profile_for_window (window);
+ if (icc_profile_filename == NULL)
+ return;
+
+
+ ret = g_file_get_contents (icc_profile_filename,
+ (gchar **) &icc_profile,
+ &icc_profile_size,
+ &error);
+ if (ret)
+ {
+ icc_profile_base64 = g_base64_encode (icc_profile,
+ icc_profile_size);
+
+ /* use this profile for saving the image */
+ screenshot_set_icc_profile (icc_profile_base64);
+ g_free (icc_profile);
+ g_free (icc_profile_base64);
+ }
+ else
+ {
+ g_warning ("could not open ICC file: %s",
+ error->message);
+ g_error_free (error);
+ }
+
+ g_free (icc_profile_filename);
+}
+
static GdkWindow *
find_current_window (void)
{
@@ -420,13 +463,7 @@ find_current_window (void)
static void
finish_prepare_screenshot (GdkRectangle *rectangle)
-{
- char *icc_profile_filename;
- guchar *icc_profile;
- gsize icc_profile_size;
- char *icc_profile_base64;
- gboolean ret;
- GError *error = NULL;
+{
GdkRectangle rect;
GdkWindow *window;
@@ -478,42 +515,13 @@ finish_prepare_screenshot (GdkRectangle *rectangle)
GDK_SELECTION_CLIPBOARD);
gtk_clipboard_set_image (clipboard, screenshot);
gtk_main_quit ();
- }
- else
- {
- /* load ICC profile */
- if (screenshot_config->include_icc_profile)
- {
- icc_profile_filename = get_profile_for_window (window);
- if (icc_profile_filename != NULL)
- {
- ret = g_file_get_contents (icc_profile_filename,
- (gchar **) &icc_profile,
- &icc_profile_size,
- &error);
- if (ret)
- {
- icc_profile_base64 = g_base64_encode (icc_profile,
- icc_profile_size);
-
- /* use this profile for saving the image */
- screenshot_set_icc_profile (icc_profile_base64);
- g_free (icc_profile);
- g_free (icc_profile_base64);
- }
- else
- {
- g_warning ("could not open ICC file: %s",
- error->message);
- g_error_free (error);
- }
- g_free (icc_profile_filename);
- }
- }
- screenshot_build_filename_async (screenshot_config->last_save_dir,
- build_filename_ready_cb, screenshot);
+ return;
}
+
+ screenshot_ensure_icc_profile (window);
+ screenshot_build_filename_async (screenshot_config->last_save_dir,
+ build_filename_ready_cb, screenshot);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]