Switch from giomm to gio

Seems that gio has more documentation than giomm.
This commit is contained in:
Vinyl Darkscratch 2018-06-01 22:43:36 -07:00
parent e31229d405
commit 7f4f9ff5a5
1 changed files with 47 additions and 46 deletions

View File

@ -23,7 +23,7 @@
#include "mac-desktop.h" #include "mac-desktop.h"
static bool isCached = false; static bool isCached = false;
#else #else
#include <giomm/settings.h> #include <gio/gio.h>
#include <xfconf/xfconf.h> #include <xfconf/xfconf.h>
#include <unistd.h> #include <unistd.h>
#include <algorithm> #include <algorithm>
@ -32,7 +32,7 @@
#include <sstream> #include <sstream>
static std::string desktop = "uninitialized"; static std::string desktop = "uninitialized";
// GNOME settings // GNOME settings
static Glib::RefPtr<Gio::Settings> bgsetting; static GSettings *bgsetting;
static std::string defPictureURI, defPictureOptions, defPrimaryColor, defColorShading; static std::string defPictureURI, defPictureOptions, defPrimaryColor, defColorShading;
// XFCE settings // XFCE settings
static XfconfChannel* bgchannel; static XfconfChannel* bgchannel;
@ -45,23 +45,24 @@
#endif #endif
#ifdef __linux__ #ifdef __linux__
void desktopEnvironmentInit() void desktopEnvironmentInit()
{ {
if (desktop != "uninitialized") { if (desktop != "uninitialized") {
return; return;
} }
desktop = shState->oneshot().desktopEnv; desktop = shState->oneshot().desktopEnv;
if (desktop == "gnome" || desktop == "mate") { if (desktop == "gnome" || desktop == "mate") {
if (desktop == "gnome") { if (desktop == "gnome") {
bgsetting = Gio::Settings::create("org.gnome.desktop.background"); bgsetting = g_settings_new("org.gnome.desktop.background");
defPictureURI = bgsetting->get_string("picture-uri"); defPictureURI = g_settings_get_string(bgsetting, "picture-uri");
std::cout << defPictureURI << std::endl;
} else { } else {
bgsetting = Gio::Settings::create("org.mate.background"); bgsetting = g_settings_new("org.mate.background");
defPictureURI = bgsetting->get_string("picture-filename"); defPictureURI = g_settings_get_string(bgsetting, "picture-filename");
} }
defPictureOptions = bgsetting->get_string("picture-options"); defPictureOptions = g_settings_get_string(bgsetting, "picture-options");
defPrimaryColor = bgsetting->get_string("primary-color"); defPrimaryColor = g_settings_get_string(bgsetting, "primary-color");
defColorShading = bgsetting->get_string("color-shading-type"); defColorShading = g_settings_get_string(bgsetting, "color-shading-type");
} else if (desktop == "xfce") { } else if (desktop == "xfce") {
GError *xferror = NULL; GError *xferror = NULL;
if (xfconf_init(&xferror)) { if (xfconf_init(&xferror)) {
@ -81,7 +82,7 @@ void desktopEnvironmentInit()
g_error_free(xferror); g_error_free(xferror);
} }
} }
} }
#endif #endif
RB_METHOD(wallpaperSet) RB_METHOD(wallpaperSet)
@ -187,13 +188,13 @@ end:
std::stringstream hexColor; std::stringstream hexColor;
hexColor << "#" << std::hex << color; hexColor << "#" << std::hex << color;
if (desktop == "gnome") { if (desktop == "gnome") {
bgsetting->set_string("picture-uri", "file://" + gameDirStr + path); g_settings_set_string(bgsetting, "picture-uri", ("file://" + gameDirStr + path).c_str());
} else { } else {
bgsetting->set_string("picture-filename", gameDirStr + path); g_settings_set_string(bgsetting, "picture-filename", (gameDirStr + path).c_str());
} }
bgsetting->set_string("picture-options", "scaled"); g_settings_set_string(bgsetting, "picture-options", "scaled");
bgsetting->set_string("primary-color", hexColor.str()); g_settings_set_string(bgsetting, "primary-color", hexColor.str().c_str());
bgsetting->set_string("color-shading-type", "solid"); g_settings_set_string(bgsetting, "color-shading-type", "solid");
} else if (desktop == "xfce") { } else if (desktop == "xfce") {
int r = (color >> 16) & 0xFF; int r = (color >> 16) & 0xFF;
int g = (color >> 8) & 0xFF; int g = (color >> 8) & 0xFF;
@ -283,13 +284,13 @@ RB_METHOD(wallpaperReset)
desktopEnvironmentInit(); desktopEnvironmentInit();
if (desktop == "gnome" || desktop == "mate") { if (desktop == "gnome" || desktop == "mate") {
if (desktop == "gnome") { if (desktop == "gnome") {
bgsetting->set_string("picture-uri", defPictureURI); g_settings_set_string(bgsetting, "picture-uri", defPictureURI.c_str());
} else { } else {
bgsetting->set_string("picture-filename", defPictureURI); g_settings_set_string(bgsetting, "picture-filename", defPictureURI.c_str());
} }
bgsetting->set_string("picture-options", defPictureOptions); g_settings_set_string(bgsetting, "picture-options", defPictureOptions.c_str());
bgsetting->set_string("primary-color", defPrimaryColor); g_settings_set_string(bgsetting, "primary-color", defPrimaryColor.c_str());
bgsetting->set_string("color-shading-type", defColorShading); g_settings_set_string(bgsetting, "color-shading-type", defColorShading.c_str());
} else if (desktop == "xfce") { } else if (desktop == "xfce") {
if (defColorExists) { if (defColorExists) {
xfconf_channel_set_property(bgchannel, optionColor.c_str(), &defColor); xfconf_channel_set_property(bgchannel, optionColor.c_str(), &defColor);