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); } } }
public static void AddIbusVersionAsErrorReportProperty() { var settingsGeneral = IntPtr.Zero; try { const string ibusSchema = "org.freedesktop.ibus.general"; if (!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); } } }
/// <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); }