package ui import ( "fyne.io/fyne/v2" "fyne.io/fyne/v2/container" "fyne.io/fyne/v2/widget" ) type NewObjectDialog struct { representation *fyne.Container // views selection *fyne.Container // 4buttons grid protocolChooser *fyne.Container packetChooser *fyne.Container } var pnod *NewObjectDialog func CreateNewObjectDialog() *NewObjectDialog { if pnod == nil { pnod = &NewObjectDialog{} pnod.representation = container.NewMax(nil) // representation // grid layout 100x100px elements in a center layout, 4 buttons, new Protocol, edit protocol, new Packet, edit Packet buttons := []widget.Button{} buttons = append(buttons, *widget.NewButton("New protocol", func() { PPF.NewProtocolFile() })) buttons = append(buttons, *widget.NewButton("Edit protocol", func() { pnod.representation.RemoveAll() pnod.representation.Add(pnod.protocolChooser) })) buttons = append(buttons, *widget.NewButton("New packet", func() { PPF.NewPacketFile() })) buttons = append(buttons, *widget.NewButton("Edit packet", func() { pnod.representation.RemoveAll() pnod.representation.Add(pnod.packetChooser) })) selectgrid := container.NewGridWithColumns(2, nil) for _, v := range buttons { selectgrid.Add(&v) } pnod.selection = container.NewMax(selectgrid) pnod.representation.Add(pnod.selection) // precreate the choosers /* protocol chooser Accordeon for - Improve existing protocols (Account required) - Open saved protocols */ // data } return pnod } func (nod *NewObjectDialog) Representation() *fyne.Container { return nod.representation } func (nod *NewObjectDialog) Refresh() { }