Gtk2 tree select
GTK window program119 lines of .st253 lines of generated Cbuilds as C and Rust
The selected row contains the text Option 1 The selected row contains the text Option 2
On this page
The .st files#
intent.st
structop {
type_app {
exec = {
lang = "C"
}
}
lib_provider {
core = {
source = "StructOp/core"
version = "@latest"
}
Gui = {
source = {
C = "StructOp/gtk2"
Rust = "StructOp/gtk-rs"
}
version = "@latest"
}
}
}main.st
ability "value" "icon" {
type = Icon
}
data "value" "icon" {
of = ability.value.icon
}
ability "app" "Gui" {
body = [ability.load_icon.Ok, ability.list_store.Options, ability.window.Main, ability.add_row.One, ability.add_row.Two, ability.add_row.Three, ability.select_row.First, ability.select_row.Second]
exit_after = 500
}
ability "load_icon" "Ok" {
name = "dialog-ok-apply"
size = 32
target = ability.value.icon
}
ability "list_store" "Options" {
columns = [String, Icon]
}
ability "add_row" "One" {
store = ability.list_store.Options
values = ["Option 1", data.value.icon.current]
}
ability "add_row" "Two" {
store = ability.list_store.Options
values = ["Option 2", data.value.icon.current]
}
ability "add_row" "Three" {
store = ability.list_store.Options
values = ["Option 3", data.value.icon.current]
}
ability "window" "Main" {
children = [ability.table.Grid]
on_close = [ability.quit.Closed]
}
ability "table" "Grid" {
rows = 2
columns = 2
children = [ability.tree_view.Table, ability.button.Close]
}
ability "tree_view" "Table" {
model = ability.list_store.Options
columns = [ability.view_column.Icon, ability.view_column.Option]
cell = [0, 2, 0, 1]
on_select = [ability.print.Row]
}
ability "view_column" "Icon" {
title = "Icon"
show = 1
draws = image
}
ability "view_column" "Option" {
title = "Option"
show = 0
draws = text
}
ability "button" "Close" {
label = "Close window"
cell = [0, 1, 1, 2]
on_click = [ability.quit.Done]
}
data "selected" "Read" {
widget = ability.tree_view.Table
column = 0
}
ability "print" "Row" {
message = "The selected row contains the text ${data.selected.Read.row}"
}
ability "select_row" "First" {
widget = ability.tree_view.Table
index = 0
}
ability "select_row" "Second" {
widget = ability.tree_view.Table
index = 1
}
ability "quit" "Done" {
}
ability "quit" "Closed" {
}Input, plan and generated C#
structop plan
structop plan
# program.app will be created
+ program.app (.structop/build/app)
+ ability.value.icon
+ ability.app.Gui
+ ability.load_icon.Ok
+ ability.list_store.Options
+ ability.window.Main
+ ability.add_row.One
+ ability.add_row.Two
+ ability.add_row.Three
+ ability.table.Grid
+ ability.tree_view.Table
+ ability.view_column.Icon
+ ability.view_column.Option
+ ability.button.Close
+ ability.print.Row
+ ability.select_row.First
+ ability.select_row.Second
+ ability.quit.Done
+ ability.quit.Closed
Plan: 1 to add, 0 to change, 0 to destroy.Generated main.c
To inspect this generated file, select C in intent.st, initialize the project and export its source.
Export locally
structop init
structop apply -source -no-runGenerated main.rs (the same .st built as Rust)
To inspect this generated file, select Rust in intent.st, initialize the project and export its source.
Export locally
structop init
structop apply -source -no-runTry it
cd gtk2-tree-select # a folder holding the .st files above
structop init
structop plan
structop apply