Gtk2 table
GTK window program95 lines of .st229 lines of generated Cbuilds as C and Rust
Button pressed 1 times Button pressed 2 times Button pressed 3 times
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" "count" {
type = Int
initial = 0
}
data "value" "count" {
of = ability.value.count
}
ability "app" "Gui" {
body = [ability.window.Main, ability.click.One, ability.click.Two, ability.click.Three]
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.Count, ability.button.Close]
}
ability "label" "Text" {
text = "My label"
cell = [0, 1, 0, 1]
}
ability "button" "Count" {
label = "Count button"
cell = [1, 2, 0, 1]
on_click = [ability.set.Add, ability.set_text.Show, ability.print.Count]
}
ability "button" "Close" {
label = "Close window"
cell = [0, 2, 1, 2]
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 "print" "Count" {
message = "Button pressed ${data.value.count.current} times"
}
ability "click" "One" {
widget = ability.button.Count
}
ability "click" "Two" {
widget = ability.button.Count
}
ability "click" "Three" {
widget = ability.button.Count
}
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.table.Grid
+ ability.label.Text
+ ability.button.Count
+ ability.button.Close
+ ability.set.Add
+ ability.set_text.Show
+ ability.print.Count
+ ability.click.One
+ ability.click.Two
+ ability.click.Three
+ 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-table # a folder holding the .st files above
structop init
structop plan
structop apply