[gedit] search: hide when hitting Esc
- From: Sebastien Lafargue <slafargue src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit] search: hide when hitting Esc
- Date: Mon, 16 Mar 2015 20:03:16 +0000 (UTC)
commit 18cd0a02e0c654da0ce9817385989acc61a0263c
Author: Sebastien Lafargue <slafargue gnome org>
Date: Mon Mar 16 20:45:47 2015 +0100
search: hide when hitting Esc
Due to gtk+ API changes for GtkSearchEntry,
we now use the new stop-search signal.
https://bugzilla.gnome.org/show_bug.cgi?id=746299
gedit/gedit-view-frame.c | 62 ++++++++++++++++++++++++---------------------
1 files changed, 33 insertions(+), 29 deletions(-)
---
diff --git a/gedit/gedit-view-frame.c b/gedit/gedit-view-frame.c
index fb67e14..243e8cf 100644
--- a/gedit/gedit-view-frame.c
+++ b/gedit/gedit-view-frame.c
@@ -583,35 +583,6 @@ search_widget_key_press_event (GtkWidget *widget,
return GDK_EVENT_STOP;
}
- /* Close window and cancel the search */
- if (event->keyval == GDK_KEY_Escape)
- {
- GtkSourceSearchContext *search_context = get_search_context (frame);
-
- if (frame->priv->search_mode == SEARCH &&
- search_context != NULL)
- {
- g_clear_object (&frame->priv->search_settings);
- frame->priv->search_settings = copy_search_settings
(frame->priv->old_search_settings);
-
- gtk_source_search_context_set_settings (search_context,
- frame->priv->search_settings);
-
- g_free (frame->priv->search_text);
- frame->priv->search_text = NULL;
-
- if (frame->priv->old_search_text != NULL)
- {
- frame->priv->search_text = g_strdup (frame->priv->old_search_text);
- }
- }
-
- hide_search_widget (frame, TRUE);
- gtk_widget_grab_focus (GTK_WIDGET (frame->priv->view));
-
- return GDK_EVENT_STOP;
- }
-
if (frame->priv->search_mode == GOTO_LINE)
{
return GDK_EVENT_PROPAGATE;
@@ -906,6 +877,34 @@ setup_popup_menu (GeditViewFrame *frame,
}
static void
+search_entry_escaped (GtkSearchEntry *entry,
+ GeditViewFrame *frame)
+{
+ GtkSourceSearchContext *search_context = get_search_context (frame);
+
+ if (frame->priv->search_mode == SEARCH &&
+ search_context != NULL)
+ {
+ g_clear_object (&frame->priv->search_settings);
+ frame->priv->search_settings = copy_search_settings (frame->priv->old_search_settings);
+
+ gtk_source_search_context_set_settings (search_context,
+ frame->priv->search_settings);
+
+ g_free (frame->priv->search_text);
+ frame->priv->search_text = NULL;
+
+ if (frame->priv->old_search_text != NULL)
+ {
+ frame->priv->search_text = g_strdup (frame->priv->old_search_text);
+ }
+ }
+
+ hide_search_widget (frame, TRUE);
+ gtk_widget_grab_focus (GTK_WIDGET (frame->priv->view));
+}
+
+static void
search_entry_populate_popup (GtkEntry *entry,
GtkMenu *menu,
GeditViewFrame *frame)
@@ -1601,6 +1600,11 @@ gedit_view_frame_init (GeditViewFrame *frame)
G_CALLBACK (search_entry_insert_text),
frame);
+ g_signal_connect (frame->priv->search_entry,
+ "stop-search",
+ G_CALLBACK (search_entry_escaped),
+ frame);
+
frame->priv->search_entry_changed_id =
g_signal_connect (frame->priv->search_entry,
"changed",
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]