AGtk 0.1.1
See the version list below for details.
dotnet add package AGtk --version 0.1.1
NuGet\Install-Package AGtk -Version 0.1.1
<PackageReference Include="AGtk" Version="0.1.1" />
<PackageVersion Include="AGtk" Version="0.1.1" />
<PackageReference Include="AGtk" />
paket add AGtk --version 0.1.1
#r "nuget: AGtk, 0.1.1"
#addin nuget:?package=AGtk&version=0.1.1
#tool nuget:?package=AGtk&version=0.1.1
AGtk
AGtk is a library of helper classes for GTK 4 in C#. Well, actually at the moment there's only one helper class: AGtk.ColView. But perhaps I'll add more in the future.
AGtk.ColView
AGtk.ColView is a subclass of the Gtk.ColumnView class, which displays a multi-column list. Gtk.ColumnView has a complicated API, so AGtk.ColView exists to make it much easier to use. Here's a brief code sample to show how easy it is:
AGtk.ColView col_view = new(["year", "title", "director"]);
col_view.Add([1981, "Raiders of the Lost Ark", "Steven Spielberg"]);
col_view.Add([1994, "The Shawshank Redemption", "Frank Darabont"]);
col_view.Add([1995, "Clueless", "Amy Heckerling"]);
...
my_window.Child = col_view;
That will produce a column view that looks like this:
Adding filtering
AGtk.ColView supports dynamic filtering. Typically you'll use this with a search box: as the user types in the box, rows will be filtered. Here's how to do this in code:
// specify the column to use for filtering
col_view.FilterColumn = 1; // title
SearchEntry entry = new();
entry.OnSearchChanged += on_search_changed;
...
void on_search_changed(SearchEntry sender, EventArgs args) {
col_view.FilterText = entry.GetText();
}
A larger example
My page Introduction to GTK 4 in C# contains a complete example of a program using AGtk.ColView.
Sorting
It would be nice if the user could click a column header to sort by that column. Unfortunately that's not yet possible due to limitations in the Gir.Core binding for GTK 4. I hope I'll be able to work with the Gir.Core developers to improve this situation before long.
Using the library
Perhaps I'll publish a nuget package at some point, but this is an early work in progress so I haven't done that yet. In the meantime, you can clone this repository to your machine, then use the dotnet add reference
command to add a reference to agtk.csproj in your project:
$ dotnet add reference /path/to/agtk.csproj
API reference
All members listed below are public.
ColView
<dl> <dt><code>ColView(params string[] names)</code></dt> <dd>Create a ColView with the given column names.</dd> <dt><code>void Add(params object[] values)</code></dt> <dd>Append a row of values to the view.</dd> <dt><code>void Clear()</code></dt> <dd>Remove all rows from the view.</dd> <dt><code>int? FilterColumn {get; set; }</code></dt> <dd>The index of the column used for filtering.</dd> <dt><code>string FilterText {get; set; }</code></dt> <dd>The text to use for filtering. Only rows whose filter column contains this text will be shown. If the value is "", all rows will be displayed.</dd> <dt><code>RowList Rows {get;}</code></dt> <dd>A list of rows in this ColView.</dd> <dt><code>uint SelectedIndex {get;}</code></dt> <dd>The index of the row that is currently selected.</dd> <dt><code>event SelectionChanged? OnSelectionChanged</code></dt> <dd>An event that fires whenever the selection changes.</dd> </dl>
Row
A row in the column view.
<dl> <dt><code>object[] Values { get; }</code></dt> <dd>An array of values in the row.</dd> </dl>
RowList
A list of rows.
<dl> <dt><code>Row this[uint i] { get; }</code></dt> <dd>An indexer to retrieve a Row.</dd> </dl>
SelectedChanged
<dl> <dt><code>delegate void SelectionChanged(uint rowIndex)</code></dt> <dd>A delegate type for a selection change event. rowIndex will contain the currently selected row.</dd> </dl>
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- GirCore.GObject-2.0.Integration (>= 0.6.2)
- GirCore.GTK-4.0 (>= 0.6.2)
-
net9.0
- GirCore.GObject-2.0.Integration (>= 0.6.2)
- GirCore.GTK-4.0 (>= 0.6.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.