static public string QueryMessage(Widget sender, string key, string title = null, string value = "") { string ret = null; Window parent; if (sender != null) { parent = sender.Toplevel as Window; } else { parent = null; } Label label = new Label(key); Entry entry = new Entry(value); Gtk.Dialog dialog = new Gtk.Dialog(title, parent, DialogFlags.DestroyWithParent); dialog.Modal = true; dialog.WidthRequest = 300; dialog.AddButton(Catalog.GetString("Add"), ResponseType.Ok); dialog.VBox.PackStart(label, false, false, 0); dialog.VBox.PackStart(entry, true, true, 0); dialog.Icon = Misc.LoadIcon(App.Current.SoftwareIconName, Gtk.IconSize.Dialog, 0); dialog.ShowAll(); if (dialog.Run() == (int)ResponseType.Ok) { ret = entry.Text; } dialog.Destroy(); return(ret); }
public static int PopupMessage(Widget sender, MessageType type, String errorMessage, CustomizeDialog customize = null) { Window toplevel; int ret; if (sender != null) { toplevel = sender.Toplevel as Window; } else { toplevel = null; } MessageDialog md = new MessageDialog(toplevel, DialogFlags.Modal, type, ButtonsType.Ok, errorMessage); md.Icon = Misc.LoadIcon(App.Current.SoftwareIconName, Gtk.IconSize.Dialog, 0); try { var vbox = md.MessageDialogGetMessageArea(); var label = (Label)vbox.Children [0]; label.SetLinkHandler(url => { try { App.Current.NetworkManager.OpenURL(url); } catch (Exception ex) { Log.WarningFormat("Could not spawn process for url {0}\n{1}", url, ex); } }); } catch (Exception ex) { Log.WarningFormat("Could not set link handler for Message Dialog\n{0}", ex); } if (customize != null) { customize(md); } ret = md.Run(); md.Destroy(); return(ret); }
public ExternalWindow() : base(WindowType.Toplevel) { // Configure window icon Icon = Misc.LoadIcon(App.Current.SoftwareIconName, IconSize.Dialog); box = new EventBox(); box.Name = "lightbackgroundeventbox"; box.KeyPressEvent += (o, args) => { App.Current.EventsBroker.Publish <KeyPressedEvent> ( new KeyPressedEvent { Sender = this, Key = App.Current.Keyboard.ParseEvent(args.Event) } ); }; base.Add(box); box.CanFocus = true; Focus = box; box.Show(); }
static public int ButtonsMessage(Widget parent, string question, List <string> textButtons, int?focusIndex, string title = null) { Window toplevel; if (parent != null) { toplevel = parent.Toplevel as Window; } else { toplevel = null; } MessageDialog md = new MessageDialog(toplevel, DialogFlags.Modal, MessageType.Question, ButtonsType.None, question); md.Icon = Misc.LoadIcon(App.Current.SoftwareIconName, IconSize.Button, 0); md.Title = title; for (int i = 0; i < textButtons.Count; i++) { var buttonText = textButtons [i]; var t = md.AddButton(buttonText, i + 1); if (focusIndex.HasValue && focusIndex.Value == i) { md.Focus = t; } } var res = md.Run(); md.Destroy(); return(res); }
static public bool QuestionMessage(Widget parent, string question, string title = null) { Window toplevel; if (parent != null) { toplevel = parent.Toplevel as Window; } else { toplevel = null; } MessageDialog md = new MessageDialog(toplevel, DialogFlags.Modal, MessageType.Question, ButtonsType.YesNo, question); md.Icon = Misc.LoadIcon(App.Current.SoftwareIconName, IconSize.Button, 0); md.Title = title; var res = md.Run(); md.Destroy(); return(res == (int)ResponseType.Yes); }