* glib/Object.cs (AddNotification, RemoveNotification): methods to
subscribe to the "notify" signal (with property details). [#71684] * glib/GLibSharp.voidObjectIntPtrSignal.cs: autogenerated, for notifications * glib/NotifyHandler.cs: sort of autogenerated svn path=/trunk/gtk-sharp/; revision=39717
This commit is contained in:
parent
289b127b10
commit
de70fff09f
9 changed files with 297 additions and 0 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2005-01-28 Dan Winship <danw@novell.com>
|
||||||
|
|
||||||
|
* glib/Object.cs (AddNotification, RemoveNotification): methods to
|
||||||
|
subscribe to the "notify" signal (with property details). [#71684]
|
||||||
|
|
||||||
|
* glib/GLibSharp.voidObjectIntPtrSignal.cs: autogenerated, for
|
||||||
|
notifications
|
||||||
|
|
||||||
|
* glib/NotifyHandler.cs: sort of autogenerated
|
||||||
|
|
||||||
2005-01-28 Mike Kestner <mkestner@novell.com>
|
2005-01-28 Mike Kestner <mkestner@novell.com>
|
||||||
|
|
||||||
* gtk/Dialog.custom : add a params array for button info to the ctor.
|
* gtk/Dialog.custom : add a params array for button info to the ctor.
|
||||||
|
|
|
@ -1,3 +1,9 @@
|
||||||
|
2005-01-28 Dan Winship <danw@novell.com>
|
||||||
|
|
||||||
|
* en/GLib/NotifyArgs.xml:
|
||||||
|
* en/GLib/NotifyHandler.xml:
|
||||||
|
* en/GLib/Object.xml (AddNotification, RemoveNotification): document
|
||||||
|
|
||||||
2005-01-18 Dan Winship <danw@novell.com>
|
2005-01-18 Dan Winship <danw@novell.com>
|
||||||
|
|
||||||
* en/GLib/Marshaller.xml (StringFormat): document
|
* en/GLib/Marshaller.xml (StringFormat): document
|
||||||
|
|
48
doc/en/GLib/NotifyArgs.xml
Normal file
48
doc/en/GLib/NotifyArgs.xml
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
<Type Name="NotifyArgs" FullName="GLib.NotifyArgs">
|
||||||
|
<TypeSignature Language="C#" Value="public class NotifyArgs : GLib.SignalArgs" Maintainer="auto" />
|
||||||
|
<AssemblyInfo>
|
||||||
|
<AssemblyName>glib-sharp</AssemblyName>
|
||||||
|
<AssemblyPublicKey>[00 24 00 00 04 80 00 00 94 00 00 00 06 02 00 00 00 24 00 00 52 53 41 31 00 04 00 00 01 00 01 00 71 EB 6C 55 75 52 9C BF 72 44 F7 A6 EA 05 62 84 F9 EA E0 3B CF F2 CC 13 2C 9C 49 0A B3 09 EA B0 B5 6B CE 44 9D F5 03 D9 C0 A8 1E 52 05 85 CD BE 70 E2 FB 90 43 4B AC 04 FA 62 22 A8 00 98 B7 A1 A7 B3 AF 99 1A 41 23 24 BB 43 25 F6 B8 65 BB 64 EB F6 D1 C2 06 D5 73 2D DF BC 70 A7 38 9E E5 3E 0C 24 6E 32 79 74 1A D0 05 03 E4 98 42 E1 9B F3 7B 19 8B 40 21 26 CB 36 89 C2 EA 64 96 A4 7C B4]</AssemblyPublicKey>
|
||||||
|
<AssemblyVersion>2.0.0.0</AssemblyVersion>
|
||||||
|
<AssemblyCulture>neutral</AssemblyCulture>
|
||||||
|
<Attributes />
|
||||||
|
</AssemblyInfo>
|
||||||
|
<ThreadSafetyStatement>Gtk# is thread aware, but not thread safe; See the <link location="node:gtk-sharp/programming/threads">Gtk# Thread Programming</link> for details.</ThreadSafetyStatement>
|
||||||
|
<Docs>
|
||||||
|
<summary>Event data.</summary>
|
||||||
|
<remarks>
|
||||||
|
<para>The <see cref="M:GLib.Object.AddNotification" /> method results in the invocation of <see cref="T:GLib.NotifyHandler" /> delegates which pass event data via this class.</para>
|
||||||
|
</remarks>
|
||||||
|
</Docs>
|
||||||
|
<Base>
|
||||||
|
<BaseTypeName>GLib.SignalArgs</BaseTypeName>
|
||||||
|
</Base>
|
||||||
|
<Interfaces />
|
||||||
|
<Attributes />
|
||||||
|
<Members>
|
||||||
|
<Member MemberName=".ctor">
|
||||||
|
<MemberSignature Language="C#" Value="public NotifyArgs ();" />
|
||||||
|
<MemberType>Constructor</MemberType>
|
||||||
|
<ReturnValue />
|
||||||
|
<Parameters />
|
||||||
|
<Docs>
|
||||||
|
<summary>Public Constructor.</summary>
|
||||||
|
<returns>A new <see cref="T:GLib.NotifyArgs" /></returns>
|
||||||
|
<remarks></remarks>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="Property">
|
||||||
|
<MemberSignature Language="C#" Value="public string Property { get; };" />
|
||||||
|
<MemberType>Property</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>System.String</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Parameters />
|
||||||
|
<Docs>
|
||||||
|
<summary>The property that changed</summary>
|
||||||
|
<returns>a <see cref="T:System.String" /></returns>
|
||||||
|
<remarks></remarks>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
</Members>
|
||||||
|
</Type>
|
38
doc/en/GLib/NotifyHandler.xml
Normal file
38
doc/en/GLib/NotifyHandler.xml
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
<Type Name="NotifyHandler" FullName="GLib.NotifyHandler">
|
||||||
|
<TypeSignature Language="C#" Value="public sealed delegate void NotifyHandler (object o, GLib.NotifyArgs args);" Maintainer="auto" />
|
||||||
|
<AssemblyInfo>
|
||||||
|
<AssemblyName>glib-sharp</AssemblyName>
|
||||||
|
<AssemblyPublicKey>[00 24 00 00 04 80 00 00 94 00 00 00 06 02 00 00 00 24 00 00 52 53 41 31 00 04 00 00 01 00 01 00 71 EB 6C 55 75 52 9C BF 72 44 F7 A6 EA 05 62 84 F9 EA E0 3B CF F2 CC 13 2C 9C 49 0A B3 09 EA B0 B5 6B CE 44 9D F5 03 D9 C0 A8 1E 52 05 85 CD BE 70 E2 FB 90 43 4B AC 04 FA 62 22 A8 00 98 B7 A1 A7 B3 AF 99 1A 41 23 24 BB 43 25 F6 B8 65 BB 64 EB F6 D1 C2 06 D5 73 2D DF BC 70 A7 38 9E E5 3E 0C 24 6E 32 79 74 1A D0 05 03 E4 98 42 E1 9B F3 7B 19 8B 40 21 26 CB 36 89 C2 EA 64 96 A4 7C B4]</AssemblyPublicKey>
|
||||||
|
<AssemblyVersion>2.0.0.0</AssemblyVersion>
|
||||||
|
<AssemblyCulture>neutral</AssemblyCulture>
|
||||||
|
<Attributes />
|
||||||
|
</AssemblyInfo>
|
||||||
|
<ThreadSafetyStatement>Gtk# is thread aware, but not thread safe; See the <link location="node:gtk-sharp/programming/threads">Gtk# Thread Programming</link> for details.</ThreadSafetyStatement>
|
||||||
|
<Docs>
|
||||||
|
<summary>Represents a method that will handle a property notification event</summary>
|
||||||
|
<remarks>
|
||||||
|
The handler is provided an <paramref name="args" /> value that contains
|
||||||
|
the event data (<see cref="T:GLib.NotifyArgs" />).
|
||||||
|
</remarks>
|
||||||
|
</Docs>
|
||||||
|
<Base>
|
||||||
|
<BaseTypeName>System.Delegate</BaseTypeName>
|
||||||
|
</Base>
|
||||||
|
<Interfaces>
|
||||||
|
<Interface>
|
||||||
|
<InterfaceName>System.ICloneable</InterfaceName>
|
||||||
|
</Interface>
|
||||||
|
<Interface>
|
||||||
|
<InterfaceName>System.Runtime.Serialization.ISerializable</InterfaceName>
|
||||||
|
</Interface>
|
||||||
|
</Interfaces>
|
||||||
|
<Attributes />
|
||||||
|
<Members />
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>System.Void</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Parameters>
|
||||||
|
<Parameter Name="o" Type="System.Object" />
|
||||||
|
<Parameter Name="args" Type="GLib.NotifyArgs" />
|
||||||
|
</Parameters>
|
||||||
|
</Type>
|
|
@ -401,5 +401,69 @@ This method is called by the generated classes by the Gtk# framework.
|
||||||
</remarks>
|
</remarks>
|
||||||
</Docs>
|
</Docs>
|
||||||
</Member>
|
</Member>
|
||||||
|
<Member MemberName="AddNotification">
|
||||||
|
<MemberSignature Language="C#" Value="public void AddNotification (string property, GLib.NotifyHandler handler);" />
|
||||||
|
<MemberType>Method</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>System.Void</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Parameters>
|
||||||
|
<Parameter Name="property" Type="System.String" />
|
||||||
|
<Parameter Name="handler" Type="GLib.NotifyHandler" />
|
||||||
|
</Parameters>
|
||||||
|
<Docs>
|
||||||
|
<summary>Request property-change notifications</summary>
|
||||||
|
<param name="property">the property to watch (the underlying GObject property name, not the managed wrapper property)</param>
|
||||||
|
<param name="handler">a <see cref="T:GLib.NotifyHandler" /> to invoke when <paramref name="property" /> changes</param>
|
||||||
|
<remarks>This connects to the GObject "notify" signal with a detail argument of <paramref name="property" />, to receive notifications when that property changes.</remarks>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="AddNotification">
|
||||||
|
<MemberSignature Language="C#" Value="public void AddNotification (GLib.NotifyHandler handler);" />
|
||||||
|
<MemberType>Method</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>System.Void</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Parameters>
|
||||||
|
<Parameter Name="handler" Type="GLib.NotifyHandler" />
|
||||||
|
</Parameters>
|
||||||
|
<Docs>
|
||||||
|
<summary>Request property-change notifications for all GObject properties</summary>
|
||||||
|
<param name="handler">a <see cref="T:GLib.NotifyHandler" /> to invoke when a GObject property changes</param>
|
||||||
|
<remarks>This connects to the GObject "notify" signal with no detail argument, to receive notifications when any property changes.</remarks>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="RemoveNotification">
|
||||||
|
<MemberSignature Language="C#" Value="public void RemoveNotification (string property, GLib.NotifyHandler handler);" />
|
||||||
|
<MemberType>Method</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>System.Void</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Parameters>
|
||||||
|
<Parameter Name="property" Type="System.String" />
|
||||||
|
<Parameter Name="handler" Type="GLib.NotifyHandler" />
|
||||||
|
</Parameters>
|
||||||
|
<Docs>
|
||||||
|
<summary>Cancels property-change notifictions for the indicated property</summary>
|
||||||
|
<param name="property">the property</param>
|
||||||
|
<param name="handler">the <see cref="T:GLib.NotifyHandler" /></param>
|
||||||
|
<remarks>This disconnects from notifications for <paramref name="property" />.</remarks>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
|
<Member MemberName="RemoveNotification">
|
||||||
|
<MemberSignature Language="C#" Value="public void RemoveNotification (GLib.NotifyHandler handler);" />
|
||||||
|
<MemberType>Method</MemberType>
|
||||||
|
<ReturnValue>
|
||||||
|
<ReturnType>System.Void</ReturnType>
|
||||||
|
</ReturnValue>
|
||||||
|
<Parameters>
|
||||||
|
<Parameter Name="handler" Type="GLib.NotifyHandler" />
|
||||||
|
</Parameters>
|
||||||
|
<Docs>
|
||||||
|
<summary>Cancels property-change notifications</summary>
|
||||||
|
<param name="handler">the <see cref="T:GLib.NotifyHandler" /></param>
|
||||||
|
<remarks>This disconnects from generic property change notifications. (This only affects notifications created with the corresponding generic version of <see cref="M:GLib.Object.AddNotification" />. It does not remove notifications for specific properties.)</remarks>
|
||||||
|
</Docs>
|
||||||
|
</Member>
|
||||||
</Members>
|
</Members>
|
||||||
</Type>
|
</Type>
|
50
glib/GLibSharp.voidObjectIntPtrSignal.cs
Normal file
50
glib/GLibSharp.voidObjectIntPtrSignal.cs
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
// copied from gtk/generated/GtkSharp.voidObjectIntPtrSignal.cs and renamespaced
|
||||||
|
|
||||||
|
// This file was generated by the Gtk# code generator.
|
||||||
|
// Any changes made will be lost if regenerated.
|
||||||
|
|
||||||
|
namespace GLibSharp {
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
internal delegate void voidObjectIntPtrDelegate(IntPtr arg0, IntPtr arg1, int key);
|
||||||
|
|
||||||
|
internal class voidObjectIntPtrSignal : GLib.SignalCallback {
|
||||||
|
|
||||||
|
private static voidObjectIntPtrDelegate _Delegate;
|
||||||
|
|
||||||
|
private static void voidObjectIntPtrCallback(IntPtr arg0, IntPtr arg1, int key)
|
||||||
|
{
|
||||||
|
if (!_Instances.Contains(key))
|
||||||
|
throw new Exception("Unexpected signal key " + key);
|
||||||
|
|
||||||
|
voidObjectIntPtrSignal inst = (voidObjectIntPtrSignal) _Instances[key];
|
||||||
|
GLib.SignalArgs args = (GLib.SignalArgs) Activator.CreateInstance (inst._argstype);
|
||||||
|
args.Args = new object[1];
|
||||||
|
args.Args[0] = arg1;
|
||||||
|
object[] argv = new object[2];
|
||||||
|
argv[0] = inst._obj;
|
||||||
|
argv[1] = args;
|
||||||
|
inst._handler.DynamicInvoke(argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
public voidObjectIntPtrSignal(GLib.Object obj, string name, Delegate eh, Type argstype, int connect_flags) : base(obj, eh, argstype)
|
||||||
|
{
|
||||||
|
if (_Delegate == null) {
|
||||||
|
_Delegate = new voidObjectIntPtrDelegate(voidObjectIntPtrCallback);
|
||||||
|
}
|
||||||
|
Connect (name, _Delegate, connect_flags);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Dispose (bool disposing)
|
||||||
|
{
|
||||||
|
_Instances.Remove(_key);
|
||||||
|
if(_Instances.Count == 0)
|
||||||
|
_Delegate = null;
|
||||||
|
|
||||||
|
Disconnect ();
|
||||||
|
base.Dispose (disposing);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -19,6 +19,7 @@ sources = \
|
||||||
EnumWrapper.cs \
|
EnumWrapper.cs \
|
||||||
FileUtils.cs \
|
FileUtils.cs \
|
||||||
GException.cs \
|
GException.cs \
|
||||||
|
GLibSharp.voidObjectIntPtrSignal.cs \
|
||||||
GString.cs \
|
GString.cs \
|
||||||
Idle.cs \
|
Idle.cs \
|
||||||
IWrapper.cs \
|
IWrapper.cs \
|
||||||
|
@ -31,6 +32,7 @@ sources = \
|
||||||
Markup.cs \
|
Markup.cs \
|
||||||
Marshaller.cs \
|
Marshaller.cs \
|
||||||
MissingIntPtrCtorException.cs \
|
MissingIntPtrCtorException.cs \
|
||||||
|
NotifyHandler.cs \
|
||||||
Object.cs \
|
Object.cs \
|
||||||
ObjectManager.cs \
|
ObjectManager.cs \
|
||||||
Opaque.cs \
|
Opaque.cs \
|
||||||
|
|
35
glib/NotifyHandler.cs
Normal file
35
glib/NotifyHandler.cs
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
// Copyright (c) 2005 Novell, Inc.
|
||||||
|
//
|
||||||
|
// This program is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of version 2 of the Lesser GNU General
|
||||||
|
// Public License as published by the Free Software Foundation.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
// Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU Lesser General Public
|
||||||
|
// License along with this program; if not, write to the
|
||||||
|
// Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
||||||
|
// Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
|
namespace GLib {
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
public delegate void NotifyHandler (object o, NotifyArgs args);
|
||||||
|
|
||||||
|
public class NotifyArgs : GLib.SignalArgs {
|
||||||
|
[DllImport("libgobject-2.0-0.dll")]
|
||||||
|
static extern IntPtr g_param_spec_get_name (IntPtr pspec);
|
||||||
|
|
||||||
|
public string Property {
|
||||||
|
get {
|
||||||
|
IntPtr raw_ret = g_param_spec_get_name ((IntPtr) Args[0]);
|
||||||
|
return Marshal.PtrToStringAnsi (raw_ret);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -280,6 +280,50 @@ namespace GLib {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ConnectNotification (string signal, NotifyHandler handler)
|
||||||
|
{
|
||||||
|
if (AfterHandlers[signal] == null)
|
||||||
|
AfterSignals[signal] = new GLibSharp.voidObjectIntPtrSignal (this, signal, handler, typeof (NotifyArgs), 1);
|
||||||
|
else
|
||||||
|
((GLib.SignalCallback) AfterSignals[signal]).AddDelegate (handler);
|
||||||
|
AfterHandlers.AddHandler (signal, handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddNotification (string property, NotifyHandler handler)
|
||||||
|
{
|
||||||
|
ConnectNotification ("notify::" + property, handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void AddNotification (NotifyHandler handler)
|
||||||
|
{
|
||||||
|
ConnectNotification ("notify", handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DisconnectNotification (string signal, NotifyHandler handler)
|
||||||
|
{
|
||||||
|
GLib.SignalCallback cb = AfterSignals[signal] as GLib.SignalCallback;
|
||||||
|
AfterHandlers.RemoveHandler (signal, handler);
|
||||||
|
|
||||||
|
if (cb == null)
|
||||||
|
return;
|
||||||
|
cb.RemoveDelegate (handler);
|
||||||
|
|
||||||
|
if (AfterHandlers[signal] == null) {
|
||||||
|
AfterSignals.Remove (signal);
|
||||||
|
cb.Dispose ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveNotification (string property, NotifyHandler handler)
|
||||||
|
{
|
||||||
|
DisconnectNotification ("notify::" + property, handler);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void RemoveNotification (NotifyHandler handler)
|
||||||
|
{
|
||||||
|
DisconnectNotification ("notify", handler);
|
||||||
|
}
|
||||||
|
|
||||||
public override int GetHashCode ()
|
public override int GetHashCode ()
|
||||||
{
|
{
|
||||||
return Handle.GetHashCode ();
|
return Handle.GetHashCode ();
|
||||||
|
|
Loading…
Reference in a new issue