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); }
protected override void Dispose(bool disposing) { if (_settingsGeneral != IntPtr.Zero) { Unmanaged.g_object_unref(_settingsGeneral); _settingsGeneral = IntPtr.Zero; } base.Dispose(disposing); }