From bf2a363ef61f0600fa34b4a9fd51651f2de743e5 Mon Sep 17 00:00:00 2001 From: Matthijs ter Woord Date: Sat, 1 Jul 2017 15:28:31 +0200 Subject: [PATCH 1/3] Update from-wpf.md Small typo in sample. --- docs/tutorial/from-wpf.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tutorial/from-wpf.md b/docs/tutorial/from-wpf.md index aa7a9bc13a..2db40cfd86 100644 --- a/docs/tutorial/from-wpf.md +++ b/docs/tutorial/from-wpf.md @@ -33,7 +33,7 @@ placed in a `DataTemplates` collection on each control (and on `Application`): - + From 6ea0635c7faa33a01816a5835ade423d6fb9e058 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Wed, 5 Jul 2017 19:19:44 +0300 Subject: [PATCH 2/3] [GTK3] Workaround for SafeHandle not allowed to be null --- src/Gtk/Avalonia.Gtk3/Interop/GObject.cs | 2 +- src/Gtk/Avalonia.Gtk3/SystemDialogs.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Gtk/Avalonia.Gtk3/Interop/GObject.cs b/src/Gtk/Avalonia.Gtk3/Interop/GObject.cs index 9ead1d2cb3..9766e8ca36 100644 --- a/src/Gtk/Avalonia.Gtk3/Interop/GObject.cs +++ b/src/Gtk/Avalonia.Gtk3/Interop/GObject.cs @@ -41,7 +41,7 @@ namespace Avalonia.Gtk3.Interop class GtkWindow : GtkWidget { - + public static GtkWindow Null { get; } = new GtkWindow(); } class GtkImContext : GObject diff --git a/src/Gtk/Avalonia.Gtk3/SystemDialogs.cs b/src/Gtk/Avalonia.Gtk3/SystemDialogs.cs index f6232ac68e..6543b4f23c 100644 --- a/src/Gtk/Avalonia.Gtk3/SystemDialogs.cs +++ b/src/Gtk/Avalonia.Gtk3/SystemDialogs.cs @@ -78,14 +78,14 @@ namespace Avalonia.Gtk3 public Task ShowFileDialogAsync(FileDialog dialog, IWindowImpl parent) { - return ShowDialog(dialog.Title, ((WindowBaseImpl) parent)?.GtkWidget, + return ShowDialog(dialog.Title, ((WindowBaseImpl) parent)?.GtkWidget ?? GtkWindow.Null, dialog is OpenFileDialog ? GtkFileChooserAction.Open : GtkFileChooserAction.Save, (dialog as OpenFileDialog)?.AllowMultiple ?? false, dialog.InitialFileName); } public async Task ShowFolderDialogAsync(OpenFolderDialog dialog, IWindowImpl parent) { - var res = await ShowDialog(dialog.Title, ((WindowBaseImpl) parent)?.GtkWidget, + var res = await ShowDialog(dialog.Title, ((WindowBaseImpl) parent)?.GtkWidget ?? GtkWindow.Null, GtkFileChooserAction.SelectFolder, false, dialog.InitialDirectory); return res?.FirstOrDefault(); } From 85f29305572917202ac75df7b1e058347a0308a5 Mon Sep 17 00:00:00 2001 From: Nikita Tsukanov Date: Wed, 5 Jul 2017 21:20:16 +0300 Subject: [PATCH 3/3] [GTK3] More changes to workaround SafeHandle not being allowed to be null --- src/Gtk/Avalonia.Gtk3/Interop/Utf8Buffer.cs | 2 ++ src/Gtk/Avalonia.Gtk3/SystemDialogs.cs | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Gtk/Avalonia.Gtk3/Interop/Utf8Buffer.cs b/src/Gtk/Avalonia.Gtk3/Interop/Utf8Buffer.cs index f108c291b8..fc76fefd1a 100644 --- a/src/Gtk/Avalonia.Gtk3/Interop/Utf8Buffer.cs +++ b/src/Gtk/Avalonia.Gtk3/Interop/Utf8Buffer.cs @@ -11,6 +11,8 @@ namespace Avalonia.Gtk3.Interop public Utf8Buffer(string s) : base(IntPtr.Zero, true) { + if (s == null) + return; _data = Encoding.UTF8.GetBytes(s); _gchandle = GCHandle.Alloc(_data, GCHandleType.Pinned); handle = _gchandle.AddrOfPinnedObject(); diff --git a/src/Gtk/Avalonia.Gtk3/SystemDialogs.cs b/src/Gtk/Avalonia.Gtk3/SystemDialogs.cs index 6543b4f23c..fb8af02d5d 100644 --- a/src/Gtk/Avalonia.Gtk3/SystemDialogs.cs +++ b/src/Gtk/Avalonia.Gtk3/SystemDialogs.cs @@ -18,7 +18,8 @@ namespace Avalonia.Gtk3 bool multiselect, string initialFileName) { GtkFileChooser dlg; - using (var name = title != null ? new Utf8Buffer(title) : null) + parent = parent ?? GtkWindow.Null; + using (var name = new Utf8Buffer(title)) dlg = Native.GtkFileChooserDialogNew(name, parent, action, IntPtr.Zero); if (multiselect) Native.GtkFileChooserSetSelectMultiple(dlg, true); @@ -78,14 +79,14 @@ namespace Avalonia.Gtk3 public Task ShowFileDialogAsync(FileDialog dialog, IWindowImpl parent) { - return ShowDialog(dialog.Title, ((WindowBaseImpl) parent)?.GtkWidget ?? GtkWindow.Null, + return ShowDialog(dialog.Title, ((WindowBaseImpl) parent)?.GtkWidget, dialog is OpenFileDialog ? GtkFileChooserAction.Open : GtkFileChooserAction.Save, (dialog as OpenFileDialog)?.AllowMultiple ?? false, dialog.InitialFileName); } public async Task ShowFolderDialogAsync(OpenFolderDialog dialog, IWindowImpl parent) { - var res = await ShowDialog(dialog.Title, ((WindowBaseImpl) parent)?.GtkWidget ?? GtkWindow.Null, + var res = await ShowDialog(dialog.Title, ((WindowBaseImpl) parent)?.GtkWidget, GtkFileChooserAction.SelectFolder, false, dialog.InitialDirectory); return res?.FirstOrDefault(); }