1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 03:37:45 +00:00

DisplaySettings: Use LibConfig where possible

Some places here still need to open `/etc/WindowServer.ini` which
we can't do with th ConfigServer yet.
This commit is contained in:
Mustafa Quraish 2021-08-29 10:05:41 -04:00 committed by Andreas Kling
parent d276657f85
commit 8fdb435d24
3 changed files with 8 additions and 5 deletions

View file

@ -22,6 +22,9 @@
#include <LibGfx/Palette.h>
#include <LibGfx/SystemTheme.h>
// Including this after to avoid LibIPC errors
#include <LibConfig/Client.h>
namespace DisplaySettings {
BackgroundSettingsWidget::BackgroundSettingsWidget()
@ -86,9 +89,8 @@ void BackgroundSettingsWidget::create_frame()
void BackgroundSettingsWidget::load_current_settings()
{
auto ws_config = Core::ConfigFile::open("/etc/WindowServer.ini");
auto wm_config = Core::ConfigFile::open_for_app("WindowManager");
auto selected_wallpaper = wm_config->read_entry("Background", "Wallpaper", "");
auto selected_wallpaper = Config::read_string("WindowManager", "Background", "Wallpaper", "");
if (!selected_wallpaper.is_empty()) {
auto index = static_cast<GUI::FileSystemModel*>(m_wallpaper_view->model())->index(selected_wallpaper, m_wallpaper_view->model_column());
m_wallpaper_view->set_cursor(index, GUI::AbstractView::SelectionUpdate::Set);
@ -118,8 +120,7 @@ void BackgroundSettingsWidget::load_current_settings()
void BackgroundSettingsWidget::apply_settings()
{
auto wm_config = Core::ConfigFile::open_for_app("WindowManager", Core::ConfigFile::AllowWriting::Yes);
wm_config->write_entry("Background", "Wallpaper", m_monitor_widget->wallpaper());
Config::write_string("WindowManager", "Background", "Wallpaper", m_monitor_widget->wallpaper());
if (!m_monitor_widget->wallpaper().is_empty()) {
GUI::Desktop::the().set_wallpaper(m_monitor_widget->wallpaper());

View file

@ -23,4 +23,4 @@ set(SOURCES
)
serenity_app(DisplaySettings ICON app-display-settings)
target_link_libraries(DisplaySettings LibGUI)
target_link_libraries(DisplaySettings LibGUI LibConfig)

View file

@ -9,6 +9,7 @@
#include "DesktopSettingsWidget.h"
#include "FontSettingsWidget.h"
#include "MonitorSettingsWidget.h"
#include <LibConfig/Client.h>
#include <LibGUI/Application.h>
#include <LibGUI/BoxLayout.h>
#include <LibGUI/Button.h>
@ -28,6 +29,7 @@ int main(int argc, char** argv)
}
auto app = GUI::Application::construct(argc, argv);
Config::pledge_domains("WindowManager");
if (pledge("stdio thread recvfd sendfd rpath cpath wpath", nullptr) < 0) {
perror("pledge");