Exemplo n.º 1
0
        public bool[] GetBooleanList(string group_name, string key)
        {
            IntPtr  native_group_name = Marshaller.StringToPtrGStrdup(group_name);
            IntPtr  native_key        = Marshaller.StringToPtrGStrdup(key);
            UIntPtr native_length;
            IntPtr  error;
            IntPtr  raw_ret = g_key_file_get_boolean_list(Handle, native_group_name, native_key, out native_length, out error);

            Marshaller.Free(native_group_name);
            Marshaller.Free(native_key);
            if (error != IntPtr.Zero)
            {
                throw new GException(error);
            }
            int length = (int)(ulong)native_length;

            int[] ints = new int [length];
            Marshal.Copy(raw_ret, ints, 0, length);
            Marshaller.Free(raw_ret);
            bool[] ret = new bool [length];
            for (int i = 0; i < length; i++)
            {
                ret [i] = ints [i] != 0;
            }
            return(ret);
        }
Exemplo n.º 2
0
        void Dispose(bool disposing)
        {
            if (Handle == IntPtr.Zero)
            {
                return;
            }

            if (elements_owned)
            {
                int count = Count;
                for (uint i = 0; i < count; i++)
                {
                    if (typeof(GLib.Object).IsAssignableFrom(element_type))
                    {
                        g_object_unref(NthData(i));
                    }
                    else if (typeof(GLib.Opaque).IsAssignableFrom(element_type))
                    {
                        GLib.Opaque.GetOpaque(NthData(i), element_type, true).Dispose();
                    }
                    else
                    {
                        Marshaller.Free(NthData(i));
                    }
                }
            }

            if (managed)
            {
                g_ptr_array_free(Handle, true);
            }

            handle = IntPtr.Zero;
        }
Exemplo n.º 3
0
        public GString(string text)
        {
            IntPtr native_text = Marshaller.StringToPtrGStrdup(text);

            handle = g_string_new(native_text);
            Marshaller.Free(native_text);
        }
        protected void Connect(string name, Delegate cb, int flags)
        {
            IntPtr native_name = Marshaller.StringToPtrGStrdup(name);

            _HandlerID = g_signal_connect_data(_obj.Handle, native_name, cb, _key, new IntPtr(0), flags);
            Marshaller.Free(native_name);
        }
Exemplo n.º 5
0
        public static bool SpawnAsync(string working_directory, string[] argv, string[] envp, SpawnFlags flags, SpawnChildSetupFunc child_setup, out Process child_process)
        {
            int    pid;
            IntPtr error;
            IntPtr native_dir = Marshaller.StringToPtrGStrdup(working_directory);

            IntPtr[] native_argv           = Marshaller.StringArrayToNullTermPointer(argv);
            IntPtr[] native_envp           = Marshaller.StringArrayToNullTermPointer(envp);
            SpawnChildSetupWrapper wrapper = new SpawnChildSetupWrapper(child_setup);
            bool result;

            if (Global.IsWindowsPlatform)
            {
                result = g_spawn_async_utf8(native_dir, native_argv, native_envp, (int)flags, wrapper.NativeCallback, wrapper.Data, out pid, out error);
            }
            else
            {
                result = g_spawn_async(native_dir, native_argv, native_envp, (int)flags, wrapper.NativeCallback, wrapper.Data, out pid, out error);
            }

            child_process = new Process(pid);
            Marshaller.Free(native_dir);
            Marshaller.Free(native_argv);
            Marshaller.Free(native_envp);
            if (error != IntPtr.Zero)
            {
                throw new GLib.GException(error);
            }
            return(result);
        }
Exemplo n.º 6
0
        public static bool SpawnSync(string working_directory, string[] argv, string[] envp, SpawnFlags flags, SpawnChildSetupFunc child_setup, out string stdout, out string stderr, out int exit_status)
        {
            IntPtr native_stdout, native_stderr, error;
            IntPtr native_dir = Marshaller.StringToPtrGStrdup(working_directory);

            IntPtr[] native_argv           = Marshaller.StringArrayToNullTermPointer(argv);
            IntPtr[] native_envp           = Marshaller.StringArrayToNullTermPointer(envp);
            SpawnChildSetupWrapper wrapper = new SpawnChildSetupWrapper(child_setup);
            bool result;

            if (Global.IsWindowsPlatform)
            {
                result = g_spawn_sync(native_dir, native_argv, native_envp, (int)flags, wrapper.NativeCallback, wrapper.Data, out native_stdout, out native_stderr, out exit_status, out error);
            }
            else
            {
                result = g_spawn_sync(native_dir, native_argv, native_envp, (int)flags, wrapper.NativeCallback, wrapper.Data, out native_stdout, out native_stderr, out exit_status, out error);
            }

            Marshaller.Free(native_dir);
            Marshaller.Free(native_argv);
            Marshaller.Free(native_envp);
            stdout = Marshaller.PtrToStringGFree(native_stdout);
            stderr = Marshaller.PtrToStringGFree(native_stderr);
            if (error != IntPtr.Zero)
            {
                throw new GLib.GException(error);
            }
            return(result);
        }
Exemplo n.º 7
0
        public void Empty()
        {
            if (elements_owned)
            {
                for (uint i = 0; i < Count; i++)
                {
                    if (typeof(GLib.Opaque).IsAssignableFrom(element_type))
                    {
                        GLib.Opaque.GetOpaque(NthData(i), element_type, true).Dispose();
                    }
                    else if (typeof(GLib.IWrapper).IsAssignableFrom(element_type))
                    {
                        g_object_unref(NthData(i));
                    }
                    else
                    {
                        Marshaller.Free(NthData(i));
                    }
                }
            }

            if (managed)
            {
                FreeList();
            }
        }
Exemplo n.º 8
0
        public VariantType(string type_string)
        {
            IntPtr native = Marshaller.StringToPtrGStrdup(type_string);

            handle = g_variant_type_new(native);
            Marshaller.Free(native);
        }
Exemplo n.º 9
0
            void Invoke(string message)
            {
                IntPtr nmessage = Marshaller.StringToPtrGStrdup(message);

                native(nmessage);
                Marshaller.Free(nmessage);
            }
Exemplo n.º 10
0
        public void SetLocaleStringList(string group_name, string key, string locale, string[] list)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }
            if (locale == null)
            {
                throw new ArgumentNullException("locale");
            }
            if (list == null)
            {
                throw new ArgumentNullException("list");
            }
            IntPtr native_group_name = Marshaller.StringToPtrGStrdup(group_name);
            IntPtr native_key        = Marshaller.StringToPtrGStrdup(key);
            IntPtr native_locale     = Marshaller.StringToPtrGStrdup(locale);
            IntPtr native_list       = Marshaller.StringArrayToStrvPtr(list);

            g_key_file_set_locale_string_list(Handle, native_group_name, native_key, native_locale, native_list, new UIntPtr((ulong)list.Length));
            Marshaller.Free(native_group_name);
            Marshaller.Free(native_key);
            Marshaller.Free(native_locale);
            Marshaller.StrFreeV(native_list);
        }
Exemplo n.º 11
0
        public Variant(string val)
        {
            IntPtr native_val = Marshaller.StringToPtrGStrdup(val);

            handle = g_variant_ref_sink(g_variant_new_string(native_val));
            Marshaller.Free(native_val);
        }
Exemplo n.º 12
0
        public bool HasGroup(string group_name)
        {
            IntPtr native_group_name = Marshaller.StringToPtrGStrdup(group_name);
            bool   ret = g_key_file_has_group(Handle, native_group_name);

            Marshaller.Free(native_group_name);
            return(ret);
        }
Exemplo n.º 13
0
        public static LogLevelFlags SetAlwaysFatal(string logDomain, LogLevelFlags fatalMask)
        {
            IntPtr        ndom   = Marshaller.StringToPtrGStrdup(logDomain);
            LogLevelFlags result = g_log_set_fatal_mask(ndom, fatalMask);

            Marshaller.Free(ndom);
            return(result);
        }
Exemplo n.º 14
0
        public static bool StringIsValid(string type_string)
        {
            IntPtr native = Marshaller.StringToPtrGStrdup(type_string);
            bool   ret    = g_variant_type_string_is_valid(native);

            Marshaller.Free(native);
            return(ret);
        }
Exemplo n.º 15
0
        public void WriteLog(string logDomain, LogLevelFlags flags, string format, params object [] args)
        {
            IntPtr ndom     = Marshaller.StringToPtrGStrdup(logDomain);
            IntPtr nmessage = Marshaller.StringToPtrGStrdup(String.Format(format, args));

            g_logv(ndom, flags, nmessage);
            Marshaller.Free(ndom);
            Marshaller.Free(nmessage);
        }
Exemplo n.º 16
0
        public void SetBoolean(string group_name, string key, bool value)
        {
            IntPtr native_group_name = Marshaller.StringToPtrGStrdup(group_name);
            IntPtr native_key        = Marshaller.StringToPtrGStrdup(key);

            g_key_file_set_boolean(Handle, native_group_name, native_key, value);
            Marshaller.Free(native_group_name);
            Marshaller.Free(native_key);
        }
Exemplo n.º 17
0
            void Invoke(string log_domain, LogLevelFlags flags, string message)
            {
                IntPtr ndom  = Marshaller.StringToPtrGStrdup(log_domain);
                IntPtr nmess = Marshaller.StringToPtrGStrdup(message);

                native(ndom, flags, nmess, IntPtr.Zero);
                Marshaller.Free(ndom);
                Marshaller.Free(nmess);
            }
Exemplo n.º 18
0
        public void SetInteger(string group_name, string key, int value)
        {
            IntPtr native_group_name = Marshaller.StringToPtrGStrdup(group_name);
            IntPtr native_key        = Marshaller.StringToPtrGStrdup(key);

            g_key_file_set_integer(Handle, native_group_name, native_key, value);
            Marshaller.Free(native_group_name);
            Marshaller.Free(native_key);
        }
Exemplo n.º 19
0
        public static void DefaultHandler(string logDomain, LogLevelFlags logLevel, string message)

        {
            IntPtr ndom  = Marshaller.StringToPtrGStrdup(logDomain);
            IntPtr nmess = Marshaller.StringToPtrGStrdup(message);

            g_log_default_handler(ndom, logLevel, nmess, IntPtr.Zero);
            Marshaller.Free(ndom);
            Marshaller.Free(nmess);
        }
Exemplo n.º 20
0
        public byte[] ToData()
        {
            UIntPtr native_length;
            IntPtr  raw_ret = g_key_file_to_data(Handle, out native_length, IntPtr.Zero);

            byte[] ret = new byte [(int)native_length];
            Marshal.Copy(raw_ret, ret, 0, (int)native_length);
            Marshaller.Free(raw_ret);
            return(ret);
        }
Exemplo n.º 21
0
        public static uint SetLogHandler(string logDomain, LogLevelFlags flags, LogFunc logFunc)
        {
            IntPtr ndom   = Marshaller.StringToPtrGStrdup(logDomain);
            uint   result = g_log_set_handler(ndom, flags, LogFuncTrampoline, logFunc);

            Marshaller.Free(ndom);
            EnsureHash();
            handlers [result] = logFunc;

            return(result);
        }
Exemplo n.º 22
0
        public void SetValue(string group_name, string key, string value)
        {
            IntPtr native_group_name = Marshaller.StringToPtrGStrdup(group_name);
            IntPtr native_key        = Marshaller.StringToPtrGStrdup(key);
            IntPtr native_value      = Marshaller.StringToPtrGStrdup(value);

            g_key_file_set_value(Handle, native_group_name, native_key, native_value);
            Marshaller.Free(native_group_name);
            Marshaller.Free(native_key);
            Marshaller.Free(native_value);
        }
Exemplo n.º 23
0
        public static void RemoveLogHandler(string logDomain, uint handlerID)
        {
            if (handlers != null && handlers.ContainsKey(handlerID))
            {
                handlers.Remove(handlerID);
            }

            IntPtr ndom = Marshaller.StringToPtrGStrdup(logDomain);

            g_log_remove_handler(ndom, handlerID);
            Marshaller.Free(ndom);
        }
Exemplo n.º 24
0
        public bool LoadFromFile(string file, KeyFileFlags flags)
        {
            IntPtr error;
            IntPtr native_file = Marshaller.StringToFilenamePtr(file);
            bool   ret         = g_key_file_load_from_file(Handle, native_file, (int)flags, out error);

            Marshaller.Free(native_file);
            if (error != IntPtr.Zero)
            {
                throw new GException(error);
            }
            return(ret);
        }
Exemplo n.º 25
0
        public bool RemoveGroup(string group_name)
        {
            IntPtr error;
            IntPtr native_group_name = Marshaller.StringToPtrGStrdup(group_name);
            bool   ret = g_key_file_remove_group(Handle, native_group_name, out error);

            Marshaller.Free(native_group_name);
            if (error != IntPtr.Zero)
            {
                throw new GException(error);
            }
            return(ret);
        }
Exemplo n.º 26
0
        static public string EscapeText(string s)
        {
            if (s == null)
            {
                return(String.Empty);
            }

            IntPtr native = Marshaller.StringToPtrGStrdup(s);
            string result = Marshaller.PtrToStringGFree(g_markup_escape_text(native, -1));

            Marshaller.Free(native);
            return(result);
        }
Exemplo n.º 27
0
        public void SetIntegerList(string group_name, string key, int[] list)
        {
            if (list == null)
            {
                throw new ArgumentNullException("list");
            }
            IntPtr native_group_name = Marshaller.StringToPtrGStrdup(group_name);
            IntPtr native_key        = Marshaller.StringToPtrGStrdup(key);

            g_key_file_set_integer_list(Handle, native_group_name, native_key, list, new UIntPtr((ulong)list.Length));
            Marshaller.Free(native_group_name);
            Marshaller.Free(native_key);
        }
Exemplo n.º 28
0
        public string[] GetKeys(string group_name)
        {
            IntPtr error;
            IntPtr native_group_name = Marshaller.StringToPtrGStrdup(group_name);

            string[] ret = Marshaller.NullTermPtrToStringArray(g_key_file_get_keys(Handle, native_group_name, IntPtr.Zero, out error), true);
            Marshaller.Free(native_group_name);
            if (error != IntPtr.Zero)
            {
                throw new GException(error);
            }
            return(ret);
        }
Exemplo n.º 29
0
        public bool HasKey(string group_name, string key)
        {
            IntPtr error;
            IntPtr native_group_name = Marshaller.StringToPtrGStrdup(group_name);
            IntPtr native_key        = Marshaller.StringToPtrGStrdup(key);
            bool   ret = g_key_file_has_key(Handle, native_group_name, native_key, out error);

            Marshaller.Free(native_group_name);
            Marshaller.Free(native_key);
            if (error != IntPtr.Zero)
            {
                throw new GException(error);
            }
            return(ret);
        }
Exemplo n.º 30
0
        public bool LoadFromDataDirs(string file, out string full_path, KeyFileFlags flags)
        {
            IntPtr error;
            IntPtr native_full_path;
            IntPtr native_file = Marshaller.StringToPtrGStrdup(file);
            bool   ret         = g_key_file_load_from_data_dirs(Handle, native_file, out native_full_path, (int)flags, out error);

            Marshaller.Free(native_file);
            if (error != IntPtr.Zero)
            {
                throw new GException(error);
            }
            full_path = Marshaller.PtrToStringGFree(native_full_path);
            return(ret);
        }