Commit e44f37e0 authored by Cosimo Cecchi's avatar Cosimo Cecchi

screenshot: cleanup ICC profile code

parent 76186714
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment