diff options
author | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2021-11-01 08:26:53 +0100 |
---|---|---|
committer | Mike Gabriel <mike.gabriel@das-netzwerkteam.de> | 2021-11-01 08:26:53 +0100 |
commit | a2ecae1e80fce10bbf80e8df406b7d6cbe48e3b9 (patch) | |
tree | 272e4c4bb420760d9211df06b16f53880b0b4260 | |
parent | 9facc9ae06c42ce822e78b605c58e1cb7d7db8dc (diff) | |
parent | 92334f72b0722710f301707eec3b7dd52d9a099d (diff) | |
download | ayatana-indicator-display-a2ecae1e80fce10bbf80e8df406b7d6cbe48e3b9.tar.gz ayatana-indicator-display-a2ecae1e80fce10bbf80e8df406b7d6cbe48e3b9.tar.bz2 ayatana-indicator-display-a2ecae1e80fce10bbf80e8df406b7d6cbe48e3b9.zip |
Merge branch 'tari01-pr/drop-has-lomiri-touch-schema'
Attributes GH PR #37: https://github.com/AyatanaIndicators/ayatana-indicator-display/pull/37
-rw-r--r-- | src/CMakeLists.txt | 4 | ||||
-rw-r--r-- | 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 <charles.kerr@canonical.com> + * Robert Tari <robert@tari.in> */ #include <src/rotation-lock.h> @@ -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<SimpleProfile> m_phone; |