Spin
GTK window program86 lines of .st240 lines of generated C

Text 3, value 3
On this page
The .st files#
intent.st
structop {
type_app {
exec = {
lang = "C"
}
}
lib_provider {
core = {
source = "StructOp/core"
version = "@latest"
}
Gui = {
source = "StructOp/gui"
version = "@latest"
}
}
}main.st
ability "app" "Gui" {
body = [ability.window.Main, ability.click.Press]
exit_after = 500
}
ability "window" "Main" {
children = [ability.table.Grid]
on_close = [ability.quit.Closed]
}
ability "table" "Grid" {
rows = 2
columns = 2
homogeneous = true
children = [ability.label.Text, ability.button.Copy, ability.button.Close, ability.spin.Num]
}
ability "label" "Text" {
text = "My label"
cell = [0, 1, 0, 1]
}
ability "button" "Copy" {
label = "Copy button"
cell = [1, 2, 0, 1]
on_click = [ability.set_text.Show, ability.print.Copied]
}
ability "button" "Close" {
label = "Close window"
cell = [0, 1, 1, 2]
on_click = [ability.quit.Done]
}
ability "spin" "Num" {
value = 3
min = -10
max = 10
step = 1
cell = [1, 2, 1, 2]
}
data "text" "Read" {
widget = ability.spin.Num
}
ability "set_text" "Show" {
widget = ability.label.Text
text = "${data.text.Read.text}"
}
data "number" "Value" {
widget = ability.spin.Num
}
ability "print" "Copied" {
message = "Text ${data.text.Read.text}, value ${data.number.Value.value}"
}
ability "click" "Press" {
widget = ability.button.Copy
}
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.app.Gui
+ ability.window.Main
+ ability.table.Grid
+ ability.label.Text
+ ability.button.Copy
+ ability.button.Close
+ ability.spin.Num
+ ability.set_text.Show
+ ability.print.Copied
+ ability.click.Press
+ 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-runTry it
cd c-spin # a folder holding the .st files above
structop init
structop plan
structop apply