using Gtk 4.0;
using Adw 1;

Adw.PreferencesWindow _root {
  default-width: 600;
  default-height: 540;
  width-request: 360;
  modal: true;
  destroy-with-parent: false;
  hide-on-close: true;
  title: _("Preferences");

  Adw.PreferencesPage {
    vexpand: true;

    Adw.PreferencesGroup {
      title: _("User Interface");

      Adw.ComboRow _themeRow {
        title: _("Theme");
        model: Gtk.StringList {
          strings [C_("Theme", "Light"), C_("Theme", "Dark"), C_("Theme", "System")]
        };

        [prefix]
        Gtk.Image {
          icon-name: "dark-mode-symbolic";
        }
      }

      Adw.ExpanderRow {
        title: _("Colors");
        subtitle: _("Customize the colors used by Denaro.");

        [prefix]
        Gtk.Image {
          icon-name: "preferences-color-symbolic";
        }
        
        Adw.ActionRow {
          title: _("Transaction Default Color");
          subtitle: _("A change in this setting will only be applied to newly added transactions.");
          activatable-widget: _transactionColorButton;
          
          [suffix]
          Gtk.ColorDialogButton _transactionColorButton {
            valign: center;
          }
        }

        Adw.ActionRow {
          title: _("Transfer Default Color");
          subtitle: _("A change in this setting will only be applied to new transfers.");
          activatable-widget: _transferColorButton;
          
          [suffix]
          Gtk.ColorDialogButton _transferColorButton {
            valign: center;
          }
        }

        Adw.ActionRow {
          title: _("Group Default Color");
          subtitle: _("A change in this setting will only be applied to new groups.");
          activatable-widget: _groupColorButton;
          
          [suffix]
          Gtk.ColorDialogButton _groupColorButton {
            valign: center;
          }
        }

        Adw.ActionRow {
          title: _("Checking Account Color");
          activatable-widget: _accountCheckingColorButton;
          
          [suffix]
          Gtk.ColorDialogButton _accountCheckingColorButton {
            valign: center;
          }
        }

        Adw.ActionRow {
          title: _("Savings Account Color");
          activatable-widget: _accountSavingsColorButton;
          
          [suffix]
          Gtk.ColorDialogButton _accountSavingsColorButton {
            valign: center;
          }
        }

        Adw.ActionRow {
          title: _("Business Account Color");
          activatable-widget: _accountBusinessColorButton;
          
          [suffix]
          Gtk.ColorDialogButton _accountBusinessColorButton {
            valign: center;
          }
        }
      }
    }

    Adw.PreferencesGroup {
      title: _("Locale");
      
      Adw.SwitchRow _nativeDigitsRow { 
        title: _("Use Native Digits");
        subtitle: _("Whether to use numerals that are native for your locale instead of latin digits.");

        [prefix]
        Gtk.Image {
          icon-name: "preferences-desktop-locale-symbolic";
        }
      }

      Adw.ComboRow _insertSeparatorRow {
        title: _("Insert Decimal Separator");
        subtitle: _("Set for which keys pressed will the locale's decimal separator be inserted into an amount field.");
        subtitle-lines: 3;
        model: Gtk.StringList {
          strings [C_("InsertSeparator", "Off"), _("Numpad period only"), _("Period and Comma")]
        };

        [prefix]
        Gtk.Image {
          icon-name: "input-keyboard-symbolic";
        }
      }
    }

    Adw.PreferencesGroup {
      title: _("Backup");

      Adw.EntryRow _csvBackupRow {
        title: _("CSV Backup Folder");
        tooltip-text: _("Unencrypted accounts will automatically export as CSV files to this folder when a change is made.");
        editable: false;

        [prefix]
        Gtk.Image {
          icon-name: "folder-download-symbolic";
        }

        [suffix]
        Gtk.Button _selectBackupFolderButton {
          valign: center;
          tooltip-text: _("Select Backup Folder");
          icon-name: "folder-open-symbolic";

          styles ["flat"]
        }

        [suffix]
        Gtk.Button _unsetBackupFolderButton {
          valign: center;
          icon-name: "larger-brush-symbolic";
          tooltip-text: _("Clear Backup Folder");

          styles ["flat"]
        }
      }
    }
  }
}