mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2024-12-23 02:05:29 +00:00
Merge pull request #179 from hol430/filechoosernative
Fixed FileChooserNative
This commit is contained in:
commit
cb38e52242
|
@ -18,14 +18,18 @@
|
||||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
// Boston, MA 02111-1307, USA.
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
namespace Gtk {
|
namespace Gtk {
|
||||||
|
using GLib;
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
public partial class FileChooserNative : Gtk.NativeDialog, Gtk.IFileChooser {
|
public partial class FileChooserNative : Gtk.NativeDialog, Gtk.IFileChooser {
|
||||||
|
private FileChooserAdapter fileChooser;
|
||||||
|
|
||||||
public FileChooserNative (IntPtr raw) : base(raw) {}
|
public FileChooserNative (IntPtr raw) : base(raw)
|
||||||
|
{
|
||||||
|
fileChooser = new FileChooserAdapter(raw);
|
||||||
|
}
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
delegate IntPtr d_gtk_file_chooser_native_new(IntPtr title, IntPtr parent, int action, IntPtr accept_label, IntPtr cancel_label);
|
delegate IntPtr d_gtk_file_chooser_native_new(IntPtr title, IntPtr parent, int action, IntPtr accept_label, IntPtr cancel_label);
|
||||||
static d_gtk_file_chooser_native_new gtk_file_chooser_native_new = FuncLoader.LoadFunction<d_gtk_file_chooser_native_new>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_file_chooser_native_new"));
|
static d_gtk_file_chooser_native_new gtk_file_chooser_native_new = FuncLoader.LoadFunction<d_gtk_file_chooser_native_new>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_file_chooser_native_new"));
|
||||||
|
@ -40,10 +44,54 @@ namespace Gtk {
|
||||||
static d_gtk_file_chooser_native_get_cancel_label gtk_file_chooser_native_get_cancel_label = FuncLoader.LoadFunction<d_gtk_file_chooser_native_get_cancel_label>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_file_chooser_native_get_cancel_label"));
|
static d_gtk_file_chooser_native_get_cancel_label gtk_file_chooser_native_get_cancel_label = FuncLoader.LoadFunction<d_gtk_file_chooser_native_get_cancel_label>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_file_chooser_native_get_cancel_label"));
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
delegate string d_gtk_file_chooser_native_set_cancel_label(IntPtr self, string cancel_label);
|
delegate string d_gtk_file_chooser_native_set_cancel_label(IntPtr self, string cancel_label);
|
||||||
static d_gtk_file_chooser_native_set_cancel_label gtk_file_chooser_native_set_cancel_label = FuncLoader.LoadFunction<d_gtk_file_chooser_native_set_cancel_label>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_file_chooser_native_set_cancel_label"));
|
static d_gtk_file_chooser_native_set_cancel_label gtk_file_chooser_native_set_cancel_label = FuncLoader.LoadFunction<d_gtk_file_chooser_native_set_cancel_label>(FuncLoader.GetProcAddress(GLibrary.Load(Library.Gtk), "gtk_file_chooser_native_set_cancel_label"));
|
||||||
|
|
||||||
public FileChooserNative (string title, Gtk.Window parent, Gtk.FileChooserAction action, string accept_label, string cancel_label) : base(FileChooserNativeCreate(title, parent, action, accept_label, cancel_label))
|
public string CurrentFolder => fileChooser.CurrentFolder;
|
||||||
{
|
|
||||||
|
public IFile CurrentFolderFile => fileChooser.CurrentFolderFile;
|
||||||
|
|
||||||
|
public string CurrentFolderUri => fileChooser.CurrentFolderUri;
|
||||||
|
|
||||||
|
public string CurrentName { get => fileChooser.CurrentName; set => fileChooser.CurrentName = value; }
|
||||||
|
|
||||||
|
public IFile File => fileChooser.File;
|
||||||
|
|
||||||
|
public string Filename => fileChooser.Filename;
|
||||||
|
|
||||||
|
public string[] Filenames => fileChooser.Filenames;
|
||||||
|
|
||||||
|
public IFile[] Files => fileChooser.Files;
|
||||||
|
|
||||||
|
public IFile PreviewFile => fileChooser.PreviewFile;
|
||||||
|
|
||||||
|
public string PreviewFilename => fileChooser.PreviewFilename;
|
||||||
|
|
||||||
|
public string PreviewUri => fileChooser.PreviewUri;
|
||||||
|
|
||||||
|
public string Uri => fileChooser.Uri;
|
||||||
|
|
||||||
|
public string[] Uris => fileChooser.Uris;
|
||||||
|
|
||||||
|
public FileFilter[] Filters => fileChooser.Filters;
|
||||||
|
|
||||||
|
public string[] ShortcutFolderUris => fileChooser.ShortcutFolderUris;
|
||||||
|
|
||||||
|
public string[] ShortcutFolders => fileChooser.ShortcutFolders;
|
||||||
|
|
||||||
|
public FileChooserAction Action { get => fileChooser.Action; set => fileChooser.Action = value; }
|
||||||
|
public FileFilter Filter { get => fileChooser.Filter; set => fileChooser.Filter = value; }
|
||||||
|
public bool LocalOnly { get => fileChooser.LocalOnly; set => fileChooser.LocalOnly = value; }
|
||||||
|
public Widget PreviewWidget { get => fileChooser.PreviewWidget; set => fileChooser.PreviewWidget = value; }
|
||||||
|
public bool PreviewWidgetActive { get => fileChooser.PreviewWidgetActive; set => fileChooser.PreviewWidgetActive = value; }
|
||||||
|
public bool UsePreviewLabel { get => fileChooser.UsePreviewLabel; set => fileChooser.UsePreviewLabel = value; }
|
||||||
|
public Widget ExtraWidget { get => fileChooser.ExtraWidget; set => fileChooser.ExtraWidget = value; }
|
||||||
|
public bool SelectMultiple { get => fileChooser.SelectMultiple; set => fileChooser.SelectMultiple = value; }
|
||||||
|
public bool ShowHidden { get => fileChooser.ShowHidden; set => fileChooser.ShowHidden = value; }
|
||||||
|
public bool DoOverwriteConfirmation { get => fileChooser.DoOverwriteConfirmation; set => fileChooser.DoOverwriteConfirmation = value; }
|
||||||
|
public bool CreateFolders { get => fileChooser.CreateFolders; set => fileChooser.CreateFolders = value; }
|
||||||
|
|
||||||
|
public FileChooserNative (string title, Gtk.Window parent, Gtk.FileChooserAction action, string accept_label, string cancel_label) : base(FileChooserNativeCreate(title, parent, action, accept_label, cancel_label))
|
||||||
|
{
|
||||||
/*
|
/*
|
||||||
if (GetType () != typeof (FileChooserNative)) {
|
if (GetType () != typeof (FileChooserNative)) {
|
||||||
var vals = new List<GLib.Value> ();
|
var vals = new List<GLib.Value> ();
|
||||||
|
@ -61,9 +109,75 @@ namespace Gtk {
|
||||||
CreateNativeObject (names.ToArray (), vals.ToArray ());
|
CreateNativeObject (names.ToArray (), vals.ToArray ());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
}
|
fileChooser = new FileChooserAdapter(Handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
public event EventHandler FileActivated
|
||||||
|
{
|
||||||
|
add
|
||||||
|
{
|
||||||
|
fileChooser.FileActivated += value;
|
||||||
|
}
|
||||||
|
|
||||||
|
remove
|
||||||
|
{
|
||||||
|
fileChooser.FileActivated -= value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public event EventHandler SelectionChanged
|
||||||
|
{
|
||||||
|
add
|
||||||
|
{
|
||||||
|
fileChooser.SelectionChanged += value;
|
||||||
|
}
|
||||||
|
|
||||||
|
remove
|
||||||
|
{
|
||||||
|
fileChooser.SelectionChanged -= value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public event EventHandler CurrentFolderChanged
|
||||||
|
{
|
||||||
|
add
|
||||||
|
{
|
||||||
|
fileChooser.CurrentFolderChanged += value;
|
||||||
|
}
|
||||||
|
|
||||||
|
remove
|
||||||
|
{
|
||||||
|
fileChooser.CurrentFolderChanged -= value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public event ConfirmOverwriteHandler ConfirmOverwrite
|
||||||
|
{
|
||||||
|
add
|
||||||
|
{
|
||||||
|
fileChooser.ConfirmOverwrite += value;
|
||||||
|
}
|
||||||
|
|
||||||
|
remove
|
||||||
|
{
|
||||||
|
fileChooser.ConfirmOverwrite -= value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public event EventHandler UpdatePreview
|
||||||
|
{
|
||||||
|
add
|
||||||
|
{
|
||||||
|
fileChooser.UpdatePreview += value;
|
||||||
|
}
|
||||||
|
|
||||||
|
remove
|
||||||
|
{
|
||||||
|
fileChooser.UpdatePreview -= value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static IntPtr FileChooserNativeCreate (string title, Gtk.Window parent, Gtk.FileChooserAction action, string accept_label, string cancel_label)
|
static IntPtr FileChooserNativeCreate (string title, Gtk.Window parent, Gtk.FileChooserAction action, string accept_label, string cancel_label)
|
||||||
{
|
{
|
||||||
IntPtr native_title = GLib.Marshaller.StringToPtrGStrdup (title);
|
IntPtr native_title = GLib.Marshaller.StringToPtrGStrdup (title);
|
||||||
|
@ -83,7 +197,127 @@ namespace Gtk {
|
||||||
GLib.Marshaller.Free (native_cancel_label);*/
|
GLib.Marshaller.Free (native_cancel_label);*/
|
||||||
|
|
||||||
return raw;
|
return raw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void AddChoice(string id, string label, string options, string option_labels)
|
||||||
|
{
|
||||||
|
fileChooser.AddChoice(id, label, options, option_labels);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddFilter(FileFilter filter)
|
||||||
|
{
|
||||||
|
fileChooser.AddFilter(filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool AddShortcutFolder(string folder)
|
||||||
|
{
|
||||||
|
return fileChooser.AddShortcutFolder(folder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool AddShortcutFolderUri(string uri)
|
||||||
|
{
|
||||||
|
return fileChooser.AddShortcutFolderUri(uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetChoice(string id)
|
||||||
|
{
|
||||||
|
return fileChooser.GetChoice(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveChoice(string id)
|
||||||
|
{
|
||||||
|
fileChooser.RemoveChoice(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveFilter(FileFilter filter)
|
||||||
|
{
|
||||||
|
fileChooser.RemoveFilter(filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool RemoveShortcutFolder(string folder)
|
||||||
|
{
|
||||||
|
return fileChooser.RemoveShortcutFolder(folder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool RemoveShortcutFolderUri(string uri)
|
||||||
|
{
|
||||||
|
return fileChooser.RemoveShortcutFolderUri(uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SelectAll()
|
||||||
|
{
|
||||||
|
fileChooser.SelectAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SelectFile(IFile file)
|
||||||
|
{
|
||||||
|
return fileChooser.SelectFile(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SelectFilename(string filename)
|
||||||
|
{
|
||||||
|
return fileChooser.SelectFilename(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SelectUri(string uri)
|
||||||
|
{
|
||||||
|
return fileChooser.SelectUri(uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetChoice(string id, string option)
|
||||||
|
{
|
||||||
|
fileChooser.SetChoice(id, option);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SetCurrentFolder(string filename)
|
||||||
|
{
|
||||||
|
return fileChooser.SetCurrentFolder(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SetCurrentFolderFile(IFile file)
|
||||||
|
{
|
||||||
|
return fileChooser.SetCurrentFolderFile(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SetCurrentFolderUri(string uri)
|
||||||
|
{
|
||||||
|
return fileChooser.SetCurrentFolderUri(uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SetFile(IFile file)
|
||||||
|
{
|
||||||
|
return fileChooser.SetFile(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SetFilename(string filename)
|
||||||
|
{
|
||||||
|
return fileChooser.SetFilename(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SetUri(string uri)
|
||||||
|
{
|
||||||
|
return fileChooser.SetUri(uri);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UnselectAll()
|
||||||
|
{
|
||||||
|
fileChooser.UnselectAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UnselectFile(IFile file)
|
||||||
|
{
|
||||||
|
fileChooser.UnselectFile(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UnselectFilename(string filename)
|
||||||
|
{
|
||||||
|
fileChooser.UnselectFilename(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UnselectUri(string uri)
|
||||||
|
{
|
||||||
|
fileChooser.UnselectUri(uri);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace Gtk {
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
public partial class NativeDialog : Gtk.FileChooserAdapter {
|
public partial class NativeDialog : GLib.Object {
|
||||||
|
|
||||||
public NativeDialog (IntPtr raw) : base(raw) { }
|
public NativeDialog (IntPtr raw) : base(raw) { }
|
||||||
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
|
||||||
|
|
Loading…
Reference in a new issue