pasgtk4
- Archived · last change 8-24-2026
- ★ 3 on GitHub
README
PasGTK4
Modern Pascal bindings for GTK4 with LibAdwaita support.
Deprecated: This project is no longer maintained. Use pasgobject instead.
Requirements
Linux
sudo apt install libgtk-4-dev libadwaita-1-devArch Linux
sudo pacman -S gtk4 libadwaitaOr install directly from AUR:
yay -S pasgtk4-gitPackage: https://aur.archlinux.org/packages/pasgtk4-git
Quick Start
1. Clone the repository
git clone https://github.com/AnmiTaliDev/pasgtk4.git
cd pasgtk42. Compile and run examples
meson setup builddir
meson compile -C builddir
# Run with LibAdwaita
./example/example_main --adwaitaBasic Usage
program simple_app;
uses
SysUtils, main, wrapper;
var
app: TModernExampleApp;
begin
// Initialize PasGTK4
if not InitializePasGTK4 then
Halt(1);
// Create and run modern application
app := TModernExampleApp.Create;
try
app.Run;
finally
app.Free;
end;
// Cleanup
FinalizePasGTK4;
end.API Overview
High-Level Classes
- TGTKApplication: Base application class
- TGTKSimpleWindow: Window with vertical/horizontal layout
- TGTKGridWindow: Window with grid layout
- TGTKModernWindow: Modern GTK4 window with HeaderBar and PopoverMenu (recommended)
- TGTKMenuWindow: Compatibility mode window with traditional menus
Core Functions
InitializePasGTK4(): Initialize GTK4 onlyInitializePasGTK4WithAdwaita(): Initialize GTK4 + LibAdwaitaFinalizePasGTK4(): Cleanup resources
Widget Creation
// Create widgets
button := TPasGTK4.CreateButton('Click me');
label := TPasGTK4.CreateLabel('Hello World');
entry := TPasGTK4.CreateEntry;
// Set properties
TPasGTK4.SetEntryText(entry, 'Initial text');
TPasGTK4.SetLabelText(label, 'New text');
// Connect signals
TPasGTK4.ConnectSignal(PGtkWidget(button), 'clicked', @callback, data);Examples
The example application supports three modes:
1. Modern GTK4
./example/example_mainFeatures modern HeaderBar with PopoverMenu and GAction system.
2. LibAdwaita
./example/example_main --adwaitaNative GNOME design with LibAdwaita widgets.
3. Compatibility Mode
./example/example_main --compatShows traditional GTK3-style menu compatibility.
Basic Window Code Example
type
TMyApp = class(TGTKSimpleWindow)
public
constructor Create;
procedure SetupWindow; override;
end;
constructor TMyApp.Create;
begin
inherited Create('com.example.myapp');
Title := 'My Application';
Width := 400;
Height := 300;
end;
procedure TMyApp.SetupWindow;
begin
inherited SetupWindow;
AddLabel('Welcome to PasGTK4!');
AddButton('Click Me', @ButtonCallback, Self);
end;LibAdwaita Features
- Modern header bars
- Toast notifications
- Adaptive layouts
- System theme integration
Debug Mode
Enable debug output during compilation:
fpc -dDEBUG -Fu./src example/example_main.pasContributing
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
License
Licensed under the GNU Lesser General Public License v3.0. See LICENSE.md file for details.
Author
AnmiTaliDev - 2025

