예제 #1
0
		public CredentialsDialog (URIish uri, IEnumerable<CredentialItem> credentials)
		{
			this.Build ();
			
			labelTop.Text = string.Format (labelTop.Text, uri.ToString ());
			
			Gtk.Table table = new Gtk.Table (0, 0, false);
			table.ColumnSpacing = 6;
			vbox.PackStart (table, true, true, 0);
			
			uint r = 0;
			Widget firstEditor = null;
			foreach (CredentialItem c in credentials) {
				Label lab = new Label (c.GetPromptText () + ":");
				lab.Xalign = 0;
				table.Attach (lab, 0, 1, r, r + 1);
				Table.TableChild tc = (Table.TableChild) table [lab];
				tc.XOptions = AttachOptions.Shrink;
				
				Widget editor = null;
				
				if (c is CredentialItem.YesNoType) {
					CredentialItem.YesNoType cred = (CredentialItem.YesNoType) c;
					if (credentials.Count (i => i is CredentialItem.YesNoType) == 1) {
						singleYesNoCred = cred;
						buttonOk.Hide ();
						buttonYes.Show ();
						buttonNo.Show ();
						// Remove the last colon
						lab.Text = lab.Text.Substring (0, lab.Text.Length - 1);
					}
					else {
						CheckButton btn = new CheckButton ();
						editor = btn;
						btn.Toggled += delegate {
							cred.SetValue (btn.Active);
						};
					}
				}
				else if (c is CredentialItem.StringType || c is CredentialItem.CharArrayType) {
					CredentialItem cred = c;
					Entry e = new Entry ();
					editor = e;
					e.ActivatesDefault = true;
					if (cred.IsValueSecure ())
						e.Visibility = false;
					e.Changed += delegate {
						if (cred is CredentialItem.StringType)
							((CredentialItem.StringType)cred).SetValue (e.Text);
						else
							((CredentialItem.CharArrayType)cred).SetValue (e.Text.ToCharArray ());
					};
					
					if (c is CredentialItem.Username)
						e.Text = uri.GetUser () ?? "";
				}
				if (editor != null) {
					table.Attach (editor, 1, 2, r, r + 1);
					tc = (Table.TableChild) table [lab];
					tc.XOptions = AttachOptions.Fill;
					if (firstEditor == null)
						firstEditor = editor;
				}
				
				r++;
			}
			table.ShowAll ();
			Focus = firstEditor;
			Default = buttonOk;
		}
 public virtual bool PromptYesNo(string msg)
 {
     CredentialItem.YesNoType v = new CredentialItem.YesNoType(msg);
     return(provider.Get(uri, v) && v.GetValue());
 }
		public virtual bool PromptYesNo(string msg)
		{
			CredentialItem.YesNoType v = new CredentialItem.YesNoType(msg);
			return provider.Get(uri, v) && v.GetValue();
		}