summaryrefslogtreecommitdiff
path: root/kde-plasma/plasma-pa/files/plasma-pa-5.13.3-optional_gconf.patch
blob: f14fd180c2493474fb55fe9988575a319072f63f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
From c9fae1fb3f8e8a820fd480ce227d7fabf87bd045 Mon Sep 17 00:00:00 2001
From: David Rosca <nowrep@gmail.com>
Date: Tue, 26 Jun 2018 10:56:04 +0200
Subject: [PATCH] Make GConf optional dependency

When building without GConf, Advanded Output Configuration will be hidden in KCM.

BUG: 386665
FIXED-IN: 5.13.4

Differential Revision: https://phabricator.kde.org/D13734
---
 CMakeLists.txt                           |  9 ++++--
 config.h.cmake                           |  3 ++
 src/CMakeLists.txt                       | 18 ++++++++----
 src/kcm/package/contents/ui/Advanced.qml |  5 +++-
 src/modulemanager.cpp                    | 47 ++++++++++++++++++++++++++------
 src/modulemanager.h                      |  3 ++
 6 files changed, 68 insertions(+), 17 deletions(-)
 create mode 100644 config.h.cmake

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e494ced..2505696 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -19,8 +19,11 @@ include(KDECompilerSettings NO_POLICY_SCOPE)
 include(ECMOptionalAddSubdirectory)
 
 include(FindPkgConfig)
-pkg_check_modules(GCONF REQUIRED gconf-2.0)
-pkg_check_modules(GOBJECT REQUIRED gobject-2.0)
+pkg_check_modules(GCONF gconf-2.0)
+pkg_check_modules(GOBJECT gobject-2.0)
+if (GCONF_FOUND AND GOBJECT_FOUND)
+    set(HAVE_GCONF TRUE)
+endif()
 
 find_package(Qt5 ${QT_MIN_VERSION} REQUIRED COMPONENTS
     Core
@@ -41,6 +44,8 @@ find_package(PulseAudio 5.0.0 REQUIRED)
 find_package(Canberra REQUIRED)
 find_package(GLIB2 REQUIRED)
 
+configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
+
 add_subdirectory(applet)
 add_subdirectory(src)
 add_subdirectory(data)
diff --git a/config.h.cmake b/config.h.cmake
new file mode 100644
index 0000000..1643e50
--- /dev/null
+++ b/config.h.cmake
@@ -0,0 +1,3 @@
+/* config.h.  Generated by cmake from config.h.cmake  */
+
+#cmakedefine01 HAVE_GCONF
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e6cddfc..09d108c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,5 +1,4 @@
-include_directories(${PULSEAUDIO_INCLUDE_DIR} ${GLIB2_INCLUDE_DIR}     ${GCONF_INCLUDE_DIRS}
-    ${GOBJECT_INCLUDE_DIRS})
+include_directories(${PULSEAUDIO_INCLUDE_DIR} ${GLIB2_INCLUDE_DIR})
 
 set(cpp_SRCS
     card.cpp
@@ -15,7 +14,6 @@ set(cpp_SRCS
     sink.cpp
     sinkinput.cpp
     modulemanager.cpp
-    gconfitem.cpp
     source.cpp
     sourceoutput.cpp
     stream.cpp
@@ -38,6 +36,11 @@ set(qml_SRCS
 set_property(SOURCE qml/dbus/osdService.xml APPEND PROPERTY CLASSNAME OsdServiceInterface)
 qt5_add_dbus_interface(dbus_SRCS qml/dbus/osdService.xml osdservice)
 
+if (HAVE_GCONF)
+    include_directories(${GCONF_INCLUDE_DIRS} ${GOBJECT_INCLUDE_DIRS})
+    set(cpp_SRCS ${cpp_SRCS} gconfitem.cpp)
+endif()
+
 add_library(plasma-volume-declarative SHARED ${dbus_SRCS} ${cpp_SRCS} ${qml_SRCS})
 target_link_libraries(plasma-volume-declarative
     Qt5::Core
@@ -47,11 +50,16 @@ target_link_libraries(plasma-volume-declarative
     KF5::GlobalAccel
     ${PULSEAUDIO_LIBRARY}
     ${PULSEAUDIO_MAINLOOP_LIBRARY}
-    ${GCONF_LDFLAGS}
-    ${GOBJECT_LDFLAGS}
     ${CANBERRA_LIBRARIES}
 )
 
+if (HAVE_GCONF)
+    target_link_libraries(plasma-volume-declarative
+        ${GCONF_LDFLAGS}
+        ${GOBJECT_LDFLAGS}
+    )
+endif()
+
 set(PRIVATE_QML_INSTALL_DIR ${QML_INSTALL_DIR}/org/kde/plasma/private/volume)
 install(TARGETS plasma-volume-declarative DESTINATION ${PRIVATE_QML_INSTALL_DIR})
 install(FILES ${qml_SRCS} DESTINATION ${PRIVATE_QML_INSTALL_DIR})
diff --git a/src/kcm/package/contents/ui/Advanced.qml b/src/kcm/package/contents/ui/Advanced.qml
index b305cf1..0cd9eb9 100644
--- a/src/kcm/package/contents/ui/Advanced.qml
+++ b/src/kcm/package/contents/ui/Advanced.qml
@@ -56,6 +56,7 @@ ScrollView {
         Header {
             Layout.fillWidth: true
             text: i18n("Advanced Output Configuration")
+            visible: moduleManager.settingsSupported
         }
 
         ModuleManager {
@@ -71,6 +72,7 @@ ScrollView {
             checked: moduleManager.combineSinks
             onCheckedChanged: moduleManager.combineSinks = checked;
             enabled: moduleManager.loadedModules.indexOf("module-gconf") != -1
+            visible: moduleManager.settingsSupported
         }
 
         CheckBox {
@@ -81,6 +83,7 @@ ScrollView {
             checked: moduleManager.switchOnConnect
             onCheckedChanged: moduleManager.switchOnConnect = checked;
             enabled: moduleManager.loadedModules.indexOf("module-gconf") != -1
+            visible: moduleManager.settingsSupported
         }
 
         Label {
@@ -88,7 +91,7 @@ ScrollView {
             enabled: false
             font.italic: true
             text: i18n("Requires 'module-gconf' PulseAudio module")
-            visible: moduleManager.loadedModules.indexOf("module-gconf") == -1
+            visible: moduleManager.settingsSupported && moduleManager.loadedModules.indexOf("module-gconf") == -1
         }
     }
 }
diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp
index 635adc8..5245ac5 100644
--- a/src/modulemanager.cpp
+++ b/src/modulemanager.cpp
@@ -21,20 +21,22 @@
 
 #include "modulemanager.h"
 #include "module.h"
+#include "../config.h"
 
+#if HAVE_GCONF
+#include "gconfitem.h"
 #define PA_GCONF_ROOT "/system/pulseaudio"
 #define PA_GCONF_PATH_MODULES PA_GCONF_ROOT"/modules"
-
-#include "gconfitem.h"
+#endif
 
 #include <QTimer>
 
 namespace QPulseAudio
 {
 
+#if HAVE_GCONF
 class GConfModule : public GConfItem
 {
-    Q_OBJECT
 public:
     GConfModule(const QString &configName, const QString &moduleName, QObject *parent);
     bool isEnabled() const;
@@ -67,17 +69,21 @@ void GConfModule::setEnabled(bool enabled, const QVariant &args)
     }
     set(QStringLiteral("locked"), false);
 }
+#endif
 
 
 ModuleManager::ModuleManager(QObject *parent) :
-    QObject(parent),
-    m_combineSinks(new GConfModule(QStringLiteral("combine"), QStringLiteral("module-combine"), this)),
-    m_switchOnConnect(new GConfModule(QStringLiteral("switch-on-connect"), QStringLiteral("module-switch-on-connect"), this)),
-    m_deviceManager(new GConfModule(QStringLiteral("device-manager"), QStringLiteral("module-device-manager"), this))
+    QObject(parent)
 {
+#if HAVE_GCONF
+    m_combineSinks = new GConfModule(QStringLiteral("combine"), QStringLiteral("module-combine"), this);
+    m_switchOnConnect = new GConfModule(QStringLiteral("switch-on-connect"), QStringLiteral("module-switch-on-connect"), this);
+    m_deviceManager = new GConfModule(QStringLiteral("device-manager"), QStringLiteral("module-device-manager"), this);
+
     connect(m_combineSinks, &GConfItem::subtreeChanged, this, &ModuleManager::combineSinksChanged);
     connect(m_switchOnConnect, &GConfItem::subtreeChanged, this, &ModuleManager::switchOnConnectChanged);
     connect(m_deviceManager, &GConfItem::subtreeChanged, this, &ModuleManager::switchOnConnectChanged);
+#endif
 
     QTimer *updateModulesTimer = new QTimer(this);
     updateModulesTimer->setInterval(500);
@@ -92,14 +98,31 @@ ModuleManager::~ModuleManager()
 {
 };
 
+bool ModuleManager::settingsSupported() const
+{
+#if HAVE_GCONF
+    return true;
+#else
+    return false;
+#endif
+}
+
 bool ModuleManager::combineSinks() const
 {
+#if HAVE_GCONF
     return m_combineSinks->isEnabled();
+#else
+    return false;
+#endif
 }
 
 void ModuleManager::setCombineSinks(bool combineSinks)
 {
+#if HAVE_GCONF
     m_combineSinks->setEnabled(combineSinks);
+#else
+    Q_UNUSED(combineSinks)
+#endif
 }
 
 bool ModuleManager::switchOnConnect() const
@@ -109,13 +132,21 @@ bool ModuleManager::switchOnConnect() const
     //Note on the first run m_deviceManager will appear to be disabled even though it's actually running
     //because there is no gconf entry, however m_switchOnConnect will only exist if set by Plasma PA
     //hence only check this entry
+#if HAVE_GCONF
     return m_switchOnConnect->isEnabled() ;
+#else
+    return false;
+#endif
 }
 
 void ModuleManager::setSwitchOnConnect(bool switchOnConnect)
 {
+#if HAVE_GCONF
     m_deviceManager->setEnabled(!switchOnConnect);
     m_switchOnConnect->setEnabled(switchOnConnect);
+#else
+    Q_UNUSED(switchOnConnect)
+#endif
 }
 
 QStringList ModuleManager::loadedModules() const
@@ -134,5 +165,3 @@ void ModuleManager::updateLoadedModules()
 }
 
 }
-
-#include "modulemanager.moc"
diff --git a/src/modulemanager.h b/src/modulemanager.h
index b8fcd0b..8108fe0 100644
--- a/src/modulemanager.h
+++ b/src/modulemanager.h
@@ -38,12 +38,15 @@ class GConfModule;
 class ModuleManager : public QObject
 {
     Q_OBJECT
+    Q_PROPERTY(bool settingsSupported READ settingsSupported CONSTANT)
     Q_PROPERTY(bool combineSinks READ combineSinks WRITE setCombineSinks NOTIFY combineSinksChanged)
     Q_PROPERTY(bool switchOnConnect READ switchOnConnect WRITE setSwitchOnConnect NOTIFY switchOnConnectChanged)
     Q_PROPERTY(QStringList loadedModules READ loadedModules NOTIFY loadedModulesChanged)
 public:
     ModuleManager(QObject *parent = nullptr);
     ~ModuleManager();
+
+    bool settingsSupported() const;
     bool combineSinks() const;
     void setCombineSinks(bool combineSinks);
     bool switchOnConnect() const;