[gnome-photos/gnome-3-20] preview-view, preview-nav-buttons: Don't walk past the edges



commit efc4a8c4dfd6786fec78dd9399fdf4bcb3fecda0
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 30b5919..57779b6 100644
--- a/src/photos-preview-nav-buttons.c
+++ b/src/photos-preview-nav-buttons.c
@@ -74,6 +74,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);
 
@@ -326,6 +335,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);
@@ -342,6 +353,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);
@@ -544,6 +557,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 1afc1a7..590f469 100644
--- a/src/photos-preview-view.c
+++ b/src/photos-preview-view.c
@@ -601,6 +601,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));
 }
 
@@ -698,12 +701,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]