Combo store
GTK window program96 lines of .st254 lines of generated C

The value of the combo is 2 Option 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.list_store.Options, ability.add_row.R1, ability.add_row.R2, ability.add_row.R3, ability.window.Main, ability.select.Pick]
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.Close, ability.combo.Choice]
}
ability "label" "Text" {
text = "My label"
cell = [0, 2, 0, 1]
}
ability "button" "Close" {
label = "Close window"
cell = [0, 1, 1, 2]
on_click = [ability.quit.Done]
}
ability "list_store" "Options" {
columns = [String]
}
ability "add_row" "R1" {
store = ability.list_store.Options
values = ["Option 1"]
}
ability "add_row" "R2" {
store = ability.list_store.Options
values = ["Option 2"]
}
ability "add_row" "R3" {
store = ability.list_store.Options
values = ["Option 3"]
}
ability "combo" "Choice" {
model = ability.list_store.Options
show = 0
active = 0
cell = [1, 2, 1, 2]
on_change = [ability.print.Value]
}
data "selected" "Index" {
widget = ability.combo.Choice
}
data "selected" "Value" {
widget = ability.combo.Choice
column = 0
}
ability "print" "Value" {
message = "The value of the combo is ${data.selected.Index.index} ${data.selected.Value.value}"
}
ability "select" "Pick" {
widget = ability.combo.Choice
index = 2
}
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.list_store.Options
+ ability.table.Grid
+ ability.label.Text
+ ability.button.Close
+ ability.add_row.R1
+ ability.add_row.R2
+ ability.add_row.R3
+ ability.window.Main
+ ability.combo.Choice
+ ability.print.Value
+ ability.select.Pick
+ 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-combo-store # a folder holding the .st files above
structop init
structop plan
structop apply