[gnome-photos/wip/rishi/zoom: 10/10] application, preview-view: ...



commit 0f189e66902327992b4cc4516c1e46a464c47e70
Author: Debarshi Ray <debarshir gnome org>
Date:   Tue Jun 6 21:51:25 2017 +0200

    application, preview-view: ...

 src/photos-application.c  |    8 ++++----
 src/photos-preview-view.c |   21 +++++++++++++++++----
 2 files changed, 21 insertions(+), 8 deletions(-)
---
diff --git a/src/photos-application.c b/src/photos-application.c
index 6aa9c95..b60ec1d 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -1916,10 +1916,10 @@ photos_application_startup (GApplication *application)
   self->zoom_best_fit_action = g_simple_action_new ("zoom-best-fit", NULL);
   g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (self->zoom_best_fit_action));
 
-  self->zoom_in_action = g_simple_action_new ("zoom-in", NULL);
+  self->zoom_in_action = g_simple_action_new ("zoom-in", G_VARIANT_TYPE_DOUBLE);
   g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (self->zoom_in_action));
 
-  self->zoom_out_action = g_simple_action_new ("zoom-out", NULL);
+  self->zoom_out_action = g_simple_action_new ("zoom-out", G_VARIANT_TYPE_DOUBLE);
   g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (self->zoom_out_action));
 
   g_signal_connect_swapped (self->state->mode_cntrlr,
@@ -1943,8 +1943,8 @@ photos_application_startup (GApplication *application)
   gtk_application_set_accels_for_action (GTK_APPLICATION (self), "app.search", search_accels);
   gtk_application_set_accels_for_action (GTK_APPLICATION (self), "app.select-all", select_all_accels);
   gtk_application_set_accels_for_action (GTK_APPLICATION (self), "app.zoom-best-fit", zoom_best_fit_accels);
-  gtk_application_set_accels_for_action (GTK_APPLICATION (self), "app.zoom-in", zoom_in_accels);
-  gtk_application_set_accels_for_action (GTK_APPLICATION (self), "app.zoom-out", zoom_out_accels);
+  gtk_application_set_accels_for_action (GTK_APPLICATION (self), "app.zoom-in(1.0)", zoom_in_accels);
+  gtk_application_set_accels_for_action (GTK_APPLICATION (self), "app.zoom-out(1.0)", zoom_out_accels);
 
   g_signal_connect_swapped (self->state->item_mngr,
                             "load-finished",
diff --git a/src/photos-preview-view.c b/src/photos-preview-view.c
index 7e7136b..f1b3539 100644
--- a/src/photos-preview-view.c
+++ b/src/photos-preview-view.c
@@ -877,24 +877,30 @@ photos_preview_view_zoom_best_fit (PhotosPreviewView *self)
 
 
 static void
-photos_preview_view_zoom_in (PhotosPreviewView *self)
+photos_preview_view_zoom_in (PhotosPreviewView *self, GVariant *parameter)
 {
   GtkWidget *view;
   GtkWidget *view_container;
   gboolean best_fit;
+  gdouble delta;
   gdouble zoom;
   gdouble zoom_factor;
+  gdouble zoom_factor_for_delta;
 
   g_return_if_fail (self->zoom_best_fit > 0.0);
 
+  delta = g_variant_get_double (parameter);
+  g_return_if_fail (delta > 0.0);
+
   view_container = gtk_stack_get_visible_child (GTK_STACK (self->stack));
   view = photos_preview_view_get_view_from_view_container (view_container);
 
   best_fit = photos_image_view_get_best_fit (PHOTOS_IMAGE_VIEW (view));
   zoom_factor = best_fit ? ZOOM_FACTOR_1 : ZOOM_FACTOR_2;
+  zoom_factor_for_delta = pow (zoom_factor, delta);
 
   zoom = photos_image_view_get_zoom (PHOTOS_IMAGE_VIEW (view));
-  zoom *= zoom_factor;
+  zoom *= zoom_factor_for_delta;
 
   photos_image_view_set_zoom (PHOTOS_IMAGE_VIEW (view), zoom);
 
@@ -904,19 +910,26 @@ photos_preview_view_zoom_in (PhotosPreviewView *self)
 
 
 static void
-photos_preview_view_zoom_out (PhotosPreviewView *self)
+photos_preview_view_zoom_out (PhotosPreviewView *self, GVariant *parameter)
 {
   GtkWidget *view;
   GtkWidget *view_container;
+  gdouble delta;
   gdouble zoom;
+  gdouble zoom_factor_for_delta;
 
   g_return_if_fail (self->zoom_best_fit > 0.0);
 
+  delta = g_variant_get_double (parameter);
+  g_return_if_fail (delta > 0.0);
+
   view_container = gtk_stack_get_visible_child (GTK_STACK (self->stack));
   view = photos_preview_view_get_view_from_view_container (view_container);
 
+  zoom_factor_for_delta = pow (ZOOM_FACTOR_2, delta);
+
   zoom = photos_image_view_get_zoom (PHOTOS_IMAGE_VIEW (view));
-  zoom /= ZOOM_FACTOR_2;
+  zoom /= zoom_factor_for_delta;
 
   if (zoom < self->zoom_best_fit || photos_utils_equal_double (self->zoom_best_fit, zoom))
     {


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