Counter
GTK window program72 lines of .st219 lines of generated C

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 "value" "count" {
type = Int
initial = 0
}
data "value" "count" {
of = ability.value.count
}
ability "app" "Gui" {
body = [ability.window.Main]
exit_after = 500
}
ability "window" "Main" {
children = [ability.box.Column]
on_close = [ability.quit.Closed]
}
ability "box" "Column" {
direction = vertical
spacing = 5
children = [ability.button.Count, ability.label.Text, ability.button.Close]
}
ability "button" "Count" {
label = "Count button"
on_click = [ability.set.Add, ability.set_text.Show]
}
ability "label" "Text" {
text = "My label"
}
ability "button" "Close" {
label = "Close window"
on_click = [ability.quit.Done]
}
ability "set" "Add" {
target = ability.value.count
value = data.value.count.current + 1
}
ability "set_text" "Show" {
widget = ability.label.Text
text = "Button pressed ${data.value.count.current} times"
}
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.count
+ ability.app.Gui
+ ability.window.Main
+ ability.box.Column
+ ability.button.Count
+ ability.label.Text
+ ability.button.Close
+ ability.set.Add
+ ability.set_text.Show
+ 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-counter # a folder holding the .st files above
structop init
structop plan
structop apply