Exemplo n.º 1
0
        // To find the corresponding schema for a dconf path, e.g. /desktop/ibus/general/preload-engines:
        //     $ gsettings list-schemas | grep desktop.ibus.general
        //     org.freedesktop.ibus.general
        //     org.freedesktop.ibus.general.hotkey
        //     $ gsettings list-keys org.freedesktop.ibus.general | grep preload-engines
        //     preload-engines

        protected virtual string[] GetMyKeyboards(IntPtr settingsGeneral)
        {
            // This is the proper path for the combined keyboard handling on Cinnamon with IBus.
            var sources = Unmanaged.g_settings_get_value(settingsGeneral, "preload-engines");

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

            Unmanaged.g_variant_unref(sources);

            // Call these only once per run of the program.
            if (CombinedIbusKeyboardSwitchingAdaptor.DefaultLayout == null)
            {
                LoadDefaultXkbSettings();
            }
            if (CombinedIbusKeyboardSwitchingAdaptor.LatinLayouts == null)
            {
                LoadLatinLayouts(settingsGeneral);
            }

            return(list);
        }
        /// <summary>
        /// Returns the list of keyboards or <c>null</c> if we can't get the combined keyboards
        /// list.
        /// </summary>
        private 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 (!KeyboardRetrievingHelper.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);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Load a couple of settings from the GNOME settings system.
        /// </summary>
        private static void LoadLatinLayouts(IntPtr settingsGeneral)
        {
            IntPtr value = Unmanaged.g_settings_get_value(settingsGeneral, "xkb-latin-layouts");

            CombinedIbusKeyboardSwitchingAdaptor.LatinLayouts =
                KeyboardRetrievingHelper.GetStringArrayFromGVariantArray(value);
            Unmanaged.g_variant_unref(value);

            CombinedIbusKeyboardSwitchingAdaptor.UseXmodmap = Unmanaged.g_settings_get_boolean(
                settingsGeneral, "use-xmodmap");
            //Console.WriteLine("DEBUG use-xmodmap = {0}", _use_xmodmap);
            //Console.Write("DEBUG xkb-latin-layouts =");
            //for (int i = 0; i < _latinLayouts.Length; ++i)
            //	Console.Write("  '{0}'", _latinLayouts[i]);
            //Console.WriteLine();
        }