Commit 0049e44b authored by Paolo Bacchilega's avatar Paolo Bacchilega
Browse files

image viewer: added ability to disable the default keybindings

parent 102b69bd
...@@ -97,7 +97,7 @@ struct _GthImageViewerPrivate { ...@@ -97,7 +97,7 @@ struct _GthImageViewerPrivate {
GdkCursor *cursor_void; GdkCursor *cursor_void;
gboolean zoom_enabled; gboolean zoom_enabled;
gboolean enable_zoom_with_keys; gboolean enable_key_bindings;
double zoom_level; double zoom_level;
guint zoom_quality : 1; /* A ZoomQualityType value. */ guint zoom_quality : 1; /* A ZoomQualityType value. */
guint zoom_change : 3; /* A ZoomChangeType value. */ guint zoom_change : 3; /* A ZoomChangeType value. */
...@@ -1049,6 +1049,9 @@ scroll_signal (GtkWidget *widget, ...@@ -1049,6 +1049,9 @@ scroll_signal (GtkWidget *widget,
GthImageViewer *self = GTH_IMAGE_VIEWER (widget); GthImageViewer *self = GTH_IMAGE_VIEWER (widget);
int xstep, ystep; int xstep, ystep;
if (! self->priv->enable_key_bindings)
return;
switch (xscroll_type) { switch (xscroll_type) {
case GTK_SCROLL_STEP_LEFT: case GTK_SCROLL_STEP_LEFT:
xstep = - gtk_adjustment_get_step_increment (self->hadj); xstep = - gtk_adjustment_get_step_increment (self->hadj);
...@@ -1170,7 +1173,7 @@ _gth_image_viewer_set_vadjustment (GthImageViewer *self, ...@@ -1170,7 +1173,7 @@ _gth_image_viewer_set_vadjustment (GthImageViewer *self,
static void static void
gth_image_viewer_zoom_in__key_binding (GthImageViewer *self) gth_image_viewer_zoom_in__key_binding (GthImageViewer *self)
{ {
if (self->priv->enable_zoom_with_keys) if (self->priv->enable_key_bindings)
gth_image_viewer_zoom_in (self); gth_image_viewer_zoom_in (self);
} }
...@@ -1178,7 +1181,7 @@ gth_image_viewer_zoom_in__key_binding (GthImageViewer *self) ...@@ -1178,7 +1181,7 @@ gth_image_viewer_zoom_in__key_binding (GthImageViewer *self)
static void static void
gth_image_viewer_zoom_out__key_binding (GthImageViewer *self) gth_image_viewer_zoom_out__key_binding (GthImageViewer *self)
{ {
if (self->priv->enable_zoom_with_keys) if (self->priv->enable_key_bindings)
gth_image_viewer_zoom_out (self); gth_image_viewer_zoom_out (self);
} }
...@@ -1186,7 +1189,7 @@ static void ...@@ -1186,7 +1189,7 @@ static void
gth_image_viewer_set_fit_mode__key_binding (GthImageViewer *self, gth_image_viewer_set_fit_mode__key_binding (GthImageViewer *self,
GthFit fit_mode) GthFit fit_mode)
{ {
if (self->priv->enable_zoom_with_keys) if (self->priv->enable_key_bindings)
gth_image_viewer_set_fit_mode (self, fit_mode); gth_image_viewer_set_fit_mode (self, fit_mode);
} }
...@@ -1195,7 +1198,7 @@ static void ...@@ -1195,7 +1198,7 @@ static void
gth_image_viewer_set_zoom__key_binding (GthImageViewer *self, gth_image_viewer_set_zoom__key_binding (GthImageViewer *self,
gdouble zoom_level) gdouble zoom_level)
{ {
if (self->priv->enable_zoom_with_keys) if (self->priv->enable_key_bindings)
gth_image_viewer_set_zoom (self, zoom_level); gth_image_viewer_set_zoom (self, zoom_level);
} }
...@@ -1555,7 +1558,7 @@ gth_image_viewer_init (GthImageViewer *self) ...@@ -1555,7 +1558,7 @@ gth_image_viewer_init (GthImageViewer *self)
self->priv->iter_surface = NULL; self->priv->iter_surface = NULL;
self->priv->zoom_enabled = TRUE; self->priv->zoom_enabled = TRUE;
self->priv->enable_zoom_with_keys = TRUE; self->priv->enable_key_bindings = TRUE;
self->priv->zoom_level = 1.0; self->priv->zoom_level = 1.0;
self->priv->zoom_quality = GTH_ZOOM_QUALITY_HIGH; self->priv->zoom_quality = GTH_ZOOM_QUALITY_HIGH;
self->priv->zoom_change = GTH_ZOOM_CHANGE_KEEP_PREV; self->priv->zoom_change = GTH_ZOOM_CHANGE_KEEP_PREV;
...@@ -2240,16 +2243,6 @@ gth_image_viewer_get_zoom_enabled (GthImageViewer *self) ...@@ -2240,16 +2243,6 @@ gth_image_viewer_get_zoom_enabled (GthImageViewer *self)
} }
void
gth_image_viewer_enable_zoom_with_keys (GthImageViewer *self,
gboolean value)
{
g_return_if_fail (GTH_IS_IMAGE_VIEWER (self));
self->priv->enable_zoom_with_keys = value;
}
void void
gth_image_viewer_clicked (GthImageViewer *self) gth_image_viewer_clicked (GthImageViewer *self)
{ {
...@@ -2304,6 +2297,16 @@ gth_image_viewer_get_transparency_style (GthImageViewer *self) ...@@ -2304,6 +2297,16 @@ gth_image_viewer_get_transparency_style (GthImageViewer *self)
} }
void
gth_image_viewer_enable_key_bindings (GthImageViewer *self,
gboolean value)
{
g_return_if_fail (GTH_IS_IMAGE_VIEWER (self));
self->priv->enable_key_bindings = value;
}
void void
gth_image_viewer_scroll_to (GthImageViewer *self, gth_image_viewer_scroll_to (GthImageViewer *self,
int x_offset, int x_offset,
......
...@@ -222,8 +222,6 @@ GthFit gth_image_viewer_get_fit_mode (GthImageViewer ...@@ -222,8 +222,6 @@ GthFit gth_image_viewer_get_fit_mode (GthImageViewer
void gth_image_viewer_set_zoom_enabled (GthImageViewer *viewer, void gth_image_viewer_set_zoom_enabled (GthImageViewer *viewer,
gboolean value); gboolean value);
gboolean gth_image_viewer_get_zoom_enabled (GthImageViewer *viewer); gboolean gth_image_viewer_get_zoom_enabled (GthImageViewer *viewer);
void gth_image_viewer_enable_zoom_with_keys (GthImageViewer *viewer,
gboolean value);
/* misc. */ /* misc. */
...@@ -236,6 +234,8 @@ void gth_image_viewer_set_transparency_style (GthImageViewer ...@@ -236,6 +234,8 @@ void gth_image_viewer_set_transparency_style (GthImageViewer
GthTransparencyStyle style); GthTransparencyStyle style);
GthTransparencyStyle GthTransparencyStyle
gth_image_viewer_get_transparency_style (GthImageViewer *viewer); gth_image_viewer_get_transparency_style (GthImageViewer *viewer);
void gth_image_viewer_enable_key_bindings (GthImageViewer *viewer,
gboolean value);
/* Scrolling. */ /* Scrolling. */
......
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