File: Atk_DocumentAdapter.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 (403 lines) | stat: -rw-r--r-- 13,141 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
// 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 DocumentAdapter : GLib.GInterfaceAdapter, Atk.IDocument {

		[StructLayout (LayoutKind.Sequential)]
		struct AtkDocumentIface {
			public GetDocumentTypeNativeDelegate GetDocumentType;
			public GetTheDocumentNativeDelegate GetTheDocument;
			public GetLocaleNativeDelegate GetLocale;
			public GetAttributesNativeDelegate GetAttributes;
			public GetAttributeValueNativeDelegate GetAttributeValue;
			public SetAttributeValueNativeDelegate SetAttributeValue;
			public GetCurrentPageNumberNativeDelegate GetCurrentPageNumber;
			public GetPageCountNativeDelegate GetPageCount;
		}

		static AtkDocumentIface iface;

		static DocumentAdapter ()
		{
			GLib.GType.Register (_gtype, typeof (DocumentAdapter));
			iface.GetDocumentType = new GetDocumentTypeNativeDelegate (GetDocumentType_cb);
			iface.GetTheDocument = new GetTheDocumentNativeDelegate (GetTheDocument_cb);
			iface.GetLocale = new GetLocaleNativeDelegate (GetLocale_cb);
			iface.GetAttributes = new GetAttributesNativeDelegate (GetAttributes_cb);
			iface.GetAttributeValue = new GetAttributeValueNativeDelegate (GetAttributeValue_cb);
			iface.SetAttributeValue = new SetAttributeValueNativeDelegate (SetAttributeValue_cb);
			iface.GetCurrentPageNumber = new GetCurrentPageNumberNativeDelegate (GetCurrentPageNumber_cb);
			iface.GetPageCount = new GetPageCountNativeDelegate (GetPageCount_cb);
		}

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

		static IntPtr GetDocumentType_cb (IntPtr inst)
		{
			try {
				IDocumentImplementor __obj = GLib.Object.GetObject (inst, false) as IDocumentImplementor;
				string __result;
				__result = __obj.DocumentType;
				return GLib.Marshaller.StringToPtrGStrdup(__result);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

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

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

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

		static IntPtr GetLocale_cb (IntPtr inst)
		{
			try {
				IDocumentImplementor __obj = GLib.Object.GetObject (inst, false) as IDocumentImplementor;
				string __result;
				__result = __obj.Locale;
				return GLib.Marshaller.StringToPtrGStrdup(__result);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

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

		static IntPtr GetAttributes_cb (IntPtr inst)
		{
			try {
				IDocumentImplementor __obj = GLib.Object.GetObject (inst, false) as IDocumentImplementor;
				Atk.Attribute[] __result;
				__result = __obj.Attributes;
				return new GLib.SList(__result, typeof (Atk.Attribute), false, false) == null ? IntPtr.Zero : new GLib.SList(__result, typeof (Atk.Attribute), false, false).Handle;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr GetAttributeValueNativeDelegate (IntPtr inst, IntPtr attribute_name);

		static IntPtr GetAttributeValue_cb (IntPtr inst, IntPtr attribute_name)
		{
			try {
				IDocumentImplementor __obj = GLib.Object.GetObject (inst, false) as IDocumentImplementor;
				string __result;
				__result = __obj.GetAttributeValue (GLib.Marshaller.Utf8PtrToString (attribute_name));
				return GLib.Marshaller.StringToPtrGStrdup(__result);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool SetAttributeValueNativeDelegate (IntPtr inst, IntPtr attribute_name, IntPtr attribute_value);

		static bool SetAttributeValue_cb (IntPtr inst, IntPtr attribute_name, IntPtr attribute_value)
		{
			try {
				IDocumentImplementor __obj = GLib.Object.GetObject (inst, false) as IDocumentImplementor;
				bool __result;
				__result = __obj.SetAttributeValue (GLib.Marshaller.Utf8PtrToString (attribute_name), GLib.Marshaller.Utf8PtrToString (attribute_value));
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

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

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

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

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

		static int class_offset = 2 * IntPtr.Size;

		static void Initialize (IntPtr ptr, IntPtr data)
		{
			IntPtr ifaceptr = new IntPtr (ptr.ToInt64 () + class_offset);
			AtkDocumentIface native_iface = (AtkDocumentIface) Marshal.PtrToStructure (ifaceptr, typeof (AtkDocumentIface));
			native_iface.GetDocumentType = iface.GetDocumentType;
			native_iface.GetTheDocument = iface.GetTheDocument;
			native_iface.GetLocale = iface.GetLocale;
			native_iface.GetAttributes = iface.GetAttributes;
			native_iface.GetAttributeValue = iface.GetAttributeValue;
			native_iface.SetAttributeValue = iface.SetAttributeValue;
			native_iface.GetCurrentPageNumber = iface.GetCurrentPageNumber;
			native_iface.GetPageCount = iface.GetPageCount;
			Marshal.StructureToPtr (native_iface, ifaceptr, false);
		}

		GLib.Object implementor;

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

		public DocumentAdapter (IDocumentImplementor 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 DocumentAdapter (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_document_get_type();

		private static GLib.GType _gtype = new GLib.GType (atk_document_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 IDocument GetObject (IntPtr handle, bool owned)
		{
			GLib.Object obj = GLib.Object.GetObject (handle, owned);
			return GetObject (obj);
		}

		public static IDocument GetObject (GLib.Object obj)
		{
			if (obj == null)
				return null;
			else if (obj is IDocumentImplementor)
				return new DocumentAdapter (obj as IDocumentImplementor);
			else if (obj as IDocument == null)
				return new DocumentAdapter (obj.Handle);
			else
				return obj as IDocument;
		}

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

		[GLib.Signal("reload")]
		public event System.EventHandler Reload {
			add {
				GLib.Object.GetObject (Handle).AddSignalHandler ("reload", value);
			}
			remove {
				GLib.Object.GetObject (Handle).RemoveSignalHandler ("reload", value);
			}
		}

		[GLib.Signal("page_changed")]
		public event Atk.PageChangedHandler PageChanged {
			add {
				GLib.Object.GetObject (Handle).AddSignalHandler ("page_changed", value, typeof (Atk.PageChangedArgs));
			}
			remove {
				GLib.Object.GetObject (Handle).RemoveSignalHandler ("page_changed", value);
			}
		}

		[GLib.Signal("load_complete")]
		public event System.EventHandler LoadComplete {
			add {
				GLib.Object.GetObject (Handle).AddSignalHandler ("load_complete", value);
			}
			remove {
				GLib.Object.GetObject (Handle).RemoveSignalHandler ("load_complete", value);
			}
		}

		[GLib.Signal("load_stopped")]
		public event System.EventHandler LoadStopped {
			add {
				GLib.Object.GetObject (Handle).AddSignalHandler ("load_stopped", value);
			}
			remove {
				GLib.Object.GetObject (Handle).RemoveSignalHandler ("load_stopped", value);
			}
		}

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

		public string GetAttributeValue(string attribute_name) {
			IntPtr native_attribute_name = GLib.Marshaller.StringToPtrGStrdup (attribute_name);
			IntPtr raw_ret = atk_document_get_attribute_value(Handle, native_attribute_name);
			string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
			GLib.Marshaller.Free (native_attribute_name);
			return ret;
		}

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

		public Atk.Attribute[] Attributes { 
			get {
				IntPtr raw_ret = atk_document_get_attributes(Handle);
				Atk.Attribute[] ret = (Atk.Attribute[]) GLib.Marshaller.ListPtrToArray (raw_ret, typeof(GLib.SList), false, false, typeof(Atk.Attribute));
				return ret;
			}
		}

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

		public int CurrentPageNumber { 
			get {
				int raw_ret = atk_document_get_current_page_number(Handle);
				int ret = raw_ret;
				return ret;
			}
		}

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

		[Obsolete]
		public IntPtr TheDocument { 
			get {
				IntPtr raw_ret = atk_document_get_document(Handle);
				IntPtr ret = raw_ret;
				return ret;
			}
		}

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

		[Obsolete]
		public string DocumentType { 
			get {
				IntPtr raw_ret = atk_document_get_document_type(Handle);
				string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
				return ret;
			}
		}

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

		[Obsolete]
		public string Locale { 
			get {
				IntPtr raw_ret = atk_document_get_locale(Handle);
				string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
				return ret;
			}
		}

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

		public int PageCount { 
			get {
				int raw_ret = atk_document_get_page_count(Handle);
				int ret = raw_ret;
				return ret;
			}
		}

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

		public bool SetAttributeValue(string attribute_name, string attribute_value) {
			IntPtr native_attribute_name = GLib.Marshaller.StringToPtrGStrdup (attribute_name);
			IntPtr native_attribute_value = GLib.Marshaller.StringToPtrGStrdup (attribute_value);
			bool raw_ret = atk_document_set_attribute_value(Handle, native_attribute_name, native_attribute_value);
			bool ret = raw_ret;
			GLib.Marshaller.Free (native_attribute_name);
			GLib.Marshaller.Free (native_attribute_value);
			return ret;
		}

#endregion
	}
}