diff options
author | Thomas Haller <thaller@redhat.com> | 2020-01-01 09:54:23 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2020-01-13 15:46:04 +0100 |
commit | 9cc6d3a26df0a2e7860a06ee72e5e7ef1689ebb2 (patch) | |
tree | c8f73de0d90c196689bdcc72043a28f3cbc106fa | |
parent | a3b29b06dcb1381c0e375cc3f5e54cd4ec863f32 (diff) | |
download | NetworkManager-9cc6d3a26df0a2e7860a06ee72e5e7ef1689ebb2.tar.gz |
tui: don't use GIOChannel to watch plain file descriptor for key press
-rw-r--r-- | clients/tui/newt/nmt-newt-form.c | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/clients/tui/newt/nmt-newt-form.c b/clients/tui/newt/nmt-newt-form.c index 320be13e6e..2142e3c567 100644 --- a/clients/tui/newt/nmt-newt-form.c +++ b/clients/tui/newt/nmt-newt-form.c @@ -312,9 +312,9 @@ static GSList *form_stack; static GSource *keypress_source; static gboolean -nmt_newt_form_keypress_callback (GIOChannel *channel, +nmt_newt_form_keypress_callback (int fd, GIOCondition condition, - gpointer user_data) + gpointer user_data) { g_return_val_if_fail (form_stack != NULL, FALSE); @@ -340,16 +340,14 @@ static void nmt_newt_form_real_show (NmtNewtForm *form) { if (!keypress_source) { - GIOChannel *io; - - io = g_io_channel_unix_new (STDIN_FILENO); - keypress_source = g_io_create_watch (io, G_IO_IN); + keypress_source = nm_g_unix_fd_source_new (STDIN_FILENO, + G_IO_IN, + G_PRIORITY_DEFAULT, + nmt_newt_form_keypress_callback, + NULL, + NULL); g_source_set_can_recurse (keypress_source, TRUE); - g_source_set_callback (keypress_source, - (GSourceFunc)(void (*) (void)) nmt_newt_form_keypress_callback, - NULL, NULL); g_source_attach (keypress_source, NULL); - g_io_channel_unref (io); } nmt_newt_form_build (form); @@ -416,10 +414,8 @@ nmt_newt_form_quit (NmtNewtForm *form) if (form_stack) nmt_newt_form_iterate (form_stack->data); - else if (keypress_source) { - g_source_destroy (keypress_source); - g_clear_pointer (&keypress_source, g_source_unref); - } + else + nm_clear_g_source_inst (&keypress_source); g_signal_emit (form, signals[QUIT], 0); g_object_unref (form); |