Modern Pascal bindings for GTK4 with LibAdwaita support.
- GTK4 Support: Complete bindings for GTK4 widgets and functionality
- LibAdwaita Integration: Modern GNOME design with Adwaita components
- Memory Safety: Comprehensive error handling and nil checks
- Cross-Platform: Works on Linux, Windows, and macOS
- Object-Oriented: Clean Pascal classes wrapping GTK4 functionality
- Conditional Debug: Debug output controlled by compiler flags
sudo apt install libgtk-4-dev libadwaita-1-devsudo pacman -S gtk4 libadwaitaOr install directly from AUR:
yay -S pasgtk4-gitPackage: https://aur.archlinux.org/packages/pasgtk4-git
git clone https://github.com/AnmiTaliDev/pasgtk4.git
cd pasgtk4meson setup builddir
meson compile -C builddir
# Run with LibAdwaita
./example/example_main --adwaitapasgtk4/
src/
wrapper.pas # Low-level GTK4 bindings
main.pas # High-level Pascal classes
example/
example_main.pas # Basic example application
README.md
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.- 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
InitializePasGTK4(): Initialize GTK4 onlyInitializePasGTK4WithAdwaita(): Initialize GTK4 + LibAdwaitaFinalizePasGTK4(): Cleanup resources
// 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);The example application supports three modes:
./example/example_mainFeatures modern HeaderBar with PopoverMenu and GAction system.
./example/example_main --adwaita Native GNOME design with LibAdwaita widgets.
./example/example_main --compatShows traditional GTK3-style menu compatibility.
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;- Modern header bars
- Toast notifications
- Adaptive layouts
- System theme integration
Enable debug output during compilation:
fpc -dDEBUG -Fu./src example/example_main.pas- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
Licensed under the GNU Lesser General Public License v3.0. See LICENSE.md file for details.
AnmiTaliDev - 2025