Skip to content
Snippets Groups Projects
window.blp 2.6 KiB
Newer Older
Bruce Cowan's avatar
Bruce Cowan committed
// SPDX-FileCopyrightText: 2022-2024 Bruce Cowan <bruce@bcowan.me.uk>
Bruce Cowan's avatar
Bruce Cowan committed
//
// SPDX-License-Identifier: GPL-3.0-or-later

using Gtk 4.0;
using Adw 1;

Bruce Cowan's avatar
Bruce Cowan committed
template $RugbyAppWindow : Adw.ApplicationWindow {
Bruce Cowan's avatar
Bruce Cowan committed
  title: "Rugby";
Bruce Cowan's avatar
Bruce Cowan committed
  width-request: 360;
  height-request: 294;
Bruce Cowan's avatar
Bruce Cowan committed

Bruce Cowan's avatar
Bruce Cowan committed
  Adw.ToolbarView {
    [top]
    Adw.HeaderBar {
      SpinButton scorespin {
        adjustment: Adjustment {
          step-increment: 1;
          upper: 200;
        };
        focusable: true;
        tooltip-text: "Score";
      }
Bruce Cowan's avatar
Bruce Cowan committed

        direction: none;
        menu-model: app_menu;
Bruce Cowan's avatar
Bruce Cowan committed
        tooltip-text: "Main Menu (F10)";
Bruce Cowan's avatar
Bruce Cowan committed
    }

Bruce Cowan's avatar
Bruce Cowan committed
    content: Box {
      orientation: vertical;

      Stack stack {
Bruce Cowan's avatar
Bruce Cowan committed
        StackPage {
          name: "empty_page";
          child: Adw.StatusPage {
            icon-name: "list";
            title: "No possibilities";
          };
        }
Bruce Cowan's avatar
Bruce Cowan committed
        StackPage {
          name: "list_page";
          child: ScrolledWindow {
            vexpand: true;
Bruce Cowan's avatar
Bruce Cowan committed
            Adw.Clamp {
              maximum-size: 600;
              tightening-threshold: 400;
Bruce Cowan's avatar
Bruce Cowan committed
              ListView listview {
                factory: BuilderListItemFactory {
                  template ListItem {
                    child: $RugbyPossibilityWidget {
                      possibility: bind template.item;
                      tooltip-text: bind $item_tooltip_cb(template.item) as <string>;
                    };
                  }
Bruce Cowan's avatar
Bruce Cowan committed
                };
                header-factory: BuilderListItemFactory {
                  template ListHeader {
                    child: Label {
                      label: bind $header_label_cb(template.item) as <string>;
                      halign: start;
Bruce Cowan's avatar
Bruce Cowan committed
                    };
                  }
                };
                model: NoSelection {
                  model: $RugbyListStore list_store {
                    score: bind scorespin.value;
Bruce Cowan's avatar
Bruce Cowan committed

                    items-changed => $list_store_items_changed_cb();
Bruce Cowan's avatar
Bruce Cowan committed
                  };
Bruce Cowan's avatar
Bruce Cowan committed
                };

                styles ["rich-list", "card"]
Bruce Cowan's avatar
Bruce Cowan committed
      }
Bruce Cowan's avatar
Bruce Cowan committed
    };
Bruce Cowan's avatar
Bruce Cowan committed
  }

  ShortcutController {
    scope: local;

    Shortcut {
      action: "action(win.score-changed)";
      arguments: "'up'";
      trigger: "<Ctrl>Up|<Ctrl>Right";
    }
    Shortcut {
      action: "action(win.score-changed)";
      arguments: "'down'";
      trigger: "<Ctrl>Down|<Ctrl>Left";
    }
  }
Bruce Cowan's avatar
Bruce Cowan committed
}

menu app_menu {
  section {
    item ("_Preferences", "app.prefs")
Bruce Cowan's avatar
Bruce Cowan committed
    item ("_Keyboard Shortcuts", "win.show-help-overlay")
Bruce Cowan's avatar
Bruce Cowan committed
    item ("_About Rugby", "app.about")
  }
}