File: Atk_TextAdapter.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 (815 lines) | stat: -rw-r--r-- 32,274 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
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
// 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 TextAdapter : GLib.GInterfaceAdapter, Atk.IText {

		[StructLayout (LayoutKind.Sequential)]
		struct AtkTextIface {
			public GetTextNativeDelegate GetText;
			public GetTextAfterOffsetNativeDelegate GetTextAfterOffset;
			public GetTextAtOffsetNativeDelegate GetTextAtOffset;
			public GetCharacterAtOffsetNativeDelegate GetCharacterAtOffset;
			public GetTextBeforeOffsetNativeDelegate GetTextBeforeOffset;
			public GetCaretOffsetNativeDelegate GetCaretOffset;
			public GetRunAttributesNativeDelegate GetRunAttributes;
			public GetDefaultAttributesNativeDelegate GetDefaultAttributes;
			public GetCharacterExtentsNativeDelegate GetCharacterExtents;
			public GetCharacterCountNativeDelegate GetCharacterCount;
			public GetOffsetAtPointNativeDelegate GetOffsetAtPoint;
			public GetNSelectionsNativeDelegate GetNSelections;
			public GetSelectionNativeDelegate GetSelection;
			public AddSelectionNativeDelegate AddSelection;
			public RemoveSelectionNativeDelegate RemoveSelection;
			public SetSelectionNativeDelegate SetSelection;
			public SetCaretOffsetNativeDelegate SetCaretOffset;
			IntPtr TextChanged;
			IntPtr TextCaretMoved;
			IntPtr TextSelectionChanged;
			IntPtr TextAttributesChanged;
			public GetRangeExtentsNativeDelegate GetRangeExtents;
			public GetBoundedRangesNativeDelegate GetBoundedRanges;
			public GetStringAtOffsetNativeDelegate GetStringAtOffset;
		}

		static AtkTextIface iface;

		static TextAdapter ()
		{
			GLib.GType.Register (_gtype, typeof (TextAdapter));
			iface.GetText = new GetTextNativeDelegate (GetText_cb);
			iface.GetTextAfterOffset = new GetTextAfterOffsetNativeDelegate (GetTextAfterOffset_cb);
			iface.GetTextAtOffset = new GetTextAtOffsetNativeDelegate (GetTextAtOffset_cb);
			iface.GetCharacterAtOffset = new GetCharacterAtOffsetNativeDelegate (GetCharacterAtOffset_cb);
			iface.GetTextBeforeOffset = new GetTextBeforeOffsetNativeDelegate (GetTextBeforeOffset_cb);
			iface.GetCaretOffset = new GetCaretOffsetNativeDelegate (GetCaretOffset_cb);
			iface.GetRunAttributes = new GetRunAttributesNativeDelegate (GetRunAttributes_cb);
			iface.GetDefaultAttributes = new GetDefaultAttributesNativeDelegate (GetDefaultAttributes_cb);
			iface.GetCharacterExtents = new GetCharacterExtentsNativeDelegate (GetCharacterExtents_cb);
			iface.GetCharacterCount = new GetCharacterCountNativeDelegate (GetCharacterCount_cb);
			iface.GetOffsetAtPoint = new GetOffsetAtPointNativeDelegate (GetOffsetAtPoint_cb);
			iface.GetNSelections = new GetNSelectionsNativeDelegate (GetNSelections_cb);
			iface.GetSelection = new GetSelectionNativeDelegate (GetSelection_cb);
			iface.AddSelection = new AddSelectionNativeDelegate (AddSelection_cb);
			iface.RemoveSelection = new RemoveSelectionNativeDelegate (RemoveSelection_cb);
			iface.SetSelection = new SetSelectionNativeDelegate (SetSelection_cb);
			iface.SetCaretOffset = new SetCaretOffsetNativeDelegate (SetCaretOffset_cb);
			iface.GetRangeExtents = new GetRangeExtentsNativeDelegate (GetRangeExtents_cb);
			iface.GetBoundedRanges = new GetBoundedRangesNativeDelegate (GetBoundedRanges_cb);
			iface.GetStringAtOffset = new GetStringAtOffsetNativeDelegate (GetStringAtOffset_cb);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr GetTextNativeDelegate (IntPtr inst, int start_offset, int end_offset);

		static IntPtr GetText_cb (IntPtr inst, int start_offset, int end_offset)
		{
			try {
				ITextImplementor __obj = GLib.Object.GetObject (inst, false) as ITextImplementor;
				string __result;
				__result = __obj.GetText (start_offset, end_offset);
				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 GetTextAfterOffsetNativeDelegate (IntPtr inst, int offset, int boundary_type, out int start_offset, out int end_offset);

		static IntPtr GetTextAfterOffset_cb (IntPtr inst, int offset, int boundary_type, out int start_offset, out int end_offset)
		{
			try {
				ITextImplementor __obj = GLib.Object.GetObject (inst, false) as ITextImplementor;
				string __result;
				__result = __obj.GetTextAfterOffset (offset, (Atk.TextBoundary) boundary_type, out start_offset, out end_offset);
				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 GetTextAtOffsetNativeDelegate (IntPtr inst, int offset, int boundary_type, out int start_offset, out int end_offset);

		static IntPtr GetTextAtOffset_cb (IntPtr inst, int offset, int boundary_type, out int start_offset, out int end_offset)
		{
			try {
				ITextImplementor __obj = GLib.Object.GetObject (inst, false) as ITextImplementor;
				string __result;
				__result = __obj.GetTextAtOffset (offset, (Atk.TextBoundary) boundary_type, out start_offset, out end_offset);
				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 uint GetCharacterAtOffsetNativeDelegate (IntPtr inst, int offset);

		static uint GetCharacterAtOffset_cb (IntPtr inst, int offset)
		{
			try {
				ITextImplementor __obj = GLib.Object.GetObject (inst, false) as ITextImplementor;
				char __result;
				__result = __obj.GetCharacterAtOffset (offset);
				return GLib.Marshaller.CharToGUnichar (__result);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr GetTextBeforeOffsetNativeDelegate (IntPtr inst, int offset, int boundary_type, out int start_offset, out int end_offset);

		static IntPtr GetTextBeforeOffset_cb (IntPtr inst, int offset, int boundary_type, out int start_offset, out int end_offset)
		{
			try {
				ITextImplementor __obj = GLib.Object.GetObject (inst, false) as ITextImplementor;
				string __result;
				__result = __obj.GetTextBeforeOffset (offset, (Atk.TextBoundary) boundary_type, out start_offset, out end_offset);
				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 int GetCaretOffsetNativeDelegate (IntPtr inst);

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr GetRunAttributesNativeDelegate (IntPtr inst, int offset, out int start_offset, out int end_offset);

		static IntPtr GetRunAttributes_cb (IntPtr inst, int offset, out int start_offset, out int end_offset)
		{
			try {
				ITextImplementor __obj = GLib.Object.GetObject (inst, false) as ITextImplementor;
				Atk.Attribute[] __result;
				__result = __obj.GetRunAttributes (offset, out start_offset, out end_offset);
				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 GetDefaultAttributesNativeDelegate (IntPtr inst);

		static IntPtr GetDefaultAttributes_cb (IntPtr inst)
		{
			try {
				ITextImplementor __obj = GLib.Object.GetObject (inst, false) as ITextImplementor;
				Atk.Attribute[] __result;
				__result = __obj.DefaultAttributes;
				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 void GetCharacterExtentsNativeDelegate (IntPtr inst, int offset, out int x, out int y, out int width, out int height, int coords);

		static void GetCharacterExtents_cb (IntPtr inst, int offset, out int x, out int y, out int width, out int height, int coords)
		{
			try {
				ITextImplementor __obj = GLib.Object.GetObject (inst, false) as ITextImplementor;
				__obj.GetCharacterExtents (offset, out x, out y, out width, out height, (Atk.CoordType) coords);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

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

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate int GetOffsetAtPointNativeDelegate (IntPtr inst, int x, int y, int coords);

		static int GetOffsetAtPoint_cb (IntPtr inst, int x, int y, int coords)
		{
			try {
				ITextImplementor __obj = GLib.Object.GetObject (inst, false) as ITextImplementor;
				int __result;
				__result = __obj.GetOffsetAtPoint (x, y, (Atk.CoordType) coords);
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

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

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr GetSelectionNativeDelegate (IntPtr inst, int selection_num, out int start_offset, out int end_offset);

		static IntPtr GetSelection_cb (IntPtr inst, int selection_num, out int start_offset, out int end_offset)
		{
			try {
				ITextImplementor __obj = GLib.Object.GetObject (inst, false) as ITextImplementor;
				string __result;
				__result = __obj.GetSelection (selection_num, out start_offset, out end_offset);
				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 AddSelectionNativeDelegate (IntPtr inst, int start_offset, int end_offset);

		static bool AddSelection_cb (IntPtr inst, int start_offset, int end_offset)
		{
			try {
				ITextImplementor __obj = GLib.Object.GetObject (inst, false) as ITextImplementor;
				bool __result;
				__result = __obj.AddSelection (start_offset, end_offset);
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool RemoveSelectionNativeDelegate (IntPtr inst, int selection_num);

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool SetSelectionNativeDelegate (IntPtr inst, int selection_num, int start_offset, int end_offset);

		static bool SetSelection_cb (IntPtr inst, int selection_num, int start_offset, int end_offset)
		{
			try {
				ITextImplementor __obj = GLib.Object.GetObject (inst, false) as ITextImplementor;
				bool __result;
				__result = __obj.SetSelection (selection_num, start_offset, end_offset);
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool SetCaretOffsetNativeDelegate (IntPtr inst, int offset);

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

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void GetRangeExtentsNativeDelegate (IntPtr inst, int start_offset, int end_offset, int coord_type, IntPtr rect);

		static void GetRangeExtents_cb (IntPtr inst, int start_offset, int end_offset, int coord_type, IntPtr rect)
		{
			try {
				ITextImplementor __obj = GLib.Object.GetObject (inst, false) as ITextImplementor;
				Atk.TextRectangle myrect;
				__obj.GetRangeExtents (start_offset, end_offset, (Atk.CoordType) coord_type, out myrect);
				if (rect != IntPtr.Zero) System.Runtime.InteropServices.Marshal.StructureToPtr (myrect, rect, false);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr GetBoundedRangesNativeDelegate (IntPtr inst, IntPtr rect, int coord_type, int x_clip_type, int y_clip_type);

		static IntPtr GetBoundedRanges_cb (IntPtr inst, IntPtr rect, int coord_type, int x_clip_type, int y_clip_type)
		{
			try {
				ITextImplementor __obj = GLib.Object.GetObject (inst, false) as ITextImplementor;
				Atk.TextRange __result;
				__result = __obj.GetBoundedRanges (Atk.TextRectangle.New (rect), (Atk.CoordType) coord_type, (Atk.TextClipType) x_clip_type, (Atk.TextClipType) y_clip_type);
				return GLib.Marshaller.StructureToPtrAlloc (__result);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate IntPtr GetStringAtOffsetNativeDelegate (IntPtr inst, int offset, int granularity, out int start_offset, out int end_offset);

		static IntPtr GetStringAtOffset_cb (IntPtr inst, int offset, int granularity, out int start_offset, out int end_offset)
		{
			try {
				ITextImplementor __obj = GLib.Object.GetObject (inst, false) as ITextImplementor;
				string __result;
				__result = __obj.GetStringAtOffset (offset, (Atk.TextGranularity) granularity, out start_offset, out end_offset);
				return GLib.Marshaller.StringToPtrGStrdup(__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);
			AtkTextIface native_iface = (AtkTextIface) Marshal.PtrToStructure (ifaceptr, typeof (AtkTextIface));
			native_iface.GetText = iface.GetText;
			native_iface.GetTextAfterOffset = iface.GetTextAfterOffset;
			native_iface.GetTextAtOffset = iface.GetTextAtOffset;
			native_iface.GetCharacterAtOffset = iface.GetCharacterAtOffset;
			native_iface.GetTextBeforeOffset = iface.GetTextBeforeOffset;
			native_iface.GetCaretOffset = iface.GetCaretOffset;
			native_iface.GetRunAttributes = iface.GetRunAttributes;
			native_iface.GetDefaultAttributes = iface.GetDefaultAttributes;
			native_iface.GetCharacterExtents = iface.GetCharacterExtents;
			native_iface.GetCharacterCount = iface.GetCharacterCount;
			native_iface.GetOffsetAtPoint = iface.GetOffsetAtPoint;
			native_iface.GetNSelections = iface.GetNSelections;
			native_iface.GetSelection = iface.GetSelection;
			native_iface.AddSelection = iface.AddSelection;
			native_iface.RemoveSelection = iface.RemoveSelection;
			native_iface.SetSelection = iface.SetSelection;
			native_iface.SetCaretOffset = iface.SetCaretOffset;
			native_iface.GetRangeExtents = iface.GetRangeExtents;
			native_iface.GetBoundedRanges = iface.GetBoundedRanges;
			native_iface.GetStringAtOffset = iface.GetStringAtOffset;
			Marshal.StructureToPtr (native_iface, ifaceptr, false);
		}

		GLib.Object implementor;

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

		public TextAdapter (ITextImplementor 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 TextAdapter (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_text_get_type();

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

		public static IText GetObject (GLib.Object obj)
		{
			if (obj == null)
				return null;
			else if (obj is ITextImplementor)
				return new TextAdapter (obj as ITextImplementor);
			else if (obj as IText == null)
				return new TextAdapter (obj.Handle);
			else
				return obj as IText;
		}

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

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

		[GLib.Signal("text_caret_moved")]
		public event Atk.TextCaretMovedHandler TextCaretMoved {
			add {
				GLib.Object.GetObject (Handle).AddSignalHandler ("text_caret_moved", value, typeof (Atk.TextCaretMovedArgs));
			}
			remove {
				GLib.Object.GetObject (Handle).RemoveSignalHandler ("text_caret_moved", value);
			}
		}

		[GLib.Signal("text_changed")]
		public event Atk.TextChangedHandler TextChanged {
			add {
				GLib.Object.GetObject (Handle).AddSignalHandler ("text_changed", value, typeof (Atk.TextChangedArgs));
			}
			remove {
				GLib.Object.GetObject (Handle).RemoveSignalHandler ("text_changed", value);
			}
		}

		[GLib.Signal("text_remove")]
		public event Atk.TextRemoveHandler TextRemove {
			add {
				GLib.Object.GetObject (Handle).AddSignalHandler ("text_remove", value, typeof (Atk.TextRemoveArgs));
			}
			remove {
				GLib.Object.GetObject (Handle).RemoveSignalHandler ("text_remove", value);
			}
		}

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

		[GLib.Signal("text_insert")]
		public event Atk.TextInsertHandler TextInsert {
			add {
				GLib.Object.GetObject (Handle).AddSignalHandler ("text_insert", value, typeof (Atk.TextInsertArgs));
			}
			remove {
				GLib.Object.GetObject (Handle).RemoveSignalHandler ("text_insert", value);
			}
		}

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

		public bool AddSelection(int start_offset, int end_offset) {
			bool raw_ret = atk_text_add_selection(Handle, start_offset, end_offset);
			bool ret = raw_ret;
			return ret;
		}

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

		public static Atk.TextAttribute AttributeForName(string name) {
			IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (name);
			int raw_ret = atk_text_attribute_for_name(native_name);
			Atk.TextAttribute ret = (Atk.TextAttribute) raw_ret;
			GLib.Marshaller.Free (native_name);
			return ret;
		}

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

		public static string AttributeGetName(Atk.TextAttribute attr) {
			IntPtr raw_ret = atk_text_attribute_get_name((int) attr);
			string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
			return ret;
		}

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

		public static string AttributeGetValue(Atk.TextAttribute attr, int index_) {
			IntPtr raw_ret = atk_text_attribute_get_value((int) attr, index_);
			string ret = GLib.Marshaller.Utf8PtrToString (raw_ret);
			return ret;
		}

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

		public static Atk.TextAttribute AttributeRegister(string name) {
			IntPtr native_name = GLib.Marshaller.StringToPtrGStrdup (name);
			int raw_ret = atk_text_attribute_register(native_name);
			Atk.TextAttribute ret = (Atk.TextAttribute) raw_ret;
			GLib.Marshaller.Free (native_name);
			return ret;
		}

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

		public static void FreeRanges(Atk.TextRange ranges) {
			IntPtr native_ranges = GLib.Marshaller.StructureToPtrAlloc (ranges);
			atk_text_free_ranges(native_ranges);
			Marshal.FreeHGlobal (native_ranges);
		}

		[DllImport("atk-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr atk_text_get_bounded_ranges(IntPtr raw, IntPtr rect, int coord_type, int x_clip_type, int y_clip_type);

		public Atk.TextRange GetBoundedRanges(Atk.TextRectangle rect, Atk.CoordType coord_type, Atk.TextClipType x_clip_type, Atk.TextClipType y_clip_type) {
			IntPtr native_rect = GLib.Marshaller.StructureToPtrAlloc (rect);
			IntPtr raw_ret = atk_text_get_bounded_ranges(Handle, native_rect, (int) coord_type, (int) x_clip_type, (int) y_clip_type);
			Atk.TextRange ret = Atk.TextRange.New (raw_ret);
			Marshal.FreeHGlobal (native_rect);
			return ret;
		}

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

		public int CaretOffset { 
			get {
				int raw_ret = atk_text_get_caret_offset(Handle);
				int ret = raw_ret;
				return ret;
			}
		}

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

		public char GetCharacterAtOffset(int offset) {
			uint raw_ret = atk_text_get_character_at_offset(Handle, offset);
			char ret = GLib.Marshaller.GUnicharToChar (raw_ret);
			return ret;
		}

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

		public int CharacterCount { 
			get {
				int raw_ret = atk_text_get_character_count(Handle);
				int ret = raw_ret;
				return ret;
			}
		}

		[DllImport("atk-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void atk_text_get_character_extents(IntPtr raw, int offset, out int x, out int y, out int width, out int height, int coords);

		public void GetCharacterExtents(int offset, out int x, out int y, out int width, out int height, Atk.CoordType coords) {
			atk_text_get_character_extents(Handle, offset, out x, out y, out width, out height, (int) coords);
		}

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

		public Atk.Attribute[] DefaultAttributes { 
			get {
				IntPtr raw_ret = atk_text_get_default_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_text_get_n_selections(IntPtr raw);

		public int NSelections { 
			get {
				int raw_ret = atk_text_get_n_selections(Handle);
				int ret = raw_ret;
				return ret;
			}
		}

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

		public int GetOffsetAtPoint(int x, int y, Atk.CoordType coords) {
			int raw_ret = atk_text_get_offset_at_point(Handle, x, y, (int) coords);
			int ret = raw_ret;
			return ret;
		}

		[DllImport("atk-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void atk_text_get_range_extents(IntPtr raw, int start_offset, int end_offset, int coord_type, IntPtr rect);

		public Atk.TextRectangle GetRangeExtents(int start_offset, int end_offset, Atk.CoordType coord_type) {
			Atk.TextRectangle rect;
			IntPtr native_rect = Marshal.AllocHGlobal (Marshal.SizeOf (typeof (Atk.TextRectangle)));
			atk_text_get_range_extents(Handle, start_offset, end_offset, (int) coord_type, native_rect);
			rect = Atk.TextRectangle.New (native_rect);
			Marshal.FreeHGlobal (native_rect);
			return rect;
		}

		[DllImport("atk-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr atk_text_get_run_attributes(IntPtr raw, int offset, out int start_offset, out int end_offset);

		public Atk.Attribute[] GetRunAttributes(int offset, out int start_offset, out int end_offset) {
			IntPtr raw_ret = atk_text_get_run_attributes(Handle, offset, out start_offset, out end_offset);
			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 IntPtr atk_text_get_selection(IntPtr raw, int selection_num, out int start_offset, out int end_offset);

		public string GetSelection(int selection_num, out int start_offset, out int end_offset) {
			IntPtr raw_ret = atk_text_get_selection(Handle, selection_num, out start_offset, out end_offset);
			string ret = GLib.Marshaller.PtrToStringGFree(raw_ret);
			return ret;
		}

		[DllImport("atk-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr atk_text_get_string_at_offset(IntPtr raw, int offset, int granularity, out int start_offset, out int end_offset);

		public string GetStringAtOffset(int offset, Atk.TextGranularity granularity, out int start_offset, out int end_offset) {
			IntPtr raw_ret = atk_text_get_string_at_offset(Handle, offset, (int) granularity, out start_offset, out end_offset);
			string ret = GLib.Marshaller.PtrToStringGFree(raw_ret);
			return ret;
		}

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

		public string GetText(int start_offset, int end_offset) {
			IntPtr raw_ret = atk_text_get_text(Handle, start_offset, end_offset);
			string ret = GLib.Marshaller.PtrToStringGFree(raw_ret);
			return ret;
		}

		[DllImport("atk-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr atk_text_get_text_after_offset(IntPtr raw, int offset, int boundary_type, out int start_offset, out int end_offset);

		[Obsolete]
		public string GetTextAfterOffset(int offset, Atk.TextBoundary boundary_type, out int start_offset, out int end_offset) {
			IntPtr raw_ret = atk_text_get_text_after_offset(Handle, offset, (int) boundary_type, out start_offset, out end_offset);
			string ret = GLib.Marshaller.PtrToStringGFree(raw_ret);
			return ret;
		}

		[DllImport("atk-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr atk_text_get_text_at_offset(IntPtr raw, int offset, int boundary_type, out int start_offset, out int end_offset);

		[Obsolete]
		public string GetTextAtOffset(int offset, Atk.TextBoundary boundary_type, out int start_offset, out int end_offset) {
			IntPtr raw_ret = atk_text_get_text_at_offset(Handle, offset, (int) boundary_type, out start_offset, out end_offset);
			string ret = GLib.Marshaller.PtrToStringGFree(raw_ret);
			return ret;
		}

		[DllImport("atk-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr atk_text_get_text_before_offset(IntPtr raw, int offset, int boundary_type, out int start_offset, out int end_offset);

		[Obsolete]
		public string GetTextBeforeOffset(int offset, Atk.TextBoundary boundary_type, out int start_offset, out int end_offset) {
			IntPtr raw_ret = atk_text_get_text_before_offset(Handle, offset, (int) boundary_type, out start_offset, out end_offset);
			string ret = GLib.Marshaller.PtrToStringGFree(raw_ret);
			return ret;
		}

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

		public bool RemoveSelection(int selection_num) {
			bool raw_ret = atk_text_remove_selection(Handle, selection_num);
			bool ret = raw_ret;
			return ret;
		}

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

		public bool SetCaretOffset(int offset) {
			bool raw_ret = atk_text_set_caret_offset(Handle, offset);
			bool ret = raw_ret;
			return ret;
		}

		[DllImport("atk-1.0-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern bool atk_text_set_selection(IntPtr raw, int selection_num, int start_offset, int end_offset);

		public bool SetSelection(int selection_num, int start_offset, int end_offset) {
			bool raw_ret = atk_text_set_selection(Handle, selection_num, start_offset, end_offset);
			bool ret = raw_ret;
			return ret;
		}

#endregion
	}
}