[gnome-photos] preview-view, preview-nav-buttons: Don't walk past the edges
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-photos] preview-view, preview-nav-buttons: Don't walk past the edges
- Date: Wed, 24 Aug 2016 15:48:50 +0000 (UTC)
commit 4754182dc6b9dd2881edabc144ffe4ee44f3ec2a
Author: Debarshi Ray <debarshir gnome org>
Date: Wed Aug 24 17:01:22 2016 +0200
preview-view, preview-nav-buttons: Don't walk past the edges
It is possible to walk past the edges when navigating very fast with
the keyboard. This is because the app.load-next and app.load-previous
GActions are implemented by both PreviewView and PreviewNavButtons. One
of them swaps out the ImageView and the other triggers the loading. It
will be more robust if only one of them implements the GActions and
drives the other as and when needed.
This partially reverts commit bcdc22c208acabce039ec9491cf1aa5f9eeaca85
by re-introducing the signals in PreviewNavButtons.
src/photos-preview-nav-buttons.c | 33 +++++++++++++++++++++++++++++++++
src/photos-preview-view.c | 9 +++------
2 files changed, 36 insertions(+), 6 deletions(-)
---
diff --git a/src/photos-preview-nav-buttons.c b/src/photos-preview-nav-buttons.c
index b7105dd..d27295c 100644
--- a/src/photos-preview-nav-buttons.c
+++ b/src/photos-preview-nav-buttons.c
@@ -73,6 +73,15 @@ enum
PROP_PREVIEW_VIEW
};
+enum
+{
+ LOAD_NEXT,
+ LOAD_PREVIOUS,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
G_DEFINE_TYPE (PhotosPreviewNavButtons, photos_preview_nav_buttons, G_TYPE_OBJECT);
@@ -321,6 +330,8 @@ photos_preview_nav_buttons_next (PhotosPreviewNavButtons *self)
if (!self->enable_next)
return;
+ g_signal_emit (self, signals[LOAD_NEXT], 0);
+
current_path = gtk_tree_row_reference_get_path (self->current_row);
gtk_tree_path_next (current_path);
photos_preview_nav_buttons_set_active_path (self, current_path);
@@ -337,6 +348,8 @@ photos_preview_nav_buttons_previous (PhotosPreviewNavButtons *self)
if (!self->enable_prev)
return;
+ g_signal_emit (self, signals[LOAD_PREVIOUS], 0);
+
current_path = gtk_tree_row_reference_get_path (self->current_row);
gtk_tree_path_prev (current_path);
photos_preview_nav_buttons_set_active_path (self, current_path);
@@ -541,6 +554,26 @@ photos_preview_nav_buttons_class_init (PhotosPreviewNavButtonsClass *class)
"The widget used for showing the preview",
PHOTOS_TYPE_PREVIEW_VIEW,
G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE));
+
+ signals[LOAD_NEXT] = g_signal_new ("load-next",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, /*accumulator */
+ NULL, /*accu_data */
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
+
+ signals[LOAD_PREVIOUS] = g_signal_new ("load-previous",
+ G_TYPE_FROM_CLASS (class),
+ G_SIGNAL_RUN_LAST,
+ 0,
+ NULL, /*accumulator */
+ NULL, /*accu_data */
+ g_cclosure_marshal_VOID__VOID,
+ G_TYPE_NONE,
+ 0);
}
diff --git a/src/photos-preview-view.c b/src/photos-preview-view.c
index 641b5b2..0ce3936 100644
--- a/src/photos-preview-view.c
+++ b/src/photos-preview-view.c
@@ -653,6 +653,9 @@ photos_preview_view_constructed (GObject *object)
G_OBJECT_CLASS (photos_preview_view_parent_class)->constructed (object);
self->nav_buttons = photos_preview_nav_buttons_new (self, GTK_OVERLAY (self->overlay));
+ g_signal_connect_swapped (self->nav_buttons, "load-next", G_CALLBACK (photos_preview_view_navigate_next),
self);
+ g_signal_connect_swapped (self->nav_buttons, "load-previous", G_CALLBACK
(photos_preview_view_navigate_previous), self);
+
gtk_widget_show_all (GTK_WIDGET (self));
}
@@ -751,12 +754,6 @@ photos_preview_view_init (PhotosPreviewView *self)
action = g_action_map_lookup_action (G_ACTION_MAP (app), "insta-current");
g_signal_connect_object (action, "activate", G_CALLBACK (photos_preview_view_insta), self,
G_CONNECT_SWAPPED);
- action = g_action_map_lookup_action (G_ACTION_MAP (app), "load-next");
- g_signal_connect_swapped (action, "activate", G_CALLBACK (photos_preview_view_navigate_next), self);
-
- action = g_action_map_lookup_action (G_ACTION_MAP (app), "load-previous");
- g_signal_connect_swapped (action, "activate", G_CALLBACK (photos_preview_view_navigate_previous), self);
-
action = g_action_map_lookup_action (G_ACTION_MAP (app), "saturation-current");
g_signal_connect_object (action,
"activate",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]