aboutsummaryrefslogtreecommitdiff
path: root/vendor/libghostty-vt/src/apprt/gtk/ui/1.5/command-palette.blp
blob: 473fb1f06dcdd3711e6aef84f169ca2f942d1bf7 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
using Gtk 4.0;
using Gio 2.0;
using Adw 1;

Adw.Dialog dialog {
  content-width: 700;
  closed => $closed();

  Adw.ToolbarView {
    top-bar-style: flat;

    [top]
    Adw.HeaderBar {
      [title]
      Gtk.SearchEntry search {
        hexpand: true;
        placeholder-text: _("Execute a command…");
        stop-search => $search_stopped();
        activate => $search_activated();

        styles [
          "command-palette-search",
        ]
      }
    }

    Gtk.ScrolledWindow {
      min-content-height: 300;

      Gtk.ListView view {
        show-separators: true;
        single-click-activate: true;
        activate => $row_activated();

        model: Gtk.SingleSelection model {
          model: Gtk.FilterListModel {
            incremental: true;

            filter: Gtk.AnyFilter {
              Gtk.StringFilter {
                expression: expr item as <$GhosttyCommand>.title;
                search: bind search.text;
              }

              Gtk.StringFilter {
                expression: expr item as <$GhosttyCommand>.action-key;
                search: bind search.text;
              }
            };

            model: Gio.ListStore source {
              item-type: typeof<$GhosttyCommand>;
            };
          };
        };

        styles [
          "rich-list",
        ]

        factory: Gtk.BuilderListItemFactory {
          template Gtk.ListItem {
            child: Gtk.Box {
              orientation: horizontal;
              spacing: 10;
              tooltip-text: bind template.item as <$GhosttyCommand>.description;

              Gtk.Box {
                orientation: vertical;
                hexpand: true;

                Gtk.Label {
                  ellipsize: end;
                  halign: start;
                  wrap: false;
                  single-line-mode: true;

                  styles [
                    "title",
                  ]

                  label: bind template.item as <$GhosttyCommand>.title;
                }

                Gtk.Label {
                  ellipsize: end;
                  halign: start;
                  wrap: false;
                  single-line-mode: true;

                  styles [
                    "subtitle",
                    "monospace",
                  ]

                  label: bind template.item as <$GhosttyCommand>.action-key;
                }
              }

              Gtk.ShortcutLabel {
                accelerator: bind template.item as <$GhosttyCommand>.action;
                valign: center;
              }
            };
          }
        };
      }
    }
  }
}