[evince] recent-view: Allow to open documents from recent view with the keyboard



commit 1a3124a21b4995c40aca29620eaba04276440635
Author: Carlos Garcia Campos <carlosgc gnome org>
Date:   Sat May 10 14:14:32 2014 +0200

    recent-view: Allow to open documents from recent view with the keyboard

 shell/ev-recent-view.c |   38 +++++++++++++++++++++++---------------
 1 files changed, 23 insertions(+), 15 deletions(-)
---
diff --git a/shell/ev-recent-view.c b/shell/ev-recent-view.c
index 995bcd2..c36ada2 100644
--- a/shell/ev-recent-view.c
+++ b/shell/ev-recent-view.c
@@ -160,24 +160,10 @@ on_button_release_event (GtkWidget      *view,
                 return FALSE;
 
         if (gtk_tree_path_compare (path, priv->pressed_item_tree_path) == 0) {
-                GtkTreeIter iter;
-                gchar      *uri;
-
                 g_clear_pointer (&priv->pressed_item_tree_path, gtk_tree_path_free);
-
-                if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->model), &iter, path)) {
-                        gtk_tree_path_free (path);
-
-                        return TRUE;
-                }
+                gtk_icon_view_item_activated (GTK_ICON_VIEW (priv->view), path);
                 gtk_tree_path_free (path);
 
-                gtk_tree_model_get (GTK_TREE_MODEL (priv->model), &iter,
-                                    EV_RECENT_VIEW_COLUMN_URI, &uri,
-                                    -1);
-                g_signal_emit (ev_recent_view, signals[ITEM_ACTIVATED], 0, uri);
-                g_free (uri);
-
                 return TRUE;
         }
 
@@ -202,6 +188,25 @@ on_button_press_event (GtkWidget      *view,
 }
 
 static void
+on_icon_view_item_activated (GtkIconView  *iconview,
+                             GtkTreePath  *path,
+                             EvRecentView *ev_recent_view)
+{
+        EvRecentViewPrivate *priv = ev_recent_view->priv;
+        GtkTreeIter          iter;
+        gchar               *uri;
+
+        if (!gtk_tree_model_get_iter (GTK_TREE_MODEL (priv->model), &iter, path))
+                return;
+
+        gtk_tree_model_get (GTK_TREE_MODEL (priv->model), &iter,
+                            EV_RECENT_VIEW_COLUMN_URI, &uri,
+                            -1);
+        g_signal_emit (ev_recent_view, signals[ITEM_ACTIVATED], 0, uri);
+        g_free (uri);
+}
+
+static void
 thumbnail_job_completed_callback (EvJobThumbnail *job,
                                   EvRecentView   *ev_recent_view)
 {
@@ -426,6 +431,9 @@ ev_recent_view_constructed (GObject *object)
         g_signal_connect (priv->view, "button-release-event",
                           G_CALLBACK (on_button_release_event),
                           ev_recent_view);
+        g_signal_connect (priv->view, "item-activated",
+                          G_CALLBACK (on_icon_view_item_activated),
+                          ev_recent_view);
 
         gtk_style_context_add_class (gtk_widget_get_style_context (priv->view), "content-view");
         gtk_container_add (GTK_CONTAINER (ev_recent_view), priv->view);


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