コード例 #1
0
        internal static bool Show(bool showPwd, string realm, bool may_save, ref string user_name, out string password, out bool save)
        {
            string pwd = "", user = user_name;
            int    s = 0;

            bool   res     = false;
            object monitor = new Object();

            EventHandler del = delegate
            {
                try
                {
                    UserPasswordDialog dlg = new UserPasswordDialog(user, realm, may_save, showPwd);
                    res = (MessageService.RunCustomDialog(dlg) == (int)Gtk.ResponseType.Ok);
                    if (res)
                    {
                        s    = dlg.SavePassword ? 1 : 0;
                        pwd  = dlg.Password;
                        user = dlg.User;
                    }
                    dlg.Destroy();
                }
                finally
                {
                    lock (monitor)
                    {
                        System.Threading.Monitor.Pulse(monitor);
                    }
                }
            };

            if (GLib.MainContext.Depth > 0)
            {
                // Already in GUI thread
                del(null, null);
            }
            else
            {
                lock (monitor)
                {
                    Gtk.Application.Invoke(del);
                    System.Threading.Monitor.Wait(monitor);
                }
            }

            user_name = user;
            save      = s != 0;
            password  = pwd;
            return(res);
        }
コード例 #2
0
		internal static bool Show (bool showPwd, string realm, bool may_save, ref string user_name, out string password, out bool save)
		{
			string pwd = "", user = user_name;
			int s = 0;
			
			bool res = false;
			object monitor = new Object ();
			
			EventHandler del = delegate {
					UserPasswordDialog dlg = new UserPasswordDialog (user, realm, may_save, showPwd);
					try {
						res = (MessageService.RunCustomDialog (dlg) == (int) Gtk.ResponseType.Ok);
						if (res) {
							s = dlg.SavePassword ? 1 : 0;
							pwd = dlg.Password;
							user = dlg.User;
						}
					} finally {
						dlg.Destroy ();
						dlg.Dispose ();
						lock (monitor) {
							System.Threading.Monitor.Pulse (monitor);
						}
					}
			};
			
			if (GLib.MainContext.Depth > 0) {
				// Already in GUI thread
				del (null, null);
			}
			else {
				lock (monitor) {
					Gtk.Application.Invoke (del);
					System.Threading.Monitor.Wait (monitor);
				}
			}
			
			user_name = user;
			save = s != 0;
			password = pwd;
			return res;
		}