[gnome-builder] prefs: close preferences window with Escape similar to dialogs
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] prefs: close preferences window with Escape similar to dialogs
- Date: Mon, 8 Dec 2014 21:57:24 +0000 (UTC)
commit 56fade24e622789ad312b71479d3505705eacfee
Author: Christian Hergert <christian hergert me>
Date: Mon Dec 8 13:56:31 2014 -0800
prefs: close preferences window with Escape similar to dialogs
src/preferences/gb-preferences-window.c | 31 +++++++++++++++++++++++++++++++
src/preferences/gb-preferences-window.h | 2 ++
2 files changed, 33 insertions(+), 0 deletions(-)
---
diff --git a/src/preferences/gb-preferences-window.c b/src/preferences/gb-preferences-window.c
index 49e9295..f5398f5 100644
--- a/src/preferences/gb-preferences-window.c
+++ b/src/preferences/gb-preferences-window.c
@@ -41,6 +41,13 @@ struct _GbPreferencesWindowPrivate
G_DEFINE_TYPE_WITH_PRIVATE (GbPreferencesWindow, gb_preferences_window,
GTK_TYPE_WINDOW)
+enum {
+ CLOSE,
+ LAST_SIGNAL
+};
+
+static guint gSignals [LAST_SIGNAL];
+
GtkWidget *
gb_preferences_window_new (void)
{
@@ -70,6 +77,14 @@ gb_preferences_window_section_changed (GtkStack *stack,
}
static void
+gb_preferences_window_close (GbPreferencesWindow *window)
+{
+ g_return_if_fail (GB_IS_PREFERENCES_WINDOW (window));
+
+ gtk_window_close (GTK_WINDOW (window));
+}
+
+static void
gb_preferences_window_constructed (GObject *object)
{
GbPreferencesWindow *window = (GbPreferencesWindow *)object;
@@ -123,12 +138,28 @@ 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;
object_class->get_property = gb_preferences_window_get_property;
object_class->set_property = gb_preferences_window_set_property;
+ klass->close = gb_preferences_window_close;
+
+ gSignals [CLOSE] =
+ g_signal_new ("close",
+ GB_TYPE_PREFERENCES_WINDOW,
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (GbPreferencesWindowClass, close),
+ NULL, NULL,
+ g_cclosure_marshal_VOID__VOID,
+ 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);
+
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/builder/ui/gb-preferences-window.ui");
diff --git a/src/preferences/gb-preferences-window.h b/src/preferences/gb-preferences-window.h
index d97f56c..cf0d6a5 100644
--- a/src/preferences/gb-preferences-window.h
+++ b/src/preferences/gb-preferences-window.h
@@ -46,6 +46,8 @@ struct _GbPreferencesWindow
struct _GbPreferencesWindowClass
{
GtkWindowClass parent;
+
+ void (*close) (GbPreferencesWindow *window);
};
GType gb_preferences_window_get_type (void) G_GNUC_CONST;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]