summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Winship <danw@gnome.org>2014-02-06 12:32:00 +0100
committerDan Winship <danw@gnome.org>2014-02-17 15:30:04 -0500
commit5d581b0d08fdebbefd65541f6f843f56d94db21a (patch)
tree40dece9482a7fc8fbe4e5bc40cc37d04e85c9434
parent12a2d64063e426419718de58f9d69309603a15a1 (diff)
downloadNetworkManager-5d581b0d08fdebbefd65541f6f843f56d94db21a.tar.gz
tui: handle Esc correctly from toplevel windows
The main "connect" and "edit" windows set the "escape-exits" flag, but that just closed the form without exiting the app, leaving the user trapped. Fix this by emitting a signal when the form quits, and catching that. (And now we don't need to watch the "clicked" signal on the quit buttons, since they have the "exit-on-activate" flag set.)
-rw-r--r--tui/newt/nmt-newt-form.c28
-rw-r--r--tui/newt/nmt-newt-form.h4
-rw-r--r--tui/nmtui-connect.c6
-rw-r--r--tui/nmtui-edit.c6
4 files changed, 37 insertions, 7 deletions
diff --git a/tui/newt/nmt-newt-form.c b/tui/newt/nmt-newt-form.c
index 20caecc455..19edef7d98 100644
--- a/tui/newt/nmt-newt-form.c
+++ b/tui/newt/nmt-newt-form.c
@@ -72,6 +72,14 @@ enum {
LAST_PROP
};
+enum {
+ QUIT,
+
+ LAST_SIGNAL
+};
+
+static guint signals[LAST_SIGNAL] = { 0 };
+
static void nmt_newt_form_redraw (NmtNewtForm *form);
/**
@@ -400,7 +408,6 @@ nmt_newt_form_quit (NmtNewtForm *form)
nmt_newt_form_destroy (form);
form_stack = g_slist_remove (form_stack, form);
- g_object_unref (form);
if (form_stack)
nmt_newt_form_iterate (form_stack->data);
@@ -408,6 +415,9 @@ nmt_newt_form_quit (NmtNewtForm *form)
g_source_destroy (keypress_source);
g_clear_pointer (&keypress_source, g_source_unref);
}
+
+ g_signal_emit (form, signals[QUIT], 0);
+ g_object_unref (form);
}
/**
@@ -556,6 +566,22 @@ nmt_newt_form_class_init (NmtNewtFormClass *form_class)
form_class->show = nmt_newt_form_real_show;
+ /* signals */
+
+ /**
+ * NmtNewtForm::quit:
+ * @form: the #NmtNewtForm
+ *
+ * Emitted when the form quits.
+ */
+ signals[QUIT] =
+ g_signal_new ("quit",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_FIRST,
+ G_STRUCT_OFFSET (NmtNewtFormClass, quit),
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 0);
+
/**
* NmtNewtForm:title:
*
diff --git a/tui/newt/nmt-newt-form.h b/tui/newt/nmt-newt-form.h
index e320d8723c..be95eb68ad 100644
--- a/tui/newt/nmt-newt-form.h
+++ b/tui/newt/nmt-newt-form.h
@@ -38,6 +38,10 @@ struct _NmtNewtForm {
typedef struct {
NmtNewtContainerClass parent;
+ /* signals */
+ void (*quit) (NmtNewtForm *form);
+
+ /* methods */
void (*show) (NmtNewtForm *form);
} NmtNewtFormClass;
diff --git a/tui/nmtui-connect.c b/tui/nmtui-connect.c
index 9f17e64797..b889815978 100644
--- a/tui/nmtui-connect.c
+++ b/tui/nmtui-connect.c
@@ -237,8 +237,8 @@ listbox_active_changed (GObject *object,
}
static void
-quit_clicked (NmtNewtButton *button,
- gpointer user_data)
+form_quit (NmtNewtForm *form,
+ gpointer user_data)
{
nmtui_quit ();
}
@@ -257,6 +257,7 @@ nmt_connect_connection_list (void)
"height", screen_height - 4,
"escape-exits", TRUE,
NULL);
+ g_signal_connect (form, "quit", G_CALLBACK (form_quit), NULL);
grid = nmt_newt_grid_new ();
@@ -278,7 +279,6 @@ nmt_connect_connection_list (void)
quit = nmt_newt_button_box_add_end (NMT_NEWT_BUTTON_BOX (bbox), _("Quit"));
nmt_newt_widget_set_exit_on_activate (quit, TRUE);
- g_signal_connect (quit, "clicked", G_CALLBACK (quit_clicked), NULL);
nmt_newt_form_set_content (form, grid);
nmt_newt_form_show (form);
diff --git a/tui/nmtui-edit.c b/tui/nmtui-edit.c
index c687a5c09b..34e51a684c 100644
--- a/tui/nmtui-edit.c
+++ b/tui/nmtui-edit.c
@@ -78,8 +78,8 @@ edit_connection_list_filter (NmtEditConnectionList *list,
}
static void
-quit_clicked (NmtNewtButton *button,
- gpointer user_data)
+form_quit (NmtNewtForm *form,
+ gpointer user_data)
{
nmtui_quit ();
}
@@ -98,10 +98,10 @@ nmt_edit_main_connection_list (void)
"height", screen_height - 4,
"escape-exits", TRUE,
NULL);
+ g_signal_connect (form, "quit", G_CALLBACK (form_quit), NULL);
quit = nmt_newt_button_new (_("Quit"));
nmt_newt_widget_set_exit_on_activate (quit, TRUE);
- g_signal_connect (quit, "clicked", G_CALLBACK (quit_clicked), NULL);
list = g_object_new (NMT_TYPE_EDIT_CONNECTION_LIST,
"extra-widget", quit,