[paprefs][PATCH 1/9] Move from GConf to GSettings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Sylvain Baubeau <sbaubeau@xxxxxxxxxx>

---
 configure.ac                            |   4 +
 src/Makefile.am                         |  10 +-
 src/org.freedesktop.paprefs.gschema.xml |  12 +
 src/paprefs.cc                          | 411 +++++++++++++++++---------------
 src/paprefs.convert                     | 160 +++++++++++++
 5 files changed, 400 insertions(+), 197 deletions(-)
 create mode 100644 src/org.freedesktop.paprefs.gschema.xml
 create mode 100644 src/paprefs.convert

diff --git a/configure.ac b/configure.ac
index 3df69d1..2dc5d7d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -71,6 +71,10 @@ fi
 
 AM_CONDITIONAL([USE_LYNX], [test "x$lynx" = xyes])
 
+#### GSettings support ####
+PKG_CHECK_MODULES(GSETTINGS, [ gio-2.0 >= 2.26.0 ])
+GLIB_GSETTINGS
+
 AM_GNU_GETTEXT([external])
 
 IT_PROG_INTLTOOL([0.35.0])
diff --git a/src/Makefile.am b/src/Makefile.am
index 34f454f..e030983 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -30,10 +30,16 @@ desktop_DATA=$(desktop_in_files:.desktop.in=.desktop)
 paprefs_SOURCES=paprefs.cc
 
 paprefs_LDADD=$(AM_LDADD) $(GUILIBS_LIBS) $(LIBPULSE_LIBS)
-paprefs_CXXFLAGS=$(AM_CXXFLAGS) $(GUILIBS_CFLAGS) $(LIBPULSE_CFLAGS)
+paprefs_CXXFLAGS=$(AM_CXXFLAGS) $(GUILIBS_CFLAGS) $(LIBPULSE_CFLAGS) $(GSETTINGS_CFLAGS)
 paprefs_CXXFLAGS+=-DGLADE_FILE=\"$(gladedir)/paprefs.glade\" -DLOCALEDIR=\"$(localedir)\" -DMODDIR=\""$(LIBPULSE_MODLIBEXECDIR)"\" -DSHREXT=\"$(SHREXT)\"
 
-EXTRA_DIST = $(glade_DATA) $(desktop_in_files)
+gsettings_SCHEMAS = org.freedesktop.paprefs.gschema.xml
+ at GSETTINGS_RULES@
+
+convertdir = $(datadir)/GConf/gsettings
+convert_DATA = paprefs.convert
+
+EXTRA_DIST = $(glade_DATA) $(desktop_in_files) paprefs.convert
 
 CLEANFILES = $(desktop_DATA)
 
diff --git a/src/org.freedesktop.paprefs.gschema.xml b/src/org.freedesktop.paprefs.gschema.xml
new file mode 100644
index 0000000..a3dcd77
--- /dev/null
+++ b/src/org.freedesktop.paprefs.gschema.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schemalist>
+  <schema id="org.freedesktop.pulseaudio.modules" path="/org/freedesktop/pulseaudio/modules/">
+    <child name="combine" schema="org.freedesktop.pulseaudio.module"/>
+    <child name="remote-access" schema="org.freedesktop.pulseaudio.module"/>
+    <child name="zeroconf-discover" schema="org.freedesktop.pulseaudio.module"/>
+    <child name="raop-discover" schema="org.freedesktop.pulseaudio.module"/>
+    <child name="rtp-recv" schema="org.freedesktop.pulseaudio.module"/>
+    <child name="rtp-send" schema="org.freedesktop.pulseaudio.module"/>
+    <child name="upnp-media-server" schema="org.freedesktop.pulseaudio.module"/>
+  </schema>
+</schemalist>
diff --git a/src/paprefs.cc b/src/paprefs.cc
index ca6d9bf..dc63e2e 100644
--- a/src/paprefs.cc
+++ b/src/paprefs.cc
@@ -24,8 +24,9 @@
 #include <signal.h>
 
 #include <gtkmm.h>
+#include <glibmm.h>
+#include <glibmm/regex.h>
 #include <libglademm.h>
-#include <gconfmm.h>
 #include <libintl.h>
 #include <dbus/dbus-glib.h>
 #include <dbus/dbus.h>
@@ -33,8 +34,8 @@
 
 #include <pulse/version.h>
 
-#define PA_GCONF_ROOT "/system/pulseaudio"
-#define PA_GCONF_PATH_MODULES PA_GCONF_ROOT"/modules"
+#define PA_GSETTINGS_PATH_MODULES "/org/freedesktop/pulseaudio/modules"
+#define MAX_MODULES 10
 
 class MainWindow : public Gtk::Window {
 public:
@@ -70,7 +71,13 @@ public:
         *rtpSpeakerRadioButton,
         *rtpNullSinkRadioButton;
 
-    Glib::RefPtr<Gnome::Conf::Client> gconf;
+    Glib::RefPtr<Gio::Settings> combineSettings;
+    Glib::RefPtr<Gio::Settings> remoteAccessSettings;
+    Glib::RefPtr<Gio::Settings> zeroconfSettings;
+    Glib::RefPtr<Gio::Settings> raopSettings;
+    Glib::RefPtr<Gio::Settings> rtpRecvSettings;
+    Glib::RefPtr<Gio::Settings> rtpSendSettings;
+    Glib::RefPtr<Gio::Settings> upnpSettings;
 
     bool ignoreChanges;
 
@@ -94,20 +101,22 @@ public:
     void rtpRecvInstallButtonClicked();
     void rtpSendInstallButtonClicked();
 
-    void readFromGConf();
+    void readFromGSettings();
 
     void checkForPackageKit();
     void checkForModules();
 
-    void writeToGConfRemoteAccess();
-    void writeToGConfZeroconfDiscover();
-    void writeToGConfZeroconfRaopDiscover();
-    void writeToGConfRtpReceive();
-    void writeToGConfRtpSend();
-    void writeToGConfCombine();
-    void writeToGConfUPnP();
+    void writeToGSettingsRemoteAccess();
+    void writeToGSettingsZeroconfDiscover();
+    void writeToGSettingsZeroconfRaopDiscover();
+    void writeToGSettingsRtpReceive();
+    void writeToGSettingsRtpSend();
+    void writeToGSettingsCombine();
+    void writeToGSettingsUPnP();
 
-    void onGConfChange(const Glib::ustring& key, const Gnome::Conf::Value& value);
+    void onGSettingsChange(const Glib::ustring& key);
+
+    bool moduleHasArgument(Glib::RefPtr<Gio::Settings> gsettings, const Glib::ustring& module, const Glib::ustring& name, const Glib::ustring& value);
 
     void showInstallButton(Gtk::Button *button, bool available);
     void installFiles(const char *a, const char *b);
@@ -159,12 +168,35 @@ MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade:
     checkForPackageKit();
     checkForModules();
 
-    gconf = Gnome::Conf::Client::get_default_client();
-    gconf->set_error_handling(Gnome::Conf::CLIENT_HANDLE_ALL);
-    gconf->add_dir(PA_GCONF_ROOT, Gnome::Conf::CLIENT_PRELOAD_RECURSIVE);
+    combineSettings = Gio::Settings::create("org.freedesktop.pulseaudio.module",
+                                            "/org/freedesktop/pulseaudio/modules/combine/");
+
+    remoteAccessSettings = Gio::Settings::create("org.freedesktop.pulseaudio.module",
+                                                 "/org/freedesktop/pulseaudio/modules/remote-access/");
+
+    zeroconfSettings = Gio::Settings::create("org.freedesktop.pulseaudio.module",
+                                             "/org/freedesktop/pulseaudio/modules/zeroconf-discover/");
+
+    raopSettings = Gio::Settings::create("org.freedesktop.pulseaudio.module",
+                                         "/org/freedesktop/pulseaudio/modules/raop-discover/");
+
+    rtpRecvSettings = Gio::Settings::create("org.freedesktop.pulseaudio.module",
+                                            "/org/freedesktop/pulseaudio/modules/rtp-recv/");
+
+    rtpSendSettings = Gio::Settings::create("org.freedesktop.pulseaudio.module",
+                                            "/org/freedesktop/pulseaudio/modules/rtp-send/");
 
-    gconf->signal_value_changed().connect(sigc::mem_fun(*this, &MainWindow::onGConfChange));
-    readFromGConf();
+    upnpSettings = Gio::Settings::create("org.freedesktop.pulseaudio.module",
+                                         "/org/freedesktop/pulseaudio/modules/upnp-media-server/");
+
+    combineSettings->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::onGSettingsChange));
+    remoteAccessSettings->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::onGSettingsChange));
+    zeroconfSettings->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::onGSettingsChange));
+    raopSettings->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::onGSettingsChange));
+    rtpRecvSettings->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::onGSettingsChange));
+    rtpSendSettings->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::onGSettingsChange));
+    upnpSettings->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::onGSettingsChange));
+    readFromGSettings();
 
     closeButton->signal_clicked().connect(sigc::mem_fun(*this, &MainWindow::onCloseButtonClicked));
 
@@ -247,7 +279,7 @@ void MainWindow::onChangeRemoteAccess() {
         return;
 
     updateSensitive();
-    writeToGConfRemoteAccess();
+    writeToGSettingsRemoteAccess();
 }
 
 void MainWindow::onChangeZeroconfDiscover() {
@@ -256,7 +288,7 @@ void MainWindow::onChangeZeroconfDiscover() {
         return;
 
     updateSensitive();
-    writeToGConfZeroconfDiscover();
+    writeToGSettingsZeroconfDiscover();
 }
 
 void MainWindow::onChangeZeroconfRaopDiscover() {
@@ -265,7 +297,7 @@ void MainWindow::onChangeZeroconfRaopDiscover() {
         return;
 
     updateSensitive();
-    writeToGConfZeroconfRaopDiscover();
+    writeToGSettingsZeroconfRaopDiscover();
 }
 
 void MainWindow::onChangeRtpReceive() {
@@ -273,8 +305,8 @@ void MainWindow::onChangeRtpReceive() {
         return;
 
     updateSensitive();
-    writeToGConfRtpReceive();
-    writeToGConfRtpSend();
+    writeToGSettingsRtpReceive();
+    writeToGSettingsRtpSend();
 }
 
 void MainWindow::onChangeRtpSend() {
@@ -282,14 +314,14 @@ void MainWindow::onChangeRtpSend() {
         return;
 
     updateSensitive();
-    writeToGConfRtpSend();
+    writeToGSettingsRtpSend();
 }
 
 void MainWindow::onChangeCombine() {
     if (ignoreChanges)
         return;
 
-    writeToGConfCombine();
+    writeToGSettingsCombine();
 }
 
 void MainWindow::onChangeUpnp() {
@@ -298,7 +330,7 @@ void MainWindow::onChangeUpnp() {
         return;
 
     updateSensitive();
-    writeToGConfUPnP();
+    writeToGSettingsUPnP();
 }
 
 void MainWindow::showInstallButton(Gtk::Button *button, bool available) {
@@ -386,171 +418,128 @@ void MainWindow::rtpSendInstallButtonClicked() {
     installModules("module-rtp-send" SHREXT);
 }
 
-void MainWindow::writeToGConfCombine() {
-    Gnome::Conf::ChangeSet changeSet;
-    changeSet.set(PA_GCONF_PATH_MODULES"/combine/locked", true);
-    gconf->change_set_commit(changeSet, true);
+void MainWindow::writeToGSettingsCombine() {
+    combineSettings->delay();
 
     if (combineCheckButton->get_active()) {
-        changeSet.set(PA_GCONF_PATH_MODULES"/combine/name0", Glib::ustring("module-combine"));
-        changeSet.set(PA_GCONF_PATH_MODULES"/combine/args0", Glib::ustring(""));
+        combineSettings->set_string("name0", Glib::ustring("module-combine"));
+        combineSettings->set_string("args0", Glib::ustring(""));
 
-        changeSet.set(PA_GCONF_PATH_MODULES"/combine/enabled", true);
+        combineSettings->set_boolean("enabled", true);
     } else
-        changeSet.set(PA_GCONF_PATH_MODULES"/combine/enabled", false);
-
-    gconf->change_set_commit(changeSet, true);
-
-    changeSet.set(PA_GCONF_PATH_MODULES"/combine/locked", false);
-    gconf->change_set_commit(changeSet, true);
+        combineSettings->set_boolean("enabled", false);
 
-    gconf->suggest_sync();
+    combineSettings->apply();
 }
 
-void MainWindow::writeToGConfRemoteAccess() {
-    Gnome::Conf::ChangeSet changeSet;
+void MainWindow::writeToGSettingsRemoteAccess() {
     bool zeroconfEnabled, anonymousEnabled;
 
-    changeSet.set(PA_GCONF_PATH_MODULES"/remote-access/locked", true);
-    gconf->change_set_commit(changeSet, true);
+    remoteAccessSettings->delay();
 
-    changeSet.set(PA_GCONF_PATH_MODULES"/remote-access/zeroconf_enabled", zeroconfEnabled = zeroconfPublishCheckButton->get_active());
-    changeSet.set(PA_GCONF_PATH_MODULES"/remote-access/anonymous_enabled", anonymousEnabled = anonymousAuthCheckButton->get_active());
+    zeroconfEnabled = zeroconfPublishCheckButton->get_active();
+    anonymousEnabled = anonymousAuthCheckButton->get_active();
 
     if (remoteAccessCheckButton->get_active()) {
-        changeSet.set(PA_GCONF_PATH_MODULES"/remote-access/name0", Glib::ustring("module-native-protocol-tcp"));
-        changeSet.set(PA_GCONF_PATH_MODULES"/remote-access/name1", Glib::ustring("module-esound-protocol-tcp"));
+        remoteAccessSettings->set_string("name0", Glib::ustring("module-native-protocol-tcp"));
+        remoteAccessSettings->set_string("name1", Glib::ustring("module-esound-protocol-tcp"));
 
         if (anonymousEnabled) {
-            changeSet.set(PA_GCONF_PATH_MODULES"/remote-access/args0", Glib::ustring("auth-anonymous=1"));
-            changeSet.set(PA_GCONF_PATH_MODULES"/remote-access/args1", Glib::ustring("auth-anonymous=1"));
+            remoteAccessSettings->set_string("args0", Glib::ustring("auth-anonymous=1"));
+            remoteAccessSettings->set_string("args1", Glib::ustring("auth-anonymous=1"));
         } else {
-            changeSet.set(PA_GCONF_PATH_MODULES"/remote-access/args0", Glib::ustring(""));
-            changeSet.set(PA_GCONF_PATH_MODULES"/remote-access/args1", Glib::ustring(""));
+            remoteAccessSettings->set_string("args0", Glib::ustring(""));
+            remoteAccessSettings->set_string("args1", Glib::ustring(""));
         }
 
         if (zeroconfEnabled) {
-            changeSet.set(PA_GCONF_PATH_MODULES"/remote-access/name2", Glib::ustring("module-zeroconf-publish"));
-            changeSet.set(PA_GCONF_PATH_MODULES"/remote-access/args2", Glib::ustring(""));
+            remoteAccessSettings->set_string("name2", Glib::ustring("module-zeroconf-publish"));
+            remoteAccessSettings->set_string("args2", Glib::ustring(""));
         } else {
-            changeSet.unset(PA_GCONF_PATH_MODULES"/remote-access/name2");
-            changeSet.unset(PA_GCONF_PATH_MODULES"/remote-access/args2");
+            remoteAccessSettings->reset("name2");
+            remoteAccessSettings->reset("args2");
         }
 
-        changeSet.set(PA_GCONF_PATH_MODULES"/remote-access/enabled", true);
+        remoteAccessSettings->set_boolean("enabled", true);
     } else
-        changeSet.set(PA_GCONF_PATH_MODULES"/remote-access/enabled", false);
+        remoteAccessSettings->set_boolean("enabled", false);
 
-    gconf->change_set_commit(changeSet, true);
-
-    changeSet.set(PA_GCONF_PATH_MODULES"/remote-access/locked", false);
-    gconf->change_set_commit(changeSet, true);
-
-    gconf->suggest_sync();
+    remoteAccessSettings->apply();
 }
 
-void MainWindow::writeToGConfZeroconfDiscover() {
-    Gnome::Conf::ChangeSet changeSet;
-
-    changeSet.set(PA_GCONF_PATH_MODULES"/zeroconf-discover/locked", true);
-    gconf->change_set_commit(changeSet, true);
+void MainWindow::writeToGSettingsZeroconfDiscover() {
+    zeroconfSettings->delay();
 
     if (zeroconfDiscoverCheckButton->get_active()) {
-        changeSet.set(PA_GCONF_PATH_MODULES"/zeroconf-discover/name0", Glib::ustring("module-zeroconf-discover"));
-        changeSet.set(PA_GCONF_PATH_MODULES"/zeroconf-discover/args0", Glib::ustring(""));
+        zeroconfSettings->set_string("name0", Glib::ustring("module-zeroconf-discover"));
+        zeroconfSettings->set_string("args0", Glib::ustring(""));
 
-        changeSet.set(PA_GCONF_PATH_MODULES"/zeroconf-discover/enabled", true);
+        zeroconfSettings->set_boolean("enabled", true);
     } else
-        changeSet.set(PA_GCONF_PATH_MODULES"/zeroconf-discover/enabled", false);
+        zeroconfSettings->set_boolean("enabled", false);
 
-    gconf->change_set_commit(changeSet, true);
-
-    changeSet.set(PA_GCONF_PATH_MODULES"/zeroconf-discover/locked", false);
-    gconf->change_set_commit(changeSet, true);
-
-    gconf->suggest_sync();
+    zeroconfSettings->apply();
 }
 
-void MainWindow::writeToGConfZeroconfRaopDiscover() {
-    Gnome::Conf::ChangeSet changeSet;
-
-    changeSet.set(PA_GCONF_PATH_MODULES"/raop-discover/locked", true);
-    gconf->change_set_commit(changeSet, true);
+void MainWindow::writeToGSettingsZeroconfRaopDiscover() {
+    raopSettings->delay();
 
     if (zeroconfRaopDiscoverCheckButton->get_active()) {
-        changeSet.set(PA_GCONF_PATH_MODULES"/raop-discover/name0", Glib::ustring("module-raop-discover"));
-        changeSet.set(PA_GCONF_PATH_MODULES"/raop-discover/args0", Glib::ustring(""));
+        raopSettings->set_string("name0", Glib::ustring("module-raop-discover"));
+        raopSettings->set_string("args0", Glib::ustring(""));
 
-        changeSet.set(PA_GCONF_PATH_MODULES"/raop-discover/enabled", true);
+        raopSettings->set_boolean("enabled", true);
     } else
-        changeSet.set(PA_GCONF_PATH_MODULES"/raop-discover/enabled", false);
+        raopSettings->set_boolean("enabled", false);
 
-    gconf->change_set_commit(changeSet, true);
-
-    changeSet.set(PA_GCONF_PATH_MODULES"/raop-discover/locked", false);
-    gconf->change_set_commit(changeSet, true);
-
-    gconf->suggest_sync();
+    raopSettings->apply();
 }
 
-void MainWindow::writeToGConfRtpReceive() {
-    Gnome::Conf::ChangeSet changeSet;
-
-    changeSet.set(PA_GCONF_PATH_MODULES"/rtp-recv/locked", true);
-    gconf->change_set_commit(changeSet, true);
+void MainWindow::writeToGSettingsRtpReceive() {
+    rtpRecvSettings->delay();
 
     if (rtpReceiveCheckButton->get_active()) {
-        changeSet.set(PA_GCONF_PATH_MODULES"/rtp-recv/name0", Glib::ustring("module-rtp-recv"));
-        changeSet.set(PA_GCONF_PATH_MODULES"/rtp-recv/args0", Glib::ustring(""));
+        rtpRecvSettings->set_string("name0", Glib::ustring("module-rtp-recv"));
+        rtpRecvSettings->set_string("args0", Glib::ustring(""));
 
-        changeSet.set(PA_GCONF_PATH_MODULES"/rtp-recv/enabled", true);
+        rtpRecvSettings->set_boolean("enabled", true);
     }  else
-        changeSet.set(PA_GCONF_PATH_MODULES"/rtp-recv/enabled", false);
+        rtpRecvSettings->set_boolean("enabled", false);
 
-    gconf->change_set_commit(changeSet, true);
-
-    changeSet.set(PA_GCONF_PATH_MODULES"/rtp-recv/locked", false);
-    gconf->change_set_commit(changeSet, true);
-
-    gconf->suggest_sync();
+    rtpRecvSettings->apply();
 }
 
-void MainWindow::writeToGConfRtpSend() {
-    Gnome::Conf::ChangeSet changeSet;
+void MainWindow::writeToGSettingsRtpSend() {
     bool loopbackEnabled, fixedPort, mikeEnabled, speakerEnabled = false;
 
-    changeSet.set(PA_GCONF_PATH_MODULES"/rtp-send/locked", true);
-    gconf->change_set_commit(changeSet, true);
-
-    changeSet.set(PA_GCONF_PATH_MODULES"/rtp-send/loopback_enabled", loopbackEnabled = rtpLoopbackCheckButton->get_active());
-    changeSet.set(PA_GCONF_PATH_MODULES"/rtp-send/fixed_port", fixedPort = rtpPortCheckButton->get_active());
+    rtpSendSettings->delay();
 
-    changeSet.set(PA_GCONF_PATH_MODULES"/rtp-send/mode", Glib::ustring(
-                          (mikeEnabled = rtpMikeRadioButton->get_active()) ? "microphone" :
-                          ((speakerEnabled = rtpSpeakerRadioButton->get_active()) ? "speaker" : "null-sink")));
+    loopbackEnabled = rtpLoopbackCheckButton->get_active();
+    fixedPort = rtpPortCheckButton->get_active();
+    mikeEnabled = rtpMikeRadioButton->get_active();
+    speakerEnabled = rtpSpeakerRadioButton->get_active();
 
     if (rtpSendCheckButton->get_active()) {
         if (!mikeEnabled && !speakerEnabled) {
-            changeSet.set(PA_GCONF_PATH_MODULES"/rtp-send/name0", Glib::ustring("module-null-sink"));
-            changeSet.set(PA_GCONF_PATH_MODULES"/rtp-send/args0", Glib::ustring("sink_name=rtp "
-                                                                                "format=s16be "
-                                                                                "channels=2 "
-                                                                                "rate=44100 "
-                                                                                "sink_properties=\"device.description='RTP Multicast' device.bus='network' device.icon_name='network-server'\""));
-
-            changeSet.set(PA_GCONF_PATH_MODULES"/rtp-send/name1", Glib::ustring("module-rtp-send"));
+            rtpSendSettings->set_string("name0", Glib::ustring("module-null-sink"));
+            rtpSendSettings->set_string("args0", Glib::ustring("sink_name=rtp "
+                                                               "format=s16be "
+                                                               "channels=2 "
+                                                               "rate=44100 "
+                                                               "sink_properties=\"device.description='RTP Multicast' device.bus='network' device.icon_name='network-server'\""));
 
             Glib::ustring params = "source=rtp.monitor";
-            if (loopbackEnabled) {
+
+            if (loopbackEnabled)
                 params += " loop=1";
-            }
-            else {
+            else
                 params += " loop=0";
-            }
-            if(fixedPort) {
+
+            if (fixedPort)
                 params += " port=5004";
-            }
-            changeSet.set(PA_GCONF_PATH_MODULES"/rtp-send/args1", params);
+
+            rtpSendSettings->set_string("name1", Glib::ustring("module-rtp-send"));
+            rtpSendSettings->set_string("args1", params);
         } else {
             char tmp[256];
 
@@ -558,95 +547,129 @@ void MainWindow::writeToGConfRtpSend() {
                      mikeEnabled ? "source=@DEFAULT_SOURCE@" : "source=@DEFAULT_MONITOR@",
                      mikeEnabled && loopbackEnabled ? "loop=1" : "loop=0");
 
-            changeSet.set(PA_GCONF_PATH_MODULES"/rtp-send/name0", Glib::ustring("module-rtp-send"));
-            changeSet.set(PA_GCONF_PATH_MODULES"/rtp-send/args0", Glib::ustring(tmp));
+            rtpSendSettings->set_string("name0", Glib::ustring("module-rtp-send"));
+            rtpSendSettings->set_string("args0", Glib::ustring(tmp));
 
-            changeSet.unset(PA_GCONF_PATH_MODULES"/rtp-send/name1");
-            changeSet.unset(PA_GCONF_PATH_MODULES"/rtp-send/args1");
+            rtpSendSettings->reset("name1");
+            rtpSendSettings->reset("args1");
         }
 
-        changeSet.set(PA_GCONF_PATH_MODULES"/rtp-send/enabled", true);
-    }  else
-        changeSet.set(PA_GCONF_PATH_MODULES"/rtp-send/enabled", false);
-
-    gconf->change_set_commit(changeSet, true);
-
-    changeSet.set(PA_GCONF_PATH_MODULES"/rtp-send/locked", false);
-    gconf->change_set_commit(changeSet, true);
+        rtpSendSettings->set_boolean("enabled", true);
+    } else
+        rtpSendSettings->set_boolean("enabled", false);
 
-    gconf->suggest_sync();
+    rtpSendSettings->apply();
 }
 
-void MainWindow::writeToGConfUPnP() {
-    Gnome::Conf::ChangeSet changeSet;
+void MainWindow::writeToGSettingsUPnP() {
+    upnpSettings->delay();
 
-    changeSet.set(PA_GCONF_PATH_MODULES"/upnp-media-server/locked", true);
-    gconf->change_set_commit(changeSet, true);
+    bool mediaServer = upnpMediaServerCheckButton->get_active();
+    bool nullSink = upnpNullSinkCheckButton->get_active();
 
-    if (upnpMediaServerCheckButton->get_active()) {
-        changeSet.set(PA_GCONF_PATH_MODULES"/upnp-media-server/name0", Glib::ustring("module-rygel-media-server"));
-        changeSet.set(PA_GCONF_PATH_MODULES"/upnp-media-server/args0", Glib::ustring(""));
+    if (mediaServer) {
+        upnpSettings->set_string("name0", Glib::ustring("module-rygel-media-server"));
+        upnpSettings->set_string("args0", Glib::ustring(""));
 
-        if (upnpNullSinkCheckButton->get_active()) {
-            changeSet.set(PA_GCONF_PATH_MODULES"/upnp-media-server/name1", Glib::ustring("module-null-sink"));
-            changeSet.set(PA_GCONF_PATH_MODULES"/upnp-media-server/args1", Glib::ustring("sink_name=upnp "
-                                                                                         "format=s16be "
-                                                                                         "channels=2 "
-                                                                                         "rate=44100 "
-                                                                                         "sink_properties=\"device.description='DLNA/UPnP Streaming' device.bus='network' device.icon_name='network-server'\""));
-            changeSet.set(PA_GCONF_PATH_MODULES"/upnp-media-server/null-sink-enabled", true);
+        if (nullSink) {
+            upnpSettings->set_string("name1", Glib::ustring("module-null-sink"));
+            upnpSettings->set_string("args1", Glib::ustring("sink_name=upnp "
+                                                            "format=s16be "
+                                                            "channels=2 "
+                                                            "rate=44100 "
+                                                            "sink_properties=\"device.description='DLNA/UPnP Streaming' device.bus='network' device.icon_name='network-server'\""));
         } else {
-            changeSet.unset(PA_GCONF_PATH_MODULES"/upnp-media-server/name1");
-            changeSet.unset(PA_GCONF_PATH_MODULES"/upnp-media-server/args1");
-            changeSet.set(PA_GCONF_PATH_MODULES"/upnp-media-server/null-sink-enabled", false);
+            upnpSettings->reset("name1");
+            upnpSettings->reset("args1");
         }
 
-        changeSet.set(PA_GCONF_PATH_MODULES"/upnp-media-server/enabled", true);
-    }  else
-        changeSet.set(PA_GCONF_PATH_MODULES"/upnp-media-server/enabled", false);
-
-    gconf->change_set_commit(changeSet, true);
-
-    changeSet.set(PA_GCONF_PATH_MODULES"/upnp-media-server/locked", false);
-    gconf->change_set_commit(changeSet, true);
+        upnpSettings->set_boolean("enabled", true);
+    } else
+        upnpSettings->set_boolean("enabled", false);
 
-    gconf->suggest_sync();
+    upnpSettings->apply();
 }
 
-void MainWindow::onGConfChange(const Glib::ustring&, const Gnome::Conf::Value&) {
-    readFromGConf();
+void MainWindow::onGSettingsChange(const Glib::ustring&) {
+    readFromGSettings();
 }
 
-void MainWindow::readFromGConf() {
-    Glib::ustring mode;
+bool MainWindow::moduleHasArgument(Glib::RefPtr<Gio::Settings> gsettings, const Glib::ustring& module, const Glib::ustring& name = "", const Glib::ustring& value = "") {
+    Glib::ustring args;
+    std::vector<std::string> moduleArgs, keyValue;
 
+    for (int i=0; i<MAX_MODULES; i++) {
+        char tmp[256];
+        snprintf(tmp, sizeof(tmp), "name%d", i);
+        if (gsettings->get_string(tmp) == module) {
+            if (name.empty() && value.empty()) {
+                return gsettings->get_boolean("enabled");
+            }
+            snprintf(tmp, sizeof(tmp), "args%d", i);
+            args = gsettings->get_string(tmp);
+            moduleArgs = Glib::Regex::split_simple(" ", args);
+            for (std::vector<std::string>::iterator it = moduleArgs.begin(); it != moduleArgs.end(); ++it) {
+                keyValue = Glib::Regex::split_simple("=", *it);
+                if (keyValue.size() >= 2 && keyValue[0] == name) {
+                    return keyValue[1] == value;
+                }
+            }
+            break;
+        }
+    }
+    return false;
+}
+
+void MainWindow::readFromGSettings() {
+    Glib::ustring mode, args;
+    std::vector<std::string> moduleArgs, keyValue;
+    bool loopbackEnabled = false;
+    bool fixedPort = false;
+    bool anonymousEnabled = false;
+    bool zeroconfEnabled = false;
+    bool mikeEnabled = false;
+    bool speakerEnabled = false;
+    bool nullSink = false;
     ignoreChanges = TRUE;
 
-    remoteAccessCheckButton->set_active(gconf->get_bool(PA_GCONF_PATH_MODULES"/remote-access/enabled"));
-    zeroconfPublishCheckButton->set_active(gconf->get_bool(PA_GCONF_PATH_MODULES"/remote-access/zeroconf_enabled"));
-    anonymousAuthCheckButton->set_active(gconf->get_bool(PA_GCONF_PATH_MODULES"/remote-access/anonymous_enabled"));
+    remoteAccessCheckButton->set_active(remoteAccessSettings->get_boolean("enabled"));
+
+    zeroconfDiscoverCheckButton->set_active(zeroconfSettings->get_boolean("enabled"));
+    zeroconfRaopDiscoverCheckButton->set_active(raopSettings->get_boolean("enabled"));
+
+    rtpReceiveCheckButton->set_active(rtpRecvSettings->get_boolean("enabled"));
 
-    zeroconfDiscoverCheckButton->set_active(gconf->get_bool(PA_GCONF_PATH_MODULES"/zeroconf-discover/enabled"));
-    zeroconfRaopDiscoverCheckButton->set_active(gconf->get_bool(PA_GCONF_PATH_MODULES"/raop-discover/enabled"));
+    rtpSendCheckButton->set_active(rtpSendSettings->get_boolean("enabled"));
 
-    rtpReceiveCheckButton->set_active(gconf->get_bool(PA_GCONF_PATH_MODULES"/rtp-recv/enabled"));
+    loopbackEnabled = moduleHasArgument(rtpSendSettings, "module-rtp-send", "loop", "1");
+    rtpLoopbackCheckButton->set_active(loopbackEnabled);
 
-    rtpSendCheckButton->set_active(gconf->get_bool(PA_GCONF_PATH_MODULES"/rtp-send/enabled"));
-    rtpLoopbackCheckButton->set_active(gconf->get_bool(PA_GCONF_PATH_MODULES"/rtp-send/loopback_enabled"));
-    rtpPortCheckButton->set_active(gconf->get_bool(PA_GCONF_PATH_MODULES"/rtp-send/fixed_port"));
+    fixedPort = moduleHasArgument(rtpSendSettings, "module-rtp-send", "port", "5004");
+    rtpPortCheckButton->set_active(fixedPort);
 
-    mode = gconf->get_string(PA_GCONF_PATH_MODULES"/rtp-send/mode");
-    if (mode == "microphone")
+    anonymousEnabled = moduleHasArgument(remoteAccessSettings, "module-native-protocol-tcp", "auth-anonymous", "1") &&
+                       moduleHasArgument(remoteAccessSettings, "module-esound-protocol-tcp", "auth-anonymous", "1");
+    anonymousAuthCheckButton->set_active(anonymousEnabled);
+
+    zeroconfEnabled = moduleHasArgument(remoteAccessSettings, "module-zeroconf-publish");
+    zeroconfPublishCheckButton->set_active(zeroconfEnabled);
+
+    mikeEnabled = moduleHasArgument(rtpSendSettings, "module-rtp-send", "source", "@DEFAULT_SOURCE@");
+    speakerEnabled = moduleHasArgument(rtpSendSettings, "module-rtp-send", "source", "@DEFAULT_MONITOR@");
+
+    if (mikeEnabled)
         rtpMikeRadioButton->set_active(TRUE);
-    else if (mode == "speaker")
+    else if (speakerEnabled)
         rtpSpeakerRadioButton->set_active(TRUE);
     else
         rtpNullSinkRadioButton->set_active(TRUE);
 
-    combineCheckButton->set_active(gconf->get_bool(PA_GCONF_PATH_MODULES"/combine/enabled"));
+    combineCheckButton->set_active(combineSettings->get_boolean("enabled"));
 
-    upnpMediaServerCheckButton->set_active(gconf->get_bool(PA_GCONF_PATH_MODULES"/upnp-media-server/enabled"));
-    upnpNullSinkCheckButton->set_active(gconf->get_bool(PA_GCONF_PATH_MODULES"/upnp-media-server/null-sink-enabled"));
+    upnpMediaServerCheckButton->set_active(upnpSettings->get_boolean("enabled"));
+
+    nullSink = moduleHasArgument(upnpSettings, "module-null-sink", "sink_name", "upnp");
+    upnpNullSinkCheckButton->set_active(nullSink);
 
     ignoreChanges = FALSE;
 
@@ -734,8 +757,6 @@ int main(int argc, char *argv[]) {
 
     Gtk::Main kit(argc, argv);
 
-    Gnome::Conf::init();
-
     Gtk::Window* mainWindow = MainWindow::create();
 
     Gtk::Main::run(*mainWindow);
diff --git a/src/paprefs.convert b/src/paprefs.convert
new file mode 100644
index 0000000..e23a963
--- /dev/null
+++ b/src/paprefs.convert
@@ -0,0 +1,160 @@
+[org.freedesktop.pulseaudio.module:/org/freedesktop/pulseaudio/modules/combine/]
+args0 = /system/pulseaudio/modules/combine/args0
+args1 = /system/pulseaudio/modules/combine/args1
+args2 = /system/pulseaudio/modules/combine/args2
+args3 = /system/pulseaudio/modules/combine/args3
+args4 = /system/pulseaudio/modules/combine/args4
+args5 = /system/pulseaudio/modules/combine/args5
+args6 = /system/pulseaudio/modules/combine/args6
+args7 = /system/pulseaudio/modules/combine/args7
+args8 = /system/pulseaudio/modules/combine/args8
+args9 = /system/pulseaudio/modules/combine/args9
+name0 = /system/pulseaudio/modules/combine/name0
+name1 = /system/pulseaudio/modules/combine/name1
+name2 = /system/pulseaudio/modules/combine/name2
+name3 = /system/pulseaudio/modules/combine/name3
+name4 = /system/pulseaudio/modules/combine/name4
+name5 = /system/pulseaudio/modules/combine/name5
+name6 = /system/pulseaudio/modules/combine/name6
+name7 = /system/pulseaudio/modules/combine/name7
+name8 = /system/pulseaudio/modules/combine/name8
+name9 = /system/pulseaudio/modules/combine/name9
+enabled = /system/pulseaudio/modules/combine/enabled
+
+[org.freedesktop.pulseaudio.module:/org/freedesktop/pulseaudio/modules/remote-access/]
+args0 = /system/pulseaudio/modules/remote-access/args0
+args1 = /system/pulseaudio/modules/remote-access/args1
+args2 = /system/pulseaudio/modules/remote-access/args2
+args3 = /system/pulseaudio/modules/remote-access/args3
+args4 = /system/pulseaudio/modules/remote-access/args4
+args5 = /system/pulseaudio/modules/remote-access/args5
+args6 = /system/pulseaudio/modules/remote-access/args6
+args7 = /system/pulseaudio/modules/remote-access/args7
+args8 = /system/pulseaudio/modules/remote-access/args8
+args9 = /system/pulseaudio/modules/remote-access/args9
+name0 = /system/pulseaudio/modules/remote-access/name0
+name1 = /system/pulseaudio/modules/remote-access/name1
+name2 = /system/pulseaudio/modules/remote-access/name2
+name3 = /system/pulseaudio/modules/remote-access/name3
+name4 = /system/pulseaudio/modules/remote-access/name4
+name5 = /system/pulseaudio/modules/remote-access/name5
+name6 = /system/pulseaudio/modules/remote-access/name6
+name7 = /system/pulseaudio/modules/remote-access/name7
+name8 = /system/pulseaudio/modules/remote-access/name8
+name9 = /system/pulseaudio/modules/remote-access/name9
+enabled = /system/pulseaudio/modules/remote-access/enabled
+
+[org.freedesktop.pulseaudio.module:/org/freedesktop/pulseaudio/modules/zeroconf-discover/]
+args0 = /system/pulseaudio/modules/zeroconf-discover/args0
+args1 = /system/pulseaudio/modules/zeroconf-discover/args1
+args2 = /system/pulseaudio/modules/zeroconf-discover/args2
+args3 = /system/pulseaudio/modules/zeroconf-discover/args3
+args4 = /system/pulseaudio/modules/zeroconf-discover/args4
+args5 = /system/pulseaudio/modules/zeroconf-discover/args5
+args6 = /system/pulseaudio/modules/zeroconf-discover/args6
+args7 = /system/pulseaudio/modules/zeroconf-discover/args7
+args8 = /system/pulseaudio/modules/zeroconf-discover/args8
+args9 = /system/pulseaudio/modules/zeroconf-discover/args9
+name0 = /system/pulseaudio/modules/zeroconf-discover/name0
+name1 = /system/pulseaudio/modules/zeroconf-discover/name1
+name2 = /system/pulseaudio/modules/zeroconf-discover/name2
+name3 = /system/pulseaudio/modules/zeroconf-discover/name3
+name4 = /system/pulseaudio/modules/zeroconf-discover/name4
+name5 = /system/pulseaudio/modules/zeroconf-discover/name5
+name6 = /system/pulseaudio/modules/zeroconf-discover/name6
+name7 = /system/pulseaudio/modules/zeroconf-discover/name7
+name8 = /system/pulseaudio/modules/zeroconf-discover/name8
+name9 = /system/pulseaudio/modules/zeroconf-discover/name9
+enabled = /system/pulseaudio/modules/zeroconf-discover/enabled
+
+[org.freedesktop.pulseaudio.module:/org/freedesktop/pulseaudio/modules/raop-discover/]
+args0 = /system/pulseaudio/modules/raop-discover/args0
+args1 = /system/pulseaudio/modules/raop-discover/args1
+args2 = /system/pulseaudio/modules/raop-discover/args2
+args3 = /system/pulseaudio/modules/raop-discover/args3
+args4 = /system/pulseaudio/modules/raop-discover/args4
+args5 = /system/pulseaudio/modules/raop-discover/args5
+args6 = /system/pulseaudio/modules/raop-discover/args6
+args7 = /system/pulseaudio/modules/raop-discover/args7
+args8 = /system/pulseaudio/modules/raop-discover/args8
+args9 = /system/pulseaudio/modules/raop-discover/args9
+name0 = /system/pulseaudio/modules/raop-discover/name0
+name1 = /system/pulseaudio/modules/raop-discover/name1
+name2 = /system/pulseaudio/modules/raop-discover/name2
+name3 = /system/pulseaudio/modules/raop-discover/name3
+name4 = /system/pulseaudio/modules/raop-discover/name4
+name5 = /system/pulseaudio/modules/raop-discover/name5
+name6 = /system/pulseaudio/modules/raop-discover/name6
+name7 = /system/pulseaudio/modules/raop-discover/name7
+name8 = /system/pulseaudio/modules/raop-discover/name8
+name9 = /system/pulseaudio/modules/raop-discover/name9
+enabled = /system/pulseaudio/modules/raop-discover/enabled
+
+[org.freedesktop.pulseaudio.module:/org/freedesktop/pulseaudio/modules/rtp-recv/]
+args0 = /system/pulseaudio/modules/rtp-recv/args0
+args1 = /system/pulseaudio/modules/rtp-recv/args1
+args2 = /system/pulseaudio/modules/rtp-recv/args2
+args3 = /system/pulseaudio/modules/rtp-recv/args3
+args4 = /system/pulseaudio/modules/rtp-recv/args4
+args5 = /system/pulseaudio/modules/rtp-recv/args5
+args6 = /system/pulseaudio/modules/rtp-recv/args6
+args7 = /system/pulseaudio/modules/rtp-recv/args7
+args8 = /system/pulseaudio/modules/rtp-recv/args8
+args9 = /system/pulseaudio/modules/rtp-recv/args9
+name0 = /system/pulseaudio/modules/rtp-recv/name0
+name1 = /system/pulseaudio/modules/rtp-recv/name1
+name2 = /system/pulseaudio/modules/rtp-recv/name2
+name3 = /system/pulseaudio/modules/rtp-recv/name3
+name4 = /system/pulseaudio/modules/rtp-recv/name4
+name5 = /system/pulseaudio/modules/rtp-recv/name5
+name6 = /system/pulseaudio/modules/rtp-recv/name6
+name7 = /system/pulseaudio/modules/rtp-recv/name7
+name8 = /system/pulseaudio/modules/rtp-recv/name8
+name9 = /system/pulseaudio/modules/rtp-recv/name9
+enabled = /system/pulseaudio/modules/rtp-recv/enabled
+
+[org.freedesktop.pulseaudio.module:/org/freedesktop/pulseaudio/modules/rtp-send/]
+args0 = /system/pulseaudio/modules/rtp-send/args0
+args1 = /system/pulseaudio/modules/rtp-send/args1
+args2 = /system/pulseaudio/modules/rtp-send/args2
+args3 = /system/pulseaudio/modules/rtp-send/args3
+args4 = /system/pulseaudio/modules/rtp-send/args4
+args5 = /system/pulseaudio/modules/rtp-send/args5
+args6 = /system/pulseaudio/modules/rtp-send/args6
+args7 = /system/pulseaudio/modules/rtp-send/args7
+args8 = /system/pulseaudio/modules/rtp-send/args8
+args9 = /system/pulseaudio/modules/rtp-send/args9
+name0 = /system/pulseaudio/modules/rtp-send/name0
+name1 = /system/pulseaudio/modules/rtp-send/name1
+name2 = /system/pulseaudio/modules/rtp-send/name2
+name3 = /system/pulseaudio/modules/rtp-send/name3
+name4 = /system/pulseaudio/modules/rtp-send/name4
+name5 = /system/pulseaudio/modules/rtp-send/name5
+name6 = /system/pulseaudio/modules/rtp-send/name6
+name7 = /system/pulseaudio/modules/rtp-send/name7
+name8 = /system/pulseaudio/modules/rtp-send/name8
+name9 = /system/pulseaudio/modules/rtp-send/name9
+enabled = /system/pulseaudio/modules/rtp-send/enabled
+
+[org.freedesktop.pulseaudio.module:/org/freedesktop/pulseaudio/modules/upnp-media-server/]
+args0 = /system/pulseaudio/modules/upnp-media-server/args0
+args1 = /system/pulseaudio/modules/upnp-media-server/args1
+args2 = /system/pulseaudio/modules/upnp-media-server/args2
+args3 = /system/pulseaudio/modules/upnp-media-server/args3
+args4 = /system/pulseaudio/modules/upnp-media-server/args4
+args5 = /system/pulseaudio/modules/upnp-media-server/args5
+args6 = /system/pulseaudio/modules/upnp-media-server/args6
+args7 = /system/pulseaudio/modules/upnp-media-server/args7
+args8 = /system/pulseaudio/modules/upnp-media-server/args8
+args9 = /system/pulseaudio/modules/upnp-media-server/args9
+name0 = /system/pulseaudio/modules/upnp-media-server/name0
+name1 = /system/pulseaudio/modules/upnp-media-server/name1
+name2 = /system/pulseaudio/modules/upnp-media-server/name2
+name3 = /system/pulseaudio/modules/upnp-media-server/name3
+name4 = /system/pulseaudio/modules/upnp-media-server/name4
+name5 = /system/pulseaudio/modules/upnp-media-server/name5
+name6 = /system/pulseaudio/modules/upnp-media-server/name6
+name7 = /system/pulseaudio/modules/upnp-media-server/name7
+name8 = /system/pulseaudio/modules/upnp-media-server/name8
+name9 = /system/pulseaudio/modules/upnp-media-server/name9
+enabled = /system/pulseaudio/modules/upnp-media-server/enabled
-- 
2.16.3



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux