File: Atk_ValueAdapter.cs

package info (click to toggle)
gnome-subtitles 1.8-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 103,144 kB
  • sloc: xml: 406,395; cs: 364,495; ansic: 3,104; perl: 1,477; sh: 769; python: 545; javascript: 500; makefile: 49
file content (431 lines) | stat: -rw-r--r-- 15,049 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
// This file was generated by the Gtk# code generator.
// Any changes made will be lost if regenerated.

namespace Atk {

	using System;
	using System.Runtime.InteropServices;

#region Autogenerated code
	public partial class ValueAdapter : GLib.GInterfaceAdapter, Atk.IValue {

		[StructLayout (LayoutKind.Sequential)]
		struct AtkValueIface {
			public GetCurrentValueNativeDelegate GetCurrentValue;
			public GetMaximumValueNativeDelegate GetMaximumValue;
			public GetMinimumValueNativeDelegate GetMinimumValue;
			public SetCurrentValueNativeDelegate SetCurrentValue;
			public GetMinimumIncrementNativeDelegate GetMinimumIncrement;
			public GetValueAndTextNativeDelegate GetValueAndText;
			public GetRangeNativeDelegate GetRange;
			public GetIncrementNativeDelegate GetIncrement;
			public GetSubRangesNativeDelegate GetSubRanges;
			public SetValueNativeDelegate SetValue;
		}

		static AtkValueIface iface;

		static ValueAdapter ()
		{
			GLib.GType.Register (_gtype, typeof (ValueAdapter));
			iface.GetCurrentValue = new GetCurrentValueNativeDelegate (GetCurrentValue_cb);
			iface.GetMaximumValue = new GetMaximumValueNativeDelegate (GetMaximumValue_cb);
			iface.GetMinimumValue = new GetMinimumValueNativeDelegate (GetMinimumValue_cb);
			iface.SetCurrentValue = new SetCurrentValueNativeDelegate (SetCurrentValue_cb);
			iface.GetMinimumIncrement = new GetMinimumIncrementNativeDelegate (GetMinimumIncrement_cb);
			iface.GetValueAndText = new GetValueAndTextNativeDelegate (GetValueAndText_cb);
			iface.GetRange = new GetRangeNativeDelegate (GetRange_cb);
			iface.GetIncrement = new GetIncrementNativeDelegate (GetIncrement_cb);
			iface.GetSubRanges = new GetSubRangesNativeDelegate (GetSubRanges_cb);
			iface.SetValue = new SetValueNativeDelegate (SetValue_cb);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void GetCurrentValueNativeDelegate (IntPtr inst, IntPtr value);

		static void GetCurrentValue_cb (IntPtr inst, IntPtr value)
		{
			try {
				IValueImplementor __obj = GLib.Object.GetObject (inst, false) as IValueImplementor;
				GLib.Value myvalue = (GLib.Value) Marshal.PtrToStructure (value, typeof (GLib.Value));
				__obj.GetCurrentValue (ref myvalue);
				if (value != IntPtr.Zero) System.Runtime.InteropServices.Marshal.StructureToPtr (myvalue, value, false);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void GetMaximumValueNativeDelegate (IntPtr inst, IntPtr value);

		static void GetMaximumValue_cb (IntPtr inst, IntPtr value)
		{
			try {
				IValueImplementor __obj = GLib.Object.GetObject (inst, false) as IValueImplementor;
				GLib.Value myvalue = (GLib.Value) Marshal.PtrToStructure (value, typeof (GLib.Value));
				__obj.GetMaximumValue (ref myvalue);
				if (value != IntPtr.Zero) System.Runtime.InteropServices.Marshal.StructureToPtr (myvalue, value, false);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void GetMinimumValueNativeDelegate (IntPtr inst, IntPtr value);

		static void GetMinimumValue_cb (IntPtr inst, IntPtr value)
		{
			try {
				IValueImplementor __obj = GLib.Object.GetObject (inst, false) as IValueImplementor;
				GLib.Value myvalue = (GLib.Value) Marshal.PtrToStructure (value, typeof (GLib.Value));
				__obj.GetMinimumValue (ref myvalue);
				if (value != IntPtr.Zero) System.Runtime.InteropServices.Marshal.StructureToPtr (myvalue, value, false);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool SetCurrentValueNativeDelegate (IntPtr inst, IntPtr value);

		static bool SetCurrentValue_cb (IntPtr inst, IntPtr value)
		{
			try {
				IValueImplementor __obj = GLib.Object.GetObject (inst, false) as IValueImplementor;
				bool __result;
				__result = __obj.SetCurrentValue ((GLib.Value) Marshal.PtrToStructure (value, typeof (GLib.Value)));
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void GetMinimumIncrementNativeDelegate (IntPtr inst, IntPtr value);

		static void GetMinimumIncrement_cb (IntPtr inst, IntPtr value)
		{
			try {
				IValueImplementor __obj = GLib.Object.GetObject (inst, false) as IValueImplementor;
				GLib.Value myvalue = (GLib.Value) Marshal.PtrToStructure (value, typeof (GLib.Value));
				__obj.GetMinimumIncrement (ref myvalue);
				if (value != IntPtr.Zero) System.Runtime.InteropServices.Marshal.StructureToPtr (myvalue, value, false);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void GetValueAndTextNativeDelegate (IntPtr inst, out double value, IntPtr text);

		static void GetValueAndText_cb (IntPtr inst, out double value, IntPtr text)
		{
			try {
				IValueImplementor __obj = GLib.Object.GetObject (inst, false) as IValueImplementor;
				__obj.GetValueAndText (out value, GLib.Marshaller.PtrToStringGFree(text));
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr GetRangeNativeDelegate (IntPtr inst);

		static IntPtr GetRange_cb (IntPtr inst)
		{
			try {
				IValueImplementor __obj = GLib.Object.GetObject (inst, false) as IValueImplementor;
				Atk.Range __result;
				__result = __obj.Range;
				return __result == null ? IntPtr.Zero : __result.Handle;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate double GetIncrementNativeDelegate (IntPtr inst);

		static double GetIncrement_cb (IntPtr inst)
		{
			try {
				IValueImplementor __obj = GLib.Object.GetObject (inst, false) as IValueImplementor;
				double __result;
				__result = __obj.Increment;
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr GetSubRangesNativeDelegate (IntPtr inst);

		static IntPtr GetSubRanges_cb (IntPtr inst)
		{
			try {
				IValueImplementor __obj = GLib.Object.GetObject (inst, false) as IValueImplementor;
				GLib.SList __result;
				__result = __obj.SubRanges;
				return __result == null ? IntPtr.Zero : __result.Handle;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void SetValueNativeDelegate (IntPtr inst, double new_value);

		static void SetValue_cb (IntPtr inst, double new_value)
		{
			try {
				IValueImplementor __obj = GLib.Object.GetObject (inst, false) as IValueImplementor;
				__obj.Value = new_value;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		static int class_offset = 2 * IntPtr.Size;

		static void Initialize (IntPtr ptr, IntPtr data)
		{
			IntPtr ifaceptr = new IntPtr (ptr.ToInt64 () + class_offset);
			AtkValueIface native_iface = (AtkValueIface) Marshal.PtrToStructure (ifaceptr, typeof (AtkValueIface));
			native_iface.GetCurrentValue = iface.GetCurrentValue;
			native_iface.GetMaximumValue = iface.GetMaximumValue;
			native_iface.GetMinimumValue = iface.GetMinimumValue;
			native_iface.SetCurrentValue = iface.SetCurrentValue;
			native_iface.GetMinimumIncrement = iface.GetMinimumIncrement;
			native_iface.GetValueAndText = iface.GetValueAndText;
			native_iface.GetRange = iface.GetRange;
			native_iface.GetIncrement = iface.GetIncrement;
			native_iface.GetSubRanges = iface.GetSubRanges;
			native_iface.SetValue = iface.SetValue;
			Marshal.StructureToPtr (native_iface, ifaceptr, false);
		}

		GLib.Object implementor;

		public ValueAdapter ()
		{
			InitHandler = new GLib.GInterfaceInitHandler (Initialize);
		}

		public ValueAdapter (IValueImplementor implementor)
		{
			if (implementor == null)
				throw new ArgumentNullException ("implementor");
			else if (!(implementor is GLib.Object))
				throw new ArgumentException ("implementor must be a subclass of GLib.Object");
			this.implementor = implementor as GLib.Object;
		}

		public ValueAdapter (IntPtr handle)
		{
			if (!_gtype.IsInstance (handle))
				throw new ArgumentException ("The gobject doesn't implement the GInterface of this adapter", "handle");
			implementor = GLib.Object.GetObject (handle);
		}

		[DllImport("atk-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr atk_value_get_type();

		private static GLib.GType _gtype = new GLib.GType (atk_value_get_type ());

		public static GLib.GType GType {
			get {
				return _gtype;
			}
		}

		public override GLib.GType GInterfaceGType {
			get {
				return _gtype;
			}
		}

		public override IntPtr Handle {
			get {
				return implementor.Handle;
			}
		}

		public IntPtr OwnedHandle {
			get {
				return implementor.OwnedHandle;
			}
		}

		public static IValue GetObject (IntPtr handle, bool owned)
		{
			GLib.Object obj = GLib.Object.GetObject (handle, owned);
			return GetObject (obj);
		}

		public static IValue GetObject (GLib.Object obj)
		{
			if (obj == null)
				return null;
			else if (obj is IValueImplementor)
				return new ValueAdapter (obj as IValueImplementor);
			else if (obj as IValue == null)
				return new ValueAdapter (obj.Handle);
			else
				return obj as IValue;
		}

		public IValueImplementor Implementor {
			get {
				return implementor as IValueImplementor;
			}
		}

		[GLib.Signal("value_changed")]
		public event Atk.ValueChangedHandler ValueChanged {
			add {
				GLib.Object.GetObject (Handle).AddSignalHandler ("value_changed", value, typeof (Atk.ValueChangedArgs));
			}
			remove {
				GLib.Object.GetObject (Handle).RemoveSignalHandler ("value_changed", value);
			}
		}

		[DllImport("atk-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void atk_value_get_current_value(IntPtr raw, IntPtr value);

		[Obsolete]
		public void GetCurrentValue(ref GLib.Value value) {
			IntPtr native_value = GLib.Marshaller.StructureToPtrAlloc (value);
			atk_value_get_current_value(Handle, native_value);
			value = (GLib.Value) Marshal.PtrToStructure (native_value, typeof (GLib.Value));
			Marshal.FreeHGlobal (native_value);
		}

		[DllImport("atk-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern double atk_value_get_increment(IntPtr raw);

		public double Increment { 
			get {
				double raw_ret = atk_value_get_increment(Handle);
				double ret = raw_ret;
				return ret;
			}
		}

		[DllImport("atk-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void atk_value_get_maximum_value(IntPtr raw, IntPtr value);

		[Obsolete]
		public void GetMaximumValue(ref GLib.Value value) {
			IntPtr native_value = GLib.Marshaller.StructureToPtrAlloc (value);
			atk_value_get_maximum_value(Handle, native_value);
			value = (GLib.Value) Marshal.PtrToStructure (native_value, typeof (GLib.Value));
			Marshal.FreeHGlobal (native_value);
		}

		[DllImport("atk-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void atk_value_get_minimum_increment(IntPtr raw, IntPtr value);

		[Obsolete]
		public void GetMinimumIncrement(ref GLib.Value value) {
			IntPtr native_value = GLib.Marshaller.StructureToPtrAlloc (value);
			atk_value_get_minimum_increment(Handle, native_value);
			value = (GLib.Value) Marshal.PtrToStructure (native_value, typeof (GLib.Value));
			Marshal.FreeHGlobal (native_value);
		}

		[DllImport("atk-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void atk_value_get_minimum_value(IntPtr raw, IntPtr value);

		[Obsolete]
		public void GetMinimumValue(ref GLib.Value value) {
			IntPtr native_value = GLib.Marshaller.StructureToPtrAlloc (value);
			atk_value_get_minimum_value(Handle, native_value);
			value = (GLib.Value) Marshal.PtrToStructure (native_value, typeof (GLib.Value));
			Marshal.FreeHGlobal (native_value);
		}

		[DllImport("atk-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr atk_value_get_range(IntPtr raw);

		public Atk.Range Range { 
			get {
				IntPtr raw_ret = atk_value_get_range(Handle);
				Atk.Range ret = raw_ret == IntPtr.Zero ? null : (Atk.Range) GLib.Opaque.GetOpaque (raw_ret, typeof (Atk.Range), false);
				return ret;
			}
		}

		[DllImport("atk-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr atk_value_get_sub_ranges(IntPtr raw);

		public GLib.SList SubRanges { 
			get {
				IntPtr raw_ret = atk_value_get_sub_ranges(Handle);
				GLib.SList ret = new GLib.SList(raw_ret);
				return ret;
			}
		}

		[DllImport("atk-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void atk_value_get_value_and_text(IntPtr raw, out double value, IntPtr text);

		public double GetValueAndText(string text) {
			double value;
			atk_value_get_value_and_text(Handle, out value, GLib.Marshaller.StringToPtrGStrdup(text));
			return value;
		}

		[DllImport("atk-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern bool atk_value_set_current_value(IntPtr raw, IntPtr value);

		[Obsolete]
		public bool SetCurrentValue(GLib.Value value) {
			IntPtr native_value = GLib.Marshaller.StructureToPtrAlloc (value);
			bool raw_ret = atk_value_set_current_value(Handle, native_value);
			bool ret = raw_ret;
			Marshal.FreeHGlobal (native_value);
			return ret;
		}

		[DllImport("atk-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void atk_value_set_value(IntPtr raw, double new_value);

		public double Value { 
			set {
				atk_value_set_value(Handle, value);
			}
		}

		[DllImport("atk-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr atk_value_type_get_localized_name(int value_type);

		public static string TypeGetLocalizedName(Atk.ValueType value_type) {
			IntPtr raw_ret = atk_value_type_get_localized_name((int) value_type);
			string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
			return ret;
		}

		[DllImport("atk-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr atk_value_type_get_name(int value_type);

		public static string TypeGetName(Atk.ValueType value_type) {
			IntPtr raw_ret = atk_value_type_get_name((int) value_type);
			string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
			return ret;
		}

#endregion
	}
}