Browse Source

Fixed InitialFileName for GTK-based file dialog

pull/3711/head
Nikita Tsukanov 6 years ago
parent
commit
bce28b3d35
  1. 5
      samples/ControlCatalog/Pages/DialogsPage.xaml.cs
  2. 3
      src/Avalonia.X11/NativeDialogs/Gtk.cs
  3. 2
      src/Avalonia.X11/NativeDialogs/GtkNativeFileDialogs.cs

5
samples/ControlCatalog/Pages/DialogsPage.xaml.cs

@ -42,14 +42,15 @@ namespace ControlCatalog.Pages
new SaveFileDialog()
{
Title = "Save file",
Filters = GetFilters()
Filters = GetFilters(),
InitialFileName = "test.txt"
}.ShowAsync(GetWindow());
};
this.FindControl<Button>("SelectFolder").Click += delegate
{
new OpenFolderDialog()
{
Title = "Select folder"
Title = "Select folder",
}.ShowAsync(GetWindow());
};
this.FindControl<Button>("DecoratedWindow").Click += delegate

3
src/Avalonia.X11/NativeDialogs/Gtk.cs

@ -190,6 +190,9 @@ namespace Avalonia.X11.NativeDialogs
[DllImport(GtkName)]
public static extern void gtk_file_chooser_set_filename(IntPtr chooser, Utf8Buffer file);
[DllImport(GtkName)]
public static extern void gtk_file_chooser_set_current_name(IntPtr chooser, Utf8Buffer file);
[DllImport(GtkName)]
public static extern IntPtr gtk_file_filter_new();

2
src/Avalonia.X11/NativeDialogs/GtkNativeFileDialogs.cs

@ -91,7 +91,7 @@ namespace Avalonia.X11.NativeDialogs
gtk_dialog_add_button(dlg, open, GtkResponseType.Cancel);
if (initialFileName != null)
using (var fn = new Utf8Buffer(initialFileName))
gtk_file_chooser_set_filename(dlg, fn);
gtk_file_chooser_set_current_name(dlg, fn);
gtk_window_present(dlg);
return tcs.Task;
}

Loading…
Cancel
Save