diff options
author | Ross Lagerwall <rosslagerwall@gmail.com> | 2014-05-04 23:28:07 +0100 |
---|---|---|
committer | Ross Lagerwall <rosslagerwall@gmail.com> | 2014-05-10 08:33:18 +0100 |
commit | 84dc778fa5901f02b0b02fb258b0e401db510c85 (patch) | |
tree | 6de108c77abfda16695f716a415623daa29ebb09 /programs | |
parent | 46bdbf1d45962b56f4c30763fbc964890b75d79a (diff) | |
download | gvfs-84dc778fa5901f02b0b02fb258b0e401db510c85.tar.gz |
gvfs-mount: Handle the ask-question signal
Present questions as a message and a numbered list of choices such
that the user must enter one of the numbers.
For example:
"""
Can't verify the identity of ...
This happens when you log in to a computer the first time.
The identity sent by the remote computer is ... If you want to be
absolutely sure it is safe to continue, contact the system
administrator.
[1] Log In Anyway
[2] Cancel Login
Choice: 1
"""
https://bugzilla.gnome.org/show_bug.cgi?id=728959
Diffstat (limited to 'programs')
-rw-r--r-- | programs/gvfs-mount.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/programs/gvfs-mount.c b/programs/gvfs-mount.c index e35fc025..69f24bda 100644 --- a/programs/gvfs-mount.c +++ b/programs/gvfs-mount.c @@ -23,6 +23,7 @@ #include <config.h> +#include <stdlib.h> #include <stdio.h> #include <string.h> @@ -157,6 +158,35 @@ ask_password_cb (GMountOperation *op, } static void +ask_question_cb (GMountOperation *op, + char *message, + char **choices, + gpointer user_data) +{ + char **ptr = choices; + char *s; + int i, choice; + + g_print ("%s\n", message); + + i = 1; + while (*ptr) + { + g_print ("[%d] %s\n", i, *ptr++); + i++; + } + + s = prompt_for ("Choice", NULL, TRUE); + choice = atoi (s); + if (choice > 0 && choice < i) + { + g_mount_operation_set_choice (op, choice - 1); + g_mount_operation_reply (op, G_MOUNT_OPERATION_HANDLED); + } + g_free (s); +} + +static void mount_mountable_done_cb (GObject *object, GAsyncResult *res, gpointer user_data) @@ -210,6 +240,7 @@ new_mount_op (void) op = g_mount_operation_new (); g_signal_connect (op, "ask_password", G_CALLBACK (ask_password_cb), NULL); + g_signal_connect (op, "ask_question", G_CALLBACK (ask_question_cb), NULL); /* TODO: we *should* also connect to the "aborted" signal but since the * main thread is blocked handling input we won't get that signal |