From 92334f72b0722710f301707eec3b7dd52d9a099d Mon Sep 17 00:00:00 2001 From: Robert Tari Date: Fri, 29 Oct 2021 14:16:27 +0200 Subject: Drop HAS_LOMIRI_TOUCH_SCHEMA, use native schema instead fixes https://github.com/AyatanaIndicators/ayatana-indicator-display/issues/8 --- src/CMakeLists.txt | 4 ---- src/rotation-lock.cpp | 40 ++++++++++++++++++++++++++++++++-------- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5066cbd..57bdc4b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,9 +1,5 @@ add_definitions(-DG_LOG_DOMAIN="${CMAKE_PROJECT_NAME}") -if(EXISTS "/usr/share/glib-2.0/schemas/com.lomiri.touch.system.gschema.xml") - add_definitions( -DHAS_LOMIRI_TOUCH_SCHEMA ) -endif() - add_compile_options( ${CXX_WARNING_ARGS} ) diff --git a/src/rotation-lock.cpp b/src/rotation-lock.cpp index a794dd2..ad89e10 100644 --- a/src/rotation-lock.cpp +++ b/src/rotation-lock.cpp @@ -1,5 +1,6 @@ /* * Copyright 2014 Canonical Ltd. + * Copyright 2021 Robert Tari * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -15,6 +16,7 @@ * * Authors: * Charles Kerr + * Robert Tari */ #include @@ -30,10 +32,37 @@ class RotationLockIndicator::Impl { public: - Impl(): - m_settings(g_settings_new(m_schema_name)), - m_action_group(create_action_group()) + Impl() { + GSettingsSchemaSource *pSource = g_settings_schema_source_get_default(); + + if (pSource != NULL) + { + GSettingsSchema *pSchema = g_settings_schema_source_lookup(pSource, "com.lomiri.touch.system", FALSE); + + if (pSchema != NULL) + { + g_settings_schema_unref(pSchema); + m_settings = g_settings_new("com.lomiri.touch.system"); + } + else + { + pSchema = g_settings_schema_source_lookup(pSource, "org.ayatana.indicator.display", FALSE); + + if (pSchema != NULL) + { + g_settings_schema_unref(pSchema); + m_settings = g_settings_new("org.ayatana.indicator.display"); + } + else + { + g_error("No schema could be found"); + } + } + } + + m_action_group = create_action_group(); + // build the icon const char *rotation_lock_icon_name {"orientation-lock"}; @@ -195,11 +224,6 @@ private: **** ***/ -#ifdef HAS_LOMIRI_TOUCH_SCHEMA - static constexpr char const * m_schema_name {"com.lomiri.touch.system"}; -#else - static constexpr char const * m_schema_name {"org.ayatana.indicator.display"}; -#endif GSettings* m_settings = nullptr; GSimpleActionGroup* m_action_group = nullptr; std::shared_ptr m_phone; -- cgit v1.2.3