[gedit/gnome-3-14] Close preferences dialog on ESC
- From: Paolo Borelli <pborelli src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gedit/gnome-3-14] Close preferences dialog on ESC
- Date: Sun, 18 Jan 2015 14:52:31 +0000 (UTC)
commit cd3d4ced5e34da611cef0948d421dd8b347bb1d8
Author: Paolo Borelli <pborelli gnome org>
Date: Sun Jan 18 15:46:37 2015 +0100
Close preferences dialog on ESC
This was handled by GtkDialog, but got lost when we started
subclassing GtkWindow directly.
gedit/gedit-preferences-dialog.c | 26 ++++++++++++++++++++++++++
gedit/gedit-preferences-dialog.h | 3 +++
2 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/gedit/gedit-preferences-dialog.c b/gedit/gedit-preferences-dialog.c
index a907d13..578db9a 100644
--- a/gedit/gedit-preferences-dialog.c
+++ b/gedit/gedit-preferences-dialog.c
@@ -63,6 +63,14 @@ enum
NUM_COLUMNS
};
+enum
+{
+ CLOSE,
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL];
+
struct _GeditPreferencesDialogPrivate
{
GSettings *editor;
@@ -131,15 +139,33 @@ gedit_preferences_dialog_dispose (GObject *object)
}
static void
+gedit_preferences_dialog_close (GeditPreferencesDialog *dialog)
+{
+ gtk_window_close (GTK_WINDOW (dialog));
+}
+
+static void
gedit_preferences_dialog_class_init (GeditPreferencesDialogClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ GtkBindingSet *binding_set;
/* Otherwise libpeas-gtk might not be linked */
g_type_ensure (PEAS_GTK_TYPE_PLUGIN_MANAGER);
object_class->dispose = gedit_preferences_dialog_dispose;
+ klass->close = gedit_preferences_dialog_close;
+
+ signals[CLOSE] = g_signal_new ("close",
+ G_OBJECT_CLASS_TYPE (klass),
+ G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
+ G_STRUCT_OFFSET (GeditPreferencesDialogClass, close),
+ NULL, NULL, NULL,
+ 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);
/* Bind class to template */
gtk_widget_class_set_template_from_resource (widget_class,
diff --git a/gedit/gedit-preferences-dialog.h b/gedit/gedit-preferences-dialog.h
index 4d2c134..0917d6a 100644
--- a/gedit/gedit-preferences-dialog.h
+++ b/gedit/gedit-preferences-dialog.h
@@ -62,6 +62,9 @@ typedef struct _GeditPreferencesDialogClass GeditPreferencesDialogClass;
struct _GeditPreferencesDialogClass
{
GtkWindowClass parent_class;
+
+ /* Keybinding signals */
+ void (* close) (GeditPreferencesDialog *dialog);
};
/*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]