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:
Bertrand Lorentz 2012-08-05 17:24:05 +02:00
parent a410d42975
commit a8e1e8fd7d
29 changed files with 1460 additions and 1459 deletions

View file

@ -19,12 +19,12 @@ namespace Gtk {
public partial struct AccelKey {
public AccelKey (Gdk.Key key, Gdk.ModifierType mods, Gtk.AccelFlags flags)
{
this.Key = key;
this.AccelMods = mods;
this._bitfield0 = 0;
this.AccelFlags = flags;
}
public AccelKey (Gdk.Key key, Gdk.ModifierType mods, Gtk.AccelFlags flags)
{
this.Key = key;
this.AccelMods = mods;
this._bitfield0 = 0;
this.AccelFlags = flags;
}
}
}

View file

@ -20,27 +20,26 @@
namespace Gtk {
using System;
using System.Runtime.InteropServices;
using System;
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;
}
}
}
}

View file

@ -64,7 +64,7 @@ namespace Gtk {
RadioAction[] actions = new RadioAction[entries.Length];
for (int i = 0; i < entries.Length; i++) {
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;
group = actions[i].Group;
actions[i].Active = value == entries[i].value;

View file

@ -23,43 +23,43 @@ namespace Gtk {
public partial class Adjustment {
[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);
[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);
public Adjustment (double value, double lower, double upper, double step_increment, double page_increment, double page_size) : base (IntPtr.Zero)
{
if (GetType () != typeof (Adjustment)) {
CreateNativeObject (new string [0], new GLib.Value [0]);
Value = value;
Lower = lower;
Upper = upper;
StepIncrement = step_increment;
PageIncrement = page_increment;
PageSize = page_size;
return;
}
public Adjustment (double value, double lower, double upper, double step_increment, double page_increment, double page_size) : base (IntPtr.Zero)
{
if (GetType () != typeof (Adjustment)) {
CreateNativeObject (new string [0], new GLib.Value [0]);
Value = value;
Lower = lower;
Upper = upper;
StepIncrement = step_increment;
PageIncrement = page_increment;
PageSize = page_size;
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)]
static extern void g_object_freeze_notify (IntPtr inst);
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern void g_object_freeze_notify (IntPtr inst);
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern void g_object_thaw_notify (IntPtr inst);
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
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)
{
// 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);
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 (this.Handle);
Lower = lower;
Upper = upper;
StepIncrement = step_increment;
PageIncrement = page_increment;
PageSize = page_size;
Lower = lower;
Upper = upper;
StepIncrement = step_increment;
PageIncrement = page_increment;
PageSize = page_size;
g_object_thaw_notify (this.Handle);
}
g_object_thaw_notify (this.Handle);
}
}
}

View file

@ -30,391 +30,391 @@ namespace Gtk {
public partial class Builder {
[System.Serializable]
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)
[System.Serializable]
public class HandlerNotFoundException : SystemException
{
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;
}
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;
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)
{
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);
}
}
}

View file

@ -25,29 +25,29 @@ namespace Gtk {
public partial class Button {
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr gtk_button_new_from_stock(IntPtr stock_id);
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr gtk_button_new_from_stock(IntPtr stock_id);
public Button (string stock_id) : base (IntPtr.Zero)
{
if (GetType () != typeof (Button)) {
GLib.Value[] vals = new GLib.Value [2];
string[] names = new string [2];
names [0] = "label";
vals [0] = new GLib.Value (stock_id);
names [1] = "use_stock";
vals [1] = new GLib.Value (true);
CreateNativeObject (names, vals);
return;
}
IntPtr native = GLib.Marshaller.StringToPtrGStrdup (stock_id);
Raw = gtk_button_new_from_stock (native);
GLib.Marshaller.Free (native);
}
public Button (string stock_id) : base (IntPtr.Zero)
{
if (GetType () != typeof (Button)) {
GLib.Value[] vals = new GLib.Value [2];
string[] names = new string [2];
names [0] = "label";
vals [0] = new GLib.Value (stock_id);
names [1] = "use_stock";
vals [1] = new GLib.Value (true);
CreateNativeObject (names, vals);
return;
}
IntPtr native = GLib.Marshaller.StringToPtrGStrdup (stock_id);
Raw = gtk_button_new_from_stock (native);
GLib.Marshaller.Free (native);
}
public Button (Widget widget) : this ()
{
Add (widget);
}
public Button (Widget widget) : this ()
{
Add (widget);
}
}
}

View file

@ -25,38 +25,37 @@ namespace Gtk {
public partial class Calendar {
public DateTime GetDate ()
{
uint year, month, day;
GetDate (out year, out month, out day);
DateTime result;
try {
result = new DateTime ((int) year, (int) month + 1, (int) day);
} catch (ArgumentOutOfRangeException) {
// Kluge to workaround GtkCalendar being in an invalid state
// when raising month_changed signals, like in bug #78524.
result = new DateTime ((int) year, (int) month + 1, DateTime.DaysInMonth ((int) year, (int) month + 1));
}
return result;
}
public DateTime GetDate ()
{
uint year, month, day;
GetDate (out year, out month, out day);
DateTime result;
try {
result = new DateTime ((int) year, (int) month + 1, (int) day);
} catch (ArgumentOutOfRangeException) {
// Kluge to workaround GtkCalendar being in an invalid state
// when raising month_changed signals, like in bug #78524.
result = new DateTime ((int) year, (int) month + 1, DateTime.DaysInMonth ((int) year, (int) month + 1));
}
return result;
}
// This defines a Date property for Calendar
// Note that the setter causes CalendarChange events to be fired
public DateTime Date
// This defines a Date property for Calendar
// Note that the setter causes CalendarChange events to be fired
public DateTime Date
{
get {
return this.GetDate();
}
set {
uint month= (uint) value.Month-1;
uint year= (uint) value.Year;
uint day = (uint) value.Day;
{
get {
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);
}
}
SelectMonth(month,year);
SelectDay(day);
}
}
}
}

View file

@ -52,7 +52,7 @@ namespace Gtk {
// TODO: Implement "nullable" attribute for value type parameters in GAPI
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
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)
{
try {
@ -87,7 +87,7 @@ namespace Gtk {
OnGetSizeCallback = new OnGetSizeDelegate (OnGetSize_cb);
gtksharp_cellrenderer_override_get_size (gtype.Val, OnGetSizeCallback);
}
[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)
{

View file

@ -23,17 +23,18 @@ namespace Gtk {
using System;
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 {
get { return color_sel; }
}
[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 ColorSelectionButton (ColorSelectionDialog cs, IntPtr raw) : base (raw) {
color_sel = cs;
}
}
public ColorSelectionDialog ColorSelectionDialog {
get { return color_sel; }
}
public ColorSelectionButton (ColorSelectionDialog cs, IntPtr raw) : base (raw) {
color_sel = cs;
}
}
}
}

View file

@ -26,222 +26,222 @@ namespace Gtk {
public partial class Container {
[DllImport("gtksharpglue-3")]
static extern void gtksharp_container_child_get_property (IntPtr container, IntPtr child, IntPtr property, ref GLib.Value value);
[DllImport("gtksharpglue-3")]
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) {
GLib.Value value = new GLib.Value ();
public GLib.Value ChildGetProperty (Gtk.Widget child, string property_name) {
GLib.Value value = new GLib.Value ();
IntPtr native = GLib.Marshaller.StringToPtrGStrdup (property_name);
gtksharp_container_child_get_property (Handle, child.Handle, native, ref value);
GLib.Marshaller.Free (native);
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;
IntPtr native = GLib.Marshaller.StringToPtrGStrdup (property_name);
gtksharp_container_child_get_property (Handle, child.Handle, native, ref value);
GLib.Marshaller.Free (native);
return value;
}
}
internal IntPtr Callback {
get {
return cb;
public IEnumerator GetEnumerator ()
{
return Children.GetEnumerator ();
}
}
public void Invoke (Widget w)
{
gtksharp_container_invoke_gtk_callback (cb, w.Handle, data);
}
}
class ChildAccumulator {
public ArrayList Children = new ArrayList ();
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 void Add (Gtk.Widget widget)
{
Children.Add (widget);
}
}
}
public Widget Child {
get {
return child;
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 {
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);
}
}
}
}

View file

@ -26,50 +26,50 @@ namespace Gtk {
using System.Runtime.InteropServices;
public partial class Dialog {
[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);
public Dialog (string title, Gtk.Window parent, Gtk.DialogFlags flags, params object[] button_data) : base(IntPtr.Zero)
{
if (GetType() != typeof (Dialog)) {
GLib.Value[] vals = new GLib.Value [1];
string[] names = new string [1];
names [0] = "title";
vals [0] = new GLib.Value (title);
CreateNativeObject (names, vals);
TransientFor = parent;
if ((flags & DialogFlags.Modal) > 0)
Modal = true;
if ((flags & DialogFlags.DestroyWithParent) > 0)
DestroyWithParent = true;
} else {
IntPtr native = GLib.Marshaller.StringToPtrGStrdup (title);
Raw = gtk_dialog_new_with_buttons (native, parent == null ? IntPtr.Zero : parent.Handle, (int) flags, IntPtr.Zero);
GLib.Marshaller.Free (native);
}
[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);
public Dialog (string title, Gtk.Window parent, Gtk.DialogFlags flags, params object[] button_data) : base(IntPtr.Zero)
{
if (GetType() != typeof (Dialog)) {
GLib.Value[] vals = new GLib.Value [1];
string[] names = new string [1];
names [0] = "title";
vals [0] = new GLib.Value (title);
CreateNativeObject (names, vals);
TransientFor = parent;
if ((flags & DialogFlags.Modal) > 0)
Modal = true;
if ((flags & DialogFlags.DestroyWithParent) > 0)
DestroyWithParent = true;
} else {
IntPtr native = GLib.Marshaller.StringToPtrGStrdup (title);
Raw = gtk_dialog_new_with_buttons (native, parent == null ? IntPtr.Zero : parent.Handle, (int) flags, IntPtr.Zero);
GLib.Marshaller.Free (native);
}
for (int i = 0; i < button_data.Length - 1; i += 2)
AddButton ((string) button_data [i], (int) button_data [i + 1]);
}
for (int i = 0; i < button_data.Length - 1; i += 2)
AddButton ((string) button_data [i], (int) button_data [i + 1]);
}
public void AddActionWidget (Widget child, ResponseType response)
{
this.AddActionWidget (child, (int) response);
}
public void AddActionWidget (Widget child, ResponseType response)
{
this.AddActionWidget (child, (int) response);
}
public Gtk.Widget AddButton (string button_text, ResponseType response)
{
return this.AddButton (button_text, (int) response);
}
public Gtk.Widget AddButton (string button_text, ResponseType response)
{
return this.AddButton (button_text, (int) response);
}
public void Respond (ResponseType response)
{
this.Respond ((int) response);
}
public void Respond (ResponseType response)
{
this.Respond ((int) response);
}
[Obsolete ("Replaced by AlternativeButtonOrder property")]
public int SetAlternativeButtonOrderFromArray (int n_params)
{
return -1;
}
[Obsolete ("Replaced by AlternativeButtonOrder property")]
public int SetAlternativeButtonOrderFromArray (int n_params)
{
return -1;
}
}
}

View file

@ -20,24 +20,25 @@ namespace Gtk {
using System;
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()
{
Text = initialText;
}
return position;
}
[Obsolete("Replaced by IsEditable property")]
public bool Editable {
get { return IsEditable; }
set { IsEditable = value; }
}
public Entry(string initialText): this()
{
Text = initialText;
}
[Obsolete("Replaced by IsEditable property")]
public bool Editable {
get { return IsEditable; }
set { IsEditable = value; }
}
}
}

View file

@ -19,7 +19,7 @@ namespace Gtk {
public partial class HBox {
public HBox () : this (false, 0) {}
public HBox () : this (false, 0) {}
}
}

View file

@ -20,14 +20,14 @@ namespace Gtk {
public partial class IconFactory {
[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);
[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);
/// <summary> Query icon dimensions </summary>
/// <summary> Query icon dimensions </summary>
/// <remarks> Queries dimensions for icons of the specified size. </remarks>
public void LookupIconSize (IconSize size, out int width, out int height)
{
gtk_icon_size_lookup (size, out width, out height);
}
public void LookupIconSize (IconSize size, out int width, out int height)
{
gtk_icon_size_lookup (size, out width, out height);
}
}
}

View file

@ -15,38 +15,38 @@
namespace Gtk {
using System;
using System.Runtime.InteropServices;
using System;
using System.Runtime.InteropServices;
public partial class IconSet {
public partial class IconSet {
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
unsafe static extern void gtk_icon_set_get_sizes (
IntPtr raw, out int *pointer_to_enum, out int n_sizes);
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
unsafe static extern void gtk_icon_set_get_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);
/// <summary> Sizes Property </summary>
/// <remarks> To be completed </remarks>
public Gtk.IconSize [] Sizes {
get {
/// <summary> Sizes Property </summary>
/// <remarks> To be completed </remarks>
public Gtk.IconSize [] Sizes {
get {
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];
Gtk.IconSize [] retval;
g_free (pointer_to_enum);
}
return 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);
}
return retval;
}
}
}
}

View file

@ -76,10 +76,10 @@ namespace Gtk {
}
}
public string[] SearchPath {
get {
public string[] SearchPath {
get {
string[] retval;
unsafe {
int length;
IntPtr raw_ret;
@ -97,7 +97,7 @@ namespace Gtk {
g_strfreev (raw_ret);
}
return retval;
}
set {

View file

@ -25,34 +25,34 @@ namespace Gtk {
public partial class Menu {
[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) {
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;
[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) {
Popup (parent_menu_shell, parent_menu_item, func, button, activate_time);
}
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)]
static extern void gtk_menu_set_active (IntPtr raw, uint index_);
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern void gtk_menu_set_screen (IntPtr raw, IntPtr screen);
public void SetActive (uint index_)
{
gtk_menu_set_active (Handle, index_);
}
public new Gdk.Screen Screen {
get {
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_);
}
}
}

View file

@ -20,30 +20,30 @@ namespace Gtk {
public partial class MessageDialog {
[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);
[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);
[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);
[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);
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;
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;
if (format == null) {
Raw = gtk_message_dialog_new (p, flags, type, bt, IntPtr.Zero, IntPtr.Zero);
return;
}
if (format == null) {
Raw = gtk_message_dialog_new (p, flags, type, bt, IntPtr.Zero, IntPtr.Zero);
return;
}
IntPtr nmsg = GLib.Marshaller.StringToPtrGStrdup (GLib.Marshaller.StringFormat (format, args));
if (use_markup)
Raw = gtk_message_dialog_new_with_markup (p, flags, type, bt, nmsg, IntPtr.Zero);
else
Raw = gtk_message_dialog_new (p, flags, type, bt, nmsg, IntPtr.Zero);
GLib.Marshaller.Free (nmsg);
}
IntPtr nmsg = GLib.Marshaller.StringToPtrGStrdup (GLib.Marshaller.StringFormat (format, args));
if (use_markup)
Raw = gtk_message_dialog_new_with_markup (p, flags, type, bt, nmsg, IntPtr.Zero);
else
Raw = gtk_message_dialog_new (p, flags, type, bt, nmsg, IntPtr.Zero);
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) {}
}
}

View file

@ -51,7 +51,7 @@ namespace Gtk {
return selection.PathIsSelected (path);
}
public void SelectAll ()
public void SelectAll ()
{
selection.SelectAll ();
}

View file

@ -129,8 +129,7 @@ namespace Gtk {
throw new Exception (String.Format ("You have two TreeNodeValueAttributes with the Column={0}", col));
getters [col] = mi;
Type t = mi is PropertyInfo ? ((PropertyInfo) mi).PropertyType
: ((FieldInfo) mi).FieldType;
Type t = mi is PropertyInfo ? ((PropertyInfo) mi).PropertyType : ((FieldInfo) mi).FieldType;
ctypes [col] = (GLib.GType) t;
}
}

View file

@ -26,18 +26,18 @@ namespace Gtk {
public partial class Notebook {
public Widget CurrentPageWidget {
get {
return GetNthPage (CurrentPage);
}
}
public Widget CurrentPageWidget {
get {
return GetNthPage (CurrentPage);
}
}
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern int gtk_notebook_page_num (IntPtr handle, IntPtr child);
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern int gtk_notebook_page_num (IntPtr handle, IntPtr child);
public int PageNum (Widget child)
{
return gtk_notebook_page_num (Handle, child.Handle);
}
public int PageNum (Widget child)
{
return gtk_notebook_page_num (Handle, child.Handle);
}
}
}

View file

@ -25,15 +25,15 @@ namespace Gtk {
public partial class RadioButton {
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr gtk_radio_button_new_with_mnemonic (IntPtr group, IntPtr label);
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr gtk_radio_button_new_with_mnemonic (IntPtr group, IntPtr label);
// creates a new group for this RadioButton
public RadioButton (string label)
{
IntPtr native = GLib.Marshaller.StringToPtrGStrdup (label);
Raw = gtk_radio_button_new_with_mnemonic (IntPtr.Zero, native);
GLib.Marshaller.Free (native);
}
// creates a new group for this RadioButton
public RadioButton (string label)
{
IntPtr native = GLib.Marshaller.StringToPtrGStrdup (label);
Raw = gtk_radio_button_new_with_mnemonic (IntPtr.Zero, native);
GLib.Marshaller.Free (native);
}
}
}

View file

@ -24,13 +24,13 @@ namespace Gtk {
public partial struct StockItem {
public StockItem (string stock_id, string label, uint keyval, Gdk.ModifierType modifier, string domain)
{
this.StockId = stock_id;
this.Label = label;
this.Keyval = keyval;
this.Modifier = modifier;
this.TranslationDomain = domain;
}
public StockItem (string stock_id, string label, uint keyval, Gdk.ModifierType modifier, string domain)
{
this.StockId = stock_id;
this.Label = label;
this.Keyval = keyval;
this.Modifier = modifier;
this.TranslationDomain = domain;
}
}
}

View file

@ -208,171 +208,171 @@ public void SetMidGC (StateType state, Gdk.GC gc)
}
#endif
[DllImport("gtksharpglue-3")]
static extern IntPtr gtksharp_gtk_style_get_bg (IntPtr style, int i);
[DllImport("gtksharpglue-3")]
static extern IntPtr gtksharp_gtk_style_get_bg (IntPtr style, int i);
public Gdk.Color Background (StateType state)
{
IntPtr raw = gtksharp_gtk_style_get_bg (Handle, (int) state);
return Gdk.Color.New (raw);
}
public Gdk.Color Background (StateType state)
{
IntPtr raw = gtksharp_gtk_style_get_bg (Handle, (int) state);
return Gdk.Color.New (raw);
}
public Gdk.Color[] Backgrounds {
get {
Gdk.Color[] ret = new Gdk.Color[5];
for (int i = 0; i < 5; i++)
ret[i] = Gdk.Color.New (gtksharp_gtk_style_get_bg (Handle, i));
return ret;
}
}
[DllImport("gtksharpglue-3")]
static extern IntPtr gtksharp_gtk_style_get_fg (IntPtr style, int i);
public Gdk.Color Foreground (StateType state)
{
IntPtr raw = gtksharp_gtk_style_get_fg (Handle, (int) state);
return Gdk.Color.New (raw);
}
public Gdk.Color[] Foregrounds {
get {
Gdk.Color[] ret = new Gdk.Color[5];
for (int i = 0; i < 5; i++)
ret[i] = Gdk.Color.New (gtksharp_gtk_style_get_fg (Handle, i));
return ret;
}
}
[DllImport("gtksharpglue-3")]
static extern IntPtr gtksharp_gtk_style_get_text (IntPtr style, int i);
public Gdk.Color Text (StateType state)
{
IntPtr raw = gtksharp_gtk_style_get_text (Handle, (int) state);
return Gdk.Color.New (raw);
}
public Gdk.Color[] TextColors {
get {
Gdk.Color[] ret = new Gdk.Color[5];
for (int i = 0; i < 5; i++)
ret[i] = Gdk.Color.New (gtksharp_gtk_style_get_text (Handle, i));
return ret;
}
}
[DllImport("gtksharpglue-3")]
static extern IntPtr gtksharp_gtk_style_get_base (IntPtr style, int i);
public Gdk.Color Base (StateType state)
{
IntPtr raw = gtksharp_gtk_style_get_base (Handle, (int) state);
return Gdk.Color.New (raw);
}
public Gdk.Color[] BaseColors {
get {
Gdk.Color[] ret = new Gdk.Color[5];
for (int i = 0; i < 5; i++)
ret[i] = Gdk.Color.New (gtksharp_gtk_style_get_base (Handle, i));
return ret;
}
}
[DllImport("gtksharpglue-3")]
static extern IntPtr gtksharp_gtk_style_get_light (IntPtr style, int i);
public Gdk.Color Light (StateType state)
{
IntPtr raw = gtksharp_gtk_style_get_light (Handle, (int) state);
return Gdk.Color.New (raw);
}
public Gdk.Color[] LightColors {
get {
Gdk.Color[] ret = new Gdk.Color[5];
for (int i = 0; i < 5; i++)
ret[i] = Gdk.Color.New (gtksharp_gtk_style_get_light (Handle, i));
return ret;
}
}
[DllImport("gtksharpglue-3")]
static extern IntPtr gtksharp_gtk_style_get_mid (IntPtr style, int i);
public Gdk.Color Mid (StateType state)
{
IntPtr raw = gtksharp_gtk_style_get_mid (Handle, (int) state);
return Gdk.Color.New (raw);
}
public Gdk.Color[] MidColors {
get {
Gdk.Color[] ret = new Gdk.Color[5];
for (int i = 0; i < 5; i++)
ret[i] = Gdk.Color.New (gtksharp_gtk_style_get_mid (Handle, i));
return ret;
}
}
[DllImport("gtksharpglue-3")]
static extern IntPtr gtksharp_gtk_style_get_dark (IntPtr style, int i);
public Gdk.Color Dark (StateType state)
{
IntPtr raw = gtksharp_gtk_style_get_dark (Handle, (int) state);
return Gdk.Color.New (raw);
}
public Gdk.Color[] DarkColors {
get {
Gdk.Color[] ret = new Gdk.Color[5];
for (int i = 0; i < 5; i++)
ret[i] = Gdk.Color.New (gtksharp_gtk_style_get_dark (Handle, i));
return ret;
}
}
[DllImport ("gtksharpglue-3")]
static extern int gtksharp_gtk_style_get_thickness (IntPtr style, int x_axis);
[DllImport ("gtksharpglue-3")]
static extern void gtksharp_gtk_style_set_thickness (IntPtr style, int value);
public int XThickness {
get {
return gtksharp_gtk_style_get_thickness (Handle, 0);
}
set {
gtksharp_gtk_style_set_thickness (Handle, value);
}
}
public int YThickness {
get {
return gtksharp_gtk_style_get_thickness (Handle, 1);
}
set {
gtksharp_gtk_style_set_thickness (Handle, -value);
}
}
[DllImport ("gtksharpglue-3")]
static extern IntPtr gtksharp_gtk_style_get_font_description (IntPtr style);
public Pango.FontDescription FontDescription {
get {
IntPtr Raw = gtksharp_gtk_style_get_font_description (Handle);
if (Raw == IntPtr.Zero)
return null;
Pango.FontDescription ret = (Pango.FontDescription) GLib.Opaque.GetOpaque (Raw, typeof (Pango.FontDescription), false);
if (ret == null)
ret = new Pango.FontDescription (Raw);
return ret;
}
}
public Gdk.Color[] Backgrounds {
get {
Gdk.Color[] ret = new Gdk.Color[5];
for (int i = 0; i < 5; i++)
ret[i] = Gdk.Color.New (gtksharp_gtk_style_get_bg (Handle, i));
return ret;
}
}
[DllImport("gtksharpglue-3")]
static extern IntPtr gtksharp_gtk_style_get_fg (IntPtr style, int i);
public Gdk.Color Foreground (StateType state)
{
IntPtr raw = gtksharp_gtk_style_get_fg (Handle, (int) state);
return Gdk.Color.New (raw);
}
public Gdk.Color[] Foregrounds {
get {
Gdk.Color[] ret = new Gdk.Color[5];
for (int i = 0; i < 5; i++)
ret[i] = Gdk.Color.New (gtksharp_gtk_style_get_fg (Handle, i));
return ret;
}
}
[DllImport("gtksharpglue-3")]
static extern IntPtr gtksharp_gtk_style_get_text (IntPtr style, int i);
public Gdk.Color Text (StateType state)
{
IntPtr raw = gtksharp_gtk_style_get_text (Handle, (int) state);
return Gdk.Color.New (raw);
}
public Gdk.Color[] TextColors {
get {
Gdk.Color[] ret = new Gdk.Color[5];
for (int i = 0; i < 5; i++)
ret[i] = Gdk.Color.New (gtksharp_gtk_style_get_text (Handle, i));
return ret;
}
}
[DllImport("gtksharpglue-3")]
static extern IntPtr gtksharp_gtk_style_get_base (IntPtr style, int i);
public Gdk.Color Base (StateType state)
{
IntPtr raw = gtksharp_gtk_style_get_base (Handle, (int) state);
return Gdk.Color.New (raw);
}
public Gdk.Color[] BaseColors {
get {
Gdk.Color[] ret = new Gdk.Color[5];
for (int i = 0; i < 5; i++)
ret[i] = Gdk.Color.New (gtksharp_gtk_style_get_base (Handle, i));
return ret;
}
}
[DllImport("gtksharpglue-3")]
static extern IntPtr gtksharp_gtk_style_get_light (IntPtr style, int i);
public Gdk.Color Light (StateType state)
{
IntPtr raw = gtksharp_gtk_style_get_light (Handle, (int) state);
return Gdk.Color.New (raw);
}
public Gdk.Color[] LightColors {
get {
Gdk.Color[] ret = new Gdk.Color[5];
for (int i = 0; i < 5; i++)
ret[i] = Gdk.Color.New (gtksharp_gtk_style_get_light (Handle, i));
return ret;
}
}
[DllImport("gtksharpglue-3")]
static extern IntPtr gtksharp_gtk_style_get_mid (IntPtr style, int i);
public Gdk.Color Mid (StateType state)
{
IntPtr raw = gtksharp_gtk_style_get_mid (Handle, (int) state);
return Gdk.Color.New (raw);
}
public Gdk.Color[] MidColors {
get {
Gdk.Color[] ret = new Gdk.Color[5];
for (int i = 0; i < 5; i++)
ret[i] = Gdk.Color.New (gtksharp_gtk_style_get_mid (Handle, i));
return ret;
}
}
[DllImport("gtksharpglue-3")]
static extern IntPtr gtksharp_gtk_style_get_dark (IntPtr style, int i);
public Gdk.Color Dark (StateType state)
{
IntPtr raw = gtksharp_gtk_style_get_dark (Handle, (int) state);
return Gdk.Color.New (raw);
}
public Gdk.Color[] DarkColors {
get {
Gdk.Color[] ret = new Gdk.Color[5];
for (int i = 0; i < 5; i++)
ret[i] = Gdk.Color.New (gtksharp_gtk_style_get_dark (Handle, i));
return ret;
}
}
[DllImport ("gtksharpglue-3")]
static extern int gtksharp_gtk_style_get_thickness (IntPtr style, int x_axis);
[DllImport ("gtksharpglue-3")]
static extern void gtksharp_gtk_style_set_thickness (IntPtr style, int value);
public int XThickness {
get {
return gtksharp_gtk_style_get_thickness (Handle, 0);
}
set {
gtksharp_gtk_style_set_thickness (Handle, value);
}
}
public int YThickness {
get {
return gtksharp_gtk_style_get_thickness (Handle, 1);
}
set {
gtksharp_gtk_style_set_thickness (Handle, -value);
}
}
[DllImport ("gtksharpglue-3")]
static extern IntPtr gtksharp_gtk_style_get_font_description (IntPtr style);
public Pango.FontDescription FontDescription {
get {
IntPtr Raw = gtksharp_gtk_style_get_font_description (Handle);
if (Raw == IntPtr.Zero)
return null;
Pango.FontDescription ret = (Pango.FontDescription) GLib.Opaque.GetOpaque (Raw, typeof (Pango.FontDescription), false);
if (ret == null)
ret = new Pango.FontDescription (Raw);
return ret;
}
}
}
}

View file

@ -25,167 +25,167 @@ namespace Gtk {
public partial class TextBuffer {
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern void gtk_text_buffer_set_text (IntPtr raw, IntPtr text, int len);
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern void gtk_text_buffer_set_text (IntPtr raw, IntPtr text, int len);
public void Clear ()
{
Gtk.TextIter start = StartIter, end = EndIter;
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);
public void Clear ()
{
Gtk.TextIter start = StartIter, end = EndIter;
Delete (ref start, ref end);
}
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);
[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 {
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;
}
}
}
}

View file

@ -24,27 +24,27 @@ namespace Gtk {
public partial interface TreeModel {
/// <summary>IterChildren Method</summary>
/// <remarks>To be completed</remarks>
bool IterChildren (out Gtk.TreeIter iter);
/// <summary>IterChildren Method</summary>
/// <remarks>To be completed</remarks>
bool IterChildren (out Gtk.TreeIter iter);
/// <summary>IterNChildren Method</summary>
/// <remarks>To be completed</remarks>
int IterNChildren ();
/// <summary>IterNChildren Method</summary>
/// <remarks>To be completed</remarks>
int IterNChildren ();
/// <summary>IterNthChild Method</summary>
/// <remarks>To be completed</remarks>
bool IterNthChild (out Gtk.TreeIter iter, int n);
/// <summary>IterNthChild Method</summary>
/// <remarks>To be completed</remarks>
bool IterNthChild (out Gtk.TreeIter iter, int n);
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, int 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, uint value);
void SetValue (Gtk.TreeIter iter, int column, object value);
object GetValue(Gtk.TreeIter iter, int column);
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, int 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, uint value);
void SetValue (Gtk.TreeIter iter, int column, object value);
object GetValue(Gtk.TreeIter iter, int column);
event RowsReorderedHandler RowsReordered;
event RowsReorderedHandler RowsReordered;
}
}

View file

@ -52,8 +52,9 @@ namespace Gtk {
IntPtr raw_ret = gtk_ui_manager_get_toplevels (Handle, (int) types);
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;
for (int i = 0; i < list.Count; i++)
result [i] = list [i] as Widget;
return result;
}
@ -65,8 +66,9 @@ namespace Gtk {
IntPtr raw_ret = gtk_ui_manager_get_action_groups (Handle);
GLib.List list = new GLib.List(raw_ret);
ActionGroup[] result = new ActionGroup [list.Count];
for (int i = 0; i < list.Count; i++)
result [i] = list [i] as ActionGroup;
for (int i = 0; i < list.Count; i++)
result [i] = list [i] as ActionGroup;
return result;
}
}

View file

@ -19,7 +19,7 @@ namespace Gtk {
public partial class VBox {
public VBox () : this (false, 0) {}
public VBox () : this (false, 0) {}
}
}

View file

@ -28,273 +28,273 @@ namespace Gtk {
using System.Runtime.InteropServices;
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)
{
this.AddAccelerator (accel_signal, accel_group, (uint) accel_key.Key, accel_key.AccelMods, accel_key.AccelFlags);
}
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;
[Obsolete ("Replaced by Window property.")]
public Gdk.Window GdkWindow {
get { return Window; }
set { Window = value; }
}
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)
{
if (ActivateMarshalCallback == null)
ActivateMarshalCallback = new ClosureMarshal (ActivateMarshal_cb);
public int FocusLineWidth {
get {
return (int) StyleGetProperty ("focus-line-width");
}
}
GtkWidgetClass klass = GetClassStruct (gtype, false);
klass.ActivateSignal = RegisterSignal ("activate_signal", gtype, GLib.Signal.Flags.RunLast, GLib.GType.None, new GLib.GType [0], ActivateMarshalCallback);
OverrideClassStruct (gtype, klass);
}
struct GClosure {
long fields;
IntPtr marshaler;
IntPtr data;
IntPtr notifiers;
}
[GLib.DefaultSignalHandler (Type=typeof (Gtk.Widget), ConnectionMethod="ConnectActivate")]
protected virtual void OnActivate ()
{
}
[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
delegate void ClosureMarshal (IntPtr closure, IntPtr return_val, uint n_param_vals, IntPtr param_values, IntPtr invocation_hint, IntPtr marshal_data);
private class BindingInvoker {
System.Reflection.MethodInfo mi;
object[] parms;
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr g_closure_new_simple (int closure_size, IntPtr dummy);
public BindingInvoker (System.Reflection.MethodInfo mi, object[] parms)
{
this.mi = mi;
this.parms = parms;
}
[DllImport ("libgobject-2.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern void g_closure_set_marshal (IntPtr closure, ClosureMarshal marshaler);
public void Invoke (Widget w)
{
mi.Invoke (w, parms);
}
}
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;
}
/* 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;
[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 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));
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;
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);
}
}
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 ClosureMarshal binding_delegate;
static ClosureMarshal BindingDelegate {
get {
if (binding_delegate == null)
binding_delegate = new ClosureMarshal (BindingMarshal_cb);
return 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)
{
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);
}
}
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr gtk_binding_set_by_class (IntPtr class_ptr);
static ClosureMarshal ActivateMarshalCallback;
[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);
static void ConnectActivate (GLib.GType gtype)
{
if (ActivateMarshalCallback == null)
ActivateMarshalCallback = new ClosureMarshal (ActivateMarshal_cb);
[StructLayout(LayoutKind.Sequential)]
struct GtkBindingArg {
public IntPtr arg_type;
public GtkBindingArgData data;
}
GtkWidgetClass klass = GetClassStruct (gtype, false);
klass.ActivateSignal = RegisterSignal ("activate_signal", gtype, GLib.Signal.Flags.RunLast, GLib.GType.None, new GLib.GType [0], ActivateMarshalCallback);
OverrideClassStruct (gtype, klass);
}
[StructLayout(LayoutKind.Explicit)]
struct GtkBindingArgData {
[GLib.DefaultSignalHandler (Type=typeof (Gtk.Widget), ConnectionMethod="ConnectActivate")]
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
[FieldOffset (0)] public int long_data;
arg.data.long_data = binding_invoker_idx;
#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
arg.data.long_data = binding_invoker_idx;
#else
arg.data.long_data = new IntPtr (binding_invoker_idx);
arg.data.long_data = new IntPtr (binding_invoker_idx);
#endif
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);
binding_args.Dispose ();
}
GLib.Marshaller.Free (native_signame);
}
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);
binding_args.Dispose ();
}
GLib.Marshaller.Free (native_signame);
}
public object StyleGetProperty (string property_name)
{
GLib.Value value;
try {
value = StyleGetPropertyValue (property_name);
} catch (ArgumentException) {
return null;
}
object ret = value.Val;
value.Dispose ();
return ret;
}
public object StyleGetProperty (string property_name)
{
GLib.Value value;
try {
value = StyleGetPropertyValue (property_name);
} catch (ArgumentException) {
return null;
}
object ret = value.Val;
value.Dispose ();
return ret;
}
[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);
[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);
[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);
[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);
internal GLib.Value StyleGetPropertyValue (string property_name)
{
IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (property_name);
try {
IntPtr pspec_ptr = gtk_widget_class_find_style_property (this.LookupGType ().GetClassPtr (), native_name);
if (pspec_ptr == IntPtr.Zero)
throw new ArgumentException (String.Format ("Cannot find style property \"{0}\"", property_name));
internal GLib.Value StyleGetPropertyValue (string property_name)
{
IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (property_name);
try {
IntPtr pspec_ptr = gtk_widget_class_find_style_property (this.LookupGType ().GetClassPtr (), native_name);
if (pspec_ptr == IntPtr.Zero)
throw new ArgumentException (String.Format ("Cannot find style property \"{0}\"", property_name));
GLib.Value value = new GLib.Value ((new GLib.ParamSpec (pspec_ptr)).ValueType);
gtk_widget_style_get_property (Handle, native_name, ref value);
return value;
} finally {
GLib.Marshaller.Free (native_name);
}
}
GLib.Value value = new GLib.Value ((new GLib.ParamSpec (pspec_ptr)).ValueType);
gtk_widget_style_get_property (Handle, native_name, ref value);
return value;
} finally {
GLib.Marshaller.Free (native_name);
}
}
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr gtk_widget_list_mnemonic_labels (IntPtr raw);
[DllImport ("libgtk-win32-3.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
static extern IntPtr gtk_widget_list_mnemonic_labels (IntPtr raw);
public Widget[] ListMnemonicLabels ()
{
IntPtr raw_ret = gtk_widget_list_mnemonic_labels (Handle);
if (raw_ret == IntPtr.Zero)
return new Widget [0];
GLib.List list = new GLib.List(raw_ret);
Widget[] result = new Widget [list.Count];
for (int i = 0; i < list.Count; i++)
result [i] = list [i] as Widget;
return result;
}
public Widget[] ListMnemonicLabels ()
{
IntPtr raw_ret = gtk_widget_list_mnemonic_labels (Handle);
if (raw_ret == IntPtr.Zero)
return new Widget [0];
GLib.List list = new GLib.List(raw_ret);
Widget[] result = new Widget [list.Count];
for (int i = 0; i < list.Count; i++)
result [i] = list [i] as Widget;
return result;
}
public void ModifyBase (Gtk.StateType state)
{
gtk_widget_modify_base (Handle, (int) state, IntPtr.Zero);
}
public void ModifyBase (Gtk.StateType state)
{
gtk_widget_modify_base (Handle, (int) state, IntPtr.Zero);
}
public void ModifyBg (Gtk.StateType state)
{
gtk_widget_modify_bg (Handle, (int) state, IntPtr.Zero);
}
public void ModifyBg (Gtk.StateType state)
{
gtk_widget_modify_bg (Handle, (int) state, IntPtr.Zero);
}
public void ModifyFg (Gtk.StateType state)
{
gtk_widget_modify_fg (Handle, (int) state, IntPtr.Zero);
}
public void ModifyFg (Gtk.StateType state)
{
gtk_widget_modify_fg (Handle, (int) state, IntPtr.Zero);
}
public void ModifyText (Gtk.StateType state)
{
gtk_widget_modify_text (Handle, (int) state, IntPtr.Zero);
}
public void ModifyText (Gtk.StateType state)
{
gtk_widget_modify_text (Handle, (int) state, IntPtr.Zero);
}
public void Path (out string path, out string path_reversed)
{
uint len;
Path (out len, out path, out path_reversed);
}
public void Path (out string path, out string path_reversed)
{
uint len;
Path (out len, out path, out path_reversed);
}
// 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);
}
protected override IntPtr Raw {
protected override IntPtr Raw {
get {
return base.Raw;
}