Exemplo n.º 1
0
		public void set_setting (Setting s)
		{
			if(_s != null)
				throw new Exception("set_setting may only be used once per instance!");
			_s = s;

			name_label.Text = _s.Name;

			if (_s.Choices != null && _s.Limited) {

				// TODO: This is broken, code was originally written to store a string
				// but in this particular case there is a setting with string type
				// and you are given an array of choices, so what should really be
				// stored is a value between 0 and the length of the array; to 
				// indicate which choice is selected. As I am changing User-Agent
				// switcher to "Un Limited" I do not have a use case for this yet.
				ComboBox cobo = new ComboBox ((String[])_s.Choices);
				cobo.SetSizeRequest (100, 20);
				cobo.Name = _s.Name;
				cobo.Changed += cobo_changed;
				vbox2.Add (cobo);
			} else if (_s.Choices != null && !_s.Limited) {
				ComboBoxEntry combo = new ComboBoxEntry ((String[])_s.Choices);
				combo.SetSizeRequest (100, 20);
				combo.Name = _s.Name;
				combo.Entry.Text = (String)_s.Value;
				combo.Changed += combo_changed;
				vbox2.Add (combo);
			} else {
				Entry e = new Entry ((string)_s.Value);
				e.Name = _s.Name;
				e.Changed += e_changed;
				vbox2.Add (e);
			}
			Label l = new Label (_s.Description);
			l.SetSizeRequest (315, 100);
			l.SetAlignment (0, 0);
			l.LineWrap = true;
			l.SingleLineMode = false;
			l.SetPadding (10, 2);
			Pango.FontDescription pf2 = new Pango.FontDescription ();
			pf2.Weight = Pango.Weight.Light;
			l.ModifyFont (pf2);
			vbox2.Add(l);
		}