mirror of
https://github.com/Ryujinx/GtkSharp.git
synced 2025-01-09 19:25:37 +00:00
Try to wrap NativeDialog for Windows
This commit is contained in:
parent
182aa7e702
commit
728c1f5aa7
88
gtk/FileChooserNative.cs
Executable file
88
gtk/FileChooserNative.cs
Executable file
|
@ -0,0 +1,88 @@
|
|||
// Gtk.FileChooserNative.cs - Gtk FileChooserNative class customizations
|
||||
//
|
||||
// Author: Mikkel Kruse Johnsen <mikkel@xmedicus.com>
|
||||
//
|
||||
// Copyright (c) 2016 XMedicus ApS
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of version 2 of the Lesser GNU General
|
||||
// Public License as published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
// Boston, MA 02111-1307, USA.
|
||||
|
||||
namespace Gtk {
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public partial class FileChooserNative : Gtk.NativeDialog, Gtk.IFileChooser {
|
||||
|
||||
public FileChooserNative (IntPtr raw) : base(raw) {}
|
||||
|
||||
[DllImport (Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr gtk_file_chooser_native_new(IntPtr title, IntPtr parent, int action, IntPtr accept_label, IntPtr cancel_label);
|
||||
|
||||
[DllImport (Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern string gtk_file_chooser_native_get_accept_label(IntPtr self);
|
||||
|
||||
[DllImport (Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern string gtk_file_chooser_native_set_accept_label(IntPtr self, string accept_label);
|
||||
|
||||
[DllImport (Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern string gtk_file_chooser_native_get_cancel_label(IntPtr self);
|
||||
|
||||
[DllImport (Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern string gtk_file_chooser_native_set_cancel_label(IntPtr self, string 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))
|
||||
{
|
||||
/*
|
||||
if (GetType () != typeof (FileChooserNative)) {
|
||||
var vals = new List<GLib.Value> ();
|
||||
var names = new List<string> ();
|
||||
names.Add ("title");
|
||||
vals.Add (new GLib.Value (title));
|
||||
names.Add ("parent");
|
||||
vals.Add (new GLib.Value (parent));
|
||||
names.Add ("action");
|
||||
vals.Add (new GLib.Value (action));
|
||||
names.Add ("accept_label");
|
||||
vals.Add (new GLib.Value (accept_label));
|
||||
names.Add ("cancel_label");
|
||||
vals.Add (new GLib.Value (cancel_label));
|
||||
CreateNativeObject (names.ToArray (), vals.ToArray ());
|
||||
return;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
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_accept_label = IntPtr.Zero;
|
||||
if (accept_label != null)
|
||||
native_accept_label = GLib.Marshaller.StringToPtrGStrdup (accept_label);
|
||||
IntPtr native_cancel_label = IntPtr.Zero;
|
||||
if (cancel_label != null)
|
||||
native_cancel_label = GLib.Marshaller.StringToPtrGStrdup (cancel_label);
|
||||
|
||||
IntPtr raw = gtk_file_chooser_native_new(native_title, parent.Handle, (int) action, native_accept_label, native_cancel_label);
|
||||
|
||||
/*GLib.Marshaller.Free (native_title);
|
||||
if (accept_label != null)
|
||||
GLib.Marshaller.Free (native_accept_label);
|
||||
if (cancel_label != null)
|
||||
GLib.Marshaller.Free (native_cancel_label);*/
|
||||
|
||||
return raw;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -43,6 +43,7 @@ sources = \
|
|||
Entry.cs \
|
||||
EntryCompletion.cs \
|
||||
FileChooserDialog.cs \
|
||||
FileChooserNative.cs \
|
||||
Frame.cs \
|
||||
Global.cs \
|
||||
HBox.cs \
|
||||
|
@ -63,6 +64,7 @@ sources = \
|
|||
Menu.cs \
|
||||
MenuItem.cs \
|
||||
MessageDialog.cs \
|
||||
NativeDialog.cs \
|
||||
NodeCellDataFunc.cs \
|
||||
NodeSelection.cs \
|
||||
NodeStore.cs \
|
||||
|
|
107
gtk/NativeDialog.cs
Executable file
107
gtk/NativeDialog.cs
Executable file
|
@ -0,0 +1,107 @@
|
|||
// Gtk.NativeDialog.cs - Gtk NativeDialog class customizations
|
||||
//
|
||||
// Author: Mikkel Kruse Johnsen <mikkel@xmedicus.com>
|
||||
//
|
||||
// Copyright (c) 2016 XMedicus ApS
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or
|
||||
// modify it under the terms of version 2 of the Lesser GNU General
|
||||
// Public License as published by the Free Software Foundation.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this program; if not, write to the
|
||||
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||
// Boston, MA 02111-1307, USA.
|
||||
|
||||
namespace Gtk {
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public partial class NativeDialog : Gtk.FileChooserAdapter {
|
||||
|
||||
public NativeDialog (IntPtr raw) : base(raw) { }
|
||||
|
||||
[DllImport (Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void gtk_native_dialog_show (IntPtr self);
|
||||
|
||||
public void Show ()
|
||||
{
|
||||
gtk_native_dialog_show (Handle);
|
||||
}
|
||||
|
||||
[DllImport (Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void gtk_native_dialog_hide (IntPtr self);
|
||||
|
||||
public void Hide ()
|
||||
{
|
||||
gtk_native_dialog_hide (Handle);
|
||||
}
|
||||
|
||||
[DllImport (Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void gtk_native_dialog_destroy (IntPtr self);
|
||||
|
||||
public void Destroy ()
|
||||
{
|
||||
gtk_native_dialog_destroy (Handle);
|
||||
}
|
||||
|
||||
[DllImport (Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern bool gtk_native_dialog_get_visible (IntPtr self);
|
||||
|
||||
public bool Visible {
|
||||
get {
|
||||
return gtk_native_dialog_get_visible (Handle);
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport (Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void gtk_native_dialog_set_modal (IntPtr self, bool modal);
|
||||
|
||||
[DllImport (Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern bool gtk_native_dialog_get_modal (IntPtr self);
|
||||
|
||||
public bool Modal {
|
||||
set {
|
||||
gtk_native_dialog_set_modal (Handle, value);
|
||||
}
|
||||
get {
|
||||
return gtk_native_dialog_get_modal (Handle);
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport (Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void gtk_native_dialog_set_title (IntPtr self, string title);
|
||||
|
||||
[DllImport (Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern string gtk_native_dialog_get_title (IntPtr self);
|
||||
|
||||
public string Title {
|
||||
set {
|
||||
gtk_native_dialog_set_title (Handle, value);
|
||||
}
|
||||
get {
|
||||
return gtk_native_dialog_get_title (Handle);
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport (Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern void gtk_native_dialog_set_transient_for (IntPtr self, IntPtr parent);
|
||||
|
||||
[DllImport (Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern IntPtr gtk_native_dialog_get_transient_for (IntPtr self);
|
||||
|
||||
[DllImport (Global.GtkNativeDll, CallingConvention = CallingConvention.Cdecl)]
|
||||
static extern int gtk_native_dialog_run (IntPtr self);
|
||||
|
||||
public int Run ()
|
||||
{
|
||||
return gtk_native_dialog_run (Handle);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue