|
| 1 | +using Gtk 4.0; |
| 2 | +using Adw 1; |
| 3 | + |
| 4 | +Adw.Window { |
| 5 | + width-request: 360; |
| 6 | + height-request: 640; |
| 7 | + default-width: 640; |
| 8 | + default-height: 640; |
| 9 | + |
| 10 | + Adw.ToolbarView toolbar_view { |
| 11 | + extend-content-to-bottom-edge: bind extend_bottom.active; |
| 12 | + extend-content-to-top-edge: bind extend_top.active; |
| 13 | + top-bar-style: bind barstyle_select.selected; |
| 14 | + bottom-bar-style: bind barstyle_select.selected; |
| 15 | + reveal-top-bars: bind reveal_topbar.active; |
| 16 | + reveal-bottom-bars: bind reveal_bottombar.active; |
| 17 | + |
| 18 | + // In this demo we are using the API to set the header bars |
| 19 | + // you can use the [top] and [bottom] child types directly instead |
| 20 | + // [top] |
| 21 | + // Adw.HeaderBar { |
| 22 | + // title-widget: Adw.WindowTitle { |
| 23 | + // title: _("Header Bar"); |
| 24 | + // }; |
| 25 | + // } |
| 26 | + |
| 27 | + |
| 28 | + content: Adw.ViewStack stack { |
| 29 | + Adw.ViewStackPage page_defualt { |
| 30 | + name: "page_default"; |
| 31 | + title: _("Toolbar View"); |
| 32 | + icon-name: "toolbars-symbolic"; |
| 33 | + child: Adw.StatusPage{ |
| 34 | + Box { |
| 35 | + halign: center; |
| 36 | + orientation: vertical; |
| 37 | + spacing: 18; |
| 38 | + Label { |
| 39 | + label: _("Toolbar View"); |
| 40 | + styles ["title-1"] |
| 41 | + } |
| 42 | + Label { |
| 43 | + wrap: true; |
| 44 | + label: _("A widget containing a page, as well as top and/or bottom bars."); |
| 45 | + } |
| 46 | + LinkButton { |
| 47 | + label: _("API Reference"); |
| 48 | + uri: "https://gnome.pages.gitlab.gnome.org/libadwaita/doc/main/class.ToolbarView.html"; |
| 49 | + } |
| 50 | + ListBox list_box { |
| 51 | + styles ["boxed-list"] |
| 52 | + selection-mode: none; |
| 53 | + Adw.ComboRow topbar_select { |
| 54 | + title: _("Top bar"); |
| 55 | + model: StringList { |
| 56 | + strings [_("Header Bar"),_("Tab Bar"),_("View Switcher Bar"),_("Action Bar"),_("PopOverMenu Bar"),_("Search Bar"),_("Gtk Box")] |
| 57 | + }; |
| 58 | + selected: 0; |
| 59 | + } |
| 60 | + Adw.ComboRow bottombar_select { |
| 61 | + title: _("Bottom bar"); |
| 62 | + model: StringList { |
| 63 | + strings [_("Header Bar"),_("Tab Bar"),_("View Switcher Bar"),_("Action Bar"),_("PopOverMenu Bar"),_("Search Bar"),_("Gtk Box")] |
| 64 | + }; |
| 65 | + selected: 2; |
| 66 | + } |
| 67 | + Adw.ComboRow barstyle_select { |
| 68 | + title: _("Style"); |
| 69 | + model: StringList { |
| 70 | + strings [_("Flat"), _("Raised"), _("Raised-Border")] |
| 71 | + }; |
| 72 | + } |
| 73 | + Adw.SwitchRow reveal_topbar { |
| 74 | + title: _("Reveal Top Bar"); |
| 75 | + active: true; |
| 76 | + } |
| 77 | + Adw.SwitchRow reveal_bottombar { |
| 78 | + title: _("Reveal Bottom Bar"); |
| 79 | + active: true; |
| 80 | + } |
| 81 | + Adw.SwitchRow extend_top { |
| 82 | + title: _("Extend content behind top bar"); |
| 83 | + active: false; |
| 84 | + } |
| 85 | + Adw.SwitchRow extend_bottom { |
| 86 | + title: _("Extend content behind bottom bar"); |
| 87 | + active: false; |
| 88 | + } |
| 89 | + } |
| 90 | + } |
| 91 | + }; |
| 92 | + } |
| 93 | + |
| 94 | + Adw.ViewStackPage page1 { |
| 95 | + name: "page1"; |
| 96 | + title: _("Page 1"); |
| 97 | + icon-name: "explore2-symbolic"; |
| 98 | + use-underline: true; |
| 99 | + child: Adw.StatusPage{ |
| 100 | + title: _("Hello"); |
| 101 | + }; |
| 102 | + } |
| 103 | + |
| 104 | + Adw.ViewStackPage page2 { |
| 105 | + name: "page2"; |
| 106 | + title: _("Page 2"); |
| 107 | + icon-name: "explore2-symbolic"; |
| 108 | + use-underline: true; |
| 109 | + child: Adw.StatusPage { |
| 110 | + title: _("from"); |
| 111 | + }; |
| 112 | + } |
| 113 | + |
| 114 | + Adw.ViewStackPage page3 { |
| 115 | + name: "page3"; |
| 116 | + title: _("Page 3"); |
| 117 | + icon-name: "explore2-symbolic"; |
| 118 | + use-underline: true; |
| 119 | + child: Adw.StatusPage { |
| 120 | + title: _("Workbench"); |
| 121 | + }; |
| 122 | + } |
| 123 | + }; |
| 124 | + } |
| 125 | +} |
| 126 | + |
| 127 | +Adw.HeaderBar header_bar { |
| 128 | + title-widget: Adw.WindowTitle { |
| 129 | + title: _("Header Bar"); |
| 130 | + }; |
| 131 | +} |
| 132 | + |
| 133 | +ActionBar action_bar { |
| 134 | + revealed: true; |
| 135 | + valign: end; |
| 136 | + |
| 137 | + [start] |
| 138 | + Button start_widget { |
| 139 | + icon-name: "call-start-symbolic"; |
| 140 | + } |
| 141 | + |
| 142 | + [center] |
| 143 | + DropDown { |
| 144 | + model: StringList { |
| 145 | + strings ["Center Widget","👁️", "❤️", "💼", "🪑"] |
| 146 | + }; |
| 147 | + } |
| 148 | + |
| 149 | + [end] |
| 150 | + Button end_widget { |
| 151 | + icon-name: "padlock2-symbolic"; |
| 152 | + } |
| 153 | +} |
| 154 | + |
| 155 | +Adw.ViewSwitcherBar switcher_bar { |
| 156 | + stack: stack; |
| 157 | + reveal: true; |
| 158 | +} |
| 159 | + |
| 160 | +PopoverMenuBar popover { |
| 161 | + menu-model: menu_app; |
| 162 | +} |
| 163 | + |
| 164 | +menu menu_app { |
| 165 | + section { |
| 166 | + item { |
| 167 | + label: _("Keyboard Shortcuts"); |
| 168 | + action: "app.shortcuts"; |
| 169 | + } |
| 170 | + |
| 171 | + item { |
| 172 | + label: _("About Workbench"); |
| 173 | + action: "app.about"; |
| 174 | + } |
| 175 | + } |
| 176 | +} |
| 177 | + |
| 178 | +SearchBar search_bar { |
| 179 | + search-mode-enabled: true; |
| 180 | + show-close-button: true; |
| 181 | + SearchEntry { |
| 182 | + placeholder-text: _("Start Searching…"); |
| 183 | + } |
| 184 | +} |
| 185 | + |
| 186 | +Box gtk_box { |
| 187 | + name: "gtk_box"; |
| 188 | + halign: fill; |
| 189 | + height-request: 20; |
| 190 | +} |
| 191 | + |
| 192 | +Adw.TabBar tab_bar { |
| 193 | + view: tab_view; |
| 194 | +} |
| 195 | + |
| 196 | +Adw.TabView tab_view { |
| 197 | + Adw.TabPage main_tab_page { |
| 198 | + title: _("First Page"); |
| 199 | + child: Adw.StatusPage { |
| 200 | + hexpand: true; |
| 201 | + vexpand: true; |
| 202 | + title: _("Tab View"); |
| 203 | + description: _("A dynamic tabbed container"); |
| 204 | + }; |
| 205 | + } |
| 206 | + |
| 207 | + Adw.TabPage main_tab_page2 { |
| 208 | + title: _("Second Page"); |
| 209 | + child: Adw.StatusPage { |
| 210 | + hexpand: true; |
| 211 | + vexpand: true; |
| 212 | + title: _("Tab View"); |
| 213 | + description: _("A dynamic tabbed container"); |
| 214 | + }; |
| 215 | + } |
| 216 | +} |
0 commit comments