コード例 #1
0
        void IUnityKeyboardSwitchingAdaptor.SelectKeyboard(uint index)
        {
            const string schema = "org.gnome.desktop.input-sources";
            bool         okay   = true;

            try
            {
                okay &= GlibHelper.SchemaIsInstalled(schema);
                if (!okay)
                {
                    return;
                }

                var settings = Unmanaged.g_settings_new(schema);
                okay &= settings != IntPtr.Zero;
                if (!okay)
                {
                    return;
                }

                okay &= Unmanaged.g_settings_set_uint(settings, "current", index);
            }
            finally
            {
                if (!okay)
                {
                    Console.WriteLine("UnityIbusKeyboardAdaptor.SelectKeyboard({0}) failed", index);
                    Logger.WriteEvent("UnityIbusKeyboardAdaptor.SelectKeyboard({0}) failed", index);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Returns the list of keyboards or <c>null</c> if we can't get the combined keyboards
        /// list.
        /// </summary>
        private static string[] GetMyKeyboards()
        {
            // This is the proper path for the combined keyboard handling, not the path
            // given in the IBus reference documentation.
            const string schema = "org.gnome.desktop.input-sources";

            if (!GlibHelper.SchemaIsInstalled(schema))
            {
                return(null);
            }

            var settings = Unmanaged.g_settings_new(schema);

            if (settings == IntPtr.Zero)
            {
                return(null);
            }

            var sources = Unmanaged.g_settings_get_value(settings, "sources");

            if (sources == IntPtr.Zero)
            {
                return(null);
            }
            var list = KeyboardRetrievingHelper.GetStringArrayFromGVariantListArray(sources);

            Unmanaged.g_variant_unref(sources);
            Unmanaged.g_object_unref(settings);

            return(list);
        }
コード例 #3
0
        public static void AddIbusVersionAsErrorReportProperty()
        {
            var settingsGeneral = IntPtr.Zero;

            try
            {
                const string ibusSchema = "org.freedesktop.ibus.general";
                if (!GlibHelper.SchemaIsInstalled(ibusSchema))
                {
                    return;
                }
                settingsGeneral = Unmanaged.g_settings_new(ibusSchema);
                if (settingsGeneral == IntPtr.Zero)
                {
                    return;
                }
                var version = Unmanaged.g_settings_get_string(settingsGeneral, "version");
                ErrorReport.AddProperty("IbusVersion", version);
            }
            catch
            {
                // Ignore any error we might get
            }
            finally
            {
                if (settingsGeneral != IntPtr.Zero)
                {
                    Unmanaged.g_object_unref(settingsGeneral);
                }
            }
        }
コード例 #4
0
        public IEnumerable <string> GetAllLayouts()
        {
            var list = Unmanaged.gnome_xkb_info_get_all_layouts(_gnomeXkbInfo);

            var array = GlibHelper.GetStringArrayFromGList(list);

            Unmanaged.g_list_free(list);
            return(array);
        }