mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-22 19:45:34 +00:00
Add FileChooserDialog to samples app
This shows the original issue on macOS/arm64 (if the rest of the PR is not applied) ``` GLib.GException: Invalid byte sequence in conversion input at GLib.Marshaller.FilenamePtrToString(IntPtr ptr) in /Users/poupou/git/external/GtkSharp/Source/Libs/GLibSharp/Marshaller.cs:line 62 at GLib.Marshaller.FilenamePtrToStringGFree(IntPtr ptr) in /Users/poupou/git/external/GtkSharp/Source/Libs/GLibSharp/Marshaller.cs:line 68 at Gtk.FileChooserDialog.get_Filename() in /Users/poupou/git/external/GtkSharp/Source/Libs/GtkSharp/Generated/Gtk/FileChooserDialog.cs:line 222 at Samples.FileChooserDialogDemo.OnPressed() in /Users/poupou/git/external/GtkSharp/Source/Samples/Sections/Dialogs/FileChooserDialogSection.cs:line 28 at Gtk.Button.Pressed_cb(IntPtr inst) in /Users/poupou/git/external/GtkSharp/Source/Libs/GtkSharp/Generated/Gtk/Button.cs:line 388 at GLib.ExceptionManager.RaiseUnhandledException(Exception e, Boolean is_terminal) in /Users/poupou/git/external/GtkSharp/Source/Libs/GLibSharp/ExceptionManager.cs:line 58 at Gtk.Button.Pressed_cb(IntPtr inst) in /Users/poupou/git/external/GtkSharp/Source/Libs/GtkSharp/Generated/Gtk/Button.cs:line 388 at Gtk.Application.Run() in /Users/poupou/git/external/GtkSharp/Source/Libs/GtkSharp/Application.cs:line 115 at Samples.Program.Main(String[] args) in /Users/poupou/git/external/GtkSharp/Source/Samples/Program.cs:line 44 ```
This commit is contained in:
parent
7391aac88d
commit
fd3eb0c839
32
Source/Samples/Sections/Dialogs/FileChooserDialogSection.cs
Normal file
32
Source/Samples/Sections/Dialogs/FileChooserDialogSection.cs
Normal file
|
@ -0,0 +1,32 @@
|
|||
using Gtk;
|
||||
|
||||
namespace Samples
|
||||
{
|
||||
[Section(ContentType = typeof(FileChooserDialog), Category = Category.Dialogs)]
|
||||
class FileChooserDialogSection : ListSection
|
||||
{
|
||||
public FileChooserDialogSection ()
|
||||
{
|
||||
AddItem ($"Press button to open {nameof(FileChooserDialog)} :", new FileChooserDialogDemo ("Press me"));
|
||||
}
|
||||
}
|
||||
|
||||
class FileChooserDialogDemo : Button
|
||||
{
|
||||
public FileChooserDialogDemo (string text) : base (text) { }
|
||||
|
||||
protected override void OnPressed ()
|
||||
{
|
||||
var fcd = new FileChooserDialog ("Open File", null, FileChooserAction.Open);
|
||||
fcd.AddButton (Stock.Cancel, ResponseType.Cancel);
|
||||
fcd.AddButton (Stock.Open, ResponseType.Ok);
|
||||
fcd.DefaultResponse = ResponseType.Ok;
|
||||
fcd.SelectMultiple = false;
|
||||
|
||||
ResponseType response = (ResponseType) fcd.Run ();
|
||||
if (response == ResponseType.Ok)
|
||||
ApplicationOutput.WriteLine (fcd.Filename);
|
||||
fcd.Destroy ();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue