[gthumb] reset the original image when exiting a tool pressing the Escape key
- From: Paolo Bacchilega <paobac src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gthumb] reset the original image when exiting a tool pressing the Escape key
- Date: Thu, 2 Aug 2012 12:35:24 +0000 (UTC)
commit 62f96be77daac07a485f0d7773c12bae33073cc1
Author: Paolo Bacchilega <paobac src gnome org>
Date: Thu Jul 5 22:23:52 2012 +0200
reset the original image when exiting a tool pressing the Escape key
.../file_tools/gth-file-tool-adjust-colors.c | 48 +++++++++----------
extensions/file_tools/gth-file-tool-crop.c | 16 ++-----
extensions/file_tools/gth-file-tool-resize.c | 37 ++++++++-------
extensions/file_tools/gth-file-tool-rotate.c | 37 +++++++--------
extensions/file_tools/gth-file-tool-sharpen.c | 46 +++++++++----------
extensions/red_eye_removal/gth-file-tool-red-eye.c | 44 +++++++++---------
gthumb/gth-file-tool.c | 23 +++++++++
gthumb/gth-file-tool.h | 2 +
gthumb/gth-toolbox.c | 2 +-
9 files changed, 134 insertions(+), 121 deletions(-)
---
diff --git a/extensions/file_tools/gth-file-tool-adjust-colors.c b/extensions/file_tools/gth-file-tool-adjust-colors.c
index 5e75c50..f604cf4 100644
--- a/extensions/file_tools/gth-file-tool-adjust-colors.c
+++ b/extensions/file_tools/gth-file-tool-adjust-colors.c
@@ -289,27 +289,6 @@ ok_button_clicked_cb (GtkButton *button,
static void
-cancel_button_clicked_cb (GtkButton *button,
- gpointer user_data)
-{
- GthFileToolAdjustColors *self = user_data;
- GtkWidget *window;
- GtkWidget *viewer_page;
-
- if (self->priv->apply_event != 0) {
- g_source_remove (self->priv->apply_event);
- self->priv->apply_event = 0;
- }
-
- window = gth_file_tool_get_window (GTH_FILE_TOOL (self));
- viewer_page = gth_browser_get_viewer_page (GTH_BROWSER (window));
- gth_image_viewer_page_reset (GTH_IMAGE_VIEWER_PAGE (viewer_page));
-
- gth_file_tool_hide_options (GTH_FILE_TOOL (self));
-}
-
-
-static void
reset_button_clicked_cb (GtkButton *button,
gpointer user_data)
{
@@ -454,10 +433,10 @@ gth_file_tool_adjust_colors_get_options (GthFileTool *base)
"clicked",
G_CALLBACK (ok_button_clicked_cb),
self);
- g_signal_connect (GET_WIDGET ("cancel_button"),
- "clicked",
- G_CALLBACK (cancel_button_clicked_cb),
- self);
+ g_signal_connect_swapped (GET_WIDGET ("cancel_button"),
+ "clicked",
+ G_CALLBACK (gth_file_tool_cancel),
+ self);
g_signal_connect (GET_WIDGET ("reset_button"),
"clicked",
G_CALLBACK (reset_button_clicked_cb),
@@ -530,6 +509,24 @@ gth_file_tool_adjust_colors_activate (GthFileTool *base)
static void
+gth_file_tool_adjust_colors_cancel (GthFileTool *file_tool)
+{
+ GthFileToolAdjustColors *self = GTH_FILE_TOOL_ADJUST_COLORS (file_tool);
+ GtkWidget *window;
+ GtkWidget *viewer_page;
+
+ if (self->priv->apply_event != 0) {
+ g_source_remove (self->priv->apply_event);
+ self->priv->apply_event = 0;
+ }
+
+ window = gth_file_tool_get_window (GTH_FILE_TOOL (self));
+ viewer_page = gth_browser_get_viewer_page (GTH_BROWSER (window));
+ gth_image_viewer_page_reset (GTH_IMAGE_VIEWER_PAGE (viewer_page));
+}
+
+
+static void
gth_file_tool_adjust_colors_init (GthFileToolAdjustColors *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTH_TYPE_FILE_TOOL_ADJUST_COLORS, GthFileToolAdjustColorsPrivate);
@@ -573,6 +570,7 @@ gth_file_tool_adjust_colors_class_init (GthFileToolAdjustColorsClass *class)
file_tool_class = (GthFileToolClass *) class;
file_tool_class->update_sensitivity = gth_file_tool_adjust_colors_update_sensitivity;
file_tool_class->activate = gth_file_tool_adjust_colors_activate;
+ file_tool_class->cancel = gth_file_tool_adjust_colors_cancel;
file_tool_class->get_options = gth_file_tool_adjust_colors_get_options;
file_tool_class->destroy_options = gth_file_tool_adjust_colors_destroy_options;
}
diff --git a/extensions/file_tools/gth-file-tool-crop.c b/extensions/file_tools/gth-file-tool-crop.c
index f9a5e18..358f74c 100644
--- a/extensions/file_tools/gth-file-tool-crop.c
+++ b/extensions/file_tools/gth-file-tool-crop.c
@@ -67,14 +67,6 @@ gth_file_tool_crop_update_sensitivity (GthFileTool *base)
static void
-cancel_button_clicked_cb (GtkButton *button,
- GthFileToolCrop *self)
-{
- gth_file_tool_hide_options (GTH_FILE_TOOL (self));
-}
-
-
-static void
crop_button_clicked_cb (GtkButton *button,
GthFileToolCrop *self)
{
@@ -473,10 +465,10 @@ gth_file_tool_crop_get_options (GthFileTool *base)
"clicked",
G_CALLBACK (crop_button_clicked_cb),
self);
- g_signal_connect (GET_WIDGET ("cancel_button"),
- "clicked",
- G_CALLBACK (cancel_button_clicked_cb),
- self);
+ g_signal_connect_swapped (GET_WIDGET ("cancel_button"),
+ "clicked",
+ G_CALLBACK (gth_file_tool_cancel),
+ self);
g_signal_connect (G_OBJECT (self->priv->crop_x_spinbutton),
"value-changed",
G_CALLBACK (selection_x_value_changed_cb),
diff --git a/extensions/file_tools/gth-file-tool-resize.c b/extensions/file_tools/gth-file-tool-resize.c
index 7442c63..4889f30 100644
--- a/extensions/file_tools/gth-file-tool-resize.c
+++ b/extensions/file_tools/gth-file-tool-resize.c
@@ -71,20 +71,6 @@ gth_file_tool_resize_update_sensitivity (GthFileTool *base)
static void
-cancel_button_clicked_cb (GtkButton *button,
- GthFileToolResize *self)
-{
- GtkWidget *window;
- GtkWidget *viewer_page;
-
- window = gth_file_tool_get_window (GTH_FILE_TOOL (self));
- viewer_page = gth_browser_get_viewer_page (GTH_BROWSER (window));
- gth_image_viewer_page_reset (GTH_IMAGE_VIEWER_PAGE (viewer_page));
- gth_file_tool_hide_options (GTH_FILE_TOOL (self));
-}
-
-
-static void
resize_button_clicked_cb (GtkButton *button,
GthFileToolResize *self)
{
@@ -532,10 +518,10 @@ gth_file_tool_resize_get_options (GthFileTool *base)
"clicked",
G_CALLBACK (resize_button_clicked_cb),
self);
- g_signal_connect (GET_WIDGET ("cancel_button"),
- "clicked",
- G_CALLBACK (cancel_button_clicked_cb),
- self);
+ g_signal_connect_swapped (GET_WIDGET ("cancel_button"),
+ "clicked",
+ G_CALLBACK (gth_file_tool_cancel),
+ self);
g_signal_connect (GET_WIDGET ("resize_width_spinbutton"),
"value-changed",
G_CALLBACK (selection_width_value_changed_cb),
@@ -634,6 +620,19 @@ gth_file_tool_resize_activate (GthFileTool *base)
static void
+gth_file_tool_resize_cancel (GthFileTool *base)
+{
+ GthFileToolResize *self = (GthFileToolResize *) base;
+ GtkWidget *window;
+ GtkWidget *viewer_page;
+
+ window = gth_file_tool_get_window (GTH_FILE_TOOL (self));
+ viewer_page = gth_browser_get_viewer_page (GTH_BROWSER (window));
+ gth_image_viewer_page_reset (GTH_IMAGE_VIEWER_PAGE (viewer_page));
+}
+
+
+static void
gth_file_tool_resize_finalize (GObject *object)
{
GthFileToolResize *self;
@@ -667,6 +666,7 @@ gth_file_tool_resize_class_init (GthFileToolResizeClass *klass)
file_tool_class = (GthFileToolClass *) klass;
file_tool_class->update_sensitivity = gth_file_tool_resize_update_sensitivity;
file_tool_class->activate = gth_file_tool_resize_activate;
+ file_tool_class->cancel = gth_file_tool_resize_cancel;
file_tool_class->get_options = gth_file_tool_resize_get_options;
file_tool_class->destroy_options = gth_file_tool_resize_destroy_options;
}
@@ -679,3 +679,4 @@ gth_file_tool_resize_init (GthFileToolResize *self)
self->priv->settings = g_settings_new (GTHUMB_RESIZE_SCHEMA);
gth_file_tool_construct (GTH_FILE_TOOL (self), "tool-resize", _("Resize..."), _("Resize"), FALSE);
}
+
diff --git a/extensions/file_tools/gth-file-tool-rotate.c b/extensions/file_tools/gth-file-tool-rotate.c
index f84a860..e43d912 100644
--- a/extensions/file_tools/gth-file-tool-rotate.c
+++ b/extensions/file_tools/gth-file-tool-rotate.c
@@ -252,21 +252,6 @@ apply_button_clicked_cb (GtkButton *button,
static void
-cancel_button_clicked_cb (GtkButton *button,
- GthFileToolRotate *self)
-{
- GtkWidget *window;
- GtkWidget *viewer_page;
-
- window = gth_file_tool_get_window (GTH_FILE_TOOL (self));
- viewer_page = gth_browser_get_viewer_page (GTH_BROWSER (window));
- gth_image_viewer_page_reset (GTH_IMAGE_VIEWER_PAGE (viewer_page));
-
- gth_file_tool_hide_options (GTH_FILE_TOOL (self));
-}
-
-
-static void
crop_settings_changed_cb (GtkAdjustment *adj,
GthFileToolRotate *self)
{
@@ -468,10 +453,10 @@ gth_file_tool_rotate_get_options (GthFileTool *base)
"clicked",
G_CALLBACK (apply_button_clicked_cb),
self);
- g_signal_connect (GET_WIDGET ("cancel_button"),
- "clicked",
- G_CALLBACK (cancel_button_clicked_cb),
- self);
+ g_signal_connect_swapped (GET_WIDGET ("cancel_button"),
+ "clicked",
+ G_CALLBACK (gth_file_tool_cancel),
+ self);
g_signal_connect (GET_WIDGET ("reset_button"),
"clicked",
G_CALLBACK (reset_button_clicked_cb),
@@ -590,6 +575,19 @@ gth_file_tool_rotate_activate (GthFileTool *base)
static void
+gth_file_tool_rotate_cancel (GthFileTool *base)
+{
+ GthFileToolRotate *self = (GthFileToolRotate *) base;
+ GtkWidget *window;
+ GtkWidget *viewer_page;
+
+ window = gth_file_tool_get_window (GTH_FILE_TOOL (self));
+ viewer_page = gth_browser_get_viewer_page (GTH_BROWSER (window));
+ gth_image_viewer_page_reset (GTH_IMAGE_VIEWER_PAGE (viewer_page));
+}
+
+
+static void
gth_file_tool_rotate_finalize (GObject *object)
{
GthFileToolRotate *self;
@@ -622,6 +620,7 @@ gth_file_tool_rotate_class_init (GthFileToolRotateClass *klass)
file_tool_class = (GthFileToolClass *) klass;
file_tool_class->update_sensitivity = gth_file_tool_rotate_update_sensitivity;
file_tool_class->activate = gth_file_tool_rotate_activate;
+ file_tool_class->cancel = gth_file_tool_rotate_cancel;
file_tool_class->get_options = gth_file_tool_rotate_get_options;
file_tool_class->destroy_options = gth_file_tool_rotate_destroy_options;
}
diff --git a/extensions/file_tools/gth-file-tool-sharpen.c b/extensions/file_tools/gth-file-tool-sharpen.c
index 1ceb062..1eec56e 100644
--- a/extensions/file_tools/gth-file-tool-sharpen.c
+++ b/extensions/file_tools/gth-file-tool-sharpen.c
@@ -180,26 +180,6 @@ ok_button_clicked_cb (GtkButton *button,
static void
-cancel_button_clicked_cb (GtkButton *button,
- GthFileToolSharpen *self)
-{
- GtkWidget *window;
- GtkWidget *viewer_page;
-
- if (self->priv->apply_event != 0) {
- g_source_remove (self->priv->apply_event);
- self->priv->apply_event = 0;
- }
-
- window = gth_file_tool_get_window (GTH_FILE_TOOL (self));
- viewer_page = gth_browser_get_viewer_page (GTH_BROWSER (window));
- gth_image_viewer_page_reset (GTH_IMAGE_VIEWER_PAGE (viewer_page));
-
- gth_file_tool_hide_options (GTH_FILE_TOOL (self));
-}
-
-
-static void
reset_button_clicked_cb (GtkButton *button,
GthFileToolSharpen *self)
{
@@ -343,10 +323,10 @@ gth_file_tool_sharpen_get_options (GthFileTool *base)
"clicked",
G_CALLBACK (ok_button_clicked_cb),
self);
- g_signal_connect (GET_WIDGET ("cancel_button"),
- "clicked",
- G_CALLBACK (cancel_button_clicked_cb),
- self);
+ g_signal_connect_swapped (GET_WIDGET ("cancel_button"),
+ "clicked",
+ G_CALLBACK (gth_file_tool_cancel),
+ self);
g_signal_connect (GET_WIDGET ("reset_button"),
"clicked",
G_CALLBACK (reset_button_clicked_cb),
@@ -409,6 +389,23 @@ gth_file_tool_sharpen_activate (GthFileTool *base)
static void
+gth_file_tool_sharpen_cancel (GthFileTool *base)
+{
+ GthFileToolSharpen *self = (GthFileToolSharpen *) base;
+ GtkWidget *window;
+ GtkWidget *viewer_page;
+
+ if (self->priv->apply_event != 0) {
+ g_source_remove (self->priv->apply_event);
+ self->priv->apply_event = 0;
+ }
+
+ window = gth_file_tool_get_window (GTH_FILE_TOOL (self));
+ viewer_page = gth_browser_get_viewer_page (GTH_BROWSER (window));
+ gth_image_viewer_page_reset (GTH_IMAGE_VIEWER_PAGE (viewer_page));
+}
+
+static void
gth_file_tool_sharpen_finalize (GObject *object)
{
GthFileToolSharpen *self;
@@ -441,6 +438,7 @@ gth_file_tool_sharpen_class_init (GthFileToolSharpenClass *klass)
file_tool_class = (GthFileToolClass *) klass;
file_tool_class->update_sensitivity = gth_file_tool_sharpen_update_sensitivity;
file_tool_class->activate = gth_file_tool_sharpen_activate;
+ file_tool_class->cancel = gth_file_tool_sharpen_cancel;
file_tool_class->get_options = gth_file_tool_sharpen_get_options;
file_tool_class->destroy_options = gth_file_tool_sharpen_destroy_options;
}
diff --git a/extensions/red_eye_removal/gth-file-tool-red-eye.c b/extensions/red_eye_removal/gth-file-tool-red-eye.c
index 0b09e53..ad17901 100644
--- a/extensions/red_eye_removal/gth-file-tool-red-eye.c
+++ b/extensions/red_eye_removal/gth-file-tool-red-eye.c
@@ -83,24 +83,6 @@ ok_button_clicked_cb (GtkButton *button,
}
-static void
-cancel_button_clicked_cb (GtkButton *button,
- GthFileToolRedEye *self)
-{
- GtkWidget *window;
- GtkWidget *viewer_page;
- GtkWidget *viewer;
-
- window = gth_file_tool_get_window (GTH_FILE_TOOL (self));
- viewer_page = gth_browser_get_viewer_page (GTH_BROWSER (window));
- viewer = gth_image_viewer_page_get_image_viewer (GTH_IMAGE_VIEWER_PAGE (viewer_page));
-
- gth_image_viewer_set_zoom_change (GTH_IMAGE_VIEWER (viewer), self->priv->original_zoom_change);
- gth_image_viewer_page_reset (GTH_IMAGE_VIEWER_PAGE (viewer_page));
- gth_file_tool_hide_options (GTH_FILE_TOOL (self));
-}
-
-
static int
find_region (int row,
int col,
@@ -404,10 +386,10 @@ gth_file_tool_red_eye_get_options (GthFileTool *base)
self->priv->builder = _gtk_builder_new_from_file ("red-eye-removal-options.ui", "red_eye_removal");
options = _gtk_builder_get_widget (self->priv->builder, "options");
gtk_widget_show (options);
- g_signal_connect (GET_WIDGET ("cancel_button"),
- "clicked",
- G_CALLBACK (cancel_button_clicked_cb),
- self);
+ g_signal_connect_swapped (GET_WIDGET ("cancel_button"),
+ "clicked",
+ G_CALLBACK (gth_file_tool_cancel),
+ self);
g_signal_connect (GET_WIDGET ("ok_button"),
"clicked",
G_CALLBACK (ok_button_clicked_cb),
@@ -463,6 +445,23 @@ gth_file_tool_red_eye_activate (GthFileTool *base)
static void
+gth_file_tool_red_eye_cancel (GthFileTool *base)
+{
+ GthFileToolRedEye *self = (GthFileToolRedEye *) base;
+ GtkWidget *window;
+ GtkWidget *viewer_page;
+ GtkWidget *viewer;
+
+ window = gth_file_tool_get_window (GTH_FILE_TOOL (self));
+ viewer_page = gth_browser_get_viewer_page (GTH_BROWSER (window));
+ viewer = gth_image_viewer_page_get_image_viewer (GTH_IMAGE_VIEWER_PAGE (viewer_page));
+
+ gth_image_viewer_set_zoom_change (GTH_IMAGE_VIEWER (viewer), self->priv->original_zoom_change);
+ gth_image_viewer_page_reset (GTH_IMAGE_VIEWER_PAGE (viewer_page));
+}
+
+
+static void
gth_file_tool_red_eye_finalize (GObject *object)
{
GthFileToolRedEye *self;
@@ -496,6 +495,7 @@ gth_file_tool_red_eye_class_init (GthFileToolRedEyeClass *class)
file_tool_class = (GthFileToolClass *) class;
file_tool_class->update_sensitivity = gth_file_tool_red_eye_update_sensitivity;
file_tool_class->activate = gth_file_tool_red_eye_activate;
+ file_tool_class->cancel = gth_file_tool_red_eye_cancel;
file_tool_class->get_options = gth_file_tool_red_eye_get_options;
file_tool_class->destroy_options = gth_file_tool_red_eye_destroy_options;
}
diff --git a/gthumb/gth-file-tool.c b/gthumb/gth-file-tool.c
index 890eb9b..7c5f7d9 100644
--- a/gthumb/gth-file-tool.c
+++ b/gthumb/gth-file-tool.c
@@ -39,6 +39,7 @@ struct _GthFileToolPrivate {
const char *button_text;
const char *options_title;
gboolean separator;
+ gboolean canceled;
};
@@ -59,6 +60,13 @@ gth_file_tool_base_activate (GthFileTool *self)
}
+static void
+gth_file_tool_base_cancel (GthFileTool *self)
+{
+ /* void*/
+}
+
+
static GtkWidget *
gth_file_tool_base_get_options (GthFileTool *self)
{
@@ -96,6 +104,7 @@ gth_file_tool_class_init (GthFileToolClass *klass)
klass->update_sensitivity = gth_file_tool_base_update_sensitivity;
klass->activate = gth_file_tool_base_activate;
+ klass->cancel = gth_file_tool_base_cancel;
klass->get_options = gth_file_tool_base_get_options;
klass->destroy_options = gth_file_tool_base_destroy_options;
@@ -127,6 +136,7 @@ gth_file_tool_init (GthFileTool *self)
self->priv->icon_name = NULL;
self->priv->button_text = NULL;
self->priv->options_title = NULL;
+ self->priv->canceled = FALSE;
gtk_button_set_relief (GTK_BUTTON (self), GTK_RELIEF_NONE);
}
@@ -185,11 +195,24 @@ gth_file_tool_get_icon_name (GthFileTool *self)
void
gth_file_tool_activate (GthFileTool *self)
{
+ self->priv->canceled = FALSE;
GTH_FILE_TOOL_GET_CLASS (self)->activate (self);
}
void
+gth_file_tool_cancel (GthFileTool *self)
+{
+ if (self->priv->canceled)
+ return;
+
+ self->priv->canceled = TRUE;
+ GTH_FILE_TOOL_GET_CLASS (self)->cancel (self);
+ gth_file_tool_hide_options (self);
+}
+
+
+void
gth_file_tool_update_sensitivity (GthFileTool *self)
{
GTH_FILE_TOOL_GET_CLASS (self)->update_sensitivity (self);
diff --git a/gthumb/gth-file-tool.h b/gthumb/gth-file-tool.h
index 6658419..60b08da 100644
--- a/gthumb/gth-file-tool.h
+++ b/gthumb/gth-file-tool.h
@@ -49,6 +49,7 @@ struct _GthFileToolClass {
void (*update_sensitivity) (GthFileTool *self);
void (*activate) (GthFileTool *self);
+ void (*cancel) (GthFileTool *self);
GtkWidget * (*get_options) (GthFileTool *self);
void (*destroy_options) (GthFileTool *self);
@@ -67,6 +68,7 @@ void gth_file_tool_construct (GthFileTool *self,
GtkWidget * gth_file_tool_get_window (GthFileTool *self);
const char * gth_file_tool_get_icon_name (GthFileTool *self);
void gth_file_tool_activate (GthFileTool *self);
+void gth_file_tool_cancel (GthFileTool *self);
void gth_file_tool_update_sensitivity (GthFileTool *self);
GtkWidget * gth_file_tool_get_options (GthFileTool *self);
const char * gth_file_tool_get_options_title (GthFileTool *self);
diff --git a/gthumb/gth-toolbox.c b/gthumb/gth-toolbox.c
index 23cf767..9d330a6 100644
--- a/gthumb/gth-toolbox.c
+++ b/gthumb/gth-toolbox.c
@@ -296,7 +296,7 @@ void
gth_toolbox_deactivate_tool (GthToolbox *toolbox)
{
if (toolbox->priv->active_tool != NULL)
- gth_file_tool_hide_options (GTH_FILE_TOOL (toolbox->priv->active_tool));
+ gth_file_tool_cancel (GTH_FILE_TOOL (toolbox->priv->active_tool));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]