Ryujinx-GtkSharp/gtk/FileChooserDialog.custom

37 lines
1.4 KiB
Plaintext
Raw Normal View History

[DllImport("libgtk-win32-2.0-0.dll")]
static extern IntPtr gtk_file_chooser_dialog_new(string title, IntPtr parent, int action, IntPtr nil);
public FileChooserDialog (string title, Window parent, FileChooserAction action)
{
Raw = gtk_file_chooser_dialog_new (title, parent == null ? IntPtr.Zero : parent.Handle, (int)action, IntPtr.Zero);
}
[DllImport("libgtk-win32-2.0-0.dll")]
static extern IntPtr gtk_file_chooser_dialog_new_with_backend(string title, IntPtr parent, int action, string backend, IntPtr nil);
public FileChooserDialog (string title, Window parent, FileChooserAction action, string backend)
{
Raw = gtk_file_chooser_dialog_new_with_backend (title, parent == null ? IntPtr.Zero : parent.Handle, (int)action, backend, IntPtr.Zero);
}
[DllImport ("libgtk-win32-2.0-0.dll")]
static extern IntPtr gtk_file_chooser_get_filenames (IntPtr raw);
[DllImport("libglib-2.0-0.dll")]
static extern void g_strfreev (IntPtr handle);
public string[] Filenames {
get {
IntPtr strv = gtk_file_chooser_get_filenames (Handle);
System.Collections.ArrayList result = new System.Collections.ArrayList ();
int i = 0;
IntPtr strptr = Marshal.ReadIntPtr (strv, IntPtr.Size * i++);
while (strptr != IntPtr.Zero) {
result.Add (Marshal.PtrToStringAnsi (strptr));
strptr = Marshal.ReadIntPtr (strv, IntPtr.Size * i++);
}
g_strfreev (strv);
return result.ToArray (typeof (string)) as string[];
}
}