Create a Window
Replace the starter counter with the Notes window: an Adwaita window with a header bar and an empty state.
The project
Project structure describes the project's files.
The scaffold's starter test, tests/app.test.tsx, looks for the counter's Increment button and imports a default export that the new src/app.tsx doesn't have, so npm run typecheck would fail. Delete it; Test the App writes the app's tests.
rm tests/app.test.tsxMark strings for translation
Install @gtkx/i18n:
npm install @gtkx/i18nUntil Translate the App adds catalogs, every t("…") shows its source text. Pass t a string literal, as every chapter does, so that GTKX can extract the message; Keep messages extractable lists the forms it reads.
The application window
Replace src/app.tsx:
import { useTranslation } from "@gtkx/i18n";
import {
AdwApplication,
AdwApplicationWindow,
AdwHeaderBar,
AdwStatusPage,
AdwToolbarView,
} from "@gtkx/jsx/adw";
import { quit } from "@gtkx/react";
export const App = () => {
const { t } = useTranslation();
return (
<AdwApplication>
<AdwApplicationWindow
title={t("Notes")}
widthRequest={360}
heightRequest={294}
onCloseRequest={quit}
>
<AdwToolbarView top={<AdwHeaderBar />}>
<AdwStatusPage
iconName="document-new-symbolic"
title={t("No Notes")}
description={t(
"Notes are Markdown files in your notes folder",
)}
/>
</AdwToolbarView>
</AdwApplicationWindow>
</AdwApplication>
);
};Elements come from @gtkx/jsx/<namespace>, one module per library, and take the native class's properties and signals as camelCase props; JSX Elements has the rules.
AdwApplicationcreates the application with the ID fromgtkx.config.tsand renders its children once it activates.AdwApplicationWindowis the main window.widthRequestandheightRequestset the smallest size it shrinks to, 360 by 294, the size the GNOME HIG asks phone-friendly apps to support.quit()from@gtkx/reactunmounts the app and quits when the window closes.AdwToolbarViewplaces bars around its content. Itstopslot holds anAdwHeaderBar, which shows the window title and the close button.AdwStatusPageis the empty state, a placeholder page with a symbolic icon, a title and a description.
Run it
Save src/app.tsx. Its imports changed, so gtkx dev restarts the app instead of refreshing it, and the window shows the empty state.


src/app.tsx above.Run npm run typecheck. It passes once the starter test is gone.