MODULE adw_widgets ; (* m2-GTK4 example - a showcase of the GNOME (libadwaita) widgets bound in this slice: AdwApplicationWindow > AdwToolbarView top bar - AdwHeaderBar with an AdwViewSwitcherTitle content - GtkBox > AdwBanner AdwSqueezer (two labels; shows the one that fits) AdwWrapBox (wrapping labels) AdwViewStack > page "Home" - AdwAvatar > page "About" - AdwSpinner + button with AdwButtonContent Build: make examples Run: ./build/examples/adw_widgets *) FROM Gio IMPORT g_application_run; FROM AdwApplication IMPORT adw_application_new; FROM AdwApplicationWindow IMPORT adw_application_window_new, adw_application_window_set_content; FROM AdwHeaderBar IMPORT adw_header_bar_new, adw_header_bar_set_title_widget; FROM AdwToolbarView IMPORT adw_toolbar_view_new, adw_toolbar_view_add_top_bar, adw_toolbar_view_set_content; FROM AdwViewSwitcherTitle IMPORT adw_view_switcher_title_new, adw_view_switcher_title_set_title, adw_view_switcher_title_set_subtitle, adw_view_switcher_title_set_stack; FROM AdwViewStack IMPORT adw_view_stack_new, adw_view_stack_add_titled, adw_view_stack_add_titled_with_icon; FROM AdwBanner IMPORT adw_banner_new, adw_banner_set_revealed; FROM AdwSqueezer IMPORT adw_squeezer_new, adw_squeezer_add; FROM AdwWrapBox IMPORT adw_wrap_box_new, adw_wrap_box_append; FROM AdwAvatar IMPORT adw_avatar_new; FROM AdwSpinner IMPORT adw_spinner_new; FROM AdwButtonContent IMPORT adw_button_content_new, adw_button_content_set_label, adw_button_content_set_icon_name; FROM GtkWindow IMPORT gtk_window_present, gtk_window_set_default_size; FROM GtkBox IMPORT gtk_box_new, gtk_box_append, gtk_box_set_spacing; FROM GtkButton IMPORT gtk_button_new, gtk_button_set_child; FROM GtkLabel IMPORT gtk_label_new; FROM GtkEnums IMPORT GtkVertical; FROM GtkClosures IMPORT Connect2; FROM SYSTEM IMPORT ADDRESS; FROM libc IMPORT printf; CONST AppId = "org.example.m2gtk4.AdwWidgets"; PROCEDURE OnActivate (application: ADDRESS; data: ADDRESS); VAR window, toolbar, header, switcherTitle, stack, home, about: ADDRESS; box, banner, squeezer, wrap, avatar, spinner, button: ADDRESS; content: ADDRESS; BEGIN window := adw_application_window_new(application); gtk_window_set_default_size(window, 420, 420); stack := adw_view_stack_new(); (* page: Home *) home := gtk_box_new(GtkVertical, 18); gtk_box_set_spacing(home, 18); avatar := adw_avatar_new(64, "Eric", 1); gtk_box_append(home, avatar); gtk_box_append(home, gtk_label_new("Welcome to the GNOME widgets demo.")); content := adw_view_stack_add_titled(stack, home, "home", "Home"); (* page: About *) about := gtk_box_new(GtkVertical, 18); gtk_box_set_spacing(about, 18); spinner := adw_spinner_new(); gtk_box_append(about, spinner); button := gtk_button_new(); content := adw_button_content_new(); adw_button_content_set_icon_name(content, "emblem-system-symbolic"); adw_button_content_set_label(content, "Preferences"); gtk_button_set_child(button, content); gtk_box_append(about, button); content := adw_view_stack_add_titled_with_icon(stack, about, "about", "About", "help-about-symbolic"); (* title that becomes a switcher when the window is wide *) switcherTitle := adw_view_switcher_title_new(); adw_view_switcher_title_set_title(switcherTitle, "m2-GTK4"); adw_view_switcher_title_set_subtitle(switcherTitle, "GNOME widgets"); adw_view_switcher_title_set_stack(switcherTitle, stack); header := adw_header_bar_new(); adw_header_bar_set_title_widget(header, switcherTitle); toolbar := adw_toolbar_view_new(); adw_toolbar_view_add_top_bar(toolbar, header); (* content: banner + squeezer + wrapbox + the stack *) box := gtk_box_new(GtkVertical, 12); gtk_box_set_spacing(box, 12); banner := adw_banner_new("This is an AdwBanner"); adw_banner_set_revealed(banner, 1); gtk_box_append(box, banner); squeezer := adw_squeezer_new(); content := adw_squeezer_add(squeezer, gtk_label_new("Wide layout")); content := adw_squeezer_add(squeezer, gtk_label_new("Narrow")); gtk_box_append(box, squeezer); wrap := adw_wrap_box_new(); adw_wrap_box_append(wrap, gtk_label_new("one")); adw_wrap_box_append(wrap, gtk_label_new("two")); adw_wrap_box_append(wrap, gtk_label_new("three")); adw_wrap_box_append(wrap, gtk_label_new("four")); gtk_box_append(box, wrap); gtk_box_append(box, stack); adw_toolbar_view_set_content(toolbar, box); adw_application_window_set_content(window, toolbar); gtk_window_present(window) END OnActivate; VAR app: ADDRESS; BEGIN app := adw_application_new(AppId, 0); IF app = NIL THEN printf("adw_application_new failed\n"); HALT(1) END; Connect2(app, "activate", OnActivate, NIL); g_application_run(app, 0, NIL) END adw_widgets.