summaryrefslogtreecommitdiff
path: root/gui/include/preferences.hpp
blob: 9bd2e7760a6a649001d831e1c993e2669b4ca653 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
 * SPDX-FileCopyrightText: 2025 Felix Morgner <felix.morgner@gmail.com>
 * SPDX-License-Identifier: LGPL-2.1-only
 */

#ifndef TURNS_GUI_PREFERENCES_HPP
#define TURNS_GUI_PREFERENCES_HPP

#include "template_widget.hpp"

#include <adwaitamm/preferencespage.hpp>
#include <adwaitamm/switchrow.hpp>
#include <giomm/settings.h>
#include <glibmm/refptr.h>
#include <glibmm/ustring.h>
#include <gtkmm/button.h>
#include <gtkmm/colordialogbutton.h>

#include <array>

namespace Turns::gui
{
  struct Preferences : template_widget<Preferences, Adwaita::PreferencesPage>
  {

    auto constexpr inline static children = std::array{
        "friendly_reset_button",
        "hostile_reset_button",
        "secret_reset_button",
        "friendly_color_button",
        "hostile_color_button",
        "secret_color_button",
        "skip_defeated",
    };

    explicit Preferences(Glib::RefPtr<Gio::Settings> settings = {});

  private:
    auto bind_reset(Glib::ustring const & key, Gtk::Button * button) -> void;
    auto bind_setting(Glib::ustring const & key, Gtk::ColorDialogButton * button) -> void;
    auto update_sensitive(Glib::ustring const & key, Gtk::Button * button) -> void;

    Glib::RefPtr<Gio::Settings> m_settings;

    Gtk::Button * m_friendly_reset_button{};
    Gtk::Button * m_hostile_reset_button{};
    Gtk::Button * m_secret_reset_button{};
    Gtk::ColorDialogButton * m_friendly_color_button{};
    Gtk::ColorDialogButton * m_hostile_color_button{};
    Gtk::ColorDialogButton * m_secret_color_button{};
    Adwaita::SwitchRow * m_skip_defeated{};
  };
}  // namespace Turns::gui

#endif