File: Gtk_TreeSortableAdapter.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 (285 lines) | stat: -rw-r--r-- 10,313 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
// This file was generated by the Gtk# code generator.
// Any changes made will be lost if regenerated.

namespace Gtk {

	using System;
	using System.Runtime.InteropServices;

#region Autogenerated code
	public partial class TreeSortableAdapter : GLib.GInterfaceAdapter, Gtk.ITreeSortable {

		[StructLayout (LayoutKind.Sequential)]
		struct GtkTreeSortableIface {
			IntPtr SortColumnChanged;
			public GetSortColumnIdNativeDelegate GetSortColumnId;
			public SetSortColumnIdNativeDelegate SetSortColumnId;
			public SetSortFuncNativeDelegate SetSortFunc;
			public SetDefaultSortFuncNativeDelegate SetDefaultSortFunc;
			public HasDefaultSortFuncNativeDelegate HasDefaultSortFunc;
		}

		static GtkTreeSortableIface iface;

		static TreeSortableAdapter ()
		{
			GLib.GType.Register (_gtype, typeof (TreeSortableAdapter));
			iface.GetSortColumnId = new GetSortColumnIdNativeDelegate (GetSortColumnId_cb);
			iface.SetSortColumnId = new SetSortColumnIdNativeDelegate (SetSortColumnId_cb);
			iface.SetSortFunc = new SetSortFuncNativeDelegate (SetSortFunc_cb);
			iface.SetDefaultSortFunc = new SetDefaultSortFuncNativeDelegate (SetDefaultSortFunc_cb);
			iface.HasDefaultSortFunc = new HasDefaultSortFuncNativeDelegate (HasDefaultSortFunc_cb);
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate bool GetSortColumnIdNativeDelegate (IntPtr inst, out int sort_column_id, out int order);

		static bool GetSortColumnId_cb (IntPtr inst, out int sort_column_id, out int order)
		{
			try {
				ITreeSortableImplementor __obj = GLib.Object.GetObject (inst, false) as ITreeSortableImplementor;
				bool __result;
				Gtk.SortType myorder;
				__result = __obj.GetSortColumnId (out sort_column_id, out myorder);
				order = (int) myorder;
				return __result;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, true);
				// NOTREACHED: above call does not return.
				throw e;
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void SetSortColumnIdNativeDelegate (IntPtr inst, int sort_column_id, int order);

		static void SetSortColumnId_cb (IntPtr inst, int sort_column_id, int order)
		{
			try {
				ITreeSortableImplementor __obj = GLib.Object.GetObject (inst, false) as ITreeSortableImplementor;
				__obj.SetSortColumnId (sort_column_id, (Gtk.SortType) order);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void SetSortFuncNativeDelegate (IntPtr inst, int sort_column_id, GtkSharp.TreeIterCompareFuncNative sort_func, IntPtr user_data, GLib.DestroyNotify destroy);

		static void SetSortFunc_cb (IntPtr inst, int sort_column_id, GtkSharp.TreeIterCompareFuncNative sort_func, IntPtr user_data, GLib.DestroyNotify destroy)
		{
			try {
				ITreeSortableImplementor __obj = GLib.Object.GetObject (inst, false) as ITreeSortableImplementor;
				GtkSharp.TreeIterCompareFuncInvoker sort_func_invoker = new GtkSharp.TreeIterCompareFuncInvoker (sort_func, user_data, destroy);
				__obj.SetSortFunc (sort_column_id, sort_func_invoker.Handler);
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

		[UnmanagedFunctionPointer (CallingConvention.Cdecl)]
		delegate void SetDefaultSortFuncNativeDelegate (IntPtr inst, GtkSharp.TreeIterCompareFuncNative sort_func, IntPtr user_data, GLib.DestroyNotify destroy);

		static void SetDefaultSortFunc_cb (IntPtr inst, GtkSharp.TreeIterCompareFuncNative sort_func, IntPtr user_data, GLib.DestroyNotify destroy)
		{
			try {
				ITreeSortableImplementor __obj = GLib.Object.GetObject (inst, false) as ITreeSortableImplementor;
				GtkSharp.TreeIterCompareFuncInvoker sort_func_invoker = new GtkSharp.TreeIterCompareFuncInvoker (sort_func, user_data, destroy);
				__obj.DefaultSortFunc = sort_func_invoker.Handler;
			} catch (Exception e) {
				GLib.ExceptionManager.RaiseUnhandledException (e, false);
			}
		}

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

		static bool HasDefaultSortFunc_cb (IntPtr inst)
		{
			try {
				ITreeSortableImplementor __obj = GLib.Object.GetObject (inst, false) as ITreeSortableImplementor;
				bool __result;
				__result = __obj.HasDefaultSortFunc;
				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);
			GtkTreeSortableIface native_iface = (GtkTreeSortableIface) Marshal.PtrToStructure (ifaceptr, typeof (GtkTreeSortableIface));
			native_iface.GetSortColumnId = iface.GetSortColumnId;
			native_iface.SetSortColumnId = iface.SetSortColumnId;
			native_iface.SetSortFunc = iface.SetSortFunc;
			native_iface.SetDefaultSortFunc = iface.SetDefaultSortFunc;
			native_iface.HasDefaultSortFunc = iface.HasDefaultSortFunc;
			Marshal.StructureToPtr (native_iface, ifaceptr, false);
		}

		GLib.Object implementor;

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

		public TreeSortableAdapter (ITreeSortableImplementor 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 TreeSortableAdapter (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("gtk-3-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern IntPtr gtk_tree_sortable_get_type();

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

		public static ITreeSortable GetObject (GLib.Object obj)
		{
			if (obj == null)
				return null;
			else if (obj is ITreeSortableImplementor)
				return new TreeSortableAdapter (obj as ITreeSortableImplementor);
			else if (obj as ITreeSortable == null)
				return new TreeSortableAdapter (obj.Handle);
			else
				return obj as ITreeSortable;
		}

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

		[GLib.Signal("sort-column-changed")]
		public event System.EventHandler SortColumnChanged {
			add {
				GLib.Object.GetObject (Handle).AddSignalHandler ("sort-column-changed", value);
			}
			remove {
				GLib.Object.GetObject (Handle).RemoveSignalHandler ("sort-column-changed", value);
			}
		}

		[DllImport("gtk-3-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern bool gtk_tree_sortable_get_sort_column_id(IntPtr raw, out int sort_column_id, out int order);

		public bool GetSortColumnId(out int sort_column_id, out Gtk.SortType order) {
			int native_order;
			bool raw_ret = gtk_tree_sortable_get_sort_column_id(Handle, out sort_column_id, out native_order);
			bool ret = raw_ret;
			order = (Gtk.SortType) native_order;
			return ret;
		}

		[DllImport("gtk-3-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern bool gtk_tree_sortable_has_default_sort_func(IntPtr raw);

		public bool HasDefaultSortFunc { 
			get {
				bool raw_ret = gtk_tree_sortable_has_default_sort_func(Handle);
				bool ret = raw_ret;
				return ret;
			}
		}

		[DllImport("gtk-3-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gtk_tree_sortable_set_default_sort_func(IntPtr raw, GtkSharp.TreeIterCompareFuncNative sort_func, IntPtr user_data, GLib.DestroyNotify destroy);

		public Gtk.TreeIterCompareFunc DefaultSortFunc { 
			set {
				GtkSharp.TreeIterCompareFuncWrapper value_wrapper = new GtkSharp.TreeIterCompareFuncWrapper (value);
				IntPtr user_data;
				GLib.DestroyNotify destroy;
				if (value == null) {
					user_data = IntPtr.Zero;
					destroy = null;
				} else {
					user_data = (IntPtr) GCHandle.Alloc (value_wrapper);
					destroy = GLib.DestroyHelper.NotifyHandler;
				}
				gtk_tree_sortable_set_default_sort_func(Handle, value_wrapper.NativeDelegate, user_data, destroy);
			}
		}

		[DllImport("gtk-3-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gtk_tree_sortable_set_sort_column_id(IntPtr raw, int sort_column_id, int order);

		public void SetSortColumnId(int sort_column_id, Gtk.SortType order) {
			gtk_tree_sortable_set_sort_column_id(Handle, sort_column_id, (int) order);
		}

		[DllImport("gtk-3-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gtk_tree_sortable_set_sort_func(IntPtr raw, int sort_column_id, GtkSharp.TreeIterCompareFuncNative sort_func, IntPtr user_data, GLib.DestroyNotify destroy);

		public void SetSortFunc(int sort_column_id, Gtk.TreeIterCompareFunc sort_func) {
			GtkSharp.TreeIterCompareFuncWrapper sort_func_wrapper = new GtkSharp.TreeIterCompareFuncWrapper (sort_func);
			IntPtr user_data;
			GLib.DestroyNotify destroy;
			if (sort_func == null) {
				user_data = IntPtr.Zero;
				destroy = null;
			} else {
				user_data = (IntPtr) GCHandle.Alloc (sort_func_wrapper);
				destroy = GLib.DestroyHelper.NotifyHandler;
			}
			gtk_tree_sortable_set_sort_func(Handle, sort_column_id, sort_func_wrapper.NativeDelegate, user_data, destroy);
		}

		[DllImport("gtk-3-0.dll", CallingConvention = CallingConvention.Cdecl)]
		static extern void gtk_tree_sortable_sort_column_changed(IntPtr raw);

		public void ChangeSortColumn() {
			gtk_tree_sortable_sort_column_changed(Handle);
		}

#endregion
	}
}