summaryrefslogtreecommitdiff
path: root/ui/src/preferences.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ui/src/preferences.cpp')
-rw-r--r--ui/src/preferences.cpp81
1 files changed, 0 insertions, 81 deletions
diff --git a/ui/src/preferences.cpp b/ui/src/preferences.cpp
deleted file mode 100644
index 88e6d0f..0000000
--- a/ui/src/preferences.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-#include "turns/ui/preferences.hpp"
-
-#include "turns/core/settings.hpp"
-#include "turns/ui/template_widget.hpp"
-
-#include <sigc++/adaptors/bind.h>
-#include <sigc++/functors/mem_fun.h>
-
-#include <glibmm/binding.h>
-#include <glibmm/objectbase.h>
-#include <glibmm/refptr.h>
-#include <glibmm/ustring.h>
-#include <glibmm/variant.h>
-
-#include <giomm/settings.h>
-
-#include <gtkmm/button.h>
-#include <gtkmm/colordialog.h>
-#include <gtkmm/colordialogbutton.h>
-#include <gtkmm/enums.h>
-
-#include <adwaitamm/switchrow.hpp>
-
-#include <gdkmm/rgba.h>
-
-namespace turns::ui
-{
- namespace
- {
- auto constexpr static TYPE_NAME = "Preferences";
- auto constexpr static TEMPLATE = "/ch/arknet/Turns/preferences.ui";
- } // namespace
-
- Preferences::Preferences(Glib::RefPtr<Gio::Settings> settings)
- : Glib::ObjectBase{TYPE_NAME}
- , template_widget{TEMPLATE}
- , m_settings{settings}
- , m_friendly_reset_button{get_widget<Gtk::Button>("friendly_reset_button")}
- , m_hostile_reset_button{get_widget<Gtk::Button>("hostile_reset_button")}
- , m_secret_reset_button{get_widget<Gtk::Button>("secret_reset_button")}
- , m_friendly_color_button{get_widget<Gtk::ColorDialogButton>("friendly_color_button")}
- , m_hostile_color_button{get_widget<Gtk::ColorDialogButton>("hostile_color_button")}
- , m_secret_color_button{get_widget<Gtk::ColorDialogButton>("secret_color_button")}
- , m_skip_defeated{get_widget<Adwaita::SwitchRow>("skip_defeated")}
- {
- if (!m_settings)
- {
- return;
- }
-
- bind_reset(core::settings::key::disposition_friendly_color, m_friendly_reset_button);
- bind_setting(core::settings::key::disposition_friendly_color, m_friendly_color_button);
- bind_reset(core::settings::key::disposition_hostile_color, m_hostile_reset_button);
- bind_setting(core::settings::key::disposition_hostile_color, m_hostile_color_button);
- bind_reset(core::settings::key::disposition_secret_color, m_secret_reset_button);
- bind_setting(core::settings::key::disposition_secret_color, m_secret_color_button);
-
- m_settings->bind(core::settings::key::skip_defeated, m_skip_defeated->property_active());
- }
-
- auto Preferences::bind_reset(Glib::ustring const & key, Gtk::Button * button) -> void
- {
- m_settings->signal_changed(key).connect([=, this](auto) { update_sensitive(key, button); });
- update_sensitive(key, button);
- button->signal_clicked().connect(sigc::bind(sigc::mem_fun(*m_settings, &Gio::Settings::reset), key));
- }
-
- auto Preferences::bind_setting(Glib::ustring const & key, Gtk::ColorDialogButton * button) -> void
- {
- m_settings->bind<Glib::ustring, Gdk::RGBA>(key, button->property_rgba(), Gio::Settings::BindFlags::DEFAULT, [](auto value) {
- return Gdk::RGBA{value};
- }, [](auto color) { return color.to_string(); });
- }
-
- auto Preferences::update_sensitive(Glib::ustring const & key, Gtk::Button * button) -> void
- {
- auto v = Glib::Variant<Glib::ustring>{};
- button->set_sensitive(m_settings->get_user_value(key, v));
- }
-
-} // namespace turns::ui::widgets \ No newline at end of file