[gnome-photos/wip/rishi/zoom: 3/3] application, help-overlay, preview-view: Hook up zooming to GActions
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos/wip/rishi/zoom: 3/3] application, help-overlay, preview-view: Hook up zooming to GActions
- Date: Thu, 6 Apr 2017 14:53:57 +0000 (UTC)
commit 7a0e6286898e158f2c472a31816ba805cc57dcc8
Author: Debarshi Ray <debarshir gnome org>
Date: Wed Mar 29 11:03:39 2017 +0200
application, help-overlay, preview-view: Hook up zooming to GActions
src/photos-application.c | 24 ++++++++++++++++++
src/photos-help-overlay.ui | 21 +++++++++++++++
src/photos-preview-view.c | 59 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 104 insertions(+), 0 deletions(-)
---
diff --git a/src/photos-application.c b/src/photos-application.c
index 89b575d..04c12de 100644
--- a/src/photos-application.c
+++ b/src/photos-application.c
@@ -110,6 +110,9 @@ struct _PhotosApplication
GSimpleAction *set_ss_action;
GSimpleAction *share_action;
GSimpleAction *sharpen_action;
+ GSimpleAction *zoom_best_fit_action;
+ GSimpleAction *zoom_in_action;
+ GSimpleAction *zoom_out_action;
GtkWidget *main_window;
PhotosBaseManager *shr_pnt_mngr;
PhotosCameraCache *camera_cache;
@@ -363,6 +366,9 @@ photos_application_actions_update (PhotosApplication *self)
g_simple_action_set_enabled (self->gear_action, enable);
g_simple_action_set_enabled (self->set_bg_action, enable);
g_simple_action_set_enabled (self->set_ss_action, enable);
+ g_simple_action_set_enabled (self->zoom_best_fit_action, enable);
+ g_simple_action_set_enabled (self->zoom_in_action, enable);
+ g_simple_action_set_enabled (self->zoom_out_action, enable);
enable = ((load_state == PHOTOS_LOAD_STATE_FINISHED && mode == PHOTOS_WINDOW_MODE_PREVIEW)
|| (selection_mode && item != NULL));
@@ -1658,6 +1664,9 @@ photos_application_startup (GApplication *application)
const gchar *save_accels[2] = {"<Primary>x", NULL};
const gchar *search_accels[2] = {"<Primary>f", NULL};
const gchar *select_all_accels[2] = {"<Primary>a", NULL};
+ const gchar *zoom_best_fit_accels[3] = {"<Primary>0", NULL};
+ const gchar *zoom_in_accels[3] = {"<Primary>plus", "<Primary>equal", NULL};
+ const gchar *zoom_out_accels[2] = {"<Primary>minus", NULL};
G_APPLICATION_CLASS (photos_application_parent_class)->startup (application);
@@ -1866,6 +1875,15 @@ photos_application_startup (GApplication *application)
self->sharpen_action = g_simple_action_new ("sharpen-current", G_VARIANT_TYPE_DOUBLE);
g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (self->sharpen_action));
+ 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);
+ 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);
+ g_action_map_add_action (G_ACTION_MAP (self), G_ACTION (self->zoom_out_action));
+
g_signal_connect_swapped (self->state->mode_cntrlr,
"window-mode-changed",
G_CALLBACK (photos_application_window_mode_changed),
@@ -1886,6 +1904,9 @@ photos_application_startup (GApplication *application)
gtk_application_set_accels_for_action (GTK_APPLICATION (self), "app.save-current", save_accels);
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);
g_signal_connect_swapped (self->state->item_mngr,
"load-finished",
@@ -1959,6 +1980,9 @@ photos_application_dispose (GObject *object)
g_clear_object (&self->set_ss_action);
g_clear_object (&self->share_action);
g_clear_object (&self->sharpen_action);
+ g_clear_object (&self->zoom_best_fit_action);
+ g_clear_object (&self->zoom_in_action);
+ g_clear_object (&self->zoom_out_action);
g_clear_object (&self->shr_pnt_mngr);
g_clear_object (&self->camera_cache);
g_clear_object (&self->sel_cntrlr);
diff --git a/src/photos-help-overlay.ui b/src/photos-help-overlay.ui
index 5f00de8..ff09da7 100644
--- a/src/photos-help-overlay.ui
+++ b/src/photos-help-overlay.ui
@@ -146,6 +146,27 @@
<child>
<object class="GtkShortcutsShortcut">
<property name="visible">1</property>
+ <property name="title" translatable="yes" context="shortcut window">Zoom in</property>
+ <property name="accelerator"><Primary>plus</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">1</property>
+ <property name="title" translatable="yes" context="shortcut window">Zoom out</property>
+ <property name="accelerator"><Primary>minus</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">1</property>
+ <property name="title" translatable="yes" context="shortcut window">Best fit</property>
+ <property name="accelerator"><Primary>0</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkShortcutsShortcut">
+ <property name="visible">1</property>
<property name="title" translatable="yes" context="shortcut window">Delete</property>
<property name="accelerator">Delete</property>
</object>
diff --git a/src/photos-preview-view.c b/src/photos-preview-view.c
index f57cef1..87f02b9 100644
--- a/src/photos-preview-view.c
+++ b/src/photos-preview-view.c
@@ -639,6 +639,52 @@ photos_preview_view_window_mode_changed (PhotosPreviewView *self, PhotosWindowMo
static void
+photos_preview_view_zoom_best_fit (PhotosPreviewView *self)
+{
+ GtkWidget *view;
+ GtkWidget *view_container;
+
+ view_container = gtk_stack_get_visible_child (GTK_STACK (self->stack));
+ view = photos_preview_view_get_view_from_view_container (view_container);
+ photos_image_view_set_best_fit (PHOTOS_IMAGE_VIEW (view), TRUE);
+}
+
+
+static void
+photos_preview_view_zoom_in (PhotosPreviewView *self)
+{
+ GtkWidget *view;
+ GtkWidget *view_container;
+ gdouble zoom;
+
+ view_container = gtk_stack_get_visible_child (GTK_STACK (self->stack));
+ view = photos_preview_view_get_view_from_view_container (view_container);
+
+ zoom = photos_image_view_get_zoom (PHOTOS_IMAGE_VIEW (view));
+ zoom *= 1.05;
+
+ photos_image_view_set_zoom (PHOTOS_IMAGE_VIEW (view), zoom);
+}
+
+
+static void
+photos_preview_view_zoom_out (PhotosPreviewView *self)
+{
+ GtkWidget *view;
+ GtkWidget *view_container;
+ gdouble zoom;
+
+ view_container = gtk_stack_get_visible_child (GTK_STACK (self->stack));
+ view = photos_preview_view_get_view_from_view_container (view_container);
+
+ zoom = photos_image_view_get_zoom (PHOTOS_IMAGE_VIEW (view));
+ zoom /= 1.05;
+
+ photos_image_view_set_zoom (PHOTOS_IMAGE_VIEW (view), zoom);
+}
+
+
+static void
photos_preview_view_dispose (GObject *object)
{
PhotosPreviewView *self = PHOTOS_PREVIEW_VIEW (object);
@@ -792,6 +838,19 @@ photos_preview_view_init (PhotosPreviewView *self)
action = g_action_map_lookup_action (G_ACTION_MAP (app), "sharpen-current");
g_signal_connect_object (action, "activate", G_CALLBACK (photos_preview_view_sharpen), self,
G_CONNECT_SWAPPED);
+
+ action = g_action_map_lookup_action (G_ACTION_MAP (app), "zoom-best-fit");
+ g_signal_connect_object (action,
+ "activate",
+ G_CALLBACK (photos_preview_view_zoom_best_fit),
+ self,
+ G_CONNECT_SWAPPED);
+
+ action = g_action_map_lookup_action (G_ACTION_MAP (app), "zoom-in");
+ g_signal_connect_object (action, "activate", G_CALLBACK (photos_preview_view_zoom_in), self,
G_CONNECT_SWAPPED);
+
+ action = g_action_map_lookup_action (G_ACTION_MAP (app), "zoom-out");
+ g_signal_connect_object (action, "activate", G_CALLBACK (photos_preview_view_zoom_out), self,
G_CONNECT_SWAPPED);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]