aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert Tari <robert@tari.in>2021-11-11 00:10:38 +0100
committerRobert Tari <robert@tari.in>2021-11-15 04:40:51 +0100
commit88e440bb1689063c6d47ac7a4965eb597a8ec9cb (patch)
treea603306b2a6ba80ca8053e48b18deccc1ee37cf5 /src
parent425c531ba241415514743f7cc6dae8c17683cb9f (diff)
downloadayatana-indicator-sound-88e440bb1689063c6d47ac7a4965eb597a8ec9cb.tar.gz
ayatana-indicator-sound-88e440bb1689063c6d47ac7a4965eb597a8ec9cb.tar.bz2
ayatana-indicator-sound-88e440bb1689063c6d47ac7a4965eb597a8ec9cb.zip
Clean up schema detection and conditional code
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt26
-rw-r--r--src/accounts-service-access.vala2
-rw-r--r--src/accounts-service-user.vala14
-rw-r--r--src/options-gsettings.vala6
4 files changed, 14 insertions, 34 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 7479518..6e24fb2 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -6,24 +6,10 @@ set(HEADER_PATH "${CMAKE_CURRENT_BINARY_DIR}/indicator-sound-service.h")
set(SYMBOLS_PATH "${CMAKE_CURRENT_BINARY_DIR}/indicator-sound-service.def")
set(VAPI_PATH "${CMAKE_CURRENT_BINARY_DIR}/indicator-sound-service.vapi")
-if(EXISTS "/usr/share/glib-2.0/schemas/com.lomiri.sound.gschema.xml")
- set (VALA_DEFINE_LOMIRI_SOUND_SCHEMA "--define=HAS_LOMIRI_SOUND_SCHEMA")
-endif()
-
-if(EXISTS "/usr/share/accountsservice/interfaces/com.lomiri.touch.AccountsService.SecurityPrivacy.xml")
- set (HAS_LOMIRI_ACCTSERVICE_PRIVACY_SETTINGS ON)
+if(LOMIRI_SCHEMAS_FOUND)
+ set (VALA_DEFINE_HAS_LOMIRI_SCHEMAS "--define=HAS_LOMIRI_SCHEMAS")
set (VALA_FILE_ACCTSERVICE_PRIVACY_SETTINGS "accounts-service-privacy-settings")
- set (VALA_DEFINE_ACCTSERVICE_PRIVACY_SETTINGS "--define=HAS_LOMIRI_ACCTSERVICE_PRIVACY_SETTINGS")
-else()
- set (HAS_LOMIRI_ACCTSERVICE_PRIVACY_SETTINGS OFF)
-endif()
-
-if(EXISTS "/usr/share/accountsservice/interfaces/com.lomiri.touch.AccountsService.Sound.xml")
- set (HAS_LOMIRI_ACCTSERVICE_SYSTEMSOUND_SETTINGS ON)
set (VALA_FILE_ACCTSERVICE_SYSTEMSOUND_SETTINGS "accounts-service-system-sound-settings")
- set (VALA_DEFINE_ACCTSERVICE_SYSTEMSOUND_SETTINGS "--define=HAS_LOMIRI_ACCTSERVICE_SYSTEMSOUND_SETTINGS")
-else()
- set (HAS_LOMIRI_ACCTSERVICE_SYSTEMSOUND_SETTINGS OFF)
endif()
vapi_gen(accounts-service
@@ -55,9 +41,7 @@ vala_init(ayatana-indicator-sound-service
--vapidir=${CMAKE_SOURCE_DIR}/vapi/
--vapidir=.
--pkg=bus-watcher
- ${VALA_DEFINE_LOMIRI_SOUND_SCHEMA}
- ${VALA_DEFINE_ACCTSERVICE_PRIVACY_SETTINGS}
- ${VALA_DEFINE_ACCTSERVICE_SYSTEMSOUND_SETTINGS}
+ ${VALA_DEFINE_HAS_LOMIRI_SCHEMAS}
)
vala_add(ayatana-indicator-sound-service
@@ -212,13 +196,11 @@ vala_add(ayatana-indicator-sound-service
accounts-service-sound-settings.vala
)
-if(${HAS_LOMIRI_ACCTSERVICE_PRIVACY_SETTINGS})
+if(LOMIRI_SCHEMAS_FOUND)
vala_add(ayatana-indicator-sound-service
accounts-service-privacy-settings.vala
)
-endif()
-if(${HAS_LOMIRI_ACCTSERVICE_SYSTEMSOUND_SETTINGS})
vala_add(ayatana-indicator-sound-service
accounts-service-system-sound-settings.vala
)
diff --git a/src/accounts-service-access.vala b/src/accounts-service-access.vala
index 1c55ff2..373e294 100644
--- a/src/accounts-service-access.vala
+++ b/src/accounts-service-access.vala
@@ -143,7 +143,7 @@ public class AccountsServiceAccess : Object
string user_path;
if (user_path_variant.check_format_string ("(o)", true)) {
user_path_variant.get ("(o)", out user_path);
-#if HAS_LOMIRI_SOUND_SCHEMA
+#if HAS_LOMIRI_SCHEMAS
_user_proxy = yield new DBusProxy.for_bus (BusType.SYSTEM, DBusProxyFlags.GET_INVALIDATED_PROPERTIES, null, "org.freedesktop.Accounts", user_path, "com.lomiri.AccountsService.Sound");
#endif
} else {
diff --git a/src/accounts-service-user.vala b/src/accounts-service-user.vala
index 0679392..ac803a1 100644
--- a/src/accounts-service-user.vala
+++ b/src/accounts-service-user.vala
@@ -23,10 +23,8 @@ public class AccountsServiceUser : Object {
Act.UserManager accounts_manager = Act.UserManager.get_default();
Act.User? user = null;
AccountsServiceSoundSettings? proxy = null;
-#if HAS_LOMIRI_ACCTSERVICE_PRIVACY_SETTINGS
+#if HAS_LOMIRI_SCHEMAS
AccountsServicePrivacySettings? privacyproxy = null;
-#endif
-#if HAS_LOMIRI_ACCTSERVICE_SYSTEMSOUND_SETTINGS
AccountsServiceSystemSoundSettings? syssoundproxy = null;
#endif
uint timer = 0;
@@ -42,7 +40,7 @@ public class AccountsServiceUser : Object {
}
set {
_silentMode = value;
-#if HAS_LOMIRI_ACCTSERVICE_SYSTEMSOUND_SETTINGS
+#if HAS_LOMIRI_SCHEMAS
if (syssoundproxy != null)
syssoundproxy.silent_mode = value;
#endif
@@ -149,7 +147,7 @@ public class AccountsServiceUser : Object {
DBusProxyFlags.GET_INVALIDATED_PROPERTIES,
null,
new_sound_proxy);
-#if HAS_LOMIRI_ACCTSERVICE_PRIVACY_SETTINGS
+#if HAS_LOMIRI_SCHEMAS
Bus.get_proxy.begin<AccountsServicePrivacySettings> (
BusType.SYSTEM,
"org.freedesktop.Accounts",
@@ -159,7 +157,7 @@ public class AccountsServiceUser : Object {
new_privacy_proxy);
#endif
-#if HAS_LOMIRI_ACCTSERVICE_SYSTEMSOUND_SETTINGS
+#if HAS_LOMIRI_SCHEMAS
Bus.get_proxy.begin<AccountsServiceSystemSoundSettings> (
BusType.SYSTEM,
"org.freedesktop.Accounts",
@@ -191,7 +189,7 @@ public class AccountsServiceUser : Object {
}
}
-#if HAS_LOMIRI_ACCTSERVICE_PRIVACY_SETTINGS
+#if HAS_LOMIRI_SCHEMAS
void new_privacy_proxy (GLib.Object? obj, AsyncResult res) {
try {
this.privacyproxy = Bus.get_proxy.end (res);
@@ -216,7 +214,7 @@ public class AccountsServiceUser : Object {
}
#endif
-#if HAS_LOMIRI_ACCTSERVICE_SYSTEMSOUND_SETTINGS
+#if HAS_LOMIRI_SCHEMAS
void new_system_sound_proxy (GLib.Object? obj, AsyncResult res) {
try {
this.syssoundproxy = Bus.get_proxy.end (res);
diff --git a/src/options-gsettings.vala b/src/options-gsettings.vala
index 17e07c6..48df2fe 100644
--- a/src/options-gsettings.vala
+++ b/src/options-gsettings.vala
@@ -33,7 +33,7 @@ public class IndicatorSound.OptionsGSettings : Options
}
private Settings _settings = new Settings ("org.ayatana.indicator.sound");
-#if HAS_LOMIRI_SOUND_SCHEMA
+#if HAS_LOMIRI_SCHEMAS
private Settings _shared_settings = new Settings ("com.lomiri.sound");
#endif
/** MAX VOLUME PROPERTY **/
@@ -45,7 +45,7 @@ public class IndicatorSound.OptionsGSettings : Options
private void init_max_volume() {
_settings.changed[NORMAL_dB_KEY].connect(() => update_max_volume());
_settings.changed[AMP_dB_KEY].connect(() => update_max_volume());
-#if HAS_LOMIRI_SOUND_SCHEMA
+#if HAS_LOMIRI_SCHEMAS
_shared_settings.changed[ALLOW_AMP_KEY].connect(() => update_max_volume());
#endif
update_max_volume();
@@ -60,7 +60,7 @@ public class IndicatorSound.OptionsGSettings : Options
}
}
private double calculate_max_volume () {
-#if HAS_LOMIRI_SOUND_SCHEMA
+#if HAS_LOMIRI_SCHEMAS
unowned string decibel_key = _shared_settings.get_boolean(ALLOW_AMP_KEY)
? AMP_dB_KEY
: NORMAL_dB_KEY;