[devhelp/wip/swilmet/various-code-improvements] sidebar: check that the hitlist is visible in entry_key_press_event_cb
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [devhelp/wip/swilmet/various-code-improvements] sidebar: check that the hitlist is visible in entry_key_press_event_cb
- Date: Fri, 9 Oct 2015 17:11:34 +0000 (UTC)
commit 4097cc9cba5c033df21f2b215d6a2b6f26abcd1c
Author: Sébastien Wilmet <swilmet gnome org>
Date: Fri Oct 9 18:57:38 2015 +0200
sidebar: check that the hitlist is visible in entry_key_press_event_cb
There was a critical message when the search entry is empty and we press
Ctrl+tab:
Gtk-CRITICAL **: gtk_widget_event: assertion 'WIDGET_REALIZED_FOR_EVENT (widget, event)' failed
Which is normal because when the search entry is empty, the hitlist
isn't shown, the book tree is visible instead.
Similarly, when Return was pressed when the search entry is empty, it
searched the previous content of the hitlist.
src/dh-sidebar.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/src/dh-sidebar.c b/src/dh-sidebar.c
index ca17909..f2f4008 100644
--- a/src/dh-sidebar.c
+++ b/src/dh-sidebar.c
@@ -233,7 +233,8 @@ sidebar_entry_key_press_event_cb (GtkEntry *entry,
if (event->keyval == GDK_KEY_Tab) {
if (event->state & GDK_CONTROL_MASK) {
- gtk_widget_grab_focus (GTK_WIDGET (priv->hitlist_view));
+ if (gtk_widget_is_visible (GTK_WIDGET (priv->hitlist_view)))
+ gtk_widget_grab_focus (GTK_WIDGET (priv->hitlist_view));
} else {
gtk_editable_set_position (GTK_EDITABLE (entry), -1);
gtk_editable_select_region (GTK_EDITABLE (entry), -1, -1);
@@ -249,7 +250,8 @@ sidebar_entry_key_press_event_cb (GtkEntry *entry,
gchar *name;
/* Get the first entry found. */
- if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->hitlist_model), &iter)) {
+ if (gtk_widget_is_visible (GTK_WIDGET (priv->hitlist_view)) &&
+ gtk_tree_model_get_iter_first (GTK_TREE_MODEL (priv->hitlist_model), &iter)) {
gtk_tree_model_get (GTK_TREE_MODEL (priv->hitlist_model),
&iter,
DH_KEYWORD_MODEL_COL_LINK, &link,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]