changeset 2045:63de60cad8bd

user/password dialog
author corvid <corvid@lavabit.com>
date Wed, 25 May 2011 22:09:26 +0000
parents 8f7dfd5247f2
children e5b533e4aaac
files src/dialog.cc
diffstat 1 files changed, 12 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/src/dialog.cc	Sun May 22 19:51:32 2011 -0400
+++ b/src/dialog.cc	Wed May 25 22:09:26 2011 +0000
@@ -222,17 +222,10 @@
 
 
 /*--------------------------------------------------------------------------*/
-/*
- * ret: 0 = Cancel, 1 = OK
- */
-static void Dialog_user_password_cb(Fl_Widget *button, void *vIntPtr)
+static void Dialog_user_password_cb(Fl_Widget *button, void *)
 {
-#if 0
-PORT1.3
-   int ret = VOIDP2INT(vIntPtr);
-  _MSG("Dialog_user_password_cb: %d\n", ret);
-  button->window()->make_exec_return(ret);
-#endif
+   button->window()->user_data(button);
+   button->window()->hide();
 }
 
 /*
@@ -249,6 +242,7 @@
 
    Fl_Window *window =
       new Fl_Window(window_w,window_h,"User/Password");
+   window->user_data(NULL);
    window->begin();
 
    /* message */
@@ -276,21 +270,24 @@
       new Fl_Button(200,button_y,50,button_h,"OK");
    ok_button->labelsize(14);
    ok_button->callback(Dialog_user_password_cb);
-   ok_button->user_data(INT2VOIDP(1));
 
    /* "Cancel" button */
    Fl_Button *cancel_button =
       new Fl_Button(50,button_y,100,button_h,"Cancel");
    cancel_button->labelsize(14);
    cancel_button->callback(Dialog_user_password_cb);
-   cancel_button->user_data(INT2VOIDP(0));
 
    window->end();
    window->size_range(window_w,window_h,window_w,window_h);
    window->resizable(window);
-#if 0
-PORT1.3
-   if ((ok = window->exec())) {
+
+   window->show();
+   while (window->shown())
+      Fl::wait();
+
+   ok = ((Fl_Widget *)window->user_data()) == ok_button ? 1 : 0;
+
+   if (ok) {
       /* call the callback */
       const char *user, *password;
       user = user_input->value();
@@ -298,7 +295,6 @@
       _MSG("a_Dialog_user_passwd: ok = %d\n", ok);
       (*cb)(user, password, vp);
    }
-#endif
    delete window;
 
    return ok;