🏡 index : quine-global-labs/bazaar.git

using Gtk 4.0;
using Adw 1;

template $BzPreferencesDialog: Adw.PreferencesDialog {
  content-height: 500;
  search-enabled: true;
  width-request: 350;
  height-request: 100;

  Adw.Breakpoint {
    condition ("max-width: 625sp")

    setters {
      flag_buttons_box.max-children-per-line: 6;
    }
  }

  Adw.PreferencesPage {
    title: _("Preferences");
    use-underline: true;

    banner: Adw.Banner {
      sensitive: bind $invert_boolean(template.state as <$BzStateInfo>.syncing as <bool>) as <bool>;
      revealed: bind template.state as <$BzStateInfo>.metered_connection as <bool>;
      title: _("Network connection is metered — automatic store data refresh is paused");
      button-label: _("Refresh Manually");
      action-name: "app.sync-remotes";
    };

    Adw.PreferencesGroup auto_updates_group {
      title: _("App Updates");
      visible: bind try {$logical_or($invert_boolean(template.state as <$BzStateInfo>.main-config as <$BzMainConfig>.hide-auto-update-options) as <bool>, automatic_updates_check.active), true};
      description: _ ("Auto-updates will pause on metered networks or when power saving is on to save data and battery.");

      Adw.ActionRow automatic_updates_row {
        title: _("_Automatic");
        subtitle: _("Automatically check for and download app updates");
        use-underline: true;
        activatable-widget: automatic_updates_check;

        [prefix]
        CheckButton automatic_updates_check {
          valign: center;
          toggled => $auto_updates_toggled_cb();
        }
      }

      Adw.ActionRow manual_updates_row {
        title: _("_Manual");
        subtitle: _("Checking for and downloading app updates must be done manually");
        use-underline: true;
        activatable-widget: manual_updates_check;

        [prefix]
        CheckButton manual_updates_check {
          valign: center;
          active: bind automatic_updates_check.active inverted;
          group: automatic_updates_check;
          toggled => $auto_updates_toggled_cb();
        }
      }
    }

    Adw.PreferencesGroup {
      visible: bind auto_updates_group.visible;

      Adw.SwitchRow auto_notif_switch {
        use-underline: true;
        title: _("Automatic Update _Notifications");
        subtitle: _("Notify when updates have been automatically installed");
      }
    }

    Adw.PreferencesGroup {
      title: _("Content Filters");

      Adw.SwitchRow only_foss_switch {
        title: _("_Free Software Only");
        subtitle: _("Hide proprietary apps when browsing and searching");
        use-underline: true;
      }

      Adw.SwitchRow only_flathub_switch {
        title: _("F_lathub Results Only");
        subtitle: _("Limit search and browse results to apps only available on Flathub");
        use-underline: true;
      }

      Adw.SwitchRow only_verified_switch {
        title: _("_Verified Results Only");
        subtitle: _("Hide results that are not verified on Flathub");
        use-underline: true;
      }

      Adw.SwitchRow hide_eol_switch {
        title: _("Hide _End-of-Life Apps");
        subtitle: _("Hide apps which are no longer supported by their developers");
        use-underline: true;
      }
    }

    Adw.PreferencesGroup {
      title: _("Progress Bar Theme");

      Adw.ActionRow {
        child: Box {
          margin-top: 6;
          margin-bottom: 6;
          halign: center;

          FlowBox flag_buttons_box {
            styles [
              "accent-button-box",
            ]

            orientation: horizontal;
            column-spacing: 4;
            row-spacing: 4;
            halign: center;
            homogeneous: true;
            max-children-per-line: 11;
            selection-mode: none;
          }
        };
      }
    }
  }
}