[evince] Add button-press signal handler to the Find sidebar
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evince] Add button-press signal handler to the Find sidebar
- Date: Sun, 23 Feb 2014 11:12:18 +0000 (UTC)
commit 7e5db6be1883678301c65b799dc54d6b2b9410f9
Author: Saurav Agarwalla <saurav agarwalla92 gmail com>
Date: Sat Feb 15 14:23:26 2014 +0530
Add button-press signal handler to the Find sidebar
This solves the bug mentioned below by handling button-press signals
in addition to the original selection-changed signals.
https://bugzilla.gnome.org/show_bug.cgi?id=703570
libview/ev-view.c | 3 --
shell/ev-find-sidebar.c | 68 ++++++++++++++++++++++++++++++++++++++--------
2 files changed, 56 insertions(+), 15 deletions(-)
---
diff --git a/libview/ev-view.c b/libview/ev-view.c
index da69022..9f62738 100644
--- a/libview/ev-view.c
+++ b/libview/ev-view.c
@@ -7744,9 +7744,6 @@ ev_view_find_previous (EvView *view)
void
ev_view_find_set_result (EvView *view, gint page, gint result)
{
- if (view->find_page == page && view->find_result == result)
- return;
-
view->find_page = page;
view->find_result = result;
jump_to_find_result (view);
diff --git a/shell/ev-find-sidebar.c b/shell/ev-find-sidebar.c
index 3775ecc..0f7a336 100644
--- a/shell/ev-find-sidebar.c
+++ b/shell/ev-find-sidebar.c
@@ -102,30 +102,71 @@ ev_find_sidebar_class_init (EvFindSidebarClass *find_sidebar_class)
}
static void
+ev_find_sidebar_activate_result_at_iter (EvFindSidebar *sidebar,
+ GtkTreeModel *model,
+ GtkTreeIter *iter)
+{
+ EvFindSidebarPrivate *priv;
+ gint page;
+ gint result;
+
+ priv = sidebar->priv;
+
+ if (priv->highlighted_result)
+ gtk_tree_path_free (priv->highlighted_result);
+ priv->highlighted_result = gtk_tree_model_get_path (model, iter);
+
+ gtk_tree_model_get (model, iter,
+ PAGE_COLUMN, &page,
+ RESULT_COLUMN, &result,
+ -1);
+ g_signal_emit (sidebar, signals[RESULT_ACTIVATED], 0, page - 1, result);
+}
+
+static void
selection_changed_callback (GtkTreeSelection *selection,
EvFindSidebar *sidebar)
{
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+
+ if (gtk_tree_selection_get_selected (selection, &model, &iter))
+ ev_find_sidebar_activate_result_at_iter (sidebar, model, &iter);
+}
+
+static gboolean
+sidebar_tree_button_press_cb (GtkTreeView *view,
+ GdkEventButton *event,
+ EvFindSidebar *sidebar)
+{
EvFindSidebarPrivate *priv;
GtkTreeModel *model;
+ GtkTreePath *path;
GtkTreeIter iter;
priv = sidebar->priv;
- if (gtk_tree_selection_get_selected (selection, &model, &iter)) {
- gint page;
- gint result;
+ gtk_tree_view_get_path_at_pos (view, event->x, event->y, &path,
+ NULL, NULL, NULL);
+ if (!path)
+ return FALSE;
- gtk_tree_model_get (model, &iter,
- PAGE_COLUMN, &page,
- RESULT_COLUMN, &result,
- -1);
+ if (priv->highlighted_result &&
+ gtk_tree_path_compare (priv->highlighted_result, path) != 0) {
+ gtk_tree_path_free (path);
+ return FALSE;
+ }
- if (priv->highlighted_result)
- gtk_tree_path_free (priv->highlighted_result);
- priv->highlighted_result = gtk_tree_model_get_path (model, &iter);
+ model = gtk_tree_view_get_model (view);
+ gtk_tree_model_get_iter (model, &iter, path);
+ gtk_tree_path_free (path);
- g_signal_emit (sidebar, signals[RESULT_ACTIVATED], 0, page - 1, result);
- }
+ ev_find_sidebar_activate_result_at_iter (sidebar, model, &iter);
+
+ /* Always return FALSE so the tree view gets the event and can update
+ * the selection etc.
+ */
+ return FALSE;
}
static void
@@ -182,6 +223,9 @@ ev_find_sidebar_init (EvFindSidebar *sidebar)
priv->selection_id = g_signal_connect (selection, "changed",
G_CALLBACK (selection_changed_callback),
sidebar);
+ g_signal_connect (priv->tree_view, "button-press-event",
+ G_CALLBACK (sidebar_tree_button_press_cb),
+ sidebar);
}
GtkWidget *
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]