[gthumb: 50/129] rotate tool: disable the zoom commands



commit e8e3de8f013d699a3b40844731c98c9a9d3b8d75
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Wed Apr 20 14:11:38 2011 +0200

    rotate tool: disable the zoom commands

 extensions/file_tools/gth-file-tool-rotate.c    |   19 +++++++++++++++++++
 extensions/image_viewer/gth-image-viewer-page.c |   13 ++++++++-----
 gthumb/gth-image-viewer.c                       |   23 +++++++++++++++++++++++
 gthumb/gth-image-viewer.h                       |    3 +++
 4 files changed, 53 insertions(+), 5 deletions(-)
---
diff --git a/extensions/file_tools/gth-file-tool-rotate.c b/extensions/file_tools/gth-file-tool-rotate.c
index 20ed0d8..fc4afd9 100644
--- a/extensions/file_tools/gth-file-tool-rotate.c
+++ b/extensions/file_tools/gth-file-tool-rotate.c
@@ -74,12 +74,20 @@ cancel_button_clicked_cb (GtkButton *button,
 			  gpointer   user_data)
 {
 	GthFileToolRotate *self = user_data;
+	GtkWidget         *window;
+	GtkWidget         *viewer_page;
+	GtkWidget         *image_viewer;
 
 	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));
+	image_viewer = gth_image_viewer_page_get_image_viewer (GTH_IMAGE_VIEWER_PAGE (viewer_page));
+	gth_image_viewer_set_zoom_enabled (GTH_IMAGE_VIEWER (image_viewer), TRUE);
+
 	gth_file_tool_hide_options (GTH_FILE_TOOL (self));
 }
 
@@ -89,8 +97,16 @@ ok_button_clicked_cb (GtkButton *button,
 		      gpointer   user_data)
 {
 	GthFileToolRotate *self = user_data;
+	GtkWidget         *window;
+	GtkWidget         *viewer_page;
+	GtkWidget         *image_viewer;
 	cairo_surface_t   *new_image;
 
+	window = gth_file_tool_get_window (GTH_FILE_TOOL (self));
+	viewer_page = gth_browser_get_viewer_page (GTH_BROWSER (window));
+	image_viewer = gth_image_viewer_page_get_image_viewer (GTH_IMAGE_VIEWER_PAGE (viewer_page));
+	gth_image_viewer_set_zoom_enabled (GTH_IMAGE_VIEWER (image_viewer), TRUE);
+
 	new_image = gth_image_rotator_get_result (self->priv->rotator);
 	if (new_image != NULL) {
 		GtkWidget *window;
@@ -356,6 +372,9 @@ gth_file_tool_rotate_get_options (GthFileTool *base)
 	if (image == NULL)
 		return NULL;
 
+	gth_image_viewer_set_zoom_enabled (GTH_IMAGE_VIEWER (viewer), FALSE);
+	gth_viewer_page_update_sensitivity (GTH_VIEWER_PAGE (viewer_page));
+
 	self->priv->pixbuf_width = cairo_image_surface_get_width (image);
 	self->priv->pixbuf_height = cairo_image_surface_get_height (image);
 	self->priv->unit = eel_gconf_get_enum (PREF_ROTATE_UNIT, GTH_TYPE_UNIT, GTH_UNIT_PERCENTAGE);
diff --git a/extensions/image_viewer/gth-image-viewer-page.c b/extensions/image_viewer/gth-image-viewer-page.c
index b3b5c02..a8c2df0 100644
--- a/extensions/image_viewer/gth-image-viewer-page.c
+++ b/extensions/image_viewer/gth-image-viewer-page.c
@@ -933,6 +933,7 @@ static void
 gth_image_viewer_page_real_update_sensitivity (GthViewerPage *base)
 {
 	GthImageViewerPage *self;
+	gboolean            zoom_enabled;
 	double              zoom;
 	GthFit              fit_mode;
 
@@ -941,14 +942,16 @@ gth_image_viewer_page_real_update_sensitivity (GthViewerPage *base)
 	_set_action_sensitive (self, "ImageViewer_Edit_Undo", gth_image_history_can_undo (self->priv->history));
 	_set_action_sensitive (self, "ImageViewer_Edit_Redo", gth_image_history_can_redo (self->priv->history));
 
+	zoom_enabled = gth_image_viewer_get_zoom_enabled (GTH_IMAGE_VIEWER (self->priv->viewer));
 	zoom = gth_image_viewer_get_zoom (GTH_IMAGE_VIEWER (self->priv->viewer));
-	_set_action_sensitive (self, "ImageViewer_View_Zoom100", ! FLOAT_EQUAL (zoom, 1.0));
-	_set_action_sensitive (self, "ImageViewer_View_ZoomOut", zoom > 0.05);
-	_set_action_sensitive (self, "ImageViewer_View_ZoomIn", zoom < 100.0);
+
+	_set_action_sensitive (self, "ImageViewer_View_Zoom100", zoom_enabled && ! FLOAT_EQUAL (zoom, 1.0));
+	_set_action_sensitive (self, "ImageViewer_View_ZoomOut", zoom_enabled && (zoom > 0.05));
+	_set_action_sensitive (self, "ImageViewer_View_ZoomIn", zoom_enabled && (zoom < 100.0));
 
 	fit_mode = gth_image_viewer_get_fit_mode (GTH_IMAGE_VIEWER (self->priv->viewer));
-	_set_action_sensitive (self, "ImageViewer_View_ZoomFit", fit_mode != GTH_FIT_SIZE);
-	_set_action_sensitive (self, "ImageViewer_View_ZoomFitWidth", fit_mode != GTH_FIT_WIDTH);
+	_set_action_sensitive (self, "ImageViewer_View_ZoomFit", zoom_enabled && (fit_mode != GTH_FIT_SIZE));
+	_set_action_sensitive (self, "ImageViewer_View_ZoomFitWidth", zoom_enabled && (fit_mode != GTH_FIT_WIDTH));
 }
 
 
diff --git a/gthumb/gth-image-viewer.c b/gthumb/gth-image-viewer.c
index f44bbac..50139ac 100644
--- a/gthumb/gth-image-viewer.c
+++ b/gthumb/gth-image-viewer.c
@@ -91,6 +91,7 @@ struct _GthImageViewerPrivate {
 	GdkCursor              *cursor;
 	GdkCursor              *cursor_void;
 
+	gboolean                zoom_enabled;
 	gboolean                enable_zoom_with_keys;
 	double                  zoom_level;
 	guint                   zoom_quality : 1;   /* A ZoomQualityType value. */
@@ -1466,6 +1467,7 @@ gth_image_viewer_instance_init (GthImageViewer *self)
 	self->priv->iter = NULL;
 	self->priv->iter_surface = NULL;
 
+	self->priv->zoom_enabled = TRUE;
 	self->priv->enable_zoom_with_keys = TRUE;
 	self->priv->zoom_level = 1.0;
 	self->priv->zoom_quality = GTH_ZOOM_QUALITY_HIGH;
@@ -1946,6 +1948,9 @@ gth_image_viewer_set_zoom (GthImageViewer *self,
 {
 	GtkAllocation allocation;
 
+	if (! self->priv->zoom_enabled)
+		return;
+
 	gtk_widget_get_allocation (GTK_WIDGET (self), &allocation);
 	set_zoom (self,
 		  zoom_level,
@@ -2013,6 +2018,9 @@ void
 gth_image_viewer_set_fit_mode (GthImageViewer *self,
 			       GthFit          fit_mode)
 {
+	if (! self->priv->zoom_enabled)
+		return;
+
 	self->priv->fit = fit_mode;
 	if (self->priv->is_void)
 		return;
@@ -2028,6 +2036,21 @@ gth_image_viewer_get_fit_mode (GthImageViewer *self)
 
 
 void
+gth_image_viewer_set_zoom_enabled (GthImageViewer *self,
+				   gboolean        value)
+{
+	self->priv->zoom_enabled = value;
+}
+
+
+gboolean
+gth_image_viewer_get_zoom_enabled (GthImageViewer *self)
+{
+	return self->priv->zoom_enabled;
+}
+
+
+void
 gth_image_viewer_enable_zoom_with_keys (GthImageViewer *self,
 					gboolean        value)
 {
diff --git a/gthumb/gth-image-viewer.h b/gthumb/gth-image-viewer.h
index 2c6e765..714984a 100644
--- a/gthumb/gth-image-viewer.h
+++ b/gthumb/gth-image-viewer.h
@@ -217,6 +217,9 @@ void           gth_image_viewer_zoom_out                 (GthImageViewer     *vi
 void           gth_image_viewer_set_fit_mode             (GthImageViewer     *viewer,
 							  GthFit              fit_mode);
 GthFit         gth_image_viewer_get_fit_mode             (GthImageViewer     *viewer);
+void           gth_image_viewer_set_zoom_enabled         (GthImageViewer     *viewer,
+							  gboolean            value);
+gboolean       gth_image_viewer_get_zoom_enabled         (GthImageViewer     *viewer);
 void           gth_image_viewer_enable_zoom_with_keys    (GthImageViewer     *viewer,
 							  gboolean            value);
 



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