[gthumb] file tools: do not accept the changes if no filter is active



commit eb54fbdd538f1b18d8f66c153803d010ba6d0f0b
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Tue Dec 23 12:00:40 2014 +0100

    file tools: do not accept the changes if no filter is active

 .../file_tools/gth-file-tool-adjust-contrast.c     |   18 ++++++++++--------
 extensions/file_tools/gth-file-tool-grayscale.c    |   19 +++++++++++--------
 gthumb/gth-filter-grid.c                           |    2 +-
 gthumb/gth-filter-grid.h                           |    2 +-
 4 files changed, 23 insertions(+), 18 deletions(-)
---
diff --git a/extensions/file_tools/gth-file-tool-adjust-contrast.c 
b/extensions/file_tools/gth-file-tool-adjust-contrast.c
index afd7f06..4f2a855 100644
--- a/extensions/file_tools/gth-file-tool-adjust-contrast.c
+++ b/extensions/file_tools/gth-file-tool-adjust-contrast.c
@@ -466,7 +466,7 @@ filter_grid_activated_cb (GthFilterGrid     *filter_grid,
 {
        GthFileToolAdjustContrast *self = user_data;
 
-       self->priv->view_original = (filter_id == GTH_FILTER_GRID_NO_ACTIVE_FILTER);
+       self->priv->view_original = (filter_id == GTH_FILTER_GRID_NO_FILTER);
        if (self->priv->view_original) {
                gth_preview_tool_set_image (GTH_PREVIEW_TOOL (self->priv->preview_tool), self->priv->preview);
        }
@@ -550,7 +550,7 @@ gth_file_tool_adjust_contrast_get_options (GthFileTool *base)
                                           get_image_task_for_method (METHOD_EQUALIZE_SQUARE_ROOT),
                                           METHOD_EQUALIZE_LINEAR,
                                           get_image_task_for_method (METHOD_EQUALIZE_LINEAR),
-                                          -1);
+                                          GTH_FILTER_GRID_NO_FILTER);
 
        return options;
 }
@@ -579,8 +579,8 @@ gth_file_tool_adjust_contrast_destroy_options (GthFileTool *base)
 
        _cairo_clear_surface (&self->priv->preview);
        _cairo_clear_surface (&self->priv->destination);
-       self->priv->method = -1;
-       self->priv->last_applied_method = -1;
+       self->priv->method = GTH_FILTER_GRID_NO_FILTER;
+       self->priv->last_applied_method = GTH_FILTER_GRID_NO_FILTER;
 }
 
 
@@ -590,8 +590,10 @@ gth_file_tool_adjust_contrast_apply_options (GthFileTool *base)
        GthFileToolAdjustContrast *self;
 
        self = (GthFileToolAdjustContrast *) base;
-       self->priv->apply_to_original = TRUE;
-       apply_changes (self);
+       if (! self->priv->view_original) {
+               self->priv->apply_to_original = TRUE;
+               apply_changes (self);
+       }
 }
 
 
@@ -642,8 +644,8 @@ gth_file_tool_adjust_contrast_init (GthFileToolAdjustContrast *self)
        self->priv->preview = NULL;
        self->priv->destination = NULL;
        self->priv->builder = NULL;
-       self->priv->method = -1;
-       self->priv->last_applied_method = -1;
+       self->priv->method = GTH_FILTER_GRID_NO_FILTER;
+       self->priv->last_applied_method = GTH_FILTER_GRID_NO_FILTER;
        self->priv->view_original = FALSE;
 
        gth_file_tool_construct (GTH_FILE_TOOL (self),
diff --git a/extensions/file_tools/gth-file-tool-grayscale.c b/extensions/file_tools/gth-file-tool-grayscale.c
index 6ebb798..afe7a77 100644
--- a/extensions/file_tools/gth-file-tool-grayscale.c
+++ b/extensions/file_tools/gth-file-tool-grayscale.c
@@ -305,7 +305,7 @@ filter_grid_activated_cb (GthFilterGrid     *filter_grid,
 {
        GthFileToolGrayscale *self = user_data;
 
-       self->priv->view_original = (filter_id == GTH_FILTER_GRID_NO_ACTIVE_FILTER);
+       self->priv->view_original = (filter_id == GTH_FILTER_GRID_NO_FILTER);
        if (self->priv->view_original) {
                gth_preview_tool_set_image (GTH_PREVIEW_TOOL (self->priv->preview_tool), self->priv->preview);
        }
@@ -389,7 +389,7 @@ gth_file_tool_grayscale_get_options (GthFileTool *base)
                                           get_image_task_for_method (METHOD_SATURATION),
                                           METHOD_AVARAGE,
                                           get_image_task_for_method (METHOD_AVARAGE),
-                                          -1);
+                                          GTH_FILTER_GRID_NO_FILTER);
 
        return options;
 }
@@ -418,8 +418,8 @@ gth_file_tool_grayscale_destroy_options (GthFileTool *base)
 
        _cairo_clear_surface (&self->priv->preview);
        _cairo_clear_surface (&self->priv->destination);
-       self->priv->method = -1;
-       self->priv->last_applied_method = -1;
+       self->priv->method = GTH_FILTER_GRID_NO_FILTER;
+       self->priv->last_applied_method = GTH_FILTER_GRID_NO_FILTER;
 }
 
 
@@ -429,8 +429,11 @@ gth_file_tool_grayscale_apply_options(GthFileTool *base)
        GthFileToolGrayscale *self;
 
        self = (GthFileToolGrayscale *) base;
-       self->priv->apply_to_original = TRUE;
-       apply_changes (self);
+
+       if (! self->priv->view_original) {
+               self->priv->apply_to_original = TRUE;
+               apply_changes (self);
+       }
 }
 
 
@@ -481,8 +484,8 @@ gth_file_tool_grayscale_init (GthFileToolGrayscale *self)
        self->priv->preview = NULL;
        self->priv->destination = NULL;
        self->priv->builder = NULL;
-       self->priv->method = -1;
-       self->priv->last_applied_method = -1;
+       self->priv->method = GTH_FILTER_GRID_NO_FILTER;
+       self->priv->last_applied_method = GTH_FILTER_GRID_NO_FILTER;
        self->priv->view_original = FALSE;
 
        gth_file_tool_construct (GTH_FILE_TOOL (self),
diff --git a/gthumb/gth-filter-grid.c b/gthumb/gth-filter-grid.c
index 1d02405..fb2efd9 100644
--- a/gthumb/gth-filter-grid.c
+++ b/gthumb/gth-filter-grid.c
@@ -225,7 +225,7 @@ button_toggled_cb (GtkWidget *toggle_button,
                   gpointer   user_data)
 {
        GthFilterGrid *self = user_data;
-       int            filter_id = GTH_FILTER_GRID_NO_ACTIVE_FILTER;
+       int            filter_id = GTH_FILTER_GRID_NO_FILTER;
 
        if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (toggle_button))) {
                if (self->priv->active_button != toggle_button) {
diff --git a/gthumb/gth-filter-grid.h b/gthumb/gth-filter-grid.h
index f6aded1..d5621a0 100644
--- a/gthumb/gth-filter-grid.h
+++ b/gthumb/gth-filter-grid.h
@@ -27,7 +27,7 @@
 
 G_BEGIN_DECLS
 
-#define GTH_FILTER_GRID_NO_ACTIVE_FILTER -1
+#define GTH_FILTER_GRID_NO_FILTER -1
 
 #define GTH_TYPE_FILTER_GRID (gth_filter_grid_get_type ())
 #define GTH_FILTER_GRID(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTH_TYPE_FILTER_GRID, GthFilterGrid))


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]