Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: fe0b35e382
Fetching contributors…

Cannot retrieve contributors at this time

file 67 lines (57 sloc) 1.373 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
using System;
using System.Collections;
using System.Reflection;

namespace Stetic.Editor {

public class ResponseId : Gtk.HBox {

Gtk.ComboBoxEntry combo;
Gtk.Entry entry;
EnumDescriptor enm;
ArrayList values;

public ResponseId ()
{
combo = Gtk.ComboBoxEntry.NewText ();
combo.Changed += combo_Changed;
combo.Show ();
PackStart (combo, true, true, 0);

entry = combo.Child as Gtk.Entry;
entry.Changed += entry_Changed;

enm = Registry.LookupEnum (typeof (Gtk.ResponseType));
values = new ArrayList ();
foreach (Enum value in enm.Values) {
if (enm[value].Label != "") {
combo.AppendText (enm[value].Label);
values.Add ((int)enm[value].Value);
}
}
}

public int Value {
get {
if (combo.Active != -1)
return (int)values[combo.Active];
else {
try {
return Int32.Parse (entry.Text);
} catch {
return 0;
}
}
}
set {
combo.Active = values.IndexOf (value);
if (combo.Active == -1)
entry.Text = value.ToString ();
}
}

public event EventHandler ValueChanged;

void combo_Changed (object o, EventArgs args)
{
if (ValueChanged != null)
ValueChanged (this, EventArgs.Empty);
}

void entry_Changed (object o, EventArgs args)
{
if (combo.Active == -1 && ValueChanged != null)
ValueChanged (this, EventArgs.Empty);
}
}
}
Something went wrong with that request. Please try again.