/// <summary> /// Shows a modal dialog. /// </summary> /// <param name="dialog">The dialog to show.</param> /// <param name="alwaysClose">If set to <c>true</c> always close the dialog as soon as a response is known.</param> /// <param name="closeForResponses">If <paramref name="alwaysClose"/> is <c>false</c>, only the provided values will exit the dialog run loop.</param> /// <returns>A value indicating whether the dialog was cancelled (<c>false</c>), aborted (<c>null</c>) or approved (<c>true</c>).</returns> /// <remarks>Dialogs with 'sub-functions' should always use a response value of Gtk.ResponseType.None. Other explicit values /// may be ignored -- that is, only specific values will exit the dialog if the <paramref name="closeForResponses"/> argument /// is non-empty and <paramref name="alwaysClose"/> is <c>false</c>. If alwaysClose is false and no response values for close are /// provided, it is a Bad Thing and you shouldn't do that.</remarks> public static bool?ShowDialog(this Gtk.Dialog dialog, bool alwaysClose, params Gtk.ResponseType[] closeForResponses) { bool?accepted = null; var result = Gtk.ResponseType.None; do { result = (Gtk.ResponseType)dialog.Run(); if (result != Gtk.ResponseType.None) { switch (result) { case Gtk.ResponseType.Reject: case Gtk.ResponseType.Cancel: case Gtk.ResponseType.Close: case Gtk.ResponseType.No: accepted = false; break; case Gtk.ResponseType.Accept: case Gtk.ResponseType.Apply: case Gtk.ResponseType.Help: case Gtk.ResponseType.Yes: case Gtk.ResponseType.Ok: accepted = true; break; default: break; } } }while (!alwaysClose && ((closeForResponses == null) || !closeForResponses.Contains(result))); VisualHelpers.Close(dialog); return(accepted); }
private void OnViewNotebook() { var dlg = new Gtk.Dialog("Boxes", this, Gtk.DialogFlags.Modal); var nbTabs = new Gtk.Notebook(); nbTabs.AppendPage(new Gtk.Label("Page1"), new Gtk.Label("Page1")); nbTabs.AppendPage(new Gtk.Label("Page2"), new Gtk.Label("Page2")); dlg.VBox.PackStart(nbTabs, true, true, 5); dlg.SetGeometryHints( dlg, new Gdk.Geometry() { MinHeight = 200, MinWidth = 320 }, Gdk.WindowHints.MinSize ); dlg.AddButton("Ok", Gtk.ResponseType.Ok); dlg.ShowAll(); dlg.Run(); dlg.Destroy(); }
private void OnViewBoxes() { var dlg = new Gtk.Dialog( "Boxes", this, Gtk.DialogFlags.Modal ); var hbBox1 = new Gtk.HBox( false, 5 ); hbBox1.Add( new Gtk.Label( "This is hbox 1" ) ); var hbBox2 = new Gtk.HBox( false, 5 ); hbBox2.Add( new Gtk.Label( "This is hbox 2" ) ); var hbBox3 = new Gtk.HBox( false, 5 ); hbBox3.Add( new Gtk.Label( "This is hbox 3" ) ); dlg.VBox.PackStart( hbBox1, true, true, 5 ); dlg.VBox.PackStart( hbBox2, true, true, 5 ); dlg.VBox.PackStart( hbBox3, true, true, 5 ); dlg.SetGeometryHints( dlg, new Gdk.Geometry() { MinHeight = 200, MinWidth = 320 }, Gdk.WindowHints.MinSize ); dlg.AddButton( "Ok", Gtk.ResponseType.Ok ); dlg.ShowAll(); dlg.Run(); dlg.Destroy(); }
public static int RunDialogWithNotification(Gtk.Dialog dialog) { if (Platform.IsMac) { MacRequestAttention(dialog.Modal); } return(dialog.Run()); }
public IAsyncOperation <IUICommand> ShowAsync() { Func <CancellationToken, Task <IUICommand> > func = async(ct) => { return(await Task.Run(() => { var waitHandle = new ManualResetEventSlim(); int result = -1; Gtk.Application.Invoke((s, a) => { var dialog = new Gtk.Dialog(Title, GtkHost.Window, Gtk.DialogFlags.Modal); dialog.SkipTaskbarHint = true; Gtk.Label label = new Gtk.Label(Content); label.Halign = Gtk.Align.Fill; dialog.ContentArea.Add(label); label.Show(); if (Commands.Count == 0) { Commands.Add(new UICommand("Close")); } for (int i = 0; i < Commands.Count; ++i) { dialog.AddButton(Commands[i].Label, i); } dialog.DefaultResponse = (Gtk.ResponseType)DefaultCommandIndex; result = dialog.Run(); dialog.Hide(); // dialog.Destroy(); dialog.Dispose(); waitHandle.Set(); }); waitHandle.Wait(); if (result < 0) { result = unchecked ((int)CancelCommandIndex); } // CancelCommandIndex still not set. if (result < 0) { result = (int)DefaultCommandIndex; } return Commands[result]; }, ct)); }; return(FromTaskFunction.Invoke(null, new object[] { func }) as IAsyncOperation <IUICommand>); }
public string Run() { pickfolder_dialog.ShowAll(); if (pickfolder_dialog.Run() == -6) { return(pickfolder_chooser.Filename); } else { return(null); } }
void ShowImage(Pixbuf img, string title) { if (DiagnosticMode) { Gtk.Dialog Win = new Gtk.Dialog(title, parent, Gtk.DialogFlags.Modal, Gtk.ButtonsType.Ok); Gtk.Image Image = new Gtk.Image(img); Win.VBox.Add(Image); Win.ShowAll(); Win.Run(); Image.Pixbuf = null; Win.Destroy(); } logger.Info(title); }
private void OnViewDrawing() { var dlg = new Gtk.Dialog("Drawing", this, Gtk.DialogFlags.Modal); var swScroll = new Gtk.ScrolledWindow(); var rnd = new System.Random(); int[][] valuesSeries = new int[3][]; // Create series for (int i = 0; i < valuesSeries.Length; ++i) { valuesSeries[i] = new int[12]; for (int j = 0; j < valuesSeries[i].Length; ++j) { valuesSeries[i][j] = rnd.Next(50); } } // Drawing area Chart chart = new Chart(512, 512) { LegendY = "Sells (in thousands)", LegendX = "Months", Values = valuesSeries }; // Layout swScroll.AddWithViewport(chart); dlg.VBox.PackStart(swScroll, true, true, 5); dlg.AddButton(Gtk.Stock.Close, Gtk.ResponseType.Close); // Polish dlg.WindowPosition = Gtk.WindowPosition.CenterOnParent; dlg.Resize(640, 640); dlg.SetGeometryHints( dlg, new Gdk.Geometry() { MinWidth = 640, MinHeight = 640 }, Gdk.WindowHints.MinSize ); dlg.ShowAll(); dlg.Run(); dlg.Destroy(); }
private bool DoGetDecision() { Glade.XML glade_xml = new Glade.XML( null, "TrustError.glade", DialogName, "f-spot"); glade_xml.Autoconnect(this); dialog = (Gtk.Dialog)glade_xml.GetWidget(DialogName); url_label.Markup = String.Format( url_label.Text, String.Format( "<b>{0}</b>", request.RequestUri)); Gtk.ResponseType response = (Gtk.ResponseType)dialog.Run(); Log.DebugFormat("Decision dialog response: " + response); dialog.Destroy(); decision = Decision.DontTrust; if (0 == response) { if (abort_radiobutton.Active) { decision = Decision.DontTrust; } else if (once_radiobutton.Active) { decision = Decision.TrustOnce; } else if (always_radiobutton.Active) { decision = Decision.TrustAlways; } else { Debug.Assert(false, "Unhandled decision"); } } decision_event.Set(); return(false); }
private bool DoGetDecision() { GtkBeans.Builder builder = new GtkBeans.Builder( Assembly.GetExecutingAssembly(), "TrustError.ui", null); builder.Autoconnect(this); dialog = (Gtk.Dialog)builder.GetObject(DialogName); url_label.Markup = String.Format( url_label.Text, String.Format( "<b>{0}</b>", request.RequestUri)); Gtk.ResponseType response = (Gtk.ResponseType)dialog.Run(); Log.Debug("Decision dialog response: " + response); dialog.Destroy(); decision = Decision.DontTrust; if (0 == response) { if (abort_radiobutton.Active) { decision = Decision.DontTrust; } else if (once_radiobutton.Active) { decision = Decision.TrustOnce; } else if (always_radiobutton.Active) { decision = Decision.TrustAlways; } else { Debug.Assert(false, "Unhandled decision"); } } decision_event.Set(); return(false); }
private static void RunModalDialog(string title, string format, params object [] args) { Gtk.Dialog dlg = new Gtk.Dialog ("Tomboy.InsertImage - " + Catalog.GetString(title), null, Gtk.DialogFlags.Modal | Gtk.DialogFlags.DestroyWithParent); var text = new Gtk.TextView (); text.WrapMode = Gtk.WrapMode.Word; text.Editable = false; if (args.Length > 0) format = string.Format (format, args); text.Buffer.Text = format; var scroll = new Gtk.ScrolledWindow (); scroll.Add (text); dlg.AddButton (Catalog.GetString("Close"), Gtk.ResponseType.Close); dlg.VBox.PackStart (scroll, true, true, 0); dlg.SetSizeRequest (300, 240); scroll.ShowAll (); dlg.Run (); dlg.Destroy (); }
void ShowErrorMessage() { DBusBackgroundWorker.Request(); DBusBackgroundWorker.InvokeGtkThread(() => { using (var dialog = new Gtk.Dialog()) { dialog.BorderWidth = 6; dialog.Resizable = false; dialog.HasSeparator = false; var message = "<span weight=\"bold\"size=\"larger\">" + "Could not register KeebuntuAppMenu with Unity panel service." + "</span>\n\n" + "This plugin only works with Ubuntu Unity desktop." + " If you do not use Unity, you should uninstall the KeebuntuAppMenu plugin." + "\n"; var label = new Gtk.Label(message); label.UseMarkup = true; label.Wrap = true; label.Yalign = 0; var icon = new Gtk.Image(Gtk.Stock.DialogError, Gtk.IconSize.Dialog); icon.Yalign = 0; var contentBox = new Gtk.HBox(); contentBox.Spacing = 12; contentBox.BorderWidth = 6; contentBox.PackStart(icon); contentBox.PackEnd(label); dialog.VBox.PackStart(contentBox); dialog.AddButton("Don't show this again", Gtk.ResponseType.Accept); dialog.AddButton("OK", Gtk.ResponseType.Ok); dialog.DefaultResponse = Gtk.ResponseType.Ok; dialog.Response += (o, args) => { dialog.Destroy(); if (args.ResponseId == Gtk.ResponseType.Accept) { pluginHost.CustomConfig.SetBool(keebuntuAppMenuWarningSeenId, true); } }; dialog.ShowAll(); dialog.KeepAbove = true; dialog.Run(); } }).Wait(); DBusBackgroundWorker.Release(); }
static void ShowMessage(Gtk.Window parent, string title, string message) { Gtk.Dialog dialog = null; try { dialog = new Gtk.Dialog(title, parent, Gtk.DialogFlags.DestroyWithParent | Gtk.DialogFlags.Modal, Gtk.ResponseType.Ok); dialog.VBox.Add(new Gtk.Label(message)); dialog.ShowAll(); dialog.Run(); } finally { if (dialog != null) { dialog.Destroy(); } } }
private void OnViewBoxes() { var dlg = new Gtk.Dialog("Boxes", this, Gtk.DialogFlags.Modal); var hbBox1 = new Gtk.HBox(false, 5) { new Gtk.Label("This is hbox 1") }; var hbBox2 = new Gtk.HBox(false, 5) { new Gtk.Label("This is hbox 2") }; var hbBox3 = new Gtk.HBox(false, 5) { new Gtk.Label("This is hbox 3") }; dlg.VBox.PackStart(hbBox1, true, true, 5); dlg.VBox.PackStart(hbBox2, true, true, 5); dlg.VBox.PackStart(hbBox3, true, true, 5); dlg.SetGeometryHints( dlg, new Gdk.Geometry() { MinHeight = 200, MinWidth = 320 }, Gdk.WindowHints.MinSize ); dlg.AddButton("Ok", Gtk.ResponseType.Ok); dlg.ShowAll(); dlg.Run(); dlg.Destroy(); }
private void OnViewFrames() { var dlg = new Gtk.Dialog("Frames", this, Gtk.DialogFlags.Modal); var frame1 = new Gtk.Frame("<b>Frame1</b>"); ((Gtk.Label)frame1.LabelWidget).UseMarkup = true; frame1.Add(new Gtk.Label("This is frame1")); var frame2 = new Gtk.Frame("<b>Frame2</b>"); ((Gtk.Label)frame2.LabelWidget).UseMarkup = true; frame2.Add(new Gtk.Label("This is frame2")); var frame3 = new Gtk.Frame("<b>Frame3</b>"); ((Gtk.Label)frame3.LabelWidget).UseMarkup = true; frame3.Add(new Gtk.Label("This is frame3")); dlg.VBox.PackStart(frame1, true, true, 5); dlg.VBox.PackStart(frame2, true, true, 5); dlg.VBox.PackStart(frame3, true, true, 5); dlg.SetGeometryHints( dlg, new Gdk.Geometry() { MinHeight = 200, MinWidth = 320 }, Gdk.WindowHints.MinSize ); dlg.AddButton("Ok", Gtk.ResponseType.Ok); dlg.ShowAll(); dlg.Run(); dlg.Destroy(); }
private void OnViewNotebook() { var dlg = new Gtk.Dialog( "Boxes", this, Gtk.DialogFlags.Modal ); var nbTabs = new Gtk.Notebook(); nbTabs.AppendPage( new Gtk.Label( "Page1" ), new Gtk.Label( "Page1" ) ); nbTabs.AppendPage( new Gtk.Label( "Page2" ), new Gtk.Label( "Page2" ) ); dlg.VBox.PackStart( nbTabs, true, true, 5 ); dlg.SetGeometryHints( dlg, new Gdk.Geometry() { MinHeight = 200, MinWidth = 320 }, Gdk.WindowHints.MinSize ); dlg.AddButton( "Ok", Gtk.ResponseType.Ok ); dlg.ShowAll(); dlg.Run(); dlg.Destroy(); }
private void OnViewFrames() { var dlg = new Gtk.Dialog( "Frames", this, Gtk.DialogFlags.Modal ); var frame1 = new Gtk.Frame( "<b>Frame1</b>" ); ( (Gtk.Label) frame1.LabelWidget ).UseMarkup = true; frame1.Add( new Gtk.Label( "This is frame1" ) ); var frame2 = new Gtk.Frame( "<b>Frame2</b>" ); ( (Gtk.Label) frame2.LabelWidget ).UseMarkup = true; frame2.Add( new Gtk.Label( "This is frame2" ) ); var frame3 = new Gtk.Frame( "<b>Frame3</b>" ); ( (Gtk.Label) frame3.LabelWidget ).UseMarkup = true; frame3.Add( new Gtk.Label( "This is frame3" ) ); dlg.VBox.PackStart( frame1, true, true, 5 ); dlg.VBox.PackStart( frame2, true, true, 5 ); dlg.VBox.PackStart( frame3, true, true, 5 ); dlg.SetGeometryHints( dlg, new Gdk.Geometry() { MinHeight = 200, MinWidth = 320 }, Gdk.WindowHints.MinSize ); dlg.AddButton( "Ok", Gtk.ResponseType.Ok ); dlg.ShowAll(); dlg.Run(); dlg.Destroy(); }
private void OnAdvancedSyncConfigButton (object sender, EventArgs args) { // Get saved behavior SyncTitleConflictResolution savedBehavior = SyncTitleConflictResolution.Cancel; object dlgBehaviorPref = Preferences.Get (Preferences.SYNC_CONFIGURED_CONFLICT_BEHAVIOR); if (dlgBehaviorPref != null && dlgBehaviorPref is int) // TODO: Check range of this int savedBehavior = (SyncTitleConflictResolution)dlgBehaviorPref; // Create dialog Gtk.Dialog advancedDlg = new Gtk.Dialog (Catalog.GetString ("Other Synchronization Options"), this, Gtk.DialogFlags.DestroyWithParent | Gtk.DialogFlags.Modal | Gtk.DialogFlags.NoSeparator, Gtk.Stock.Close, Gtk.ResponseType.Close); // Populate dialog Gtk.Label label = new Gtk.Label (Catalog.GetString ("When a conflict is detected between " + "a local note and a note on the configured " + "synchronization server:")); label.Wrap = true; label.Xalign = 0; promptOnConflictRadio = new Gtk.RadioButton (Catalog.GetString ("Always ask me what to do.")); promptOnConflictRadio.Toggled += OnConflictOptionToggle; renameOnConflictRadio = new Gtk.RadioButton (promptOnConflictRadio, Catalog.GetString ("Rename my local note.")); renameOnConflictRadio.Toggled += OnConflictOptionToggle; overwriteOnConflictRadio = new Gtk.RadioButton (promptOnConflictRadio, Catalog.GetString ("Replace my local note with the server's update.")); overwriteOnConflictRadio.Toggled += OnConflictOptionToggle; switch (savedBehavior) { case SyncTitleConflictResolution.RenameExistingNoUpdate: renameOnConflictRadio.Active = true; break; case SyncTitleConflictResolution.OverwriteExisting: overwriteOnConflictRadio.Active = true; break; default: promptOnConflictRadio.Active = true; break; } Gtk.VBox vbox = new Gtk.VBox (); vbox.BorderWidth = 18; vbox.PackStart (promptOnConflictRadio); vbox.PackStart (renameOnConflictRadio); vbox.PackStart (overwriteOnConflictRadio); advancedDlg.VBox.PackStart (label, false, false, 6); advancedDlg.VBox.PackStart (vbox, false, false, 0); advancedDlg.ShowAll (); // Run dialog advancedDlg.Run (); advancedDlg.Destroy (); }
public int Run() { dialog.ShowAll(); dialog.TransientFor = parent; return(dialog.Run()); }
private bool DoGetDecision() { GtkBeans.Builder builder = new GtkBeans.Builder ( Assembly.GetExecutingAssembly (), "TrustError.ui", null); builder.Autoconnect (this); dialog = (Gtk.Dialog) builder.GetObject (DialogName); url_label.Markup = String.Format ( url_label.Text, String.Format ( "<b>{0}</b>", request.RequestUri)); Gtk.ResponseType response = (Gtk.ResponseType) dialog.Run (); Log.Debug ("Decision dialog response: " + response); dialog.Destroy (); decision = Decision.DontTrust; if (0 == response) { if (abort_radiobutton.Active) { decision = Decision.DontTrust; } else if (once_radiobutton.Active) { decision = Decision.TrustOnce; } else if (always_radiobutton.Active) { decision = Decision.TrustAlways; } else { Debug.Assert (false, "Unhandled decision"); } } decision_event.Set (); return false; }
void ShowImage(Pixbuf img, string title) { if(DiagnosticMode) { Gtk.Dialog Win = new Gtk.Dialog(title, parent, Gtk.DialogFlags.Modal, Gtk.ButtonsType.Ok); Gtk.Image Image = new Gtk.Image(img); Win.VBox.Add(Image); Win.ShowAll(); Win.Run(); Image.Pixbuf = null; Win.Destroy(); } logger.Info(title); }
void GtkDBusInit() { /* setup ApplicationMenu */ dbusMenu = new MenuStripDBusMenu(pluginHost.MainWindow.MainMenu); emptyDBusMenu = new MenuStripDBusMenu(new MenuStrip()); var sessionBus = Bus.Session; #if DEBUG const string dbusBusPath = "/org/freedesktop/DBus"; const string dbusBusName = "org.freedesktop.DBus"; var dbusObjectPath = new ObjectPath(dbusBusPath); var dbusService = sessionBus.GetObject <org.freedesktop.DBus.IBus>(dbusBusName, dbusObjectPath); dbusService.NameAcquired += (name) => Console.WriteLine("NameAcquired: " + name); #endif const string registrarBusPath = "/com/canonical/AppMenu/Registrar"; const string registratBusName = "com.canonical.AppMenu.Registrar"; var registrarObjectPath = new ObjectPath(registrarBusPath); unityPanelServiceBus = sessionBus.GetObject <com.canonical.AppMenu.Registrar.IRegistrar>(registratBusName, registrarObjectPath); mainFormXid = GetWindowXid(pluginHost.MainWindow); mainFormObjectPath = new ObjectPath(string.Format(menuPath, mainFormXid)); sessionBus.Register(mainFormObjectPath, dbusMenu); try { unityPanelServiceBus.RegisterWindow((uint)mainFormXid.ToInt32(), mainFormObjectPath); gtkInitOk = true; gtkInitDoneEvent.Set(); } catch (Exception) { gtkInitDoneEvent.Set(); if (!pluginHost.CustomConfig.GetBool(keebuntuAppMenuWarningSeenId, false)) { using (var dialog = new Gtk.Dialog()) { dialog.BorderWidth = 6; dialog.Resizable = false; dialog.HasSeparator = false; var message = "<span weight=\"bold\"size=\"larger\">" + "Could not register KeebuntuAppMenu with Unity panel service." + "</span>\n\n" + "This plugin only works with Ubuntu Unity desktop." + " If you do not use Unity, you should uninstall the KeebuntuAppMenu plugin." + "\n"; var label = new Gtk.Label(message); label.UseMarkup = true; label.Wrap = true; label.Yalign = 0; var icon = new Gtk.Image(Gtk.Stock.DialogError, Gtk.IconSize.Dialog); icon.Yalign = 0; var contentBox = new Gtk.HBox(); contentBox.Spacing = 12; contentBox.BorderWidth = 6; contentBox.PackStart(icon); contentBox.PackEnd(label); dialog.VBox.PackStart(contentBox); dialog.AddButton("Don't show this again", Gtk.ResponseType.Accept); dialog.AddButton("OK", Gtk.ResponseType.Ok); dialog.DefaultResponse = Gtk.ResponseType.Ok; dialog.Response += (o, args) => { dialog.Destroy(); if (args.ResponseId == Gtk.ResponseType.Accept) { pluginHost.CustomConfig.SetBool(keebuntuAppMenuWarningSeenId, true); } }; dialog.ShowAll(); dialog.KeepAbove = true; dialog.Run(); } DBusBackgroundWorker.Stop(); } } }
public int Run() { return(dialog.Run()); }
private bool DoGetDecision () { Glade.XML glade_xml = new Glade.XML ( null, "TrustError.glade", DialogName, "f-spot"); glade_xml.Autoconnect (this); dialog = (Gtk.Dialog) glade_xml.GetWidget (DialogName); url_label.Markup = String.Format ( url_label.Text, String.Format ( "<b>{0}</b>", request.RequestUri)); Gtk.ResponseType response = (Gtk.ResponseType) dialog.Run (); Log.DebugFormat ("Decision dialog response: " + response); dialog.Destroy (); decision = Decision.DontTrust; if (0 == response) { if (abort_radiobutton.Active) { decision = Decision.DontTrust; } else if (once_radiobutton.Active) { decision = Decision.TrustOnce; } else if (always_radiobutton.Active) { decision = Decision.TrustAlways; } else { Debug.Assert (false, "Unhandled decision"); } } decision_event.Set (); return false; }