Commit ffe0ec68 authored by Matthias Clasen's avatar Matthias Clasen

GtkAssistant: Make Escape cancel the assistant

This is an expected keybinding, and it is not hard to support.
Note that we use a private ::escape signal instead of using
::cancel directly, since we want to be able to suppress the
cancellation when we are on a progress page.

https://bugzilla.gnome.org/show_bug.cgi?id=579625
parent 145c3e60
......@@ -205,6 +205,7 @@ enum
PREPARE,
APPLY,
CLOSE,
ESCAPE,
LAST_SIGNAL
};
......@@ -362,12 +363,28 @@ gtk_assistant_constructed (GObject *object)
apply_use_header_bar (assistant);
}
static void
escape_cb (GtkAssistant *assistant)
{
GtkAssistantPrivate *priv = assistant->priv;
/* Do not allow cancelling in the middle of a progress page */
if (priv->current_page &&
(priv->current_page->type != GTK_ASSISTANT_PAGE_PROGRESS ||
priv->current_page->complete))
g_signal_emit (assistant, signals [CANCEL], 0, NULL);
/* don't run any user handlers - this is not a public signal */
g_signal_stop_emission (assistant, signals[ESCAPE], 0);
}
static void
gtk_assistant_class_init (GtkAssistantClass *class)
{
GObjectClass *gobject_class;
GtkWidgetClass *widget_class;
GtkContainerClass *container_class;
GtkBindingSet *binding_set;
gobject_class = (GObjectClass *) class;
widget_class = (GtkWidgetClass *) class;
......@@ -474,6 +491,18 @@ gtk_assistant_class_init (GtkAssistantClass *class)
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
signals[ESCAPE] =
g_signal_new_class_handler (I_("escape"),
G_TYPE_FROM_CLASS (gobject_class),
G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION,
G_CALLBACK (escape_cb),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
binding_set = gtk_binding_set_by_class (class);
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0, "escape", 0);
/**
* GtkAssistant:use-header-bar:
*
......
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