Implement wallpaper changing for Linux
This commit is contained in:
parent
4ecc05d4cd
commit
af01495e9b
|
|
@ -20,7 +20,13 @@ static bool isCached = false;
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
#include "mac-desktop.h"
|
#include "mac-desktop.h"
|
||||||
#else
|
#else
|
||||||
// XXX Implement me!
|
#include <giomm/settings.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <sstream>
|
||||||
|
Glib::RefPtr<Gio::Settings> bgsetting = Gio::Settings::create("org.gnome.desktop.background");
|
||||||
|
std::string defPictureURI = bgsetting->get_string("picture-uri");
|
||||||
|
std::string defPictureOptions = bgsetting->get_string("picture-options");
|
||||||
|
std::string defPrimaryColor = bgsetting->get_string("primary-color");
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -110,7 +116,17 @@ end:
|
||||||
}
|
}
|
||||||
MacDesktop::ChangeBackground(imgname, ((color >> 16) & 0xFF) / 255.0, ((color >> 8) & 0xFF) / 255.0, ((color) & 0xFF) / 255.0);
|
MacDesktop::ChangeBackground(imgname, ((color >> 16) & 0xFF) / 255.0, ((color >> 8) & 0xFF) / 255.0, ((color) & 0xFF) / 255.0);
|
||||||
#else
|
#else
|
||||||
// XXX Implement me!
|
char gameDir[1024];
|
||||||
|
if (getcwd(gameDir, sizeof(gameDir)) != NULL) {
|
||||||
|
std::string gameDirStr(gameDir);
|
||||||
|
std::stringstream hexColor;
|
||||||
|
hexColor << "#" << std::hex << color;
|
||||||
|
bgsetting->set_string("picture-uri", "file://" + gameDirStr + "/Wallpaper/" + imageName + ".png");
|
||||||
|
bgsetting->set_string("picture-options", "scaled");
|
||||||
|
bgsetting->set_string("primary-color", hexColor.str());
|
||||||
|
} else {
|
||||||
|
// Error handling?
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
return Qnil;
|
return Qnil;
|
||||||
|
|
@ -148,7 +164,9 @@ RB_METHOD(wallpaperReset)
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
MacDesktop::ResetBackground();
|
MacDesktop::ResetBackground();
|
||||||
#else
|
#else
|
||||||
// XXX Implement me!
|
bgsetting->set_string("picture-uri", defPictureURI);
|
||||||
|
bgsetting->set_string("picture-options", defPictureOptions);
|
||||||
|
bgsetting->set_string("primary-color", defPrimaryColor);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
return Qnil;
|
return Qnil;
|
||||||
|
|
@ -156,9 +174,9 @@ RB_METHOD(wallpaperReset)
|
||||||
|
|
||||||
void wallpaperBindingInit()
|
void wallpaperBindingInit()
|
||||||
{
|
{
|
||||||
VALUE module = rb_define_module("Wallpaper");
|
VALUE module = rb_define_module("Wallpaper");
|
||||||
|
|
||||||
//Functions
|
// Functions
|
||||||
_rb_define_module_function(module, "set", wallpaperSet);
|
_rb_define_module_function(module, "set", wallpaperSet);
|
||||||
_rb_define_module_function(module, "reset", wallpaperReset);
|
_rb_define_module_function(module, "reset", wallpaperReset);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
2
mkxp.pro
2
mkxp.pro
|
|
@ -47,7 +47,7 @@ unix {
|
||||||
SOURCES += src/mac-desktop.mm
|
SOURCES += src/mac-desktop.mm
|
||||||
}
|
}
|
||||||
!macx: {
|
!macx: {
|
||||||
# PKGCONFIG += openal zlib
|
PKGCONFIG += giomm-2.4
|
||||||
INCLUDEPATH += /usr/include/AL /usr/local/include/AL
|
INCLUDEPATH += /usr/include/AL /usr/local/include/AL
|
||||||
SOURCES += src/xdg-user-dir-lookup.c
|
SOURCES += src/xdg-user-dir-lookup.c
|
||||||
LIBS += -lX11
|
LIBS += -lX11
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue