[paprefs][PATCH 2/9] Run gsettings-data-convert at startup if needed

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

 



From: Sylvain Baubeau <sbaubeau@xxxxxxxxxx>

---
 src/paprefs.cc | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/src/paprefs.cc b/src/paprefs.cc
index dc63e2e..9b6ac78 100644
--- a/src/paprefs.cc
+++ b/src/paprefs.cc
@@ -25,6 +25,7 @@
 
 #include <gtkmm.h>
 #include <glibmm.h>
+#include <glibmm/keyfile.h>
 #include <glibmm/regex.h>
 #include <libglademm.h>
 #include <libintl.h>
@@ -105,6 +106,7 @@ public:
 
     void checkForPackageKit();
     void checkForModules();
+    void ensureMigrated();
 
     void writeToGSettingsRemoteAccess();
     void writeToGSettingsZeroconfDiscover();
@@ -167,6 +169,7 @@ MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade:
 
     checkForPackageKit();
     checkForModules();
+    ensureMigrated();
 
     combineSettings = Gio::Settings::create("org.freedesktop.pulseaudio.module",
                                             "/org/freedesktop/pulseaudio/modules/combine/");
@@ -745,6 +748,23 @@ void MainWindow::checkForPackageKit() {
     dbus_error_free(&err);
 }
 
+void MainWindow::ensureMigrated() {
+    Glib::KeyFile kf;
+    std::string keypath;
+    std::vector<std::string> list;
+
+    try {
+        kf.load_from_data_dirs("gsettings-data-convert",
+                               keypath, Glib::KEY_FILE_NONE);
+        list = kf.get_string_list("State", "converted");
+    } catch(Glib::KeyFileError) {}
+
+    if (std::find(list.begin(), list.end(), "paprefs.convert") == list.end()) {
+        Glib::spawn_command_line_sync("gsettings-data-convert",
+                                      NULL, NULL, NULL);
+
+    }
+}
 
 int main(int argc, char *argv[]) {
 
@@ -757,7 +777,7 @@ int main(int argc, char *argv[]) {
 
     Gtk::Main kit(argc, argv);
 
-    Gtk::Window* mainWindow = MainWindow::create();
+    MainWindow* mainWindow = MainWindow::create();
 
     Gtk::Main::run(*mainWindow);
     delete mainWindow;
-- 
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