public void SetButtons(IEnumerable <DialogButton> newButtons) { if (buttons != null) { foreach (var b in buttons) { ((Gtk.Container)b.Parent).Remove(b); b.Destroy(); } } dialogButtons = newButtons .OrderBy(b => b.PackOrigin) .OrderBy(b => b == DefaultButton).ToArray(); buttons = new Gtk.Button [dialogButtons.Length]; for (int n = 0; n < dialogButtons.Length; n++) { var db = dialogButtons[n]; Gtk.Button b = new Gtk.Button(); b.Show(); b.Label = db.Label; Window.ActionArea.Add(b); UpdateButton(db, b); buttons[n] = b; buttons[n].Clicked += HandleButtonClicked; if (db == DefaultButton) { b.CanDefault = true; b.GrabDefault(); } } UpdateActionAreaVisibility(); }
private void AddButton(Gtk.Button button, Gtk.ResponseType response, bool isDefault) { AddActionWidget(button, response); if (isDefault) { Default = button; DefaultResponse = response; button.GrabDefault(); } }
public override void Initialize() { NeedsEventBox = false; Widget = new Gtk.Button(); Widget.Realized += (o, arg) => { if (Widget.IsRealized && Widget.CanDefault) { Widget.GrabDefault(); } }; base.Widget.Show(); }
public void SetButtons(IEnumerable<DialogButton> newButtons) { if (buttons != null) { foreach (var b in buttons) { ((Gtk.Container)b.Parent).Remove (b); b.Destroy (); } } dialogButtons = newButtons .OrderBy (b => b.PackOrigin) .OrderBy (b => b == DefaultButton).ToArray (); buttons = new Gtk.Button [dialogButtons.Length]; for (int n=0; n<dialogButtons.Length; n++) { var db = dialogButtons[n]; Gtk.Button b = new Gtk.Button (); b.Show (); b.Label = db.Label; Window.ActionArea.Add (b); UpdateButton (db, b); buttons[n] = b; buttons[n].Clicked += HandleButtonClicked; if (db == DefaultButton) { b.CanDefault = true; b.GrabDefault (); } } UpdateActionAreaVisibility (); }