Commit cb3e6995 authored by Paolo Borelli's avatar Paolo Borelli

Close preferences dialog on ESC

This was handled by GtkDialog, but got lost when we started
subclassing GtkWindow directly.
parent 5a20204f
......@@ -63,6 +63,14 @@ enum
NUM_COLUMNS
};
enum
{
CLOSE,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL];
struct _GeditPreferencesDialogPrivate
{
GSettings *editor;
......@@ -130,16 +138,34 @@ gedit_preferences_dialog_dispose (GObject *object)
G_OBJECT_CLASS (gedit_preferences_dialog_parent_class)->dispose (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,
......
......@@ -62,6 +62,9 @@ typedef struct _GeditPreferencesDialogClass GeditPreferencesDialogClass;
struct _GeditPreferencesDialogClass
{
GtkWindowClass parent_class;
/* Keybinding signals */
void (* close) (GeditPreferencesDialog *dialog);
};
/*
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment