gtk: Re-indent code that was moved inside partial classes
No real code change in this commit, just whitespace changes.
This commit is contained in:
parent
a410d42975
commit
a8e1e8fd7d
29 changed files with 1460 additions and 1459 deletions
|
@ -19,12 +19,12 @@ namespace Gtk {
|
||||||
|
|
||||||
public partial struct AccelKey {
|
public partial struct AccelKey {
|
||||||
|
|
||||||
public AccelKey (Gdk.Key key, Gdk.ModifierType mods, Gtk.AccelFlags flags)
|
public AccelKey (Gdk.Key key, Gdk.ModifierType mods, Gtk.AccelFlags flags)
|
||||||
{
|
{
|
||||||
this.Key = key;
|
this.Key = key;
|
||||||
this.AccelMods = mods;
|
this.AccelMods = mods;
|
||||||
this._bitfield0 = 0;
|
this._bitfield0 = 0;
|
||||||
this.AccelFlags = flags;
|
this.AccelFlags = flags;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,27 +20,26 @@
|
||||||
|
|
||||||
namespace Gtk {
|
namespace Gtk {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
public partial class Action {
|
public partial class Action {
|
||||||
|
|
||||||
public Action (string name, string label) : this (name, label, null, null)
|
public Action (string name, string label) : this (name, label, null, null)
|
||||||
{
|
{}
|
||||||
|
|
||||||
|
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern IntPtr gtk_action_get_proxies (IntPtr raw);
|
||||||
|
|
||||||
|
public Gtk.Widget[] Proxies {
|
||||||
|
get {
|
||||||
|
IntPtr raw_ret = gtk_action_get_proxies (Handle);
|
||||||
|
GLib.SList list = new GLib.SList (raw_ret);
|
||||||
|
Widget[] result = new Widget [list.Count];
|
||||||
|
for (int i = 0; i < list.Count; i++)
|
||||||
|
result [i] = list [i] as Widget;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
static extern IntPtr gtk_action_get_proxies (IntPtr raw);
|
|
||||||
|
|
||||||
public Gtk.Widget[] Proxies {
|
|
||||||
get {
|
|
||||||
IntPtr raw_ret = gtk_action_get_proxies (Handle);
|
|
||||||
GLib.SList list = new GLib.SList (raw_ret);
|
|
||||||
Widget[] result = new Widget [list.Count];
|
|
||||||
for (int i = 0; i < list.Count; i++)
|
|
||||||
result [i] = list [i] as Widget;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ namespace Gtk {
|
||||||
RadioAction[] actions = new RadioAction[entries.Length];
|
RadioAction[] actions = new RadioAction[entries.Length];
|
||||||
for (int i = 0; i < entries.Length; i++) {
|
for (int i = 0; i < entries.Length; i++) {
|
||||||
actions[i] = new RadioAction (entries[i].name, entries[i].label,
|
actions[i] = new RadioAction (entries[i].name, entries[i].label,
|
||||||
entries[i].tooltip, entries[i].stock_id, entries[i].value);
|
entries[i].tooltip, entries[i].stock_id, entries[i].value);
|
||||||
actions[i].Group = group;
|
actions[i].Group = group;
|
||||||
group = actions[i].Group;
|
group = actions[i].Group;
|
||||||
actions[i].Active = value == entries[i].value;
|
actions[i].Active = value == entries[i].value;
|
||||||
|
|
|
@ -23,43 +23,43 @@ namespace Gtk {
|
||||||
|
|
||||||
public partial class Adjustment {
|
public partial class Adjustment {
|
||||||
|
|
||||||
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
static extern IntPtr gtk_adjustment_new(double value, double lower, double upper, double step_increment, double page_increment, double page_size);
|
static extern IntPtr gtk_adjustment_new(double value, double lower, double upper, double step_increment, double page_increment, double page_size);
|
||||||
|
|
||||||
public Adjustment (double value, double lower, double upper, double step_increment, double page_increment, double page_size) : base (IntPtr.Zero)
|
public Adjustment (double value, double lower, double upper, double step_increment, double page_increment, double page_size) : base (IntPtr.Zero)
|
||||||
{
|
{
|
||||||
if (GetType () != typeof (Adjustment)) {
|
if (GetType () != typeof (Adjustment)) {
|
||||||
CreateNativeObject (new string [0], new GLib.Value [0]);
|
CreateNativeObject (new string [0], new GLib.Value [0]);
|
||||||
Value = value;
|
Value = value;
|
||||||
Lower = lower;
|
Lower = lower;
|
||||||
Upper = upper;
|
Upper = upper;
|
||||||
StepIncrement = step_increment;
|
StepIncrement = step_increment;
|
||||||
PageIncrement = page_increment;
|
PageIncrement = page_increment;
|
||||||
PageSize = page_size;
|
PageSize = page_size;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Raw = gtk_adjustment_new(value, lower, upper, step_increment, page_increment, page_size);
|
Raw = gtk_adjustment_new(value, lower, upper, step_increment, page_increment, page_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
static extern void g_object_freeze_notify (IntPtr inst);
|
static extern void g_object_freeze_notify (IntPtr inst);
|
||||||
|
|
||||||
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
static extern void g_object_thaw_notify (IntPtr inst);
|
static extern void g_object_thaw_notify (IntPtr inst);
|
||||||
|
|
||||||
public void SetBounds (double lower, double upper, double step_increment, double page_increment, double page_size)
|
public void SetBounds (double lower, double upper, double step_increment, double page_increment, double page_size)
|
||||||
{
|
{
|
||||||
// g_object_freeze_notify/g_object_thaw_notify calls are necessary to to avoid multiple emissions of the "changed" signal
|
// g_object_freeze_notify/g_object_thaw_notify calls are necessary to to avoid multiple emissions of the "changed" signal
|
||||||
g_object_freeze_notify (this.Handle);
|
g_object_freeze_notify (this.Handle);
|
||||||
|
|
||||||
Lower = lower;
|
Lower = lower;
|
||||||
Upper = upper;
|
Upper = upper;
|
||||||
StepIncrement = step_increment;
|
StepIncrement = step_increment;
|
||||||
PageIncrement = page_increment;
|
PageIncrement = page_increment;
|
||||||
PageSize = page_size;
|
PageSize = page_size;
|
||||||
|
|
||||||
g_object_thaw_notify (this.Handle);
|
g_object_thaw_notify (this.Handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
760
gtk/Builder.cs
760
gtk/Builder.cs
|
@ -30,391 +30,391 @@ namespace Gtk {
|
||||||
|
|
||||||
public partial class Builder {
|
public partial class Builder {
|
||||||
|
|
||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
public class HandlerNotFoundException : SystemException
|
public class HandlerNotFoundException : SystemException
|
||||||
{
|
|
||||||
string handler_name;
|
|
||||||
string signal_name;
|
|
||||||
System.Reflection.EventInfo evnt;
|
|
||||||
Type delegate_type;
|
|
||||||
|
|
||||||
public HandlerNotFoundException (string handler_name, string signal_name,
|
|
||||||
System.Reflection.EventInfo evnt, Type delegate_type)
|
|
||||||
: this (handler_name, signal_name, evnt, delegate_type, null)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public HandlerNotFoundException (string handler_name, string signal_name,
|
|
||||||
System.Reflection.EventInfo evnt, Type delegate_type, Exception inner)
|
|
||||||
: base ("No handler " + handler_name + " found for signal " + signal_name,
|
|
||||||
inner)
|
|
||||||
{
|
|
||||||
this.handler_name = handler_name;
|
|
||||||
this.signal_name = signal_name;
|
|
||||||
this.evnt = evnt;
|
|
||||||
this.delegate_type = delegate_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public HandlerNotFoundException (string message, string handler_name, string signal_name,
|
|
||||||
System.Reflection.EventInfo evnt, Type delegate_type)
|
|
||||||
: base ((message != null) ? message : "No handler " + handler_name + " found for signal " + signal_name,
|
|
||||||
null)
|
|
||||||
{
|
|
||||||
this.handler_name = handler_name;
|
|
||||||
this.signal_name = signal_name;
|
|
||||||
this.evnt = evnt;
|
|
||||||
this.delegate_type = delegate_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected HandlerNotFoundException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
|
|
||||||
: base (info, context)
|
|
||||||
{
|
|
||||||
handler_name = info.GetString ("HandlerName");
|
|
||||||
signal_name = info.GetString ("SignalName");
|
|
||||||
evnt = info.GetValue ("Event", typeof (System.Reflection.EventInfo)) as System.Reflection.EventInfo;
|
|
||||||
delegate_type = info.GetValue ("DelegateType", typeof (Type)) as Type;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string HandlerName
|
|
||||||
{
|
|
||||||
get {
|
|
||||||
return handler_name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string SignalName
|
|
||||||
{
|
|
||||||
get {
|
|
||||||
return signal_name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public System.Reflection.EventInfo Event
|
|
||||||
{
|
|
||||||
get {
|
|
||||||
return evnt;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Type DelegateType
|
|
||||||
{
|
|
||||||
get {
|
|
||||||
return delegate_type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void GetObjectData (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
|
|
||||||
{
|
|
||||||
base.GetObjectData (info, context);
|
|
||||||
info.AddValue ("HandlerName", handler_name);
|
|
||||||
info.AddValue ("SignalName", signal_name);
|
|
||||||
info.AddValue ("Event", evnt);
|
|
||||||
info.AddValue ("DelegateType", delegate_type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
[AttributeUsage (AttributeTargets.Field)]
|
|
||||||
public class ObjectAttribute : Attribute
|
|
||||||
{
|
|
||||||
private string name;
|
|
||||||
private bool specified;
|
|
||||||
|
|
||||||
public ObjectAttribute (string name)
|
|
||||||
{
|
|
||||||
specified = true;
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ObjectAttribute ()
|
|
||||||
{
|
|
||||||
specified = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string Name
|
|
||||||
{
|
|
||||||
get { return name; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Specified
|
|
||||||
{
|
|
||||||
get { return specified; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IntPtr GetRawObject(string name) {
|
|
||||||
IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (name);
|
|
||||||
IntPtr raw_ret = gtk_builder_get_object(Handle, native_name);
|
|
||||||
GLib.Marshaller.Free (native_name);
|
|
||||||
return raw_ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder (System.IO.Stream s) : this (s, null)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder (System.IO.Stream s, string translation_domain)
|
|
||||||
{
|
|
||||||
if (s == null)
|
|
||||||
throw new ArgumentNullException ("s");
|
|
||||||
|
|
||||||
int size = (int) s.Length;
|
|
||||||
byte[] buffer = new byte[size];
|
|
||||||
s.Read (buffer, 0, size);
|
|
||||||
s.Close ();
|
|
||||||
|
|
||||||
AddFromString(System.Text.Encoding.UTF8.GetString (buffer));
|
|
||||||
|
|
||||||
TranslationDomain = translation_domain;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder (string resource_name) : this (resource_name, null)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder (string resource_name, string translation_domain) : this (System.Reflection.Assembly.GetEntryAssembly (), resource_name, translation_domain)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public Builder (System.Reflection.Assembly assembly, string resource_name, string translation_domain) : this ()
|
|
||||||
{
|
|
||||||
if (GetType() != typeof (Builder))
|
|
||||||
throw new InvalidOperationException ("Cannot chain to this constructor from subclasses.");
|
|
||||||
|
|
||||||
if (assembly == null)
|
|
||||||
assembly = System.Reflection.Assembly.GetCallingAssembly ();
|
|
||||||
|
|
||||||
System.IO.Stream s = assembly.GetManifestResourceStream (resource_name);
|
|
||||||
if (s == null)
|
|
||||||
throw new ArgumentException ("Cannot get resource file '" + resource_name + "'",
|
|
||||||
"resource_name");
|
|
||||||
|
|
||||||
int size = (int) s.Length;
|
|
||||||
byte[] buffer = new byte[size];
|
|
||||||
s.Read (buffer, 0, size);
|
|
||||||
s.Close ();
|
|
||||||
|
|
||||||
AddFromString(System.Text.Encoding.UTF8.GetString (buffer));
|
|
||||||
|
|
||||||
TranslationDomain = translation_domain;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Autoconnect (object handler)
|
|
||||||
{
|
|
||||||
BindFields (handler);
|
|
||||||
(new SignalConnector (this, handler)).ConnectSignals ();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Autoconnect (Type handler_class)
|
|
||||||
{
|
|
||||||
BindFields (handler_class);
|
|
||||||
(new SignalConnector (this, handler_class)).ConnectSignals ();
|
|
||||||
}
|
|
||||||
|
|
||||||
class SignalConnector
|
|
||||||
{
|
|
||||||
Builder builder;
|
|
||||||
Type handler_type;
|
|
||||||
object handler;
|
|
||||||
|
|
||||||
public SignalConnector (Builder builder, object handler)
|
|
||||||
{
|
|
||||||
this.builder = builder;
|
|
||||||
this.handler = handler;
|
|
||||||
handler_type = handler.GetType ();
|
|
||||||
}
|
|
||||||
|
|
||||||
public SignalConnector (Builder builder, Type handler_type)
|
|
||||||
{
|
|
||||||
this.builder = builder;
|
|
||||||
this.handler = null;
|
|
||||||
this.handler_type = handler_type;
|
|
||||||
}
|
|
||||||
|
|
||||||
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
static extern void gtk_builder_connect_signals_full(IntPtr raw, GtkSharp.BuilderConnectFuncNative func, IntPtr user_data);
|
|
||||||
|
|
||||||
public void ConnectSignals() {
|
|
||||||
GtkSharp.BuilderConnectFuncWrapper func_wrapper = new GtkSharp.BuilderConnectFuncWrapper (new BuilderConnectFunc (ConnectFunc));
|
|
||||||
gtk_builder_connect_signals_full(builder.Handle, func_wrapper.NativeDelegate, IntPtr.Zero);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ConnectFunc (Builder builder, GLib.Object objekt, string signal_name, string handler_name, GLib.Object connect_object, GLib.ConnectFlags flags)
|
|
||||||
{
|
|
||||||
/* search for the event to connect */
|
|
||||||
System.Reflection.MemberInfo[] evnts = objekt.GetType ().
|
|
||||||
FindMembers (System.Reflection.MemberTypes.Event,
|
|
||||||
System.Reflection.BindingFlags.Instance
|
|
||||||
| System.Reflection.BindingFlags.Static
|
|
||||||
| System.Reflection.BindingFlags.Public
|
|
||||||
| System.Reflection.BindingFlags.NonPublic,
|
|
||||||
new System.Reflection.MemberFilter (SignalFilter), signal_name);
|
|
||||||
foreach (System.Reflection.EventInfo ei in evnts) {
|
|
||||||
bool connected = false;
|
|
||||||
System.Reflection.MethodInfo add = ei.GetAddMethod ();
|
|
||||||
System.Reflection.ParameterInfo[] addpi = add.GetParameters ();
|
|
||||||
if (addpi.Length == 1) { /* this should be always true, unless there's something broken */
|
|
||||||
Type delegate_type = addpi[0].ParameterType;
|
|
||||||
|
|
||||||
/* look for an instance method */
|
|
||||||
if (connect_object != null || handler != null)
|
|
||||||
try {
|
|
||||||
Delegate d = Delegate.CreateDelegate (delegate_type, connect_object != null ? connect_object : handler, handler_name);
|
|
||||||
add.Invoke (objekt, new object[] { d } );
|
|
||||||
connected = true;
|
|
||||||
} catch (ArgumentException) { /* ignore if there is not such instance method */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* look for a static method if no instance method has been found */
|
|
||||||
if (!connected && handler_type != null)
|
|
||||||
try {
|
|
||||||
Delegate d = Delegate.CreateDelegate (delegate_type, handler_type, handler_name);
|
|
||||||
add.Invoke (objekt, new object[] { d } );
|
|
||||||
connected = true;
|
|
||||||
} catch (ArgumentException) { /* ignore if there is not such static method */
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!connected) {
|
|
||||||
string msg = ExplainError (ei.Name, delegate_type, handler_type, handler_name);
|
|
||||||
throw new HandlerNotFoundException (msg, handler_name, signal_name, ei, delegate_type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool SignalFilter (System.Reflection.MemberInfo m, object filterCriteria)
|
|
||||||
{
|
|
||||||
string signame = (filterCriteria as string);
|
|
||||||
object[] attrs = m.GetCustomAttributes (typeof (GLib.SignalAttribute), false);
|
|
||||||
if (attrs.Length > 0)
|
|
||||||
{
|
{
|
||||||
foreach (GLib.SignalAttribute a in attrs)
|
string handler_name;
|
||||||
|
string signal_name;
|
||||||
|
System.Reflection.EventInfo evnt;
|
||||||
|
Type delegate_type;
|
||||||
|
|
||||||
|
public HandlerNotFoundException (string handler_name, string signal_name,
|
||||||
|
System.Reflection.EventInfo evnt, Type delegate_type)
|
||||||
|
: this (handler_name, signal_name, evnt, delegate_type, null)
|
||||||
{
|
{
|
||||||
if (signame == a.CName)
|
}
|
||||||
{
|
|
||||||
return true;
|
public HandlerNotFoundException (string handler_name, string signal_name,
|
||||||
|
System.Reflection.EventInfo evnt, Type delegate_type, Exception inner)
|
||||||
|
: base ("No handler " + handler_name + " found for signal " + signal_name,
|
||||||
|
inner)
|
||||||
|
{
|
||||||
|
this.handler_name = handler_name;
|
||||||
|
this.signal_name = signal_name;
|
||||||
|
this.evnt = evnt;
|
||||||
|
this.delegate_type = delegate_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public HandlerNotFoundException (string message, string handler_name, string signal_name,
|
||||||
|
System.Reflection.EventInfo evnt, Type delegate_type)
|
||||||
|
: base ((message != null) ? message : "No handler " + handler_name + " found for signal " + signal_name,
|
||||||
|
null)
|
||||||
|
{
|
||||||
|
this.handler_name = handler_name;
|
||||||
|
this.signal_name = signal_name;
|
||||||
|
this.evnt = evnt;
|
||||||
|
this.delegate_type = delegate_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected HandlerNotFoundException (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
|
||||||
|
: base (info, context)
|
||||||
|
{
|
||||||
|
handler_name = info.GetString ("HandlerName");
|
||||||
|
signal_name = info.GetString ("SignalName");
|
||||||
|
evnt = info.GetValue ("Event", typeof (System.Reflection.EventInfo)) as System.Reflection.EventInfo;
|
||||||
|
delegate_type = info.GetValue ("DelegateType", typeof (Type)) as Type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string HandlerName
|
||||||
|
{
|
||||||
|
get {
|
||||||
|
return handler_name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
public string SignalName
|
||||||
else
|
{
|
||||||
{
|
get {
|
||||||
/* this tries to match the names when no attibutes are present.
|
return signal_name;
|
||||||
It is only a fallback. */
|
|
||||||
signame = signame.ToLower ().Replace ("_", "");
|
|
||||||
string evname = m.Name.ToLower ();
|
|
||||||
return signame == evname;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static string GetSignature (System.Reflection.MethodInfo method)
|
|
||||||
{
|
|
||||||
if (method == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
System.Reflection.ParameterInfo [] parameters = method.GetParameters ();
|
|
||||||
System.Text.StringBuilder sb = new System.Text.StringBuilder ();
|
|
||||||
sb.Append ('(');
|
|
||||||
foreach (System.Reflection.ParameterInfo info in parameters) {
|
|
||||||
sb.Append (info.ParameterType.ToString ());
|
|
||||||
sb.Append (',');
|
|
||||||
}
|
|
||||||
if (sb.Length != 0)
|
|
||||||
sb.Length--;
|
|
||||||
|
|
||||||
sb.Append (')');
|
|
||||||
return sb.ToString ();
|
|
||||||
}
|
|
||||||
|
|
||||||
static string GetSignature (Type delegate_type)
|
|
||||||
{
|
|
||||||
System.Reflection.MethodInfo method = delegate_type.GetMethod ("Invoke");
|
|
||||||
return GetSignature (method);
|
|
||||||
}
|
|
||||||
|
|
||||||
const System.Reflection.BindingFlags flags = System.Reflection.BindingFlags.NonPublic |
|
|
||||||
System.Reflection.BindingFlags.Public |
|
|
||||||
System.Reflection.BindingFlags.Static |
|
|
||||||
System.Reflection.BindingFlags.Instance;
|
|
||||||
static string GetSignature (Type klass, string method_name)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
System.Reflection.MethodInfo method = klass.GetMethod (method_name, flags);
|
|
||||||
return GetSignature (method);
|
|
||||||
} catch {
|
|
||||||
// May be more than one method with that name and none matches
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static string ExplainError (string event_name, Type deleg, Type klass, string method)
|
|
||||||
{
|
|
||||||
if (deleg == null || klass == null || method == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
System.Text.StringBuilder sb = new System.Text.StringBuilder ();
|
|
||||||
string expected = GetSignature (deleg);
|
|
||||||
string actual = GetSignature (klass, method);
|
|
||||||
if (actual == null)
|
|
||||||
return null;
|
|
||||||
sb.AppendFormat ("The handler for the event {0} should take '{1}', " +
|
|
||||||
"but the signature of the provided handler ('{2}') is '{3}'\n",
|
|
||||||
event_name, expected, method, actual);
|
|
||||||
return sb.ToString ();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void BindFields (object target)
|
|
||||||
{
|
|
||||||
BindFields (target, target.GetType ());
|
|
||||||
}
|
|
||||||
|
|
||||||
void BindFields (Type type)
|
|
||||||
{
|
|
||||||
BindFields (null, type);
|
|
||||||
}
|
|
||||||
|
|
||||||
void BindFields (object target, Type type)
|
|
||||||
{
|
|
||||||
System.Reflection.BindingFlags flags = System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.DeclaredOnly;
|
|
||||||
if (target != null)
|
|
||||||
flags |= System.Reflection.BindingFlags.Instance;
|
|
||||||
else
|
|
||||||
flags |= System.Reflection.BindingFlags.Static;
|
|
||||||
|
|
||||||
do {
|
|
||||||
System.Reflection.FieldInfo[] fields = type.GetFields (flags);
|
|
||||||
if (fields == null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
foreach (System.Reflection.FieldInfo field in fields)
|
|
||||||
{
|
|
||||||
object[] attrs = field.GetCustomAttributes (typeof (ObjectAttribute), false);
|
|
||||||
if (attrs == null || attrs.Length == 0)
|
|
||||||
continue;
|
|
||||||
// The widget to field binding must be 1:1, so only check
|
|
||||||
// the first attribute.
|
|
||||||
ObjectAttribute attr = (ObjectAttribute) attrs[0];
|
|
||||||
GLib.Object gobject;
|
|
||||||
if (attr.Specified)
|
|
||||||
gobject = GetObject (attr.Name);
|
|
||||||
else
|
|
||||||
gobject = GetObject (field.Name);
|
|
||||||
|
|
||||||
if (gobject != null)
|
|
||||||
try {
|
|
||||||
field.SetValue (target, gobject, flags, null, null);
|
|
||||||
} catch (Exception e) {
|
|
||||||
Console.WriteLine ("Unable to set value for field " + field.Name);
|
|
||||||
throw e;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public System.Reflection.EventInfo Event
|
||||||
|
{
|
||||||
|
get {
|
||||||
|
return evnt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Type DelegateType
|
||||||
|
{
|
||||||
|
get {
|
||||||
|
return delegate_type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void GetObjectData (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
|
||||||
|
{
|
||||||
|
base.GetObjectData (info, context);
|
||||||
|
info.AddValue ("HandlerName", handler_name);
|
||||||
|
info.AddValue ("SignalName", signal_name);
|
||||||
|
info.AddValue ("Event", evnt);
|
||||||
|
info.AddValue ("DelegateType", delegate_type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[AttributeUsage (AttributeTargets.Field)]
|
||||||
|
public class ObjectAttribute : Attribute
|
||||||
|
{
|
||||||
|
private string name;
|
||||||
|
private bool specified;
|
||||||
|
|
||||||
|
public ObjectAttribute (string name)
|
||||||
|
{
|
||||||
|
specified = true;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ObjectAttribute ()
|
||||||
|
{
|
||||||
|
specified = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get { return name; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Specified
|
||||||
|
{
|
||||||
|
get { return specified; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntPtr GetRawObject(string name) {
|
||||||
|
IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (name);
|
||||||
|
IntPtr raw_ret = gtk_builder_get_object(Handle, native_name);
|
||||||
|
GLib.Marshaller.Free (native_name);
|
||||||
|
return raw_ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder (System.IO.Stream s) : this (s, null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder (System.IO.Stream s, string translation_domain)
|
||||||
|
{
|
||||||
|
if (s == null)
|
||||||
|
throw new ArgumentNullException ("s");
|
||||||
|
|
||||||
|
int size = (int) s.Length;
|
||||||
|
byte[] buffer = new byte[size];
|
||||||
|
s.Read (buffer, 0, size);
|
||||||
|
s.Close ();
|
||||||
|
|
||||||
|
AddFromString(System.Text.Encoding.UTF8.GetString (buffer));
|
||||||
|
|
||||||
|
TranslationDomain = translation_domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder (string resource_name) : this (resource_name, null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder (string resource_name, string translation_domain) : this (System.Reflection.Assembly.GetEntryAssembly (), resource_name, translation_domain)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder (System.Reflection.Assembly assembly, string resource_name, string translation_domain) : this ()
|
||||||
|
{
|
||||||
|
if (GetType() != typeof (Builder))
|
||||||
|
throw new InvalidOperationException ("Cannot chain to this constructor from subclasses.");
|
||||||
|
|
||||||
|
if (assembly == null)
|
||||||
|
assembly = System.Reflection.Assembly.GetCallingAssembly ();
|
||||||
|
|
||||||
|
System.IO.Stream s = assembly.GetManifestResourceStream (resource_name);
|
||||||
|
if (s == null)
|
||||||
|
throw new ArgumentException ("Cannot get resource file '" + resource_name + "'",
|
||||||
|
"resource_name");
|
||||||
|
|
||||||
|
int size = (int) s.Length;
|
||||||
|
byte[] buffer = new byte[size];
|
||||||
|
s.Read (buffer, 0, size);
|
||||||
|
s.Close ();
|
||||||
|
|
||||||
|
AddFromString(System.Text.Encoding.UTF8.GetString (buffer));
|
||||||
|
|
||||||
|
TranslationDomain = translation_domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Autoconnect (object handler)
|
||||||
|
{
|
||||||
|
BindFields (handler);
|
||||||
|
(new SignalConnector (this, handler)).ConnectSignals ();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Autoconnect (Type handler_class)
|
||||||
|
{
|
||||||
|
BindFields (handler_class);
|
||||||
|
(new SignalConnector (this, handler_class)).ConnectSignals ();
|
||||||
|
}
|
||||||
|
|
||||||
|
class SignalConnector
|
||||||
|
{
|
||||||
|
Builder builder;
|
||||||
|
Type handler_type;
|
||||||
|
object handler;
|
||||||
|
|
||||||
|
public SignalConnector (Builder builder, object handler)
|
||||||
|
{
|
||||||
|
this.builder = builder;
|
||||||
|
this.handler = handler;
|
||||||
|
handler_type = handler.GetType ();
|
||||||
|
}
|
||||||
|
|
||||||
|
public SignalConnector (Builder builder, Type handler_type)
|
||||||
|
{
|
||||||
|
this.builder = builder;
|
||||||
|
this.handler = null;
|
||||||
|
this.handler_type = handler_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern void gtk_builder_connect_signals_full(IntPtr raw, GtkSharp.BuilderConnectFuncNative func, IntPtr user_data);
|
||||||
|
|
||||||
|
public void ConnectSignals() {
|
||||||
|
GtkSharp.BuilderConnectFuncWrapper func_wrapper = new GtkSharp.BuilderConnectFuncWrapper (new BuilderConnectFunc (ConnectFunc));
|
||||||
|
gtk_builder_connect_signals_full(builder.Handle, func_wrapper.NativeDelegate, IntPtr.Zero);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ConnectFunc (Builder builder, GLib.Object objekt, string signal_name, string handler_name, GLib.Object connect_object, GLib.ConnectFlags flags)
|
||||||
|
{
|
||||||
|
/* search for the event to connect */
|
||||||
|
System.Reflection.MemberInfo[] evnts = objekt.GetType ().
|
||||||
|
FindMembers (System.Reflection.MemberTypes.Event,
|
||||||
|
System.Reflection.BindingFlags.Instance
|
||||||
|
| System.Reflection.BindingFlags.Static
|
||||||
|
| System.Reflection.BindingFlags.Public
|
||||||
|
| System.Reflection.BindingFlags.NonPublic,
|
||||||
|
new System.Reflection.MemberFilter (SignalFilter), signal_name);
|
||||||
|
foreach (System.Reflection.EventInfo ei in evnts) {
|
||||||
|
bool connected = false;
|
||||||
|
System.Reflection.MethodInfo add = ei.GetAddMethod ();
|
||||||
|
System.Reflection.ParameterInfo[] addpi = add.GetParameters ();
|
||||||
|
if (addpi.Length == 1) { /* this should be always true, unless there's something broken */
|
||||||
|
Type delegate_type = addpi[0].ParameterType;
|
||||||
|
|
||||||
|
/* look for an instance method */
|
||||||
|
if (connect_object != null || handler != null)
|
||||||
|
try {
|
||||||
|
Delegate d = Delegate.CreateDelegate (delegate_type, connect_object != null ? connect_object : handler, handler_name);
|
||||||
|
add.Invoke (objekt, new object[] { d } );
|
||||||
|
connected = true;
|
||||||
|
} catch (ArgumentException) { /* ignore if there is not such instance method */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* look for a static method if no instance method has been found */
|
||||||
|
if (!connected && handler_type != null)
|
||||||
|
try {
|
||||||
|
Delegate d = Delegate.CreateDelegate (delegate_type, handler_type, handler_name);
|
||||||
|
add.Invoke (objekt, new object[] { d } );
|
||||||
|
connected = true;
|
||||||
|
} catch (ArgumentException) { /* ignore if there is not such static method */
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!connected) {
|
||||||
|
string msg = ExplainError (ei.Name, delegate_type, handler_type, handler_name);
|
||||||
|
throw new HandlerNotFoundException (msg, handler_name, signal_name, ei, delegate_type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool SignalFilter (System.Reflection.MemberInfo m, object filterCriteria)
|
||||||
|
{
|
||||||
|
string signame = (filterCriteria as string);
|
||||||
|
object[] attrs = m.GetCustomAttributes (typeof (GLib.SignalAttribute), false);
|
||||||
|
if (attrs.Length > 0)
|
||||||
|
{
|
||||||
|
foreach (GLib.SignalAttribute a in attrs)
|
||||||
|
{
|
||||||
|
if (signame == a.CName)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* this tries to match the names when no attibutes are present.
|
||||||
|
It is only a fallback. */
|
||||||
|
signame = signame.ToLower ().Replace ("_", "");
|
||||||
|
string evname = m.Name.ToLower ();
|
||||||
|
return signame == evname;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static string GetSignature (System.Reflection.MethodInfo method)
|
||||||
|
{
|
||||||
|
if (method == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
System.Reflection.ParameterInfo [] parameters = method.GetParameters ();
|
||||||
|
System.Text.StringBuilder sb = new System.Text.StringBuilder ();
|
||||||
|
sb.Append ('(');
|
||||||
|
foreach (System.Reflection.ParameterInfo info in parameters) {
|
||||||
|
sb.Append (info.ParameterType.ToString ());
|
||||||
|
sb.Append (',');
|
||||||
|
}
|
||||||
|
if (sb.Length != 0)
|
||||||
|
sb.Length--;
|
||||||
|
|
||||||
|
sb.Append (')');
|
||||||
|
return sb.ToString ();
|
||||||
|
}
|
||||||
|
|
||||||
|
static string GetSignature (Type delegate_type)
|
||||||
|
{
|
||||||
|
System.Reflection.MethodInfo method = delegate_type.GetMethod ("Invoke");
|
||||||
|
return GetSignature (method);
|
||||||
|
}
|
||||||
|
|
||||||
|
const System.Reflection.BindingFlags flags = System.Reflection.BindingFlags.NonPublic |
|
||||||
|
System.Reflection.BindingFlags.Public |
|
||||||
|
System.Reflection.BindingFlags.Static |
|
||||||
|
System.Reflection.BindingFlags.Instance;
|
||||||
|
static string GetSignature (Type klass, string method_name)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
System.Reflection.MethodInfo method = klass.GetMethod (method_name, flags);
|
||||||
|
return GetSignature (method);
|
||||||
|
} catch {
|
||||||
|
// May be more than one method with that name and none matches
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static string ExplainError (string event_name, Type deleg, Type klass, string method)
|
||||||
|
{
|
||||||
|
if (deleg == null || klass == null || method == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
System.Text.StringBuilder sb = new System.Text.StringBuilder ();
|
||||||
|
string expected = GetSignature (deleg);
|
||||||
|
string actual = GetSignature (klass, method);
|
||||||
|
if (actual == null)
|
||||||
|
return null;
|
||||||
|
sb.AppendFormat ("The handler for the event {0} should take '{1}', " +
|
||||||
|
"but the signature of the provided handler ('{2}') is '{3}'\n",
|
||||||
|
event_name, expected, method, actual);
|
||||||
|
return sb.ToString ();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void BindFields (object target)
|
||||||
|
{
|
||||||
|
BindFields (target, target.GetType ());
|
||||||
|
}
|
||||||
|
|
||||||
|
void BindFields (Type type)
|
||||||
|
{
|
||||||
|
BindFields (null, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
void BindFields (object target, Type type)
|
||||||
|
{
|
||||||
|
System.Reflection.BindingFlags flags = System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.DeclaredOnly;
|
||||||
|
if (target != null)
|
||||||
|
flags |= System.Reflection.BindingFlags.Instance;
|
||||||
|
else
|
||||||
|
flags |= System.Reflection.BindingFlags.Static;
|
||||||
|
|
||||||
|
do {
|
||||||
|
System.Reflection.FieldInfo[] fields = type.GetFields (flags);
|
||||||
|
if (fields == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
foreach (System.Reflection.FieldInfo field in fields)
|
||||||
|
{
|
||||||
|
object[] attrs = field.GetCustomAttributes (typeof (ObjectAttribute), false);
|
||||||
|
if (attrs == null || attrs.Length == 0)
|
||||||
|
continue;
|
||||||
|
// The widget to field binding must be 1:1, so only check
|
||||||
|
// the first attribute.
|
||||||
|
ObjectAttribute attr = (ObjectAttribute) attrs[0];
|
||||||
|
GLib.Object gobject;
|
||||||
|
if (attr.Specified)
|
||||||
|
gobject = GetObject (attr.Name);
|
||||||
|
else
|
||||||
|
gobject = GetObject (field.Name);
|
||||||
|
|
||||||
|
if (gobject != null)
|
||||||
|
try {
|
||||||
|
field.SetValue (target, gobject, flags, null, null);
|
||||||
|
} catch (Exception e) {
|
||||||
|
Console.WriteLine ("Unable to set value for field " + field.Name);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
type = type.BaseType;
|
||||||
|
}
|
||||||
|
while (type != typeof(object) && type != null);
|
||||||
}
|
}
|
||||||
type = type.BaseType;
|
|
||||||
}
|
|
||||||
while (type != typeof(object) && type != null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,29 +25,29 @@ namespace Gtk {
|
||||||
|
|
||||||
public partial class Button {
|
public partial class Button {
|
||||||
|
|
||||||
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
static extern IntPtr gtk_button_new_from_stock(IntPtr stock_id);
|
static extern IntPtr gtk_button_new_from_stock(IntPtr stock_id);
|
||||||
|
|
||||||
public Button (string stock_id) : base (IntPtr.Zero)
|
public Button (string stock_id) : base (IntPtr.Zero)
|
||||||
{
|
{
|
||||||
if (GetType () != typeof (Button)) {
|
if (GetType () != typeof (Button)) {
|
||||||
GLib.Value[] vals = new GLib.Value [2];
|
GLib.Value[] vals = new GLib.Value [2];
|
||||||
string[] names = new string [2];
|
string[] names = new string [2];
|
||||||
names [0] = "label";
|
names [0] = "label";
|
||||||
vals [0] = new GLib.Value (stock_id);
|
vals [0] = new GLib.Value (stock_id);
|
||||||
names [1] = "use_stock";
|
names [1] = "use_stock";
|
||||||
vals [1] = new GLib.Value (true);
|
vals [1] = new GLib.Value (true);
|
||||||
CreateNativeObject (names, vals);
|
CreateNativeObject (names, vals);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IntPtr native = GLib.Marshaller.StringToPtrGStrdup (stock_id);
|
IntPtr native = GLib.Marshaller.StringToPtrGStrdup (stock_id);
|
||||||
Raw = gtk_button_new_from_stock (native);
|
Raw = gtk_button_new_from_stock (native);
|
||||||
GLib.Marshaller.Free (native);
|
GLib.Marshaller.Free (native);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Button (Widget widget) : this ()
|
public Button (Widget widget) : this ()
|
||||||
{
|
{
|
||||||
Add (widget);
|
Add (widget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,38 +25,37 @@ namespace Gtk {
|
||||||
|
|
||||||
public partial class Calendar {
|
public partial class Calendar {
|
||||||
|
|
||||||
public DateTime GetDate ()
|
public DateTime GetDate ()
|
||||||
{
|
{
|
||||||
uint year, month, day;
|
uint year, month, day;
|
||||||
GetDate (out year, out month, out day);
|
GetDate (out year, out month, out day);
|
||||||
DateTime result;
|
DateTime result;
|
||||||
try {
|
try {
|
||||||
result = new DateTime ((int) year, (int) month + 1, (int) day);
|
result = new DateTime ((int) year, (int) month + 1, (int) day);
|
||||||
} catch (ArgumentOutOfRangeException) {
|
} catch (ArgumentOutOfRangeException) {
|
||||||
// Kluge to workaround GtkCalendar being in an invalid state
|
// Kluge to workaround GtkCalendar being in an invalid state
|
||||||
// when raising month_changed signals, like in bug #78524.
|
// when raising month_changed signals, like in bug #78524.
|
||||||
result = new DateTime ((int) year, (int) month + 1, DateTime.DaysInMonth ((int) year, (int) month + 1));
|
result = new DateTime ((int) year, (int) month + 1, DateTime.DaysInMonth ((int) year, (int) month + 1));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// This defines a Date property for Calendar
|
// This defines a Date property for Calendar
|
||||||
// Note that the setter causes CalendarChange events to be fired
|
// Note that the setter causes CalendarChange events to be fired
|
||||||
public DateTime Date
|
public DateTime Date
|
||||||
|
{
|
||||||
|
get {
|
||||||
|
return this.GetDate();
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
uint month= (uint) value.Month-1;
|
||||||
|
uint year= (uint) value.Year;
|
||||||
|
uint day = (uint) value.Day;
|
||||||
|
|
||||||
{
|
SelectMonth(month,year);
|
||||||
get {
|
SelectDay(day);
|
||||||
return this.GetDate();
|
}
|
||||||
}
|
}
|
||||||
set {
|
|
||||||
uint month= (uint) value.Month-1;
|
|
||||||
uint year= (uint) value.Year;
|
|
||||||
uint day = (uint) value.Day;
|
|
||||||
|
|
||||||
SelectMonth(month,year);
|
|
||||||
SelectDay(day);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ namespace Gtk {
|
||||||
// TODO: Implement "nullable" attribute for value type parameters in GAPI
|
// TODO: Implement "nullable" attribute for value type parameters in GAPI
|
||||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||||
delegate void OnGetSizeDelegate (IntPtr item, IntPtr widget, IntPtr cell_area_ptr, IntPtr x_offset, IntPtr y_offset, IntPtr width, IntPtr height);
|
delegate void OnGetSizeDelegate (IntPtr item, IntPtr widget, IntPtr cell_area_ptr, IntPtr x_offset, IntPtr y_offset, IntPtr width, IntPtr height);
|
||||||
|
|
||||||
static void OnGetSize_cb (IntPtr item, IntPtr widget, IntPtr cell_area_ptr, IntPtr x_offset, IntPtr y_offset, IntPtr width, IntPtr height)
|
static void OnGetSize_cb (IntPtr item, IntPtr widget, IntPtr cell_area_ptr, IntPtr x_offset, IntPtr y_offset, IntPtr width, IntPtr height)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
@ -87,7 +87,7 @@ namespace Gtk {
|
||||||
OnGetSizeCallback = new OnGetSizeDelegate (OnGetSize_cb);
|
OnGetSizeCallback = new OnGetSizeDelegate (OnGetSize_cb);
|
||||||
gtksharp_cellrenderer_override_get_size (gtype.Val, OnGetSizeCallback);
|
gtksharp_cellrenderer_override_get_size (gtype.Val, OnGetSizeCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
[GLib.DefaultSignalHandler (Type=typeof(Gtk.CellRenderer), ConnectionMethod="OverrideOnGetSize")]
|
[GLib.DefaultSignalHandler (Type=typeof(Gtk.CellRenderer), ConnectionMethod="OverrideOnGetSize")]
|
||||||
protected virtual void OnGetSize (Gtk.Widget widget, ref Gdk.Rectangle cell_area, out int x_offset, out int y_offset, out int width, out int height)
|
protected virtual void OnGetSize (Gtk.Widget widget, ref Gdk.Rectangle cell_area, out int x_offset, out int y_offset, out int width, out int height)
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,17 +23,18 @@ namespace Gtk {
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
public partial class ColorSelectionDialog {
|
public partial class ColorSelectionDialog {
|
||||||
[Obsolete ("Do not use this class. It will cause your app to crash in mysterious ways.")]
|
|
||||||
public class ColorSelectionButton : Gtk.Button {
|
|
||||||
private ColorSelectionDialog color_sel;
|
|
||||||
|
|
||||||
public ColorSelectionDialog ColorSelectionDialog {
|
[Obsolete ("Do not use this class. It will cause your app to crash in mysterious ways.")]
|
||||||
get { return color_sel; }
|
public class ColorSelectionButton : Gtk.Button {
|
||||||
}
|
private ColorSelectionDialog color_sel;
|
||||||
|
|
||||||
public ColorSelectionButton (ColorSelectionDialog cs, IntPtr raw) : base (raw) {
|
public ColorSelectionDialog ColorSelectionDialog {
|
||||||
color_sel = cs;
|
get { return color_sel; }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public ColorSelectionButton (ColorSelectionDialog cs, IntPtr raw) : base (raw) {
|
||||||
|
color_sel = cs;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
414
gtk/Container.cs
414
gtk/Container.cs
|
@ -26,222 +26,222 @@ namespace Gtk {
|
||||||
|
|
||||||
public partial class Container {
|
public partial class Container {
|
||||||
|
|
||||||
[DllImport("gtksharpglue-3")]
|
[DllImport("gtksharpglue-3")]
|
||||||
static extern void gtksharp_container_child_get_property (IntPtr container, IntPtr child, IntPtr property, ref GLib.Value value);
|
static extern void gtksharp_container_child_get_property (IntPtr container, IntPtr child, IntPtr property, ref GLib.Value value);
|
||||||
|
|
||||||
public GLib.Value ChildGetProperty (Gtk.Widget child, string property_name) {
|
public GLib.Value ChildGetProperty (Gtk.Widget child, string property_name) {
|
||||||
GLib.Value value = new GLib.Value ();
|
GLib.Value value = new GLib.Value ();
|
||||||
|
|
||||||
IntPtr native = GLib.Marshaller.StringToPtrGStrdup (property_name);
|
IntPtr native = GLib.Marshaller.StringToPtrGStrdup (property_name);
|
||||||
gtksharp_container_child_get_property (Handle, child.Handle, native, ref value);
|
gtksharp_container_child_get_property (Handle, child.Handle, native, ref value);
|
||||||
GLib.Marshaller.Free (native);
|
GLib.Marshaller.Free (native);
|
||||||
return value;
|
return value;
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerator GetEnumerator ()
|
|
||||||
{
|
|
||||||
return Children.GetEnumerator ();
|
|
||||||
}
|
|
||||||
|
|
||||||
class ChildAccumulator {
|
|
||||||
public ArrayList Children = new ArrayList ();
|
|
||||||
|
|
||||||
public void Add (Gtk.Widget widget)
|
|
||||||
{
|
|
||||||
Children.Add (widget);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public IEnumerable AllChildren {
|
|
||||||
get {
|
|
||||||
ChildAccumulator acc = new ChildAccumulator ();
|
|
||||||
Forall (new Gtk.Callback (acc.Add));
|
|
||||||
return acc.Children;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
static extern bool gtk_container_get_focus_chain (IntPtr raw, out IntPtr list_ptr);
|
|
||||||
|
|
||||||
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
static extern void gtk_container_set_focus_chain (IntPtr raw, IntPtr list_ptr);
|
|
||||||
|
|
||||||
public Widget[] FocusChain {
|
|
||||||
get {
|
|
||||||
IntPtr list_ptr;
|
|
||||||
bool success = gtk_container_get_focus_chain (Handle, out list_ptr);
|
|
||||||
if (!success)
|
|
||||||
return new Widget [0];
|
|
||||||
|
|
||||||
GLib.List list = new GLib.List (list_ptr);
|
|
||||||
Widget[] result = new Widget [list.Count];
|
|
||||||
for (int i = 0; i < list.Count; i++)
|
|
||||||
result [i] = list [i] as Widget;
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
set {
|
|
||||||
GLib.List list = new GLib.List (IntPtr.Zero);
|
|
||||||
foreach (Widget val in value)
|
|
||||||
list.Append (val.Handle);
|
|
||||||
gtk_container_set_focus_chain (Handle, list.Handle);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
[DllImport("gtksharpglue-3")]
|
|
||||||
static extern void gtksharp_container_base_forall (IntPtr handle, bool include_internals, IntPtr cb, IntPtr data);
|
|
||||||
|
|
||||||
[DllImport("gtksharpglue-3")]
|
|
||||||
static extern void gtksharp_container_override_forall (IntPtr gtype, ForallDelegate cb);
|
|
||||||
|
|
||||||
[DllImport("gtksharpglue-3")]
|
|
||||||
static extern void gtksharp_container_invoke_gtk_callback (IntPtr cb, IntPtr handle, IntPtr data);
|
|
||||||
|
|
||||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
|
||||||
delegate void ForallDelegate (IntPtr container, bool include_internals, IntPtr cb, IntPtr data);
|
|
||||||
|
|
||||||
static ForallDelegate ForallOldCallback;
|
|
||||||
static ForallDelegate ForallCallback;
|
|
||||||
|
|
||||||
public struct CallbackInvoker {
|
|
||||||
IntPtr cb;
|
|
||||||
IntPtr data;
|
|
||||||
|
|
||||||
internal CallbackInvoker (IntPtr cb, IntPtr data)
|
|
||||||
{
|
|
||||||
this.cb = cb;
|
|
||||||
this.data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal IntPtr Data {
|
|
||||||
get {
|
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
internal IntPtr Callback {
|
public IEnumerator GetEnumerator ()
|
||||||
get {
|
{
|
||||||
return cb;
|
return Children.GetEnumerator ();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void Invoke (Widget w)
|
class ChildAccumulator {
|
||||||
{
|
public ArrayList Children = new ArrayList ();
|
||||||
gtksharp_container_invoke_gtk_callback (cb, w.Handle, data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ForallOld_cb (IntPtr container, bool include_internals, IntPtr cb, IntPtr data)
|
public void Add (Gtk.Widget widget)
|
||||||
{
|
{
|
||||||
try {
|
Children.Add (widget);
|
||||||
Container obj = GLib.Object.GetObject (container, false) as Container;
|
}
|
||||||
CallbackInvoker invoker = new CallbackInvoker (cb, data);
|
|
||||||
obj.ForAll (include_internals, invoker);
|
|
||||||
} catch (Exception e) {
|
|
||||||
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void OverrideForallOld (GLib.GType gtype)
|
|
||||||
{
|
|
||||||
if (ForallOldCallback == null)
|
|
||||||
ForallOldCallback = new ForallDelegate (ForallOld_cb);
|
|
||||||
gtksharp_container_override_forall (gtype.Val, ForallOldCallback);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Obsolete ("Override the ForAll(bool,Gtk.Callback) method instead")]
|
|
||||||
[GLib.DefaultSignalHandler (Type=typeof(Gtk.Container), ConnectionMethod="OverrideForallOld")]
|
|
||||||
protected virtual void ForAll (bool include_internals, CallbackInvoker invoker)
|
|
||||||
{
|
|
||||||
gtksharp_container_base_forall (Handle, include_internals, invoker.Callback, invoker.Data);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void Forall_cb (IntPtr container, bool include_internals, IntPtr cb, IntPtr data)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
Container obj = GLib.Object.GetObject (container, false) as Container;
|
|
||||||
CallbackInvoker invoker = new CallbackInvoker (cb, data);
|
|
||||||
obj.ForAll (include_internals, new Gtk.Callback (invoker.Invoke));
|
|
||||||
} catch (Exception e) {
|
|
||||||
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void OverrideForall (GLib.GType gtype)
|
|
||||||
{
|
|
||||||
if (ForallCallback == null)
|
|
||||||
ForallCallback = new ForallDelegate (Forall_cb);
|
|
||||||
gtksharp_container_override_forall (gtype.Val, ForallCallback);
|
|
||||||
}
|
|
||||||
|
|
||||||
[GLib.DefaultSignalHandler (Type=typeof(Gtk.Container), ConnectionMethod="OverrideForall")]
|
|
||||||
protected virtual void ForAll (bool include_internals, Gtk.Callback callback)
|
|
||||||
{
|
|
||||||
CallbackInvoker invoker;
|
|
||||||
try {
|
|
||||||
invoker = (CallbackInvoker)callback.Target;
|
|
||||||
} catch {
|
|
||||||
throw new ApplicationException ("ForAll can only be called as \"base.ForAll()\". Use Forall() or Foreach().");
|
|
||||||
}
|
|
||||||
gtksharp_container_base_forall (Handle, include_internals, invoker.Callback, invoker.Data);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compatibility code for old ChildType() virtual method
|
|
||||||
static IntPtr ObsoleteChildType_cb (IntPtr raw)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
Container obj = GLib.Object.GetObject (raw, false) as Container;
|
|
||||||
GLib.GType gtype = obj.ChildType ();
|
|
||||||
return gtype.Val;
|
|
||||||
} catch (Exception e) {
|
|
||||||
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
return GLib.GType.Invalid.Val;
|
|
||||||
}
|
|
||||||
|
|
||||||
static ChildTypeNativeDelegate ObsoleteChildTypeVMCallback;
|
|
||||||
|
|
||||||
static void OverrideObsoleteChildType (GLib.GType gtype)
|
|
||||||
{
|
|
||||||
if (ObsoleteChildTypeVMCallback == null)
|
|
||||||
ObsoleteChildTypeVMCallback = new ChildTypeNativeDelegate (ObsoleteChildType_cb);
|
|
||||||
OverrideChildType (gtype, ObsoleteChildTypeVMCallback); // -> autogenerated method
|
|
||||||
}
|
|
||||||
|
|
||||||
[Obsolete ("Replaced by OnChildType for implementations and SupportedChildType for callers.")]
|
|
||||||
[GLib.DefaultSignalHandler (Type=typeof(Gtk.Container), ConnectionMethod="OverrideObsoleteChildType")]
|
|
||||||
public virtual GLib.GType ChildType() {
|
|
||||||
return InternalChildType (); // -> autogenerated method
|
|
||||||
}
|
|
||||||
|
|
||||||
public class ContainerChild {
|
|
||||||
protected Container parent;
|
|
||||||
protected Widget child;
|
|
||||||
|
|
||||||
public ContainerChild (Container parent, Widget child)
|
|
||||||
{
|
|
||||||
this.parent = parent;
|
|
||||||
this.child = child;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Container Parent {
|
|
||||||
get {
|
|
||||||
return parent;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public Widget Child {
|
public IEnumerable AllChildren {
|
||||||
get {
|
get {
|
||||||
return child;
|
ChildAccumulator acc = new ChildAccumulator ();
|
||||||
|
Forall (new Gtk.Callback (acc.Add));
|
||||||
|
return acc.Children;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern bool gtk_container_get_focus_chain (IntPtr raw, out IntPtr list_ptr);
|
||||||
|
|
||||||
|
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern void gtk_container_set_focus_chain (IntPtr raw, IntPtr list_ptr);
|
||||||
|
|
||||||
|
public Widget[] FocusChain {
|
||||||
|
get {
|
||||||
|
IntPtr list_ptr;
|
||||||
|
bool success = gtk_container_get_focus_chain (Handle, out list_ptr);
|
||||||
|
if (!success)
|
||||||
|
return new Widget [0];
|
||||||
|
|
||||||
|
GLib.List list = new GLib.List (list_ptr);
|
||||||
|
Widget[] result = new Widget [list.Count];
|
||||||
|
for (int i = 0; i < list.Count; i++)
|
||||||
|
result [i] = list [i] as Widget;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
GLib.List list = new GLib.List (IntPtr.Zero);
|
||||||
|
foreach (Widget val in value)
|
||||||
|
list.Append (val.Handle);
|
||||||
|
gtk_container_set_focus_chain (Handle, list.Handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport("gtksharpglue-3")]
|
||||||
|
static extern void gtksharp_container_base_forall (IntPtr handle, bool include_internals, IntPtr cb, IntPtr data);
|
||||||
|
|
||||||
|
[DllImport("gtksharpglue-3")]
|
||||||
|
static extern void gtksharp_container_override_forall (IntPtr gtype, ForallDelegate cb);
|
||||||
|
|
||||||
|
[DllImport("gtksharpglue-3")]
|
||||||
|
static extern void gtksharp_container_invoke_gtk_callback (IntPtr cb, IntPtr handle, IntPtr data);
|
||||||
|
|
||||||
|
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||||
|
delegate void ForallDelegate (IntPtr container, bool include_internals, IntPtr cb, IntPtr data);
|
||||||
|
|
||||||
|
static ForallDelegate ForallOldCallback;
|
||||||
|
static ForallDelegate ForallCallback;
|
||||||
|
|
||||||
|
public struct CallbackInvoker {
|
||||||
|
IntPtr cb;
|
||||||
|
IntPtr data;
|
||||||
|
|
||||||
|
internal CallbackInvoker (IntPtr cb, IntPtr data)
|
||||||
|
{
|
||||||
|
this.cb = cb;
|
||||||
|
this.data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal IntPtr Data {
|
||||||
|
get {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal IntPtr Callback {
|
||||||
|
get {
|
||||||
|
return cb;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Invoke (Widget w)
|
||||||
|
{
|
||||||
|
gtksharp_container_invoke_gtk_callback (cb, w.Handle, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ForallOld_cb (IntPtr container, bool include_internals, IntPtr cb, IntPtr data)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
Container obj = GLib.Object.GetObject (container, false) as Container;
|
||||||
|
CallbackInvoker invoker = new CallbackInvoker (cb, data);
|
||||||
|
obj.ForAll (include_internals, invoker);
|
||||||
|
} catch (Exception e) {
|
||||||
|
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void OverrideForallOld (GLib.GType gtype)
|
||||||
|
{
|
||||||
|
if (ForallOldCallback == null)
|
||||||
|
ForallOldCallback = new ForallDelegate (ForallOld_cb);
|
||||||
|
gtksharp_container_override_forall (gtype.Val, ForallOldCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Obsolete ("Override the ForAll(bool,Gtk.Callback) method instead")]
|
||||||
|
[GLib.DefaultSignalHandler (Type=typeof(Gtk.Container), ConnectionMethod="OverrideForallOld")]
|
||||||
|
protected virtual void ForAll (bool include_internals, CallbackInvoker invoker)
|
||||||
|
{
|
||||||
|
gtksharp_container_base_forall (Handle, include_internals, invoker.Callback, invoker.Data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void Forall_cb (IntPtr container, bool include_internals, IntPtr cb, IntPtr data)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
Container obj = GLib.Object.GetObject (container, false) as Container;
|
||||||
|
CallbackInvoker invoker = new CallbackInvoker (cb, data);
|
||||||
|
obj.ForAll (include_internals, new Gtk.Callback (invoker.Invoke));
|
||||||
|
} catch (Exception e) {
|
||||||
|
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void OverrideForall (GLib.GType gtype)
|
||||||
|
{
|
||||||
|
if (ForallCallback == null)
|
||||||
|
ForallCallback = new ForallDelegate (Forall_cb);
|
||||||
|
gtksharp_container_override_forall (gtype.Val, ForallCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
[GLib.DefaultSignalHandler (Type=typeof(Gtk.Container), ConnectionMethod="OverrideForall")]
|
||||||
|
protected virtual void ForAll (bool include_internals, Gtk.Callback callback)
|
||||||
|
{
|
||||||
|
CallbackInvoker invoker;
|
||||||
|
try {
|
||||||
|
invoker = (CallbackInvoker)callback.Target;
|
||||||
|
} catch {
|
||||||
|
throw new ApplicationException ("ForAll can only be called as \"base.ForAll()\". Use Forall() or Foreach().");
|
||||||
|
}
|
||||||
|
gtksharp_container_base_forall (Handle, include_internals, invoker.Callback, invoker.Data);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compatibility code for old ChildType() virtual method
|
||||||
|
static IntPtr ObsoleteChildType_cb (IntPtr raw)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
Container obj = GLib.Object.GetObject (raw, false) as Container;
|
||||||
|
GLib.GType gtype = obj.ChildType ();
|
||||||
|
return gtype.Val;
|
||||||
|
} catch (Exception e) {
|
||||||
|
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return GLib.GType.Invalid.Val;
|
||||||
|
}
|
||||||
|
|
||||||
|
static ChildTypeNativeDelegate ObsoleteChildTypeVMCallback;
|
||||||
|
|
||||||
|
static void OverrideObsoleteChildType (GLib.GType gtype)
|
||||||
|
{
|
||||||
|
if (ObsoleteChildTypeVMCallback == null)
|
||||||
|
ObsoleteChildTypeVMCallback = new ChildTypeNativeDelegate (ObsoleteChildType_cb);
|
||||||
|
OverrideChildType (gtype, ObsoleteChildTypeVMCallback); // -> autogenerated method
|
||||||
|
}
|
||||||
|
|
||||||
|
[Obsolete ("Replaced by OnChildType for implementations and SupportedChildType for callers.")]
|
||||||
|
[GLib.DefaultSignalHandler (Type=typeof(Gtk.Container), ConnectionMethod="OverrideObsoleteChildType")]
|
||||||
|
public virtual GLib.GType ChildType() {
|
||||||
|
return InternalChildType (); // -> autogenerated method
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ContainerChild {
|
||||||
|
protected Container parent;
|
||||||
|
protected Widget child;
|
||||||
|
|
||||||
|
public ContainerChild (Container parent, Widget child)
|
||||||
|
{
|
||||||
|
this.parent = parent;
|
||||||
|
this.child = child;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Container Parent {
|
||||||
|
get {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Widget Child {
|
||||||
|
get {
|
||||||
|
return child;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual ContainerChild this [Widget w] {
|
||||||
|
get {
|
||||||
|
return new ContainerChild (this, w);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual ContainerChild this [Widget w] {
|
|
||||||
get {
|
|
||||||
return new ContainerChild (this, w);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -26,50 +26,50 @@ namespace Gtk {
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
public partial class Dialog {
|
public partial class Dialog {
|
||||||
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
static extern IntPtr gtk_dialog_new_with_buttons (IntPtr title, IntPtr i, int flags, IntPtr dummy);
|
static extern IntPtr gtk_dialog_new_with_buttons (IntPtr title, IntPtr i, int flags, IntPtr dummy);
|
||||||
public Dialog (string title, Gtk.Window parent, Gtk.DialogFlags flags, params object[] button_data) : base(IntPtr.Zero)
|
public Dialog (string title, Gtk.Window parent, Gtk.DialogFlags flags, params object[] button_data) : base(IntPtr.Zero)
|
||||||
{
|
{
|
||||||
if (GetType() != typeof (Dialog)) {
|
if (GetType() != typeof (Dialog)) {
|
||||||
GLib.Value[] vals = new GLib.Value [1];
|
GLib.Value[] vals = new GLib.Value [1];
|
||||||
string[] names = new string [1];
|
string[] names = new string [1];
|
||||||
names [0] = "title";
|
names [0] = "title";
|
||||||
vals [0] = new GLib.Value (title);
|
vals [0] = new GLib.Value (title);
|
||||||
CreateNativeObject (names, vals);
|
CreateNativeObject (names, vals);
|
||||||
TransientFor = parent;
|
TransientFor = parent;
|
||||||
if ((flags & DialogFlags.Modal) > 0)
|
if ((flags & DialogFlags.Modal) > 0)
|
||||||
Modal = true;
|
Modal = true;
|
||||||
if ((flags & DialogFlags.DestroyWithParent) > 0)
|
if ((flags & DialogFlags.DestroyWithParent) > 0)
|
||||||
DestroyWithParent = true;
|
DestroyWithParent = true;
|
||||||
} else {
|
} else {
|
||||||
IntPtr native = GLib.Marshaller.StringToPtrGStrdup (title);
|
IntPtr native = GLib.Marshaller.StringToPtrGStrdup (title);
|
||||||
Raw = gtk_dialog_new_with_buttons (native, parent == null ? IntPtr.Zero : parent.Handle, (int) flags, IntPtr.Zero);
|
Raw = gtk_dialog_new_with_buttons (native, parent == null ? IntPtr.Zero : parent.Handle, (int) flags, IntPtr.Zero);
|
||||||
GLib.Marshaller.Free (native);
|
GLib.Marshaller.Free (native);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < button_data.Length - 1; i += 2)
|
for (int i = 0; i < button_data.Length - 1; i += 2)
|
||||||
AddButton ((string) button_data [i], (int) button_data [i + 1]);
|
AddButton ((string) button_data [i], (int) button_data [i + 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddActionWidget (Widget child, ResponseType response)
|
public void AddActionWidget (Widget child, ResponseType response)
|
||||||
{
|
{
|
||||||
this.AddActionWidget (child, (int) response);
|
this.AddActionWidget (child, (int) response);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Gtk.Widget AddButton (string button_text, ResponseType response)
|
public Gtk.Widget AddButton (string button_text, ResponseType response)
|
||||||
{
|
{
|
||||||
return this.AddButton (button_text, (int) response);
|
return this.AddButton (button_text, (int) response);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Respond (ResponseType response)
|
public void Respond (ResponseType response)
|
||||||
{
|
{
|
||||||
this.Respond ((int) response);
|
this.Respond ((int) response);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Obsolete ("Replaced by AlternativeButtonOrder property")]
|
[Obsolete ("Replaced by AlternativeButtonOrder property")]
|
||||||
public int SetAlternativeButtonOrderFromArray (int n_params)
|
public int SetAlternativeButtonOrderFromArray (int n_params)
|
||||||
{
|
{
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
31
gtk/Entry.cs
31
gtk/Entry.cs
|
@ -20,24 +20,25 @@ namespace Gtk {
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
public partial class Entry {
|
public partial class Entry {
|
||||||
public int InsertText (string new_text)
|
|
||||||
{
|
|
||||||
int position = 0;
|
|
||||||
|
|
||||||
InsertText (new_text, ref position);
|
public int InsertText (string new_text)
|
||||||
|
{
|
||||||
|
int position = 0;
|
||||||
|
|
||||||
return position;
|
InsertText (new_text, ref position);
|
||||||
}
|
|
||||||
|
|
||||||
public Entry(string initialText): this()
|
return position;
|
||||||
{
|
}
|
||||||
Text = initialText;
|
|
||||||
}
|
|
||||||
|
|
||||||
[Obsolete("Replaced by IsEditable property")]
|
public Entry(string initialText): this()
|
||||||
public bool Editable {
|
{
|
||||||
get { return IsEditable; }
|
Text = initialText;
|
||||||
set { IsEditable = value; }
|
}
|
||||||
}
|
|
||||||
|
[Obsolete("Replaced by IsEditable property")]
|
||||||
|
public bool Editable {
|
||||||
|
get { return IsEditable; }
|
||||||
|
set { IsEditable = value; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace Gtk {
|
||||||
|
|
||||||
public partial class HBox {
|
public partial class HBox {
|
||||||
|
|
||||||
public HBox () : this (false, 0) {}
|
public HBox () : this (false, 0) {}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,14 +20,14 @@ namespace Gtk {
|
||||||
|
|
||||||
public partial class IconFactory {
|
public partial class IconFactory {
|
||||||
|
|
||||||
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
extern static void gtk_icon_size_lookup (IconSize size, out int width, out int height);
|
extern static void gtk_icon_size_lookup (IconSize size, out int width, out int height);
|
||||||
|
|
||||||
/// <summary> Query icon dimensions </summary>
|
/// <summary> Query icon dimensions </summary>
|
||||||
/// <remarks> Queries dimensions for icons of the specified size. </remarks>
|
/// <remarks> Queries dimensions for icons of the specified size. </remarks>
|
||||||
public void LookupIconSize (IconSize size, out int width, out int height)
|
public void LookupIconSize (IconSize size, out int width, out int height)
|
||||||
{
|
{
|
||||||
gtk_icon_size_lookup (size, out width, out height);
|
gtk_icon_size_lookup (size, out width, out height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,38 +15,38 @@
|
||||||
|
|
||||||
namespace Gtk {
|
namespace Gtk {
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
public partial class IconSet {
|
public partial class IconSet {
|
||||||
|
|
||||||
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
unsafe static extern void gtk_icon_set_get_sizes (
|
unsafe static extern void gtk_icon_set_get_sizes (
|
||||||
IntPtr raw, out int *pointer_to_enum, out int n_sizes);
|
IntPtr raw, out int *pointer_to_enum, out int n_sizes);
|
||||||
|
|
||||||
[DllImport ("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport ("libglib-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
unsafe static extern void g_free (int *mem);
|
unsafe static extern void g_free (int *mem);
|
||||||
|
|
||||||
/// <summary> Sizes Property </summary>
|
/// <summary> Sizes Property </summary>
|
||||||
/// <remarks> To be completed </remarks>
|
/// <remarks> To be completed </remarks>
|
||||||
public Gtk.IconSize [] Sizes {
|
public Gtk.IconSize [] Sizes {
|
||||||
get {
|
get {
|
||||||
|
|
||||||
Gtk.IconSize [] retval;
|
Gtk.IconSize [] retval;
|
||||||
|
|
||||||
unsafe {
|
|
||||||
int length;
|
|
||||||
int *pointer_to_enum;
|
|
||||||
gtk_icon_set_get_sizes (Handle, out pointer_to_enum, out length);
|
|
||||||
retval = new Gtk.IconSize [length];
|
|
||||||
for (int i = 0; i < length; i++)
|
|
||||||
retval [i] = (Gtk.IconSize) pointer_to_enum [i];
|
|
||||||
|
|
||||||
g_free (pointer_to_enum);
|
unsafe {
|
||||||
}
|
int length;
|
||||||
|
int *pointer_to_enum;
|
||||||
return retval;
|
gtk_icon_set_get_sizes (Handle, out pointer_to_enum, out length);
|
||||||
}
|
retval = new Gtk.IconSize [length];
|
||||||
}
|
for (int i = 0; i < length; i++)
|
||||||
}
|
retval [i] = (Gtk.IconSize) pointer_to_enum [i];
|
||||||
|
|
||||||
|
g_free (pointer_to_enum);
|
||||||
|
}
|
||||||
|
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,10 +76,10 @@ namespace Gtk {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string[] SearchPath {
|
public string[] SearchPath {
|
||||||
get {
|
get {
|
||||||
string[] retval;
|
string[] retval;
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
int length;
|
int length;
|
||||||
IntPtr raw_ret;
|
IntPtr raw_ret;
|
||||||
|
@ -97,7 +97,7 @@ namespace Gtk {
|
||||||
|
|
||||||
g_strfreev (raw_ret);
|
g_strfreev (raw_ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
|
|
50
gtk/Menu.cs
50
gtk/Menu.cs
|
@ -25,34 +25,34 @@ namespace Gtk {
|
||||||
|
|
||||||
public partial class Menu {
|
public partial class Menu {
|
||||||
|
|
||||||
[Obsolete("Replaced by overload without IntPtr argument")]
|
[Obsolete("Replaced by overload without IntPtr argument")]
|
||||||
public void Popup (Gtk.Widget parent_menu_shell, Gtk.Widget parent_menu_item, Gtk.MenuPositionFunc func, IntPtr data, uint button, uint activate_time) {
|
public void Popup (Gtk.Widget parent_menu_shell, Gtk.Widget parent_menu_item, Gtk.MenuPositionFunc func, IntPtr data, uint button, uint activate_time) {
|
||||||
Popup (parent_menu_shell, parent_menu_item, func, button, activate_time);
|
Popup (parent_menu_shell, parent_menu_item, func, button, activate_time);
|
||||||
}
|
|
||||||
|
|
||||||
public void Popup ()
|
|
||||||
{
|
|
||||||
Popup (null, null, null, 3, Global.CurrentEventTime);
|
|
||||||
}
|
|
||||||
|
|
||||||
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
static extern void gtk_menu_set_screen (IntPtr raw, IntPtr screen);
|
|
||||||
|
|
||||||
public new Gdk.Screen Screen {
|
|
||||||
get {
|
|
||||||
return base.Screen;
|
|
||||||
}
|
}
|
||||||
set {
|
|
||||||
gtk_menu_set_screen (Handle, value.Handle);
|
public void Popup ()
|
||||||
|
{
|
||||||
|
Popup (null, null, null, 3, Global.CurrentEventTime);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
static extern void gtk_menu_set_active (IntPtr raw, uint index_);
|
static extern void gtk_menu_set_screen (IntPtr raw, IntPtr screen);
|
||||||
|
|
||||||
public void SetActive (uint index_)
|
public new Gdk.Screen Screen {
|
||||||
{
|
get {
|
||||||
gtk_menu_set_active (Handle, index_);
|
return base.Screen;
|
||||||
}
|
}
|
||||||
|
set {
|
||||||
|
gtk_menu_set_screen (Handle, value.Handle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern void gtk_menu_set_active (IntPtr raw, uint index_);
|
||||||
|
|
||||||
|
public void SetActive (uint index_)
|
||||||
|
{
|
||||||
|
gtk_menu_set_active (Handle, index_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,30 +20,30 @@ namespace Gtk {
|
||||||
|
|
||||||
public partial class MessageDialog {
|
public partial class MessageDialog {
|
||||||
|
|
||||||
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
static extern IntPtr gtk_message_dialog_new (IntPtr parent_window, DialogFlags flags, MessageType type, ButtonsType bt, IntPtr msg, IntPtr args);
|
static extern IntPtr gtk_message_dialog_new (IntPtr parent_window, DialogFlags flags, MessageType type, ButtonsType bt, IntPtr msg, IntPtr args);
|
||||||
|
|
||||||
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
static extern IntPtr gtk_message_dialog_new_with_markup (IntPtr parent_window, DialogFlags flags, MessageType type, ButtonsType bt, IntPtr msg, IntPtr args);
|
static extern IntPtr gtk_message_dialog_new_with_markup (IntPtr parent_window, DialogFlags flags, MessageType type, ButtonsType bt, IntPtr msg, IntPtr args);
|
||||||
|
|
||||||
public MessageDialog (Gtk.Window parent_window, DialogFlags flags, MessageType type, ButtonsType bt, bool use_markup, string format, params object[] args)
|
public MessageDialog (Gtk.Window parent_window, DialogFlags flags, MessageType type, ButtonsType bt, bool use_markup, string format, params object[] args)
|
||||||
{
|
{
|
||||||
IntPtr p = (parent_window != null) ? parent_window.Handle : IntPtr.Zero;
|
IntPtr p = (parent_window != null) ? parent_window.Handle : IntPtr.Zero;
|
||||||
|
|
||||||
if (format == null) {
|
if (format == null) {
|
||||||
Raw = gtk_message_dialog_new (p, flags, type, bt, IntPtr.Zero, IntPtr.Zero);
|
Raw = gtk_message_dialog_new (p, flags, type, bt, IntPtr.Zero, IntPtr.Zero);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IntPtr nmsg = GLib.Marshaller.StringToPtrGStrdup (GLib.Marshaller.StringFormat (format, args));
|
IntPtr nmsg = GLib.Marshaller.StringToPtrGStrdup (GLib.Marshaller.StringFormat (format, args));
|
||||||
if (use_markup)
|
if (use_markup)
|
||||||
Raw = gtk_message_dialog_new_with_markup (p, flags, type, bt, nmsg, IntPtr.Zero);
|
Raw = gtk_message_dialog_new_with_markup (p, flags, type, bt, nmsg, IntPtr.Zero);
|
||||||
else
|
else
|
||||||
Raw = gtk_message_dialog_new (p, flags, type, bt, nmsg, IntPtr.Zero);
|
Raw = gtk_message_dialog_new (p, flags, type, bt, nmsg, IntPtr.Zero);
|
||||||
GLib.Marshaller.Free (nmsg);
|
GLib.Marshaller.Free (nmsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MessageDialog (Gtk.Window parent_window, DialogFlags flags, MessageType type, ButtonsType bt, string format, params object[] args) : this (parent_window, flags, type, bt, true, format, args) {}
|
public MessageDialog (Gtk.Window parent_window, DialogFlags flags, MessageType type, ButtonsType bt, string format, params object[] args) : this (parent_window, flags, type, bt, true, format, args) {}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ namespace Gtk {
|
||||||
return selection.PathIsSelected (path);
|
return selection.PathIsSelected (path);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SelectAll ()
|
public void SelectAll ()
|
||||||
{
|
{
|
||||||
selection.SelectAll ();
|
selection.SelectAll ();
|
||||||
}
|
}
|
||||||
|
|
|
@ -129,8 +129,7 @@ namespace Gtk {
|
||||||
throw new Exception (String.Format ("You have two TreeNodeValueAttributes with the Column={0}", col));
|
throw new Exception (String.Format ("You have two TreeNodeValueAttributes with the Column={0}", col));
|
||||||
|
|
||||||
getters [col] = mi;
|
getters [col] = mi;
|
||||||
Type t = mi is PropertyInfo ? ((PropertyInfo) mi).PropertyType
|
Type t = mi is PropertyInfo ? ((PropertyInfo) mi).PropertyType : ((FieldInfo) mi).FieldType;
|
||||||
: ((FieldInfo) mi).FieldType;
|
|
||||||
ctypes [col] = (GLib.GType) t;
|
ctypes [col] = (GLib.GType) t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,18 +26,18 @@ namespace Gtk {
|
||||||
|
|
||||||
public partial class Notebook {
|
public partial class Notebook {
|
||||||
|
|
||||||
public Widget CurrentPageWidget {
|
public Widget CurrentPageWidget {
|
||||||
get {
|
get {
|
||||||
return GetNthPage (CurrentPage);
|
return GetNthPage (CurrentPage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
static extern int gtk_notebook_page_num (IntPtr handle, IntPtr child);
|
static extern int gtk_notebook_page_num (IntPtr handle, IntPtr child);
|
||||||
|
|
||||||
public int PageNum (Widget child)
|
public int PageNum (Widget child)
|
||||||
{
|
{
|
||||||
return gtk_notebook_page_num (Handle, child.Handle);
|
return gtk_notebook_page_num (Handle, child.Handle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,15 +25,15 @@ namespace Gtk {
|
||||||
|
|
||||||
public partial class RadioButton {
|
public partial class RadioButton {
|
||||||
|
|
||||||
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
static extern IntPtr gtk_radio_button_new_with_mnemonic (IntPtr group, IntPtr label);
|
static extern IntPtr gtk_radio_button_new_with_mnemonic (IntPtr group, IntPtr label);
|
||||||
|
|
||||||
// creates a new group for this RadioButton
|
// creates a new group for this RadioButton
|
||||||
public RadioButton (string label)
|
public RadioButton (string label)
|
||||||
{
|
{
|
||||||
IntPtr native = GLib.Marshaller.StringToPtrGStrdup (label);
|
IntPtr native = GLib.Marshaller.StringToPtrGStrdup (label);
|
||||||
Raw = gtk_radio_button_new_with_mnemonic (IntPtr.Zero, native);
|
Raw = gtk_radio_button_new_with_mnemonic (IntPtr.Zero, native);
|
||||||
GLib.Marshaller.Free (native);
|
GLib.Marshaller.Free (native);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,13 +24,13 @@ namespace Gtk {
|
||||||
|
|
||||||
public partial struct StockItem {
|
public partial struct StockItem {
|
||||||
|
|
||||||
public StockItem (string stock_id, string label, uint keyval, Gdk.ModifierType modifier, string domain)
|
public StockItem (string stock_id, string label, uint keyval, Gdk.ModifierType modifier, string domain)
|
||||||
{
|
{
|
||||||
this.StockId = stock_id;
|
this.StockId = stock_id;
|
||||||
this.Label = label;
|
this.Label = label;
|
||||||
this.Keyval = keyval;
|
this.Keyval = keyval;
|
||||||
this.Modifier = modifier;
|
this.Modifier = modifier;
|
||||||
this.TranslationDomain = domain;
|
this.TranslationDomain = domain;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
328
gtk/Style.cs
328
gtk/Style.cs
|
@ -208,171 +208,171 @@ public void SetMidGC (StateType state, Gdk.GC gc)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
[DllImport("gtksharpglue-3")]
|
[DllImport("gtksharpglue-3")]
|
||||||
static extern IntPtr gtksharp_gtk_style_get_bg (IntPtr style, int i);
|
static extern IntPtr gtksharp_gtk_style_get_bg (IntPtr style, int i);
|
||||||
|
|
||||||
public Gdk.Color Background (StateType state)
|
public Gdk.Color Background (StateType state)
|
||||||
{
|
{
|
||||||
IntPtr raw = gtksharp_gtk_style_get_bg (Handle, (int) state);
|
IntPtr raw = gtksharp_gtk_style_get_bg (Handle, (int) state);
|
||||||
return Gdk.Color.New (raw);
|
return Gdk.Color.New (raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Gdk.Color[] Backgrounds {
|
public Gdk.Color[] Backgrounds {
|
||||||
get {
|
get {
|
||||||
Gdk.Color[] ret = new Gdk.Color[5];
|
Gdk.Color[] ret = new Gdk.Color[5];
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < 5; i++)
|
||||||
ret[i] = Gdk.Color.New (gtksharp_gtk_style_get_bg (Handle, i));
|
ret[i] = Gdk.Color.New (gtksharp_gtk_style_get_bg (Handle, i));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport("gtksharpglue-3")]
|
[DllImport("gtksharpglue-3")]
|
||||||
static extern IntPtr gtksharp_gtk_style_get_fg (IntPtr style, int i);
|
static extern IntPtr gtksharp_gtk_style_get_fg (IntPtr style, int i);
|
||||||
|
|
||||||
public Gdk.Color Foreground (StateType state)
|
public Gdk.Color Foreground (StateType state)
|
||||||
{
|
{
|
||||||
IntPtr raw = gtksharp_gtk_style_get_fg (Handle, (int) state);
|
IntPtr raw = gtksharp_gtk_style_get_fg (Handle, (int) state);
|
||||||
return Gdk.Color.New (raw);
|
return Gdk.Color.New (raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Gdk.Color[] Foregrounds {
|
public Gdk.Color[] Foregrounds {
|
||||||
get {
|
get {
|
||||||
Gdk.Color[] ret = new Gdk.Color[5];
|
Gdk.Color[] ret = new Gdk.Color[5];
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < 5; i++)
|
||||||
ret[i] = Gdk.Color.New (gtksharp_gtk_style_get_fg (Handle, i));
|
ret[i] = Gdk.Color.New (gtksharp_gtk_style_get_fg (Handle, i));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport("gtksharpglue-3")]
|
[DllImport("gtksharpglue-3")]
|
||||||
static extern IntPtr gtksharp_gtk_style_get_text (IntPtr style, int i);
|
static extern IntPtr gtksharp_gtk_style_get_text (IntPtr style, int i);
|
||||||
|
|
||||||
public Gdk.Color Text (StateType state)
|
public Gdk.Color Text (StateType state)
|
||||||
{
|
{
|
||||||
IntPtr raw = gtksharp_gtk_style_get_text (Handle, (int) state);
|
IntPtr raw = gtksharp_gtk_style_get_text (Handle, (int) state);
|
||||||
return Gdk.Color.New (raw);
|
return Gdk.Color.New (raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Gdk.Color[] TextColors {
|
public Gdk.Color[] TextColors {
|
||||||
get {
|
get {
|
||||||
Gdk.Color[] ret = new Gdk.Color[5];
|
Gdk.Color[] ret = new Gdk.Color[5];
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < 5; i++)
|
||||||
ret[i] = Gdk.Color.New (gtksharp_gtk_style_get_text (Handle, i));
|
ret[i] = Gdk.Color.New (gtksharp_gtk_style_get_text (Handle, i));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport("gtksharpglue-3")]
|
[DllImport("gtksharpglue-3")]
|
||||||
static extern IntPtr gtksharp_gtk_style_get_base (IntPtr style, int i);
|
static extern IntPtr gtksharp_gtk_style_get_base (IntPtr style, int i);
|
||||||
|
|
||||||
public Gdk.Color Base (StateType state)
|
public Gdk.Color Base (StateType state)
|
||||||
{
|
{
|
||||||
IntPtr raw = gtksharp_gtk_style_get_base (Handle, (int) state);
|
IntPtr raw = gtksharp_gtk_style_get_base (Handle, (int) state);
|
||||||
return Gdk.Color.New (raw);
|
return Gdk.Color.New (raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Gdk.Color[] BaseColors {
|
public Gdk.Color[] BaseColors {
|
||||||
get {
|
get {
|
||||||
Gdk.Color[] ret = new Gdk.Color[5];
|
Gdk.Color[] ret = new Gdk.Color[5];
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < 5; i++)
|
||||||
ret[i] = Gdk.Color.New (gtksharp_gtk_style_get_base (Handle, i));
|
ret[i] = Gdk.Color.New (gtksharp_gtk_style_get_base (Handle, i));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport("gtksharpglue-3")]
|
[DllImport("gtksharpglue-3")]
|
||||||
static extern IntPtr gtksharp_gtk_style_get_light (IntPtr style, int i);
|
static extern IntPtr gtksharp_gtk_style_get_light (IntPtr style, int i);
|
||||||
|
|
||||||
public Gdk.Color Light (StateType state)
|
public Gdk.Color Light (StateType state)
|
||||||
{
|
{
|
||||||
IntPtr raw = gtksharp_gtk_style_get_light (Handle, (int) state);
|
IntPtr raw = gtksharp_gtk_style_get_light (Handle, (int) state);
|
||||||
return Gdk.Color.New (raw);
|
return Gdk.Color.New (raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Gdk.Color[] LightColors {
|
public Gdk.Color[] LightColors {
|
||||||
get {
|
get {
|
||||||
Gdk.Color[] ret = new Gdk.Color[5];
|
Gdk.Color[] ret = new Gdk.Color[5];
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < 5; i++)
|
||||||
ret[i] = Gdk.Color.New (gtksharp_gtk_style_get_light (Handle, i));
|
ret[i] = Gdk.Color.New (gtksharp_gtk_style_get_light (Handle, i));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport("gtksharpglue-3")]
|
[DllImport("gtksharpglue-3")]
|
||||||
static extern IntPtr gtksharp_gtk_style_get_mid (IntPtr style, int i);
|
static extern IntPtr gtksharp_gtk_style_get_mid (IntPtr style, int i);
|
||||||
|
|
||||||
public Gdk.Color Mid (StateType state)
|
public Gdk.Color Mid (StateType state)
|
||||||
{
|
{
|
||||||
IntPtr raw = gtksharp_gtk_style_get_mid (Handle, (int) state);
|
IntPtr raw = gtksharp_gtk_style_get_mid (Handle, (int) state);
|
||||||
return Gdk.Color.New (raw);
|
return Gdk.Color.New (raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Gdk.Color[] MidColors {
|
public Gdk.Color[] MidColors {
|
||||||
get {
|
get {
|
||||||
Gdk.Color[] ret = new Gdk.Color[5];
|
Gdk.Color[] ret = new Gdk.Color[5];
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < 5; i++)
|
||||||
ret[i] = Gdk.Color.New (gtksharp_gtk_style_get_mid (Handle, i));
|
ret[i] = Gdk.Color.New (gtksharp_gtk_style_get_mid (Handle, i));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport("gtksharpglue-3")]
|
[DllImport("gtksharpglue-3")]
|
||||||
static extern IntPtr gtksharp_gtk_style_get_dark (IntPtr style, int i);
|
static extern IntPtr gtksharp_gtk_style_get_dark (IntPtr style, int i);
|
||||||
|
|
||||||
public Gdk.Color Dark (StateType state)
|
public Gdk.Color Dark (StateType state)
|
||||||
{
|
{
|
||||||
IntPtr raw = gtksharp_gtk_style_get_dark (Handle, (int) state);
|
IntPtr raw = gtksharp_gtk_style_get_dark (Handle, (int) state);
|
||||||
return Gdk.Color.New (raw);
|
return Gdk.Color.New (raw);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Gdk.Color[] DarkColors {
|
public Gdk.Color[] DarkColors {
|
||||||
get {
|
get {
|
||||||
Gdk.Color[] ret = new Gdk.Color[5];
|
Gdk.Color[] ret = new Gdk.Color[5];
|
||||||
for (int i = 0; i < 5; i++)
|
for (int i = 0; i < 5; i++)
|
||||||
ret[i] = Gdk.Color.New (gtksharp_gtk_style_get_dark (Handle, i));
|
ret[i] = Gdk.Color.New (gtksharp_gtk_style_get_dark (Handle, i));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport ("gtksharpglue-3")]
|
[DllImport ("gtksharpglue-3")]
|
||||||
static extern int gtksharp_gtk_style_get_thickness (IntPtr style, int x_axis);
|
static extern int gtksharp_gtk_style_get_thickness (IntPtr style, int x_axis);
|
||||||
[DllImport ("gtksharpglue-3")]
|
[DllImport ("gtksharpglue-3")]
|
||||||
static extern void gtksharp_gtk_style_set_thickness (IntPtr style, int value);
|
static extern void gtksharp_gtk_style_set_thickness (IntPtr style, int value);
|
||||||
|
|
||||||
public int XThickness {
|
public int XThickness {
|
||||||
get {
|
get {
|
||||||
return gtksharp_gtk_style_get_thickness (Handle, 0);
|
return gtksharp_gtk_style_get_thickness (Handle, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
set {
|
set {
|
||||||
gtksharp_gtk_style_set_thickness (Handle, value);
|
gtksharp_gtk_style_set_thickness (Handle, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int YThickness {
|
public int YThickness {
|
||||||
get {
|
get {
|
||||||
return gtksharp_gtk_style_get_thickness (Handle, 1);
|
return gtksharp_gtk_style_get_thickness (Handle, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
set {
|
set {
|
||||||
gtksharp_gtk_style_set_thickness (Handle, -value);
|
gtksharp_gtk_style_set_thickness (Handle, -value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport ("gtksharpglue-3")]
|
[DllImport ("gtksharpglue-3")]
|
||||||
static extern IntPtr gtksharp_gtk_style_get_font_description (IntPtr style);
|
static extern IntPtr gtksharp_gtk_style_get_font_description (IntPtr style);
|
||||||
|
|
||||||
public Pango.FontDescription FontDescription {
|
public Pango.FontDescription FontDescription {
|
||||||
get {
|
get {
|
||||||
IntPtr Raw = gtksharp_gtk_style_get_font_description (Handle);
|
IntPtr Raw = gtksharp_gtk_style_get_font_description (Handle);
|
||||||
|
|
||||||
if (Raw == IntPtr.Zero)
|
if (Raw == IntPtr.Zero)
|
||||||
return null;
|
return null;
|
||||||
Pango.FontDescription ret = (Pango.FontDescription) GLib.Opaque.GetOpaque (Raw, typeof (Pango.FontDescription), false);
|
Pango.FontDescription ret = (Pango.FontDescription) GLib.Opaque.GetOpaque (Raw, typeof (Pango.FontDescription), false);
|
||||||
if (ret == null)
|
if (ret == null)
|
||||||
ret = new Pango.FontDescription (Raw);
|
ret = new Pango.FontDescription (Raw);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,167 +25,167 @@ namespace Gtk {
|
||||||
|
|
||||||
public partial class TextBuffer {
|
public partial class TextBuffer {
|
||||||
|
|
||||||
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
static extern void gtk_text_buffer_set_text (IntPtr raw, IntPtr text, int len);
|
static extern void gtk_text_buffer_set_text (IntPtr raw, IntPtr text, int len);
|
||||||
|
|
||||||
public void Clear ()
|
public void Clear ()
|
||||||
{
|
{
|
||||||
Gtk.TextIter start = StartIter, end = EndIter;
|
Gtk.TextIter start = StartIter, end = EndIter;
|
||||||
Delete (ref start, ref end);
|
Delete (ref start, ref end);
|
||||||
}
|
|
||||||
|
|
||||||
[Obsolete ("Replaced by 'ref TextIter, ref TextIter' overload")]
|
|
||||||
public void Delete (TextIter start, TextIter end )
|
|
||||||
{
|
|
||||||
Delete (ref start, ref end);
|
|
||||||
}
|
|
||||||
|
|
||||||
// overload to paste clipboard contents at cursor editable by default.
|
|
||||||
public void PasteClipboard (Gtk.Clipboard clipboard)
|
|
||||||
{
|
|
||||||
gtk_text_buffer_paste_clipboard(Handle, clipboard.Handle, IntPtr.Zero, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
static extern void gtk_text_buffer_insert (IntPtr raw, ref Gtk.TextIter iter, IntPtr text, int len);
|
|
||||||
|
|
||||||
[Obsolete ("Replaced by 'ref TextIter iter' overload")]
|
|
||||||
public void Insert (TextIter iter, string text)
|
|
||||||
{
|
|
||||||
Insert (ref iter, text);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Insert (ref Gtk.TextIter iter, string text)
|
|
||||||
{
|
|
||||||
IntPtr native = GLib.Marshaller.StringToPtrGStrdup (text);
|
|
||||||
gtk_text_buffer_insert (Handle, ref iter, native, -1);
|
|
||||||
GLib.Marshaller.Free (native);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Obsolete ("Replaced by 'ref TextIter iter' overload")]
|
|
||||||
public void InsertRange (TextIter iter, TextIter start, TextIter end )
|
|
||||||
{
|
|
||||||
InsertRange (ref iter, start, end);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Obsolete ("Replaced by 'ref TextIter iter' overload")]
|
|
||||||
public void InsertWithTags (TextIter iter, string text, params TextTag[] tags)
|
|
||||||
{
|
|
||||||
InsertWithTags (ref iter, text, tags);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void InsertWithTags (ref TextIter iter, string text, params TextTag[] tags)
|
|
||||||
{
|
|
||||||
TextIter start;
|
|
||||||
int offset = iter.Offset;
|
|
||||||
Insert (ref iter, text);
|
|
||||||
|
|
||||||
start = GetIterAtOffset (offset);
|
|
||||||
iter = GetIterAtOffset (offset + text.Length);
|
|
||||||
|
|
||||||
foreach (TextTag t in tags)
|
|
||||||
this.ApplyTag (t, start, iter);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void InsertWithTagsByName (ref TextIter iter, string text, params string[] tagnames)
|
|
||||||
{
|
|
||||||
TextIter start;
|
|
||||||
int offset = iter.Offset;
|
|
||||||
Insert (ref iter, text);
|
|
||||||
|
|
||||||
start = GetIterAtOffset (offset);
|
|
||||||
iter = GetIterAtOffset (offset + text.Length);
|
|
||||||
|
|
||||||
foreach (string tagname in tagnames) {
|
|
||||||
TextTag tag = TagTable.Lookup (tagname);
|
|
||||||
if (tag != null)
|
|
||||||
this.ApplyTag (tag, start, iter);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Obsolete("Use the TextBuffer.Text property's setter")]
|
|
||||||
public void SetText (string text)
|
|
||||||
{
|
|
||||||
Text = text;
|
|
||||||
}
|
|
||||||
|
|
||||||
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
static extern bool gtk_text_buffer_insert_interactive(IntPtr raw, ref Gtk.TextIter iter, IntPtr text, int len, bool default_editable);
|
|
||||||
|
|
||||||
public bool InsertInteractive(ref Gtk.TextIter iter, string text, bool default_editable)
|
|
||||||
{
|
|
||||||
IntPtr native = GLib.Marshaller.StringToPtrGStrdup (text);
|
|
||||||
bool result = gtk_text_buffer_insert_interactive(Handle, ref iter, native, -1, default_editable);
|
|
||||||
GLib.Marshaller.Free (native);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
static extern bool gtk_text_buffer_insert_interactive_at_cursor(IntPtr raw, IntPtr text, int len, bool default_editable);
|
|
||||||
|
|
||||||
public bool InsertInteractiveAtCursor(string text, bool default_editable)
|
|
||||||
{
|
|
||||||
IntPtr native = GLib.Marshaller.StringToPtrGStrdup (text);
|
|
||||||
bool result = gtk_text_buffer_insert_interactive_at_cursor(Handle, native, -1, default_editable);
|
|
||||||
GLib.Marshaller.Free (native);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
static extern void gtk_text_buffer_insert_at_cursor(IntPtr raw, IntPtr text, int len);
|
|
||||||
|
|
||||||
public void InsertAtCursor(string text)
|
|
||||||
{
|
|
||||||
IntPtr native = GLib.Marshaller.StringToPtrGStrdup (text);
|
|
||||||
gtk_text_buffer_insert_at_cursor(Handle, native, -1);
|
|
||||||
GLib.Marshaller.Free (native);
|
|
||||||
}
|
|
||||||
|
|
||||||
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
static extern IntPtr gtk_text_buffer_serialize (IntPtr raw, IntPtr content_buffer, IntPtr format, ref Gtk.TextIter start, ref Gtk.TextIter end, out UIntPtr length);
|
|
||||||
|
|
||||||
public byte[] Serialize(Gtk.TextBuffer content_buffer, Gdk.Atom format, Gtk.TextIter start, Gtk.TextIter end)
|
|
||||||
{
|
|
||||||
UIntPtr length;
|
|
||||||
IntPtr raw_ret = gtk_text_buffer_serialize (Handle, content_buffer == null ? IntPtr.Zero : content_buffer.Handle, format == null ? IntPtr.Zero : format.Handle, ref start, ref end, out length);
|
|
||||||
if (raw_ret == IntPtr.Zero)
|
|
||||||
return new byte [0];
|
|
||||||
int sz = (int) (uint) length;
|
|
||||||
byte[] ret = new byte [sz];
|
|
||||||
Marshal.Copy (raw_ret, ret, 0, sz);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
static extern IntPtr gtk_text_buffer_get_serialize_formats(IntPtr raw, out int n_formats);
|
|
||||||
|
|
||||||
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
static extern IntPtr gtk_text_buffer_get_deserialize_formats(IntPtr raw, out int n_formats);
|
|
||||||
|
|
||||||
public Gdk.Atom[] DeserializeFormats {
|
|
||||||
get {
|
|
||||||
int n_formats;
|
|
||||||
IntPtr raw_ret = gtk_text_buffer_get_deserialize_formats(Handle, out n_formats);
|
|
||||||
Gdk.Atom[] result = new Gdk.Atom [n_formats];
|
|
||||||
for (int i = 0; i < n_formats; i++) {
|
|
||||||
IntPtr format = Marshal.ReadIntPtr (raw_ret, i * IntPtr.Size);
|
|
||||||
result [i] = format == IntPtr.Zero ? null : (Gdk.Atom) GLib.Opaque.GetOpaque (format, typeof (Gdk.Atom), false);
|
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Gdk.Atom[] SerializeFormats {
|
[Obsolete ("Replaced by 'ref TextIter, ref TextIter' overload")]
|
||||||
get {
|
public void Delete (TextIter start, TextIter end )
|
||||||
int n_formats;
|
{
|
||||||
IntPtr raw_ret = gtk_text_buffer_get_serialize_formats(Handle, out n_formats);
|
Delete (ref start, ref end);
|
||||||
Gdk.Atom[] result = new Gdk.Atom [n_formats];
|
}
|
||||||
for (int i = 0; i < n_formats; i++) {
|
|
||||||
IntPtr format = Marshal.ReadIntPtr (raw_ret, i * IntPtr.Size);
|
// overload to paste clipboard contents at cursor editable by default.
|
||||||
result [i] = format == IntPtr.Zero ? null : (Gdk.Atom) GLib.Opaque.GetOpaque (format, typeof (Gdk.Atom), false);
|
public void PasteClipboard (Gtk.Clipboard clipboard)
|
||||||
|
{
|
||||||
|
gtk_text_buffer_paste_clipboard(Handle, clipboard.Handle, IntPtr.Zero, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern void gtk_text_buffer_insert (IntPtr raw, ref Gtk.TextIter iter, IntPtr text, int len);
|
||||||
|
|
||||||
|
[Obsolete ("Replaced by 'ref TextIter iter' overload")]
|
||||||
|
public void Insert (TextIter iter, string text)
|
||||||
|
{
|
||||||
|
Insert (ref iter, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Insert (ref Gtk.TextIter iter, string text)
|
||||||
|
{
|
||||||
|
IntPtr native = GLib.Marshaller.StringToPtrGStrdup (text);
|
||||||
|
gtk_text_buffer_insert (Handle, ref iter, native, -1);
|
||||||
|
GLib.Marshaller.Free (native);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Obsolete ("Replaced by 'ref TextIter iter' overload")]
|
||||||
|
public void InsertRange (TextIter iter, TextIter start, TextIter end )
|
||||||
|
{
|
||||||
|
InsertRange (ref iter, start, end);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Obsolete ("Replaced by 'ref TextIter iter' overload")]
|
||||||
|
public void InsertWithTags (TextIter iter, string text, params TextTag[] tags)
|
||||||
|
{
|
||||||
|
InsertWithTags (ref iter, text, tags);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void InsertWithTags (ref TextIter iter, string text, params TextTag[] tags)
|
||||||
|
{
|
||||||
|
TextIter start;
|
||||||
|
int offset = iter.Offset;
|
||||||
|
Insert (ref iter, text);
|
||||||
|
|
||||||
|
start = GetIterAtOffset (offset);
|
||||||
|
iter = GetIterAtOffset (offset + text.Length);
|
||||||
|
|
||||||
|
foreach (TextTag t in tags)
|
||||||
|
this.ApplyTag (t, start, iter);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void InsertWithTagsByName (ref TextIter iter, string text, params string[] tagnames)
|
||||||
|
{
|
||||||
|
TextIter start;
|
||||||
|
int offset = iter.Offset;
|
||||||
|
Insert (ref iter, text);
|
||||||
|
|
||||||
|
start = GetIterAtOffset (offset);
|
||||||
|
iter = GetIterAtOffset (offset + text.Length);
|
||||||
|
|
||||||
|
foreach (string tagname in tagnames) {
|
||||||
|
TextTag tag = TagTable.Lookup (tagname);
|
||||||
|
if (tag != null)
|
||||||
|
this.ApplyTag (tag, start, iter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Obsolete("Use the TextBuffer.Text property's setter")]
|
||||||
|
public void SetText (string text)
|
||||||
|
{
|
||||||
|
Text = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern bool gtk_text_buffer_insert_interactive(IntPtr raw, ref Gtk.TextIter iter, IntPtr text, int len, bool default_editable);
|
||||||
|
|
||||||
|
public bool InsertInteractive(ref Gtk.TextIter iter, string text, bool default_editable)
|
||||||
|
{
|
||||||
|
IntPtr native = GLib.Marshaller.StringToPtrGStrdup (text);
|
||||||
|
bool result = gtk_text_buffer_insert_interactive(Handle, ref iter, native, -1, default_editable);
|
||||||
|
GLib.Marshaller.Free (native);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern bool gtk_text_buffer_insert_interactive_at_cursor(IntPtr raw, IntPtr text, int len, bool default_editable);
|
||||||
|
|
||||||
|
public bool InsertInteractiveAtCursor(string text, bool default_editable)
|
||||||
|
{
|
||||||
|
IntPtr native = GLib.Marshaller.StringToPtrGStrdup (text);
|
||||||
|
bool result = gtk_text_buffer_insert_interactive_at_cursor(Handle, native, -1, default_editable);
|
||||||
|
GLib.Marshaller.Free (native);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern void gtk_text_buffer_insert_at_cursor(IntPtr raw, IntPtr text, int len);
|
||||||
|
|
||||||
|
public void InsertAtCursor(string text)
|
||||||
|
{
|
||||||
|
IntPtr native = GLib.Marshaller.StringToPtrGStrdup (text);
|
||||||
|
gtk_text_buffer_insert_at_cursor(Handle, native, -1);
|
||||||
|
GLib.Marshaller.Free (native);
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern IntPtr gtk_text_buffer_serialize (IntPtr raw, IntPtr content_buffer, IntPtr format, ref Gtk.TextIter start, ref Gtk.TextIter end, out UIntPtr length);
|
||||||
|
|
||||||
|
public byte[] Serialize(Gtk.TextBuffer content_buffer, Gdk.Atom format, Gtk.TextIter start, Gtk.TextIter end)
|
||||||
|
{
|
||||||
|
UIntPtr length;
|
||||||
|
IntPtr raw_ret = gtk_text_buffer_serialize (Handle, content_buffer == null ? IntPtr.Zero : content_buffer.Handle, format == null ? IntPtr.Zero : format.Handle, ref start, ref end, out length);
|
||||||
|
if (raw_ret == IntPtr.Zero)
|
||||||
|
return new byte [0];
|
||||||
|
int sz = (int) (uint) length;
|
||||||
|
byte[] ret = new byte [sz];
|
||||||
|
Marshal.Copy (raw_ret, ret, 0, sz);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern IntPtr gtk_text_buffer_get_serialize_formats(IntPtr raw, out int n_formats);
|
||||||
|
|
||||||
|
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern IntPtr gtk_text_buffer_get_deserialize_formats(IntPtr raw, out int n_formats);
|
||||||
|
|
||||||
|
public Gdk.Atom[] DeserializeFormats {
|
||||||
|
get {
|
||||||
|
int n_formats;
|
||||||
|
IntPtr raw_ret = gtk_text_buffer_get_deserialize_formats(Handle, out n_formats);
|
||||||
|
Gdk.Atom[] result = new Gdk.Atom [n_formats];
|
||||||
|
for (int i = 0; i < n_formats; i++) {
|
||||||
|
IntPtr format = Marshal.ReadIntPtr (raw_ret, i * IntPtr.Size);
|
||||||
|
result [i] = format == IntPtr.Zero ? null : (Gdk.Atom) GLib.Opaque.GetOpaque (format, typeof (Gdk.Atom), false);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Gdk.Atom[] SerializeFormats {
|
||||||
|
get {
|
||||||
|
int n_formats;
|
||||||
|
IntPtr raw_ret = gtk_text_buffer_get_serialize_formats(Handle, out n_formats);
|
||||||
|
Gdk.Atom[] result = new Gdk.Atom [n_formats];
|
||||||
|
for (int i = 0; i < n_formats; i++) {
|
||||||
|
IntPtr format = Marshal.ReadIntPtr (raw_ret, i * IntPtr.Size);
|
||||||
|
result [i] = format == IntPtr.Zero ? null : (Gdk.Atom) GLib.Opaque.GetOpaque (format, typeof (Gdk.Atom), false);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,27 +24,27 @@ namespace Gtk {
|
||||||
|
|
||||||
public partial interface TreeModel {
|
public partial interface TreeModel {
|
||||||
|
|
||||||
/// <summary>IterChildren Method</summary>
|
/// <summary>IterChildren Method</summary>
|
||||||
/// <remarks>To be completed</remarks>
|
/// <remarks>To be completed</remarks>
|
||||||
bool IterChildren (out Gtk.TreeIter iter);
|
bool IterChildren (out Gtk.TreeIter iter);
|
||||||
|
|
||||||
/// <summary>IterNChildren Method</summary>
|
/// <summary>IterNChildren Method</summary>
|
||||||
/// <remarks>To be completed</remarks>
|
/// <remarks>To be completed</remarks>
|
||||||
int IterNChildren ();
|
int IterNChildren ();
|
||||||
|
|
||||||
/// <summary>IterNthChild Method</summary>
|
/// <summary>IterNthChild Method</summary>
|
||||||
/// <remarks>To be completed</remarks>
|
/// <remarks>To be completed</remarks>
|
||||||
bool IterNthChild (out Gtk.TreeIter iter, int n);
|
bool IterNthChild (out Gtk.TreeIter iter, int n);
|
||||||
|
|
||||||
void SetValue (Gtk.TreeIter iter, int column, bool value);
|
void SetValue (Gtk.TreeIter iter, int column, bool value);
|
||||||
void SetValue (Gtk.TreeIter iter, int column, double value);
|
void SetValue (Gtk.TreeIter iter, int column, double value);
|
||||||
void SetValue (Gtk.TreeIter iter, int column, int value);
|
void SetValue (Gtk.TreeIter iter, int column, int value);
|
||||||
void SetValue (Gtk.TreeIter iter, int column, string value);
|
void SetValue (Gtk.TreeIter iter, int column, string value);
|
||||||
void SetValue (Gtk.TreeIter iter, int column, float value);
|
void SetValue (Gtk.TreeIter iter, int column, float value);
|
||||||
void SetValue (Gtk.TreeIter iter, int column, uint value);
|
void SetValue (Gtk.TreeIter iter, int column, uint value);
|
||||||
void SetValue (Gtk.TreeIter iter, int column, object value);
|
void SetValue (Gtk.TreeIter iter, int column, object value);
|
||||||
object GetValue(Gtk.TreeIter iter, int column);
|
object GetValue(Gtk.TreeIter iter, int column);
|
||||||
|
|
||||||
event RowsReorderedHandler RowsReordered;
|
event RowsReorderedHandler RowsReordered;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,8 +52,9 @@ namespace Gtk {
|
||||||
IntPtr raw_ret = gtk_ui_manager_get_toplevels (Handle, (int) types);
|
IntPtr raw_ret = gtk_ui_manager_get_toplevels (Handle, (int) types);
|
||||||
GLib.SList list = new GLib.SList (raw_ret);
|
GLib.SList list = new GLib.SList (raw_ret);
|
||||||
Widget[] result = new Widget [list.Count];
|
Widget[] result = new Widget [list.Count];
|
||||||
for (int i = 0; i < list.Count; i++)
|
for (int i = 0; i < list.Count; i++)
|
||||||
result [i] = list [i] as Widget;
|
result [i] = list [i] as Widget;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,8 +66,9 @@ namespace Gtk {
|
||||||
IntPtr raw_ret = gtk_ui_manager_get_action_groups (Handle);
|
IntPtr raw_ret = gtk_ui_manager_get_action_groups (Handle);
|
||||||
GLib.List list = new GLib.List(raw_ret);
|
GLib.List list = new GLib.List(raw_ret);
|
||||||
ActionGroup[] result = new ActionGroup [list.Count];
|
ActionGroup[] result = new ActionGroup [list.Count];
|
||||||
for (int i = 0; i < list.Count; i++)
|
for (int i = 0; i < list.Count; i++)
|
||||||
result [i] = list [i] as ActionGroup;
|
result [i] = list [i] as ActionGroup;
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ namespace Gtk {
|
||||||
|
|
||||||
public partial class VBox {
|
public partial class VBox {
|
||||||
|
|
||||||
public VBox () : this (false, 0) {}
|
public VBox () : this (false, 0) {}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
470
gtk/Widget.cs
470
gtk/Widget.cs
|
@ -28,273 +28,273 @@ namespace Gtk {
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
public partial class Widget {
|
public partial class Widget {
|
||||||
[Obsolete ("Replaced by Window property.")]
|
|
||||||
public Gdk.Window GdkWindow {
|
|
||||||
get { return Window; }
|
|
||||||
set { Window = value; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AddAccelerator (string accel_signal, AccelGroup accel_group, AccelKey accel_key)
|
[Obsolete ("Replaced by Window property.")]
|
||||||
{
|
public Gdk.Window GdkWindow {
|
||||||
this.AddAccelerator (accel_signal, accel_group, (uint) accel_key.Key, accel_key.AccelMods, accel_key.AccelFlags);
|
get { return Window; }
|
||||||
|
set { Window = value; }
|
||||||
}
|
|
||||||
|
|
||||||
public int FocusLineWidth {
|
|
||||||
get {
|
|
||||||
return (int) StyleGetProperty ("focus-line-width");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct GClosure {
|
|
||||||
long fields;
|
|
||||||
IntPtr marshaler;
|
|
||||||
IntPtr data;
|
|
||||||
IntPtr notifiers;
|
|
||||||
}
|
|
||||||
|
|
||||||
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
|
||||||
delegate void ClosureMarshal (IntPtr closure, IntPtr return_val, uint n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data);
|
|
||||||
|
|
||||||
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
static extern IntPtr g_closure_new_simple (int closure_size, IntPtr dummy);
|
|
||||||
|
|
||||||
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
static extern void g_closure_set_marshal (IntPtr closure, ClosureMarshal marshaler);
|
|
||||||
|
|
||||||
static IntPtr CreateClosure (ClosureMarshal marshaler) {
|
|
||||||
IntPtr raw_closure = g_closure_new_simple (Marshal.SizeOf (typeof (GClosure)), IntPtr.Zero);
|
|
||||||
g_closure_set_marshal (raw_closure, marshaler);
|
|
||||||
return raw_closure;
|
|
||||||
}
|
|
||||||
|
|
||||||
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
|
||||||
static extern uint g_signal_newv (IntPtr signal_name, IntPtr gtype, GLib.Signal.Flags signal_flags, IntPtr closure, IntPtr accumulator, IntPtr accu_data, IntPtr c_marshaller, IntPtr return_type, uint n_params, [MarshalAs (UnmanagedType.LPArray)] IntPtr[] param_types);
|
|
||||||
|
|
||||||
static uint RegisterSignal (string signal_name, GLib.GType gtype, GLib.Signal.Flags signal_flags, GLib.GType return_type, GLib.GType[] param_types, ClosureMarshal marshaler)
|
|
||||||
{
|
|
||||||
IntPtr[] native_param_types = new IntPtr [param_types.Length];
|
|
||||||
for (int parm_idx = 0; parm_idx < param_types.Length; parm_idx++)
|
|
||||||
native_param_types [parm_idx] = param_types [parm_idx].Val;
|
|
||||||
|
|
||||||
IntPtr native_signal_name = GLib.Marshaller.StringToPtrGStrdup (signal_name);
|
|
||||||
try {
|
|
||||||
return g_signal_newv (native_signal_name, gtype.Val, signal_flags, CreateClosure (marshaler), IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, return_type.Val, (uint) param_types.Length, native_param_types);
|
|
||||||
} finally {
|
|
||||||
GLib.Marshaller.Free (native_signal_name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ActivateMarshal_cb (IntPtr raw_closure, IntPtr return_val, uint n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data)
|
|
||||||
{
|
|
||||||
try {
|
|
||||||
GLib.Value inst_val = (GLib.Value) Marshal.PtrToStructure (param_values, typeof (GLib.Value));
|
|
||||||
Widget inst;
|
|
||||||
try {
|
|
||||||
inst = inst_val.Val as Widget;
|
|
||||||
} catch (GLib.MissingIntPtrCtorException) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
inst.OnActivate ();
|
|
||||||
} catch (Exception e) {
|
|
||||||
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static ClosureMarshal ActivateMarshalCallback;
|
public void AddAccelerator (string accel_signal, AccelGroup accel_group, AccelKey accel_key)
|
||||||
|
{
|
||||||
|
this.AddAccelerator (accel_signal, accel_group, (uint) accel_key.Key, accel_key.AccelMods, accel_key.AccelFlags);
|
||||||
|
}
|
||||||
|
|
||||||
static void ConnectActivate (GLib.GType gtype)
|
public int FocusLineWidth {
|
||||||
{
|
get {
|
||||||
if (ActivateMarshalCallback == null)
|
return (int) StyleGetProperty ("focus-line-width");
|
||||||
ActivateMarshalCallback = new ClosureMarshal (ActivateMarshal_cb);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GtkWidgetClass klass = GetClassStruct (gtype, false);
|
struct GClosure {
|
||||||
klass.ActivateSignal = RegisterSignal ("activate_signal", gtype, GLib.Signal.Flags.RunLast, GLib.GType.None, new GLib.GType [0], ActivateMarshalCallback);
|
long fields;
|
||||||
OverrideClassStruct (gtype, klass);
|
IntPtr marshaler;
|
||||||
}
|
IntPtr data;
|
||||||
|
IntPtr notifiers;
|
||||||
|
}
|
||||||
|
|
||||||
[GLib.DefaultSignalHandler (Type=typeof (Gtk.Widget), ConnectionMethod="ConnectActivate")]
|
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
|
||||||
protected virtual void OnActivate ()
|
delegate void ClosureMarshal (IntPtr closure, IntPtr return_val, uint n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data);
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
private class BindingInvoker {
|
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
System.Reflection.MethodInfo mi;
|
static extern IntPtr g_closure_new_simple (int closure_size, IntPtr dummy);
|
||||||
object[] parms;
|
|
||||||
|
|
||||||
public BindingInvoker (System.Reflection.MethodInfo mi, object[] parms)
|
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
{
|
static extern void g_closure_set_marshal (IntPtr closure, ClosureMarshal marshaler);
|
||||||
this.mi = mi;
|
|
||||||
this.parms = parms;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Invoke (Widget w)
|
static IntPtr CreateClosure (ClosureMarshal marshaler) {
|
||||||
{
|
IntPtr raw_closure = g_closure_new_simple (Marshal.SizeOf (typeof (GClosure)), IntPtr.Zero);
|
||||||
mi.Invoke (w, parms);
|
g_closure_set_marshal (raw_closure, marshaler);
|
||||||
}
|
return raw_closure;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* As gtk_binding_entry_add_signall only allows passing long, double and string parameters to the specified signal, we cannot pass a pointer to the BindingInvoker directly
|
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
* to the signal. Instead, the signal takes the index of the BindingInvoker in binding_invokers.
|
static extern uint g_signal_newv (IntPtr signal_name, IntPtr gtype, GLib.Signal.Flags signal_flags, IntPtr closure, IntPtr accumulator, IntPtr accu_data, IntPtr c_marshaller, IntPtr return_type, uint n_params, [MarshalAs (UnmanagedType.LPArray)] IntPtr[] param_types);
|
||||||
*/
|
|
||||||
static ArrayList binding_invokers;
|
|
||||||
|
|
||||||
static void BindingMarshal_cb (IntPtr raw_closure, IntPtr return_val, uint n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data)
|
static uint RegisterSignal (string signal_name, GLib.GType gtype, GLib.Signal.Flags signal_flags, GLib.GType return_type, GLib.GType[] param_types, ClosureMarshal marshaler)
|
||||||
{
|
{
|
||||||
try {
|
IntPtr[] native_param_types = new IntPtr [param_types.Length];
|
||||||
GLib.Value[] inst_and_params = new GLib.Value [n_param_vals];
|
for (int parm_idx = 0; parm_idx < param_types.Length; parm_idx++)
|
||||||
int gvalue_size = Marshal.SizeOf (typeof (GLib.Value));
|
native_param_types [parm_idx] = param_types [parm_idx].Val;
|
||||||
for (int idx = 0; idx < n_param_vals; idx++)
|
|
||||||
inst_and_params [idx] = (GLib.Value) Marshal.PtrToStructure (new IntPtr (param_values.ToInt64 () + idx * gvalue_size), typeof (GLib.Value));
|
|
||||||
|
|
||||||
Widget w = inst_and_params [0].Val as Widget;
|
IntPtr native_signal_name = GLib.Marshaller.StringToPtrGStrdup (signal_name);
|
||||||
BindingInvoker invoker = binding_invokers [(int) (long) inst_and_params [1]] as BindingInvoker;
|
try {
|
||||||
invoker.Invoke (w);
|
return g_signal_newv (native_signal_name, gtype.Val, signal_flags, CreateClosure (marshaler), IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, return_type.Val, (uint) param_types.Length, native_param_types);
|
||||||
} catch (Exception e) {
|
} finally {
|
||||||
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
GLib.Marshaller.Free (native_signal_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static ClosureMarshal binding_delegate;
|
static void ActivateMarshal_cb (IntPtr raw_closure, IntPtr return_val, uint n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data)
|
||||||
static ClosureMarshal BindingDelegate {
|
{
|
||||||
get {
|
try {
|
||||||
if (binding_delegate == null)
|
GLib.Value inst_val = (GLib.Value) Marshal.PtrToStructure (param_values, typeof (GLib.Value));
|
||||||
binding_delegate = new ClosureMarshal (BindingMarshal_cb);
|
Widget inst;
|
||||||
return binding_delegate;
|
try {
|
||||||
}
|
inst = inst_val.Val as Widget;
|
||||||
}
|
} catch (GLib.MissingIntPtrCtorException) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
inst.OnActivate ();
|
||||||
|
} catch (Exception e) {
|
||||||
|
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
static ClosureMarshal ActivateMarshalCallback;
|
||||||
static extern IntPtr gtk_binding_set_by_class (IntPtr class_ptr);
|
|
||||||
|
|
||||||
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
static void ConnectActivate (GLib.GType gtype)
|
||||||
static extern void gtk_binding_entry_add_signall (IntPtr binding_set, uint keyval, Gdk.ModifierType modifiers, IntPtr signal_name, IntPtr binding_args);
|
{
|
||||||
|
if (ActivateMarshalCallback == null)
|
||||||
|
ActivateMarshalCallback = new ClosureMarshal (ActivateMarshal_cb);
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
GtkWidgetClass klass = GetClassStruct (gtype, false);
|
||||||
struct GtkBindingArg {
|
klass.ActivateSignal = RegisterSignal ("activate_signal", gtype, GLib.Signal.Flags.RunLast, GLib.GType.None, new GLib.GType [0], ActivateMarshalCallback);
|
||||||
public IntPtr arg_type;
|
OverrideClassStruct (gtype, klass);
|
||||||
public GtkBindingArgData data;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Explicit)]
|
[GLib.DefaultSignalHandler (Type=typeof (Gtk.Widget), ConnectionMethod="ConnectActivate")]
|
||||||
struct GtkBindingArgData {
|
protected virtual void OnActivate ()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private class BindingInvoker {
|
||||||
|
System.Reflection.MethodInfo mi;
|
||||||
|
object[] parms;
|
||||||
|
|
||||||
|
public BindingInvoker (System.Reflection.MethodInfo mi, object[] parms)
|
||||||
|
{
|
||||||
|
this.mi = mi;
|
||||||
|
this.parms = parms;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Invoke (Widget w)
|
||||||
|
{
|
||||||
|
mi.Invoke (w, parms);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* As gtk_binding_entry_add_signall only allows passing long, double and string parameters to the specified signal, we cannot pass a pointer to the BindingInvoker directly
|
||||||
|
* to the signal. Instead, the signal takes the index of the BindingInvoker in binding_invokers.
|
||||||
|
*/
|
||||||
|
static ArrayList binding_invokers;
|
||||||
|
|
||||||
|
static void BindingMarshal_cb (IntPtr raw_closure, IntPtr return_val, uint n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
GLib.Value[] inst_and_params = new GLib.Value [n_param_vals];
|
||||||
|
int gvalue_size = Marshal.SizeOf (typeof (GLib.Value));
|
||||||
|
for (int idx = 0; idx < n_param_vals; idx++)
|
||||||
|
inst_and_params [idx] = (GLib.Value) Marshal.PtrToStructure (new IntPtr (param_values.ToInt64 () + idx * gvalue_size), typeof (GLib.Value));
|
||||||
|
|
||||||
|
Widget w = inst_and_params [0].Val as Widget;
|
||||||
|
BindingInvoker invoker = binding_invokers [(int) (long) inst_and_params [1]] as BindingInvoker;
|
||||||
|
invoker.Invoke (w);
|
||||||
|
} catch (Exception e) {
|
||||||
|
GLib.ExceptionManager.RaiseUnhandledException (e, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static ClosureMarshal binding_delegate;
|
||||||
|
static ClosureMarshal BindingDelegate {
|
||||||
|
get {
|
||||||
|
if (binding_delegate == null)
|
||||||
|
binding_delegate = new ClosureMarshal (BindingMarshal_cb);
|
||||||
|
return binding_delegate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern IntPtr gtk_binding_set_by_class (IntPtr class_ptr);
|
||||||
|
|
||||||
|
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
|
static extern void gtk_binding_entry_add_signall (IntPtr binding_set, uint keyval, Gdk.ModifierType modifiers, IntPtr signal_name, IntPtr binding_args);
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
struct GtkBindingArg {
|
||||||
|
public IntPtr arg_type;
|
||||||
|
public GtkBindingArgData data;
|
||||||
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Explicit)]
|
||||||
|
struct GtkBindingArgData {
|
||||||
|
#if WIN64LONGS
|
||||||
|
[FieldOffset (0)] public int long_data;
|
||||||
|
#else
|
||||||
|
[FieldOffset (0)] public IntPtr long_data;
|
||||||
|
#endif
|
||||||
|
[FieldOffset (0)] public double double_data;
|
||||||
|
[FieldOffset (0)] public IntPtr string_data;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ClassInit (GLib.GType gtype, Type t)
|
||||||
|
{
|
||||||
|
object[] attrs = t.GetCustomAttributes (typeof (BindingAttribute), true);
|
||||||
|
if (attrs.Length == 0) return;
|
||||||
|
|
||||||
|
string signame = t.Name.Replace (".", "_") + "_bindings";
|
||||||
|
IntPtr native_signame = GLib.Marshaller.StringToPtrGStrdup (signame);
|
||||||
|
RegisterSignal (signame, gtype, GLib.Signal.Flags.RunLast | GLib.Signal.Flags.Action, GLib.GType.None, new GLib.GType[] {GLib.GType.Long}, BindingDelegate);
|
||||||
|
|
||||||
|
if (binding_invokers == null)
|
||||||
|
binding_invokers = new ArrayList ();
|
||||||
|
|
||||||
|
foreach (BindingAttribute attr in attrs) {
|
||||||
|
System.Reflection.MethodInfo mi = t.GetMethod (attr.Handler, System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public);
|
||||||
|
if (mi == null)
|
||||||
|
throw new Exception ("Instance method " + attr.Handler + " not found in " + t);
|
||||||
|
|
||||||
|
GtkBindingArg arg = new GtkBindingArg ();
|
||||||
|
arg.arg_type = GLib.GType.Long.Val;
|
||||||
|
int binding_invoker_idx = binding_invokers.Add (new BindingInvoker (mi, attr.Parms));
|
||||||
#if WIN64LONGS
|
#if WIN64LONGS
|
||||||
[FieldOffset (0)] public int long_data;
|
arg.data.long_data = binding_invoker_idx;
|
||||||
#else
|
#else
|
||||||
[FieldOffset (0)] public IntPtr long_data;
|
arg.data.long_data = new IntPtr (binding_invoker_idx);
|
||||||
#endif
|
|
||||||
[FieldOffset (0)] public double double_data;
|
|
||||||
[FieldOffset (0)] public IntPtr string_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void ClassInit (GLib.GType gtype, Type t)
|
|
||||||
{
|
|
||||||
object[] attrs = t.GetCustomAttributes (typeof (BindingAttribute), true);
|
|
||||||
if (attrs.Length == 0) return;
|
|
||||||
|
|
||||||
string signame = t.Name.Replace (".", "_") + "_bindings";
|
|
||||||
IntPtr native_signame = GLib.Marshaller.StringToPtrGStrdup (signame);
|
|
||||||
RegisterSignal (signame, gtype, GLib.Signal.Flags.RunLast | GLib.Signal.Flags.Action, GLib.GType.None, new GLib.GType[] {GLib.GType.Long}, BindingDelegate);
|
|
||||||
|
|
||||||
if (binding_invokers == null)
|
|
||||||
binding_invokers = new ArrayList ();
|
|
||||||
|
|
||||||
foreach (BindingAttribute attr in attrs) {
|
|
||||||
System.Reflection.MethodInfo mi = t.GetMethod (attr.Handler, System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public);
|
|
||||||
if (mi == null)
|
|
||||||
throw new Exception ("Instance method " + attr.Handler + " not found in " + t);
|
|
||||||
|
|
||||||
GtkBindingArg arg = new GtkBindingArg ();
|
|
||||||
arg.arg_type = GLib.GType.Long.Val;
|
|
||||||
int binding_invoker_idx = binding_invokers.Add (new BindingInvoker (mi, attr.Parms));
|
|
||||||
#if WIN64LONGS
|
|
||||||
arg.data.long_data = binding_invoker_idx;
|
|
||||||
#else
|
|
||||||
arg.data.long_data = new IntPtr (binding_invoker_idx);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
GLib.SList binding_args = new GLib.SList (new object[] {arg}, typeof (GtkBindingArg), false, false);
|
GLib.SList binding_args = new GLib.SList (new object[] {arg}, typeof (GtkBindingArg), false, false);
|
||||||
gtk_binding_entry_add_signall (gtk_binding_set_by_class (gtype.GetClassPtr ()), (uint) attr.Key, attr.Mod, native_signame, binding_args.Handle);
|
gtk_binding_entry_add_signall (gtk_binding_set_by_class (gtype.GetClassPtr ()), (uint) attr.Key, attr.Mod, native_signame, binding_args.Handle);
|
||||||
binding_args.Dispose ();
|
binding_args.Dispose ();
|
||||||
}
|
}
|
||||||
GLib.Marshaller.Free (native_signame);
|
GLib.Marshaller.Free (native_signame);
|
||||||
}
|
}
|
||||||
|
|
||||||
public object StyleGetProperty (string property_name)
|
public object StyleGetProperty (string property_name)
|
||||||
{
|
{
|
||||||
GLib.Value value;
|
GLib.Value value;
|
||||||
try {
|
try {
|
||||||
value = StyleGetPropertyValue (property_name);
|
value = StyleGetPropertyValue (property_name);
|
||||||
} catch (ArgumentException) {
|
} catch (ArgumentException) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
object ret = value.Val;
|
object ret = value.Val;
|
||||||
value.Dispose ();
|
value.Dispose ();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
static extern IntPtr gtk_widget_class_find_style_property (IntPtr class_ptr, IntPtr property_name);
|
static extern IntPtr gtk_widget_class_find_style_property (IntPtr class_ptr, IntPtr property_name);
|
||||||
|
|
||||||
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
static extern IntPtr gtk_widget_style_get_property (IntPtr inst, IntPtr property_name, ref GLib.Value value);
|
static extern IntPtr gtk_widget_style_get_property (IntPtr inst, IntPtr property_name, ref GLib.Value value);
|
||||||
|
|
||||||
internal GLib.Value StyleGetPropertyValue (string property_name)
|
internal GLib.Value StyleGetPropertyValue (string property_name)
|
||||||
{
|
{
|
||||||
IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (property_name);
|
IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (property_name);
|
||||||
try {
|
try {
|
||||||
IntPtr pspec_ptr = gtk_widget_class_find_style_property (this.LookupGType ().GetClassPtr (), native_name);
|
IntPtr pspec_ptr = gtk_widget_class_find_style_property (this.LookupGType ().GetClassPtr (), native_name);
|
||||||
if (pspec_ptr == IntPtr.Zero)
|
if (pspec_ptr == IntPtr.Zero)
|
||||||
throw new ArgumentException (String.Format ("Cannot find style property \"{0}\"", property_name));
|
throw new ArgumentException (String.Format ("Cannot find style property \"{0}\"", property_name));
|
||||||
|
|
||||||
GLib.Value value = new GLib.Value ((new GLib.ParamSpec (pspec_ptr)).ValueType);
|
GLib.Value value = new GLib.Value ((new GLib.ParamSpec (pspec_ptr)).ValueType);
|
||||||
gtk_widget_style_get_property (Handle, native_name, ref value);
|
gtk_widget_style_get_property (Handle, native_name, ref value);
|
||||||
return value;
|
return value;
|
||||||
} finally {
|
} finally {
|
||||||
GLib.Marshaller.Free (native_name);
|
GLib.Marshaller.Free (native_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
|
||||||
static extern IntPtr gtk_widget_list_mnemonic_labels (IntPtr raw);
|
static extern IntPtr gtk_widget_list_mnemonic_labels (IntPtr raw);
|
||||||
|
|
||||||
public Widget[] ListMnemonicLabels ()
|
public Widget[] ListMnemonicLabels ()
|
||||||
{
|
{
|
||||||
IntPtr raw_ret = gtk_widget_list_mnemonic_labels (Handle);
|
IntPtr raw_ret = gtk_widget_list_mnemonic_labels (Handle);
|
||||||
if (raw_ret == IntPtr.Zero)
|
if (raw_ret == IntPtr.Zero)
|
||||||
return new Widget [0];
|
return new Widget [0];
|
||||||
GLib.List list = new GLib.List(raw_ret);
|
GLib.List list = new GLib.List(raw_ret);
|
||||||
Widget[] result = new Widget [list.Count];
|
Widget[] result = new Widget [list.Count];
|
||||||
for (int i = 0; i < list.Count; i++)
|
for (int i = 0; i < list.Count; i++)
|
||||||
result [i] = list [i] as Widget;
|
result [i] = list [i] as Widget;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ModifyBase (Gtk.StateType state)
|
public void ModifyBase (Gtk.StateType state)
|
||||||
{
|
{
|
||||||
gtk_widget_modify_base (Handle, (int) state, IntPtr.Zero);
|
gtk_widget_modify_base (Handle, (int) state, IntPtr.Zero);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ModifyBg (Gtk.StateType state)
|
public void ModifyBg (Gtk.StateType state)
|
||||||
{
|
{
|
||||||
gtk_widget_modify_bg (Handle, (int) state, IntPtr.Zero);
|
gtk_widget_modify_bg (Handle, (int) state, IntPtr.Zero);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ModifyFg (Gtk.StateType state)
|
public void ModifyFg (Gtk.StateType state)
|
||||||
{
|
{
|
||||||
gtk_widget_modify_fg (Handle, (int) state, IntPtr.Zero);
|
gtk_widget_modify_fg (Handle, (int) state, IntPtr.Zero);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ModifyText (Gtk.StateType state)
|
public void ModifyText (Gtk.StateType state)
|
||||||
{
|
{
|
||||||
gtk_widget_modify_text (Handle, (int) state, IntPtr.Zero);
|
gtk_widget_modify_text (Handle, (int) state, IntPtr.Zero);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Path (out string path, out string path_reversed)
|
public void Path (out string path, out string path_reversed)
|
||||||
{
|
{
|
||||||
uint len;
|
uint len;
|
||||||
Path (out len, out path, out path_reversed);
|
Path (out len, out path, out path_reversed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Code from custom code for Gtk.Object in 2.x
|
// Code from custom code for Gtk.Object in 2.x
|
||||||
|
@ -382,7 +382,7 @@ public void Path (out string path, out string path_reversed)
|
||||||
base.Dispose (disposing);
|
base.Dispose (disposing);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override IntPtr Raw {
|
protected override IntPtr Raw {
|
||||||
get {
|
get {
|
||||||
return base.Raw;
|
return base.Raw;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue