Commit 804680a9 authored by Paolo Bacchilega's avatar Paolo Bacchilega
Browse files

added toolbar button to control color profile activation

parent 2949dbaa
......@@ -6,6 +6,7 @@ iconsdir = $(themedir)/$(size)/$(context)
icons_DATA = \
change-date-symbolic.svg \
color-profile.svg \
comment-symbolic.svg \
convert-format-symbolic.svg \
curves-symbolic.svg \
......@@ -22,7 +23,7 @@ icons_DATA = \
filter-symbolic.svg \
format-linear-symbolic.svg \
format-logarithmic-symbolic.svg \
histogram-symbolic.svg \
histogram-symbolic.svg \
image-adjust-colors-symbolic.svg \
image-adjust-contrast-symbolic.svg \
image-crop-symbolic.svg \
......
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="16"
height="16"
id="svg2"
version="1.1"
inkscape:version="0.91 r13725"
sodipodi:docname="icc-profile.svg">
<defs
id="defs4">
<linearGradient
id="linearGradient3946">
<stop
id="stop3948"
offset="0"
style="stop-color:#000000;stop-opacity:0.74698794;" />
<stop
id="stop3950"
offset="1"
style="stop-color:#000000;stop-opacity:0.02409638;" />
</linearGradient>
<linearGradient
id="linearGradient3830-9">
<stop
style="stop-color:#000000;stop-opacity:0.74698794;"
offset="0"
id="stop3832-7" />
<stop
style="stop-color:#000000;stop-opacity:0.02409638;"
offset="1"
id="stop3834-5" />
</linearGradient>
<linearGradient
id="linearGradient3984">
<stop
style="stop-color:#f4deba;stop-opacity:1;"
offset="0"
id="stop3986" />
<stop
style="stop-color:#de9625;stop-opacity:0;"
offset="1"
id="stop3988" />
</linearGradient>
</defs>
<sodipodi:namedview
id="base"
pagecolor="#555753"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="1"
inkscape:pageshadow="2"
inkscape:zoom="15.471429"
inkscape:cx="7.7208382"
inkscape:cy="13.528323"
inkscape:document-units="px"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:snap-grids="true"
inkscape:window-width="1680"
inkscape:window-height="984"
inkscape:window-x="0"
inkscape:window-y="27"
inkscape:window-maximized="1"
showborder="true"
fit-margin-top="0"
fit-margin-right="0"
fit-margin-left="0"
fit-margin-bottom="0"
showguides="true"
inkscape:guide-bbox="true">
<inkscape:grid
type="xygrid"
id="grid7044"
empspacing="8"
visible="true"
enabled="true"
snapvisiblegridlinesonly="true"
originx="-31.97559px"
originy="-816.00002px" />
</sodipodi:namedview>
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Livello 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(-31.97559,-220.36218)">
<path
style="opacity:0.8;fill:#bebebe;fill-opacity:1;stroke:none;stroke-width:26.45669365;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
d="M 8 0 L 8 5 A 3 3 0 0 1 8.0234375 5 A 3 3 0 0 1 11.023438 8 L 16 8 A 8 8 0 0 0 8 0 z "
transform="translate(31.97559,220.36218)"
id="path4865" />
<path
style="opacity:0.4;fill:#bebebe;fill-opacity:1;stroke:none;stroke-width:26.45669365;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
d="M 8 0 A 8 8 0 0 0 0 8 L 5.0234375 8 A 3 3 0 0 1 8 5 L 8 0 z "
transform="translate(31.97559,220.36218)"
id="path4876" />
<path
style="opacity:0.2;fill:#bebebe;fill-opacity:1;stroke:none;stroke-width:26.45669365;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
d="M 0 8 A 8 8 0 0 0 8 16 L 8 10.998047 A 3 3 0 0 1 5.0234375 8 L 0 8 z "
transform="translate(31.97559,220.36218)"
id="path4878" />
<path
style="opacity:0.6;fill:#bebebe;fill-opacity:1;stroke:none;stroke-width:26.45669365;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
d="M 11.023438 8 A 3 3 0 0 1 8.0234375 11 A 3 3 0 0 1 8 10.998047 L 8 16 A 8 8 0 0 0 16 8 L 11.023438 8 z "
transform="translate(31.97559,220.36218)"
id="path4880" />
<circle
style="opacity:1;fill:none;fill-opacity:1;stroke:#bebebe;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="path4894"
cx="40"
cy="228.3622"
r="7.5152354" />
<circle
style="opacity:1;fill:none;fill-opacity:1;stroke:none;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="path4896"
cx="40"
cy="228.3622"
r="4" />
<circle
style="opacity:1;fill:none;fill-opacity:1;stroke:#bebebe;stroke-width:1;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
id="path4914"
cx="40"
cy="228.3622"
r="3" />
</g>
</svg>
......@@ -124,3 +124,15 @@ gth_browser_activate_paste_image (GSimpleAction *action,
GthBrowser *browser = user_data;
gth_image_viewer_page_paste_image (GTH_IMAGE_VIEWER_PAGE (gth_browser_get_viewer_page (browser)));
}
void
gth_browser_activate_apply_icc_profile (GSimpleAction *action,
GVariant *state,
gpointer user_data)
{
GthBrowser *browser = user_data;
g_simple_action_set_state (action, state);
gth_image_viewer_page_apply_icc_profile (GTH_IMAGE_VIEWER_PAGE (gth_browser_get_viewer_page (browser)), g_variant_get_boolean (state));
}
......@@ -33,5 +33,6 @@ DEF_ACTION_CALLBACK (gth_browser_activate_image_undo)
DEF_ACTION_CALLBACK (gth_browser_activate_image_redo)
DEF_ACTION_CALLBACK (gth_browser_activate_copy_image)
DEF_ACTION_CALLBACK (gth_browser_activate_paste_image)
DEF_ACTION_CALLBACK (gth_browser_activate_apply_icc_profile)
#endif /* ACTIONS_H */
......@@ -30,7 +30,7 @@
#define UPDATE_QUALITY_DELAY 200
#define UPDATE_VISIBILITY_DELAY 100
#define N_HEADER_BAR_BUTTONS 3
#define N_HEADER_BAR_BUTTONS 4
#define HIDE_OVERVIEW_TIMEOUT 2 /* in seconds */
#define OVERLAY_MARGIN 10
#undef ALWAYS_LOAD_ORIGINAL_SIZE
......@@ -56,6 +56,7 @@ static const GActionEntry actions[] = {
{ "image-redo", gth_browser_activate_image_redo },
{ "copy-image", gth_browser_activate_copy_image },
{ "paste-image", gth_browser_activate_paste_image },
{ "apply-icc-profile", toggle_action_activated, NULL, "true", gth_browser_activate_apply_icc_profile },
};
......@@ -96,6 +97,7 @@ struct _GthImageViewerPagePrivate {
gboolean pointer_on_viewer;
gboolean pointer_on_overview;
guint hide_overview_id;
gboolean apply_icc_profile;
};
......@@ -295,7 +297,10 @@ _g_mime_type_can_load_different_quality (const char *mime_type)
static void
_gth_image_preloader_init_preloader (GthImageViewerPage *self)
{
gth_image_preloader_set_out_profile (self->priv->preloader, gth_browser_get_screen_profile (self->priv->browser));
if (self->priv->apply_icc_profile)
gth_image_preloader_set_out_profile (self->priv->preloader, gth_browser_get_screen_profile (self->priv->browser));
else
gth_image_preloader_set_out_profile (self->priv->preloader, NULL);
}
......@@ -853,6 +858,14 @@ gth_image_viewer_page_real_activate (GthViewerPage *base,
_("Fit to width"),
"win.image-zoom-fit-width",
NULL);
self->priv->buttons[3] =
gth_browser_add_header_bar_toggle_button (browser,
GTH_BROWSER_HEADER_SECTION_VIEWER_TOOLS,
"color-profile",
_("Apply the embedded color profile"),
"win.apply-icc-profile",
NULL);
gth_window_add_accelerators (GTH_WINDOW (browser), accelerators, G_N_ELEMENTS (accelerators));
self->priv->preloader = gth_browser_get_image_preloader (browser);
......@@ -1085,34 +1098,19 @@ clear_data:
static void
gth_image_viewer_page_real_view (GthViewerPage *base,
GthFileData *file_data)
{
GthImageViewerPage *self;
GthFileStore *file_store;
GtkTreeIter iter;
int i;
GthFileData *next_file_data[N_FORWARD_PRELOADERS];
GthFileData *prev_file_data[N_BACKWARD_PRELOADERS];
self = (GthImageViewerPage*) base;
g_return_if_fail (file_data != NULL);
gth_viewer_page_focus (GTH_VIEWER_PAGE (self));
_g_clear_object (&self->priv->last_loaded);
if ((self->priv->file_data != NULL)
&& g_file_equal (file_data->file, self->priv->file_data->file)
&& (gth_file_data_get_mtime (file_data) == gth_file_data_get_mtime (self->priv->file_data))
&& ! self->priv->image_changed)
{
gth_image_viewer_page_file_loaded (self, TRUE);
return;
_gth_image_viewer_page_load (GthImageViewerPage *self,
GthFileData *file_data)
{
GthFileStore *file_store;
GtkTreeIter iter;
int i;
GthFileData *next_file_data[N_FORWARD_PRELOADERS];
GthFileData *prev_file_data[N_BACKWARD_PRELOADERS];
if (self->priv->file_data != file_data) {
_g_object_unref (self->priv->file_data);
self->priv->file_data = gth_file_data_dup (file_data);
}
_g_object_unref (self->priv->file_data);
self->priv->file_data = gth_file_data_dup (file_data);
self->priv->image_changed = FALSE;
self->priv->loading_image = TRUE;
......@@ -1158,6 +1156,33 @@ gth_image_viewer_page_real_view (GthViewerPage *base,
next_file_data[1],
prev_file_data[0],
prev_file_data[1]);
}
static void
gth_image_viewer_page_real_view (GthViewerPage *base,
GthFileData *file_data)
{
GthImageViewerPage *self;
self = (GthImageViewerPage*) base;
g_return_if_fail (file_data != NULL);
gth_viewer_page_focus (GTH_VIEWER_PAGE (self));
_g_clear_object (&self->priv->last_loaded);
if ((self->priv->file_data != NULL)
&& g_file_equal (file_data->file, self->priv->file_data->file)
&& (gth_file_data_get_mtime (file_data) == gth_file_data_get_mtime (self->priv->file_data))
&& ! self->priv->image_changed)
{
gth_image_viewer_page_file_loaded (self, TRUE);
return;
}
_gth_image_viewer_page_load (self, file_data);
}
......@@ -1210,6 +1235,7 @@ gth_image_viewer_page_real_update_sensitivity (GthViewerPage *base)
gboolean zoom_enabled;
double zoom;
GthFit fit_mode;
GthImage *image;
self = (GthImageViewerPage*) base;
......@@ -1227,6 +1253,10 @@ gth_image_viewer_page_real_update_sensitivity (GthViewerPage *base)
gth_window_enable_action (GTH_WINDOW (self->priv->browser), "image-zoom-fit", zoom_enabled && (fit_mode != GTH_FIT_SIZE));
gth_window_enable_action (GTH_WINDOW (self->priv->browser), "image-zoom-fit-width", zoom_enabled && (fit_mode != GTH_FIT_WIDTH));
image = gth_image_viewer_get_image (GTH_IMAGE_VIEWER (self->priv->viewer));
gtk_widget_set_visible (self->priv->buttons[3], (image != NULL) && (gth_image_get_icc_profile (image) != NULL));
gth_window_enable_action (GTH_WINDOW (self->priv->browser), "apply-icc-profile", (image != NULL) && (gth_image_get_icc_profile (image) != NULL));
_gth_image_viewer_page_update_paste_command_sensitivity (self, NULL);
}
......@@ -1644,6 +1674,7 @@ gth_image_viewer_page_init (GthImageViewerPage *self)
self->priv->pointer_on_overview = FALSE;
self->priv->pointer_on_viewer = FALSE;
self->priv->hide_overview_id = 0;
self->priv->apply_icc_profile = TRUE;
}
......@@ -2052,3 +2083,18 @@ gth_original_image_task_get_image (GthTask *task)
{
return gth_image_task_get_destination_surface (GTH_IMAGE_TASK (task));
}
void
gth_image_viewer_page_apply_icc_profile (GthImageViewerPage *self,
gboolean apply)
{
GthFileData *file_data;
self->priv->apply_icc_profile = apply;
gth_image_preloader_clear_cache (self->priv->preloader);
file_data = gth_browser_get_current_file (self->priv->browser);
if (file_data != NULL)
_gth_image_viewer_page_load (self, file_data);
}
......@@ -75,6 +75,8 @@ gboolean gth_image_viewer_page_get_original_finish (GthImageViewerPage
GError **error);
GthTask * gth_original_image_task_new (GthImageViewerPage *self);
cairo_surface_t * gth_original_image_task_get_image (GthTask *task);
void gth_image_viewer_page_apply_icc_profile (GthImageViewerPage *self,
gboolean apply);
G_END_DECLS
......
......@@ -3257,3 +3257,17 @@ _g_error_free (GError *error)
if (error != NULL)
g_error_free (error);
}
void
toggle_action_activated (GSimpleAction *action,
GVariant *parameter,
gpointer data)
{
GVariant *state;
state = g_action_get_state (G_ACTION (action));
g_action_change_state (G_ACTION (action), g_variant_new_boolean (! g_variant_get_boolean (state)));
g_variant_unref (state);
}
......@@ -356,6 +356,8 @@ GList * _g_list_prepend_link (GList *list,
GList *link);
void _g_error_free (GError *error);
DEF_ACTION_CALLBACK (toggle_action_activated)
G_END_DECLS
#endif /* _GLIB_UTILS_H */
......@@ -39,20 +39,6 @@
#include "main.h"
void
toggle_action_activated (GSimpleAction *action,
GVariant *parameter,
gpointer data)
{
GVariant *state;
state = g_action_get_state (G_ACTION (action));
g_action_change_state (G_ACTION (action), g_variant_new_boolean (! g_variant_get_boolean (state)));
g_variant_unref (state);
}
static GtkWidget *
_gth_application_get_current_window (GApplication *application)
{
......
......@@ -25,7 +25,6 @@
#include <gtk/gtk.h>
#include "glib-utils.h"
DEF_ACTION_CALLBACK (toggle_action_activated)
DEF_ACTION_CALLBACK (gth_application_activate_new_window)
DEF_ACTION_CALLBACK (gth_application_activate_preferences)
DEF_ACTION_CALLBACK (gth_application_activate_show_shortcuts)
......
......@@ -4278,6 +4278,7 @@ gth_browser_init (GthBrowser *browser)
gtk_widget_set_margin_left (browser->priv->header_sections[GTH_BROWSER_HEADER_SECTION_VIEWER_VIEW], GTH_BROWSER_HEADER_BAR_BIG_MARGIN);
gtk_widget_set_margin_left (browser->priv->header_sections[GTH_BROWSER_HEADER_SECTION_VIEWER_COMMANDS], GTH_BROWSER_HEADER_BAR_BIG_MARGIN);
gtk_widget_set_margin_right (browser->priv->header_sections[GTH_BROWSER_HEADER_SECTION_EDITOR_COMMANDS], GTH_BROWSER_HEADER_BAR_BIG_MARGIN);
gtk_widget_set_margin_right (browser->priv->header_sections[GTH_BROWSER_HEADER_SECTION_VIEWER_TOOLS], GTH_BROWSER_HEADER_BAR_BIG_MARGIN);
gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), browser->priv->header_sections[GTH_BROWSER_HEADER_SECTION_BROWSER_NAVIGATION]);
gtk_header_bar_pack_start (GTK_HEADER_BAR (header_bar), browser->priv->header_sections[GTH_BROWSER_HEADER_SECTION_BROWSER_LOCATIONS]);
......
......@@ -912,3 +912,11 @@ gth_image_preloader_get_modified_image (GthImagePreloader *self)
return NULL;
}
void
gth_image_preloader_clear_cache (GthImagePreloader *self)
{
g_queue_free_full (self->priv->cache, (GDestroyNotify) cache_data_unref);
self->priv->cache = g_queue_new ();
}
......@@ -72,5 +72,6 @@ gboolean gth_image_preloader_load_finish (GthImagePreloader *
void gth_image_preloader_set_modified_image (GthImagePreloader *self,
cairo_surface_t *image);
cairo_surface_t * gth_image_preloader_get_modified_image (GthImagePreloader *self);
void gth_image_preloader_clear_cache (GthImagePreloader *self);
#endif /* GTH_IMAGE_PRELOADER_H */
......@@ -1779,6 +1779,8 @@ gth_image_viewer_set_image (GthImageViewer *self,
if (self->priv->image != image)
_g_clear_object (&self->priv->image);
self->priv->image = g_object_ref (image);
if (gth_image_get_is_animation (image)) {
GdkPixbufAnimation *animation;
......@@ -1791,7 +1793,6 @@ gth_image_viewer_set_image (GthImageViewer *self,
cairo_surface_t *surface;
if (gth_image_get_is_zoomable (image)) {
self->priv->image = g_object_ref (image);
gth_image_set_zoom (self->priv->image,
self->priv->zoom_level,
&original_width,
......
......@@ -380,6 +380,7 @@ gth_image_set_icc_profile (GthImage *image,
GthICCProfile
gth_image_get_icc_profile (GthImage *image)
{
g_return_val_if_fail (image != NULL, NULL);
return image->priv->icc_profile;
}
......
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