public Image(bool allowStock, bool allowFile) : base(false, 6) { image = new Gtk.Image(Gnome.Stock.Blank, Gtk.IconSize.Button); PackStart(image, false, false, 0); if (allowStock) { store = new Gtk.ListStore(typeof(string), typeof(string)); store.AppendValues(Gnome.Stock.Blank, Catalog.GetString("(None)")); for (int i = 0; i < stockIds.Length; i++) { store.AppendValues(stockIds[i], stockLabels[i]); } combo = new Gtk.ComboBoxEntry(store, LabelColumn); Gtk.CellRendererPixbuf iconRenderer = new Gtk.CellRendererPixbuf(); iconRenderer.StockSize = (uint)Gtk.IconSize.Menu; combo.PackStart(iconRenderer, false); combo.Reorder(iconRenderer, 0); combo.AddAttribute(iconRenderer, "stock-id", IconColumn); combo.Changed += combo_Changed; // Pack the combo non-expandily into a VBox so it doesn't // get stretched to the file button's height Gtk.VBox vbox = new Gtk.VBox(false, 0); vbox.PackStart(combo, true, false, 0); PackStart(vbox, true, true, 0); entry = (Gtk.Entry)combo.Child; entry.Changed += entry_Changed; useStock = true; } if (allowFile) { if (!allowStock) { entry = new Gtk.Entry(); PackStart(entry, true, true, 0); entry.Changed += entry_Changed; } button = new Gtk.Button(); Gtk.Image icon = new Gtk.Image(Gtk.Stock.Open, Gtk.IconSize.Button); button.Add(icon); PackStart(button, false, false, 0); button.Clicked += button_Clicked; } ShowAll(); }
/// <summary> /// Initializes this widget children. /// </summary> private void InitializeWidgets() { this.Add(this.symbolLabelEditorHB); // A model is neccesary to store the different values model = new Gtk.ListStore(typeof(string), typeof(string)); symbolsCBEntry.Model = model; symbolsCBEntry.TextColumn = 0; Gtk.CellRendererText cell = new Gtk.CellRendererText(); symbolsCBEntry.PackStart(cell, true); symbolsCBEntry.AddAttribute(cell, "text", 1); LoadSymbols(); // We adjust the wrap so it is mostrly a square. symbolsCBEntry.WrapWidth = (int)Math.Ceiling(Math.Sqrt(model.IterNChildren())) - 1; }
public Image(bool allowStock, bool allowFile) : base(false, 6) { image = new Gtk.Image (Gnome.Stock.Blank, Gtk.IconSize.Button); PackStart (image, false, false, 0); if (allowStock) { store = new Gtk.ListStore (typeof (string), typeof (string)); store.AppendValues (Gnome.Stock.Blank, Catalog.GetString ("(None)")); for (int i = 0; i < stockIds.Length; i++) store.AppendValues (stockIds[i], stockLabels[i]); combo = new Gtk.ComboBoxEntry (store, LabelColumn); Gtk.CellRendererPixbuf iconRenderer = new Gtk.CellRendererPixbuf (); iconRenderer.StockSize = (uint)Gtk.IconSize.Menu; combo.PackStart (iconRenderer, false); combo.Reorder (iconRenderer, 0); combo.AddAttribute (iconRenderer, "stock-id", IconColumn); combo.Changed += combo_Changed; // Pack the combo non-expandily into a VBox so it doesn't // get stretched to the file button's height Gtk.VBox vbox = new Gtk.VBox (false, 0); vbox.PackStart (combo, true, false, 0); PackStart (vbox, true, true, 0); entry = (Gtk.Entry)combo.Child; entry.Changed += entry_Changed; useStock = true; } if (allowFile) { if (!allowStock) { entry = new Gtk.Entry (); PackStart (entry, true, true, 0); entry.Changed += entry_Changed; } button = new Gtk.Button (); Gtk.Image icon = new Gtk.Image (Gtk.Stock.Open, Gtk.IconSize.Button); button.Add (icon); PackStart (button, false, false, 0); button.Clicked += button_Clicked; } ShowAll (); }