Browse Source
Merge pull request #3711 from AvaloniaUI/fix-gtk-initial-name
Fixed InitialFileName for GTK-based file dialog
pull/3741/head
danwalmsley
7 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
7 additions and
3 deletions
-
samples/ControlCatalog/Pages/DialogsPage.xaml.cs
-
src/Avalonia.X11/NativeDialogs/Gtk.cs
-
src/Avalonia.X11/NativeDialogs/GtkNativeFileDialogs.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 |
|
|
|
|
|
|
|
@ -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(); |
|
|
|
|
|
|
|
|
|
|
|
@ -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; |
|
|
|
} |
|
|
|
|