Exemple #1
0
        private void InternalAskQuestion(string message, string[] choices)
        {
            AskQuestionNativeDelegate unmanaged = null;

            unsafe {
                IntPtr *raw_ptr = (IntPtr *)(((long)this.LookupGType().GetThresholdType().GetClassPtr()) + (long)class_abi.GetFieldOffset("ask_question"));
                unmanaged = (AskQuestionNativeDelegate)Marshal.GetDelegateForFunctionPointer(*raw_ptr, typeof(AskQuestionNativeDelegate));
            }
            if (unmanaged == null)
            {
                return;
            }

            IntPtr native_message = GLib.Marshaller.StringToPtrGStrdup(message);
            int    cnt_choices    = choices == null ? 0 : choices.Length;

            IntPtr[] native_choices = new IntPtr [cnt_choices];
            for (int i = 0; i < cnt_choices; i++)
            {
                native_choices [i] = GLib.Marshaller.StringToPtrGStrdup(choices[i]);
            }
            unmanaged(this.Handle, native_message, native_choices);
            GLib.Marshaller.Free(native_message);
            for (int i = 0; i < native_choices.Length; i++)
            {
                choices [i] = GLib.Marshaller.Utf8PtrToString(native_choices[i]);
                GLib.Marshaller.Free(native_choices[i]);
            }
        }
Exemple #2
0
        private void InternalAskQuestion(string message, string[] choices)
        {
            AskQuestionNativeDelegate unmanaged = class_abi.BaseOverride <AskQuestionNativeDelegate>(this.LookupGType(), "ask_question");

            if (unmanaged == null)
            {
                return;
            }

            IntPtr native_message = GLib.Marshaller.StringToPtrGStrdup(message);
            int    cnt_choices    = choices == null ? 0 : choices.Length;

            IntPtr[] native_choices = new IntPtr [cnt_choices];
            for (int i = 0; i < cnt_choices; i++)
            {
                native_choices [i] = GLib.Marshaller.StringToPtrGStrdup(choices[i]);
            }
            unmanaged(this.Handle, native_message, native_choices);
            GLib.Marshaller.Free(native_message);
            for (int i = 0; i < native_choices.Length; i++)
            {
                choices [i] = GLib.Marshaller.Utf8PtrToString(native_choices[i]);
                GLib.Marshaller.Free(native_choices[i]);
            }
        }
Exemple #3
0
 static void OverrideAskQuestion(GLib.GType gtype, AskQuestionNativeDelegate callback)
 {
     unsafe {
         IntPtr *raw_ptr = (IntPtr *)(((long)gtype.GetClassPtr()) + (long)class_abi.GetFieldOffset("ask_question"));
         *raw_ptr = Marshal.GetFunctionPointerForDelegate((Delegate)callback);
     }
 }
Exemple #4
0
		static void OverrideAskQuestion (GLib.GType gtype, AskQuestionNativeDelegate callback)
		{
			GMountOperationClass class_iface = GetClassStruct (gtype, false);
			class_iface.AskQuestion = callback;
			OverrideClassStruct (gtype, class_iface);
		}