diff --git a/core/export/cabrillo/cabrillo.go b/core/export/cabrillo/cabrillo.go index 2f6233c..55d49c5 100644 --- a/core/export/cabrillo/cabrillo.go +++ b/core/export/cabrillo/cabrillo.go @@ -29,6 +29,17 @@ type View interface { SetName(string) SetEmail(string) + SetLocation(string) + SetAddressText(string) + SetAddressCity(string) + SetAddressPostalCode(string) + SetAddressStateProvince(string) + SetAddressCountry(string) + SetClub(string) + SetSpecific(string) + + SetCertificate(bool) + SetSoapBox(string) SetOpenAfterExport(bool) } @@ -40,10 +51,20 @@ type Controller struct { qsoBand cabrillo.CategoryBand qsoMode cabrillo.CategoryMode - category cabrillo.Category - name string - email string - openAfterExport bool + category cabrillo.Category + name string + email string + location string + addressText string + addressCity string + addressPostalCode string + addressStateProvince string + addressCountry string + club string + specific string + certificate bool + soapBox string + openAfterExport bool } func NewController() *Controller { @@ -74,6 +95,16 @@ func (c *Controller) Run(settings core.Settings, claimedScore int, qsos []core.Q c.updateCategorySettings() c.view.SetName(c.name) c.view.SetEmail(c.email) + c.view.SetLocation(c.location) + c.view.SetAddressText(c.addressText) + c.view.SetAddressCity(c.addressCity) + c.view.SetAddressPostalCode(c.addressPostalCode) + c.view.SetAddressStateProvince(c.addressStateProvince) + c.view.SetAddressCountry(c.addressCountry) + c.view.SetClub(c.club) + c.view.SetSpecific(c.specific) + c.view.SetCertificate(c.certificate) + c.view.SetSoapBox(c.soapBox) c.view.SetOpenAfterExport(c.openAfterExport) accepted := c.view.Show() if !accepted { @@ -84,6 +115,16 @@ func (c *Controller) Run(settings core.Settings, claimedScore int, qsos []core.Q export.Category = c.category export.Name = c.name export.Email = c.email + export.Location = c.location + export.Address.Text = c.addressText + export.Address.City = c.addressCity + export.Address.Postalcode = c.addressPostalCode + export.Address.StateProvince = c.addressStateProvince + export.Address.Country = c.addressCountry + export.Club = c.club + export.Custom["SPECIFIC"] = c.specific + export.Certificate = c.certificate + export.Soapbox = c.soapBox return export, c.openAfterExport, true } @@ -320,6 +361,46 @@ func (c *Controller) SetEmail(email string) { c.email = email } +func (c *Controller) SetLocation(location string) { + c.location = location +} + +func (c *Controller) SetAddressText(addressText string) { + c.addressText = addressText +} + +func (c *Controller) SetAddressCity(addressCity string) { + c.addressCity = addressCity +} + +func (c *Controller) SetAddressPostalCode(addressPostalCode string) { + c.addressPostalCode = addressPostalCode +} + +func (c *Controller) SetAddressStateProvince(addressStateProvince string) { + c.addressStateProvince = addressStateProvince +} + +func (c *Controller) SetAddressCountry(addressCountry string) { + c.addressCountry = addressCountry +} + +func (c *Controller) SetClub(club string) { + c.club = club +} + +func (c *Controller) SetSpecific(specific string) { + c.specific = specific +} + +func (c *Controller) SetCertificate(certificate bool) { + c.certificate = certificate +} + +func (c *Controller) SetSoapBox(soapBox string) { + c.soapBox = soapBox +} + func (c *Controller) SetOpenAfterExport(open bool) { c.openAfterExport = open } @@ -332,7 +413,6 @@ func createCabrilloLog(settings core.Settings, claimedScore int, qsos []core.QSO export.Operators = []callsign.Callsign{settings.Station().Operator} export.GridLocator = settings.Station().Locator export.ClaimedScore = claimedScore - export.Certificate = true qsoData := make([]cabrillo.QSO, 0, len(qsos)) ignoredQSOs := make([]cabrillo.QSO, 0, len(qsos)) diff --git a/ui/builder.go b/ui/builder.go index 986a5f5..d517c38 100644 --- a/ui/builder.go +++ b/ui/builder.go @@ -25,17 +25,18 @@ func buildExplanationLabel(grid *gtk.Grid, row int, labelText string) *gtk.Label return label } -func buildSeparator(grid *gtk.Grid, row int) { +func buildSeparator(grid *gtk.Grid, row int, width int) { separator, _ := gtk.SeparatorNew(gtk.ORIENTATION_HORIZONTAL) separator.SetHExpand(true) separator.SetMarginTop(5) separator.SetMarginBottom(5) - grid.Attach(separator, 0, row, 2, 1) + grid.Attach(separator, 0, row, width, 1) } func buildLabeledCombo(grid *gtk.Grid, row int, labelText string, withEntry bool, items []string, handler any) *gtk.ComboBoxText { label, _ := gtk.LabelNew(labelText) label.SetHAlign(gtk.ALIGN_END) + label.SetHExpand(false) grid.Attach(label, 0, row, 1, 1) var combo *gtk.ComboBoxText @@ -45,7 +46,6 @@ func buildLabeledCombo(grid *gtk.Grid, row int, labelText string, withEntry bool combo, _ = gtk.ComboBoxTextNew() } combo.SetHExpand(true) - combo.RemoveAll() combo.Append("", "") for _, item := range items { combo.Append(item, item) @@ -60,6 +60,7 @@ func buildLabeledCombo(grid *gtk.Grid, row int, labelText string, withEntry bool func buildLabeledEntry(grid *gtk.Grid, row int, labelText string, handler any) *gtk.Entry { label, _ := gtk.LabelNew(labelText) label.SetHAlign(gtk.ALIGN_END) + label.SetHExpand(false) grid.Attach(label, 0, row, 1, 1) entry, _ := gtk.EntryNew() @@ -71,10 +72,32 @@ func buildLabeledEntry(grid *gtk.Grid, row int, labelText string, handler any) * return entry } +func buildLabeledTextView(grid *gtk.Grid, row int, labelText string, handler any) *gtk.TextView { + label, _ := gtk.LabelNew(labelText) + label.SetHAlign(gtk.ALIGN_START) + grid.Attach(label, 0, row, 1, 1) + + textView, _ := gtk.TextViewNew() + + scrolledWindow, _ := gtk.ScrolledWindowNew(nil, nil) + scrolledWindow.Add(textView) + scrolledWindow.SetHExpand(true) + scrolledWindow.SetVExpand(true) + scrolledWindow.SetSizeRequest(0, 100) + scrolledWindow.SetMarginStart(5) + scrolledWindow.SetMarginEnd(5) + grid.Attach(scrolledWindow, 0, row+1, 1, 1) + + buffer, _ := textView.GetBuffer() + buffer.Connect("changed", handler) + + return textView +} + func buildCheckButton(grid *gtk.Grid, row int, labelText string, handler any) *gtk.CheckButton { checkButton, _ := gtk.CheckButtonNewWithLabel(labelText) checkButton.SetHExpand(true) - grid.Attach(checkButton, 0, row, 2, 1) + grid.Attach(checkButton, 0, row, 1, 1) checkButton.Connect("toggled", handler) diff --git a/ui/exportCabrilloDialog.go b/ui/exportCabrilloDialog.go index b4ec67e..e743178 100644 --- a/ui/exportCabrilloDialog.go +++ b/ui/exportCabrilloDialog.go @@ -21,8 +21,20 @@ type exportCabrilloDialog struct { categoryOverlay string categoryTime string - name string - email string + name string + email string + location string + addressText string + addressCity string + addressPostalCode string + addressStateProvince string + addressCountry string + club string + specific string + + certificate bool + soapBox string + openAfterExport bool } @@ -53,6 +65,18 @@ func (d *exportCabrilloDialog) Show() bool { d.view.categoryTimeCombo.SetActiveID(d.categoryTime) d.view.nameEntry.SetText(d.name) d.view.emailEntry.SetText(d.email) + d.view.locationEntry.SetText(d.location) + d.view.addressTextEntry.SetText(d.addressText) + d.view.addressCityEntry.SetText(d.addressCity) + d.view.addressPostalCodeEntry.SetText(d.addressPostalCode) + d.view.addressStateProvinceEntry.SetText(d.addressStateProvince) + d.view.addressCountryEntry.SetText(d.addressCountry) + d.view.clubEntry.SetText(d.club) + d.view.specificEntry.SetText(d.specific) + d.view.certificateCheckButton.SetActive(d.certificate) + buffer, _ := d.view.soapBoxEntry.GetBuffer() + buffer.SetText(d.soapBox) + // d.view.soapBoxEntry.SetBuffer(buffer) d.view.openAfterExportCheckButton.SetActive(d.openAfterExport) dialog, _ := gtk.DialogNew() @@ -153,6 +177,77 @@ func (d *exportCabrilloDialog) SetEmail(email string) { } } +func (d *exportCabrilloDialog) SetLocation(location string) { + d.location = location + if d.view != nil { + d.view.locationEntry.SetText(location) + } +} + +func (d *exportCabrilloDialog) SetAddressText(addressText string) { + d.addressText = addressText + if d.view != nil { + d.view.addressTextEntry.SetText(addressText) + } +} + +func (d *exportCabrilloDialog) SetAddressCity(addressCity string) { + d.addressCity = addressCity + if d.view != nil { + d.view.addressCityEntry.SetText(addressCity) + } +} + +func (d *exportCabrilloDialog) SetAddressPostalCode(addressPostalCode string) { + d.addressPostalCode = addressPostalCode + if d.view != nil { + d.view.addressPostalCodeEntry.SetText(addressPostalCode) + } +} + +func (d *exportCabrilloDialog) SetAddressStateProvince(addressStateProvince string) { + d.addressStateProvince = addressStateProvince + if d.view != nil { + d.view.addressStateProvinceEntry.SetText(addressStateProvince) + } +} + +func (d *exportCabrilloDialog) SetAddressCountry(addressCountry string) { + d.addressCountry = addressCountry + if d.view != nil { + d.view.addressCountryEntry.SetText(addressCountry) + } +} + +func (d *exportCabrilloDialog) SetClub(club string) { + d.club = club + if d.view != nil { + d.view.clubEntry.SetText(club) + } +} + +func (d *exportCabrilloDialog) SetSpecific(specific string) { + d.specific = specific + if d.view != nil { + d.view.specificEntry.SetText(specific) + } +} + +func (d *exportCabrilloDialog) SetCertificate(certificate bool) { + d.certificate = certificate + if d.view != nil { + d.view.certificateCheckButton.SetActive(certificate) + } +} + +func (d *exportCabrilloDialog) SetSoapBox(soapBox string) { + d.soapBox = soapBox + if d.view != nil { + buffer, _ := d.view.soapBoxEntry.GetBuffer() + buffer.SetText(soapBox) + } +} + func (d *exportCabrilloDialog) SetOpenAfterExport(open bool) { d.openAfterExport = open } diff --git a/ui/exportCabrilloView.go b/ui/exportCabrilloView.go index ba20a57..188c285 100644 --- a/ui/exportCabrilloView.go +++ b/ui/exportCabrilloView.go @@ -28,6 +28,16 @@ type ExportCabrilloController interface { SetCategoryTime(string) SetName(string) SetEmail(string) + SetLocation(string) + SetAddressText(string) + SetAddressCity(string) + SetAddressPostalCode(string) + SetAddressStateProvince(string) + SetAddressCountry(string) + SetClub(string) + SetSpecific(string) + SetCertificate(bool) + SetSoapBox(string) SetOpenAfterExport(bool) } @@ -47,8 +57,20 @@ type exportCabrilloView struct { categoryOverlayCombo *gtk.ComboBoxText categoryTimeCombo *gtk.ComboBoxText - nameEntry *gtk.Entry - emailEntry *gtk.Entry + nameEntry *gtk.Entry + emailEntry *gtk.Entry + locationEntry *gtk.Entry + addressTextEntry *gtk.Entry + addressCityEntry *gtk.Entry + addressPostalCodeEntry *gtk.Entry + addressStateProvinceEntry *gtk.Entry + addressCountryEntry *gtk.Entry + clubEntry *gtk.Entry + specificEntry *gtk.Entry + + certificateCheckButton *gtk.CheckButton + soapBoxEntry *gtk.TextView + openAfterExportCheckButton *gtk.CheckButton } @@ -67,14 +89,14 @@ func newExportCabrilloView(controller ExportCabrilloController) *exportCabrilloV columns, _ := gtk.GridNew() columns.SetOrientation(gtk.ORIENTATION_HORIZONTAL) columns.SetHExpand(true) - columns.SetVExpand(true) + columns.SetVExpand(false) columns.SetColumnSpacing(10) result.root.Attach(columns, 0, 1, 1, 1) leftColumn, _ := gtk.GridNew() leftColumn.SetOrientation(gtk.ORIENTATION_VERTICAL) - leftColumn.SetHExpand(false) - leftColumn.SetVExpand(true) + leftColumn.SetHExpand(true) + leftColumn.SetVExpand(false) leftColumn.SetColumnSpacing(5) leftColumn.SetRowSpacing(5) columns.Attach(leftColumn, 0, 0, 1, 1) @@ -82,7 +104,7 @@ func newExportCabrilloView(controller ExportCabrilloController) *exportCabrilloV rightColumn, _ := gtk.GridNew() rightColumn.SetOrientation(gtk.ORIENTATION_VERTICAL) rightColumn.SetHExpand(true) - rightColumn.SetVExpand(true) + rightColumn.SetVExpand(false) rightColumn.SetColumnSpacing(5) rightColumn.SetRowSpacing(5) columns.Attach(rightColumn, 1, 0, 1, 1) @@ -97,7 +119,7 @@ func newExportCabrilloView(controller ExportCabrilloController) *exportCabrilloV result.categoryOperatorCombo = buildLabeledCombo(leftColumn, 5, "Operator", false, result.controller.CategoryOperators(), result.onCategoryOperatorChanged) result.categoryPowerCombo = buildLabeledCombo(leftColumn, 6, "Power", false, result.controller.CategoryPowers(), result.onCategoryPowerChanged) result.categoryAssistedCombo = buildLabeledCombo(leftColumn, 7, "Assisted", false, result.controller.CategoryAssisted(), result.onCategoryAssistedChanged) - buildSeparator(leftColumn, 8) + buildSeparator(leftColumn, 8, 2) result.categoryStationCombo = buildLabeledCombo(leftColumn, 9, "Station", false, result.controller.CategoryStations(), result.onCategoryStationChanged) result.categoryTransmitterCombo = buildLabeledCombo(leftColumn, 10, "Transmitter", false, result.controller.CategoryTransmitters(), result.onCategoryTransmitterChanged) result.categoryOverlayCombo = buildLabeledCombo(leftColumn, 11, "Overlay", true, result.controller.CategoryOverlays(), result.onCategoryOverlayChanged) @@ -106,10 +128,23 @@ func newExportCabrilloView(controller ExportCabrilloController) *exportCabrilloV buildHeaderLabel(rightColumn, 0, "Personal Information") result.nameEntry = buildLabeledEntry(rightColumn, 1, "Name", result.onNameChanged) result.emailEntry = buildLabeledEntry(rightColumn, 2, "Email", result.onEmailChanged) + result.locationEntry = buildLabeledEntry(rightColumn, 3, "Location", result.onLocationChanged) + buildSeparator(rightColumn, 4, 2) + result.addressTextEntry = buildLabeledEntry(rightColumn, 5, "Address", result.onAddressTextChanged) + result.addressCityEntry = buildLabeledEntry(rightColumn, 6, "City", result.onAddressCityChanged) + result.addressPostalCodeEntry = buildLabeledEntry(rightColumn, 7, "Postal Code", result.onAddressPostalCodeChanged) + result.addressStateProvinceEntry = buildLabeledEntry(rightColumn, 8, "State/Province", result.onAddressStateProvinceChanged) + result.addressCountryEntry = buildLabeledEntry(rightColumn, 9, "Country", result.onAddressCountryChanged) + buildSeparator(rightColumn, 10, 2) + result.clubEntry = buildLabeledEntry(rightColumn, 11, "Club", result.onClubChanged) + result.specificEntry = buildLabeledEntry(rightColumn, 12, "Specific", result.onSpecificChanged) + + result.certificateCheckButton = buildCheckButton(result.root, 2, "Request a certificate", result.onCertificateToggled) + result.soapBoxEntry = buildLabeledTextView(result.root, 3, "Soap Box", result.onSoapBoxChanged) - buildSeparator(result.root, 2) + buildSeparator(result.root, 5, 1) - result.openAfterExportCheckButton = buildCheckButton(result.root, 3, "Open the file after export", result.onOpenAfterExportToggled) + result.openAfterExportCheckButton = buildCheckButton(result.root, 6, "Open the file after export", result.onOpenAfterExportToggled) return result } @@ -164,6 +199,56 @@ func (v *exportCabrilloView) onEmailChanged() { v.controller.SetEmail(text) } +func (v *exportCabrilloView) onLocationChanged() { + text, _ := v.locationEntry.GetText() + v.controller.SetLocation(text) +} + +func (v *exportCabrilloView) onAddressTextChanged() { + text, _ := v.addressTextEntry.GetText() + v.controller.SetAddressText(text) +} + +func (v *exportCabrilloView) onAddressCityChanged() { + text, _ := v.addressCityEntry.GetText() + v.controller.SetAddressCity(text) +} + +func (v *exportCabrilloView) onAddressPostalCodeChanged() { + text, _ := v.addressPostalCodeEntry.GetText() + v.controller.SetAddressPostalCode(text) +} + +func (v *exportCabrilloView) onAddressStateProvinceChanged() { + text, _ := v.addressStateProvinceEntry.GetText() + v.controller.SetAddressStateProvince(text) +} + +func (v *exportCabrilloView) onAddressCountryChanged() { + text, _ := v.addressCountryEntry.GetText() + v.controller.SetAddressCountry(text) +} + +func (v *exportCabrilloView) onClubChanged() { + text, _ := v.clubEntry.GetText() + v.controller.SetClub(text) +} + +func (v *exportCabrilloView) onSpecificChanged() { + text, _ := v.specificEntry.GetText() + v.controller.SetSpecific(text) +} + +func (v *exportCabrilloView) onCertificateToggled() { + v.controller.SetCertificate(v.certificateCheckButton.GetActive()) +} + +func (v *exportCabrilloView) onSoapBoxChanged() { + buffer, _ := v.soapBoxEntry.GetBuffer() + text, _ := buffer.GetText(buffer.GetStartIter(), buffer.GetEndIter(), true) + v.controller.SetSoapBox(text) +} + func (v *exportCabrilloView) onOpenAfterExportToggled() { v.controller.SetOpenAfterExport(v.openAfterExportCheckButton.GetActive()) }