[gnome-builder] prefs: escape should close prefs dialog if search is not focused
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] prefs: escape should close prefs dialog if search is not focused
- Date: Sat, 9 May 2015 21:10:46 +0000 (UTC)
commit 87f94c9bffbc774ed094619736e69dc036989f82
Author: Christian Hergert <christian hergert me>
Date: Sat May 9 14:10:39 2015 -0700
prefs: escape should close prefs dialog if search is not focused
Make this work like a normal dialog. Escape inside the search bar will
hide the search bar, escape outside the search bar will hide the window.
contrib/egg/egg-search-bar.c | 9 +--------
src/preferences/gb-preferences-window.c | 4 ++++
2 files changed, 5 insertions(+), 8 deletions(-)
---
diff --git a/contrib/egg/egg-search-bar.c b/contrib/egg/egg-search-bar.c
index de32e5f..fc5c7f7 100644
--- a/contrib/egg/egg-search-bar.c
+++ b/contrib/egg/egg-search-bar.c
@@ -112,7 +112,7 @@ toplevel_key_press_event_before (EggSearchBar *self,
switch (event->keyval)
{
case GDK_KEY_Escape:
- if (gtk_widget_has_focus (GTK_WIDGET (priv->entry)))
+ if (priv->search_mode_enabled && gtk_widget_has_focus (GTK_WIDGET (priv->entry)))
{
egg_search_bar_set_search_mode_enabled (self, FALSE);
return GDK_EVENT_STOP;
@@ -143,13 +143,6 @@ toplevel_key_press_event_after (EggSearchBar *self,
switch (event->keyval)
{
case GDK_KEY_Escape:
- if (priv->search_mode_enabled)
- {
- egg_search_bar_set_search_mode_enabled (self, FALSE);
- return GDK_EVENT_STOP;
- }
- break;
-
case GDK_KEY_Up:
case GDK_KEY_KP_Up:
case GDK_KEY_Down:
diff --git a/src/preferences/gb-preferences-window.c b/src/preferences/gb-preferences-window.c
index fb94538..dddef77 100644
--- a/src/preferences/gb-preferences-window.c
+++ b/src/preferences/gb-preferences-window.c
@@ -214,6 +214,7 @@ gb_preferences_window_class_init (GbPreferencesWindowClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GtkBindingSet *binding_set;
object_class->constructed = gb_preferences_window_constructed;
object_class->finalize = gb_preferences_window_finalize;
@@ -230,6 +231,9 @@ gb_preferences_window_class_init (GbPreferencesWindowClass *klass)
G_TYPE_NONE,
0);
+ binding_set = gtk_binding_set_by_class (klass);
+ gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0, "close", 0);
+
GB_WIDGET_CLASS_TEMPLATE (widget_class, "gb-preferences-window.ui");
GB_WIDGET_CLASS_BIND (widget_class, GbPreferencesWindow, right_header_bar);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]