Skip to content

Commit

Permalink
remove the buttons for contest pages and the configuration file from …
Browse files Browse the repository at this point in the history
…the settings dialog
  • Loading branch information
ftl committed Jun 18, 2023
1 parent 44cb977 commit 9563d86
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 102 deletions.
23 changes: 20 additions & 3 deletions core/settings/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,16 @@ func (f ContestListenerFunc) ContestChanged(contest core.Contest) {
f(contest)
}

type ContestPagesListener interface {
ContestPagesChanged(rulesAvailable bool, uploadAvailable bool)
}

type ContestPagesListenerFunc func(bool, bool)

func (f ContestPagesListenerFunc) ContestPagesChanged(rulesAvailable bool, uploadAvailable bool) {
f(rulesAvailable, uploadAvailable)
}

type SettingsListener interface {
SettingsChanged(core.Settings)
}
Expand Down Expand Up @@ -71,7 +81,6 @@ type View interface {
SetStationLocator(string)

SetContestIdentifiers(ids []string, texts []string)
SetContestPagesAvailable(bool, bool)
SelectContestIdentifier(string)

SetContestExchangeFields([]core.ExchangeField)
Expand Down Expand Up @@ -212,6 +221,14 @@ func (s *Settings) emitContestChanged() {
}
}

func (s *Settings) emitContestPagesChanged(rulesAvailable bool, uploadAvailable bool) {
for _, listener := range s.listeners {
if contestPagesListener, ok := listener.(ContestPagesListener); ok {
contestPagesListener.ContestPagesChanged(rulesAvailable, uploadAvailable)
}
}
}

func (s *Settings) emitSettingsChanged() {
for _, listener := range s.listeners {
if SettingsListener, ok := listener.(SettingsListener); ok {
Expand Down Expand Up @@ -403,9 +420,9 @@ func (s *Settings) updateContestPages() {
}

if s.contest.Definition == nil {
s.view.SetContestPagesAvailable(false, false)
s.emitContestPagesChanged(false, false)
} else {
s.view.SetContestPagesAvailable(s.contest.Definition.OfficialRules != "", s.contest.Definition.UploadURL != "")
s.emitContestPagesChanged(s.contest.Definition.OfficialRules != "", s.contest.Definition.UploadURL != "")
}
}

Expand Down
1 change: 1 addition & 0 deletions ui/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ func (a *application) activate() {
// TODO: use a listener model for the bandmap to allow multiple views on the bandmap (scope, spots list, mini-scope)
a.controller.Bandmap.SetView(a.spotsWindow)
a.controller.Settings.SetView(a.settingsDialog)
a.controller.Settings.Notify(a.mainWindow)
a.controller.NewContest.SetView(a.newContestDialog)
a.controller.NewContest.SetFileSelector(a.mainWindow)
a.controller.Clusters.SetView(a.mainWindow)
Expand Down
85 changes: 15 additions & 70 deletions ui/glade/contest.glade
Original file line number Diff line number Diff line change
Expand Up @@ -421,20 +421,6 @@ THE SOFTWARE.
<object class="GtkButtonBox">
<property name="can-focus">False</property>
<property name="layout-style">end</property>
<child>
<object class="GtkButton" id="openConfigurationButton">
<property name="label" translatable="yes">Open Configuration</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="use-underline">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="resetButton">
<property name="label">_Reset</property>
Expand Down Expand Up @@ -489,7 +475,7 @@ THE SOFTWARE.
</packing>
</child>
<child>
<!-- n-columns=2 n-rows=14 -->
<!-- n-columns=2 n-rows=13 -->
<object class="GtkGrid" id="stationGrid">
<property name="visible">True</property>
<property name="can-focus">False</property>
Expand Down Expand Up @@ -621,7 +607,7 @@ THE SOFTWARE.
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">7</property>
<property name="top-attach">6</property>
</packing>
</child>
<child>
Expand All @@ -635,7 +621,7 @@ THE SOFTWARE.
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">7</property>
<property name="top-attach">6</property>
</packing>
</child>
<child>
Expand All @@ -648,7 +634,7 @@ THE SOFTWARE.
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">12</property>
<property name="top-attach">11</property>
</packing>
</child>
<child>
Expand Down Expand Up @@ -676,44 +662,6 @@ THE SOFTWARE.
<property name="top-attach">5</property>
</packing>
</child>
<child>
<!-- n-columns=2 n-rows=1 -->
<object class="GtkGrid">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="column-spacing">5</property>
<child>
<object class="GtkButton" id="openContestRulesPageButton">
<property name="label" translatable="yes">Open Rules</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="hexpand">True</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="openContestUploadPageButton">
<property name="label" translatable="yes">Open Upload Page</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="hexpand">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
</packing>
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">6</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
Expand All @@ -729,7 +677,7 @@ THE SOFTWARE.
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">9</property>
<property name="top-attach">8</property>
</packing>
</child>
<child>
Expand All @@ -751,7 +699,7 @@ THE SOFTWARE.
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">9</property>
<property name="top-attach">8</property>
</packing>
</child>
<child>
Expand All @@ -773,7 +721,7 @@ THE SOFTWARE.
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">12</property>
<property name="top-attach">11</property>
</packing>
</child>
<child>
Expand All @@ -786,7 +734,7 @@ THE SOFTWARE.
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">11</property>
<property name="top-attach">10</property>
</packing>
</child>
<child>
Expand Down Expand Up @@ -825,7 +773,7 @@ THE SOFTWARE.
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">11</property>
<property name="top-attach">10</property>
</packing>
</child>
<child>
Expand Down Expand Up @@ -921,7 +869,7 @@ THE SOFTWARE.
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">13</property>
<property name="top-attach">12</property>
</packing>
</child>
<child>
Expand All @@ -935,7 +883,7 @@ THE SOFTWARE.
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">13</property>
<property name="top-attach">12</property>
</packing>
</child>
<child>
Expand All @@ -949,7 +897,7 @@ THE SOFTWARE.
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">10</property>
<property name="top-attach">9</property>
</packing>
</child>
<child>
Expand All @@ -974,7 +922,7 @@ THE SOFTWARE.
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">10</property>
<property name="top-attach">9</property>
</packing>
</child>
<child>
Expand All @@ -990,7 +938,7 @@ THE SOFTWARE.
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">8</property>
<property name="top-attach">7</property>
</packing>
</child>
<child>
Expand Down Expand Up @@ -1043,12 +991,9 @@ THE SOFTWARE.
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">8</property>
<property name="top-attach">7</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">True</property>
Expand Down
5 changes: 5 additions & 0 deletions ui/mainMenu.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ func (m *mainMenu) WorkmodeChanged(workmode core.Workmode) {
}
}

func (m *mainMenu) ContestPagesChanged(rulesAvailable bool, uploadAvailable bool) {
m.fileOpenRules.SetSensitive(rulesAvailable)
m.fileOpenUpload.SetSensitive(uploadAvailable)
}

func (m *mainMenu) onAbout() {
m.controller.About()
}
Expand Down
32 changes: 3 additions & 29 deletions ui/settingsView.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,9 @@ type settingsView struct {

ignoreChangedEvent bool

message *gtk.Label
openContestRulesPage *gtk.Button
openContestUploadPage *gtk.Button
openConfigurationFile *gtk.Button
reset *gtk.Button
close *gtk.Button
message *gtk.Label
reset *gtk.Button
close *gtk.Button

fields map[fieldID]interface{}

Expand All @@ -87,10 +84,6 @@ func setupSettingsView(builder *gtk.Builder, parent *gtk.Dialog, controller Sett
result.fields = make(map[fieldID]interface{})

result.message = getUI(builder, "settingsMessageLabel").(*gtk.Label)
result.openContestRulesPage = getUI(builder, "openContestRulesPageButton").(*gtk.Button)
result.openContestRulesPage.Connect("clicked", result.onOpenContestRulesPagePressed)
result.openContestUploadPage = getUI(builder, "openContestUploadPageButton").(*gtk.Button)
result.openContestUploadPage.Connect("clicked", result.onOpenContestUploadPagePressed)
result.exchangeFieldsParent = getUI(builder, "contestExchangeFieldsGrid").(*gtk.Grid)
result.contestStartTimeTodayButton = getUI(builder, "contestStartTimeTodayButton").(*gtk.Button)
result.contestStartTimeTodayButton.Connect("clicked", result.onContestStartTimeTodayPressed)
Expand All @@ -100,8 +93,6 @@ func setupSettingsView(builder *gtk.Builder, parent *gtk.Dialog, controller Sett
result.clearCallHistorySettingsButton = getUI(builder, "contestCallHistoryClearButton").(*gtk.Button)
result.clearCallHistorySettingsButton.Connect("clicked", result.onClearCallHistoryPressed)

result.openConfigurationFile = getUI(builder, "openConfigurationButton").(*gtk.Button)
result.openConfigurationFile.Connect("clicked", result.onOpenConfigurationFilePressed)
result.reset = getUI(builder, "resetButton").(*gtk.Button)
result.reset.Connect("clicked", result.onResetPressed)
result.close = getUI(builder, "closeButton").(*gtk.Button)
Expand Down Expand Up @@ -232,14 +223,6 @@ func (v *settingsView) onFieldChanged(w any) bool {
return false
}

func (v *settingsView) onOpenContestRulesPagePressed(_ *gtk.Button) {
v.controller.OpenContestRulesPage()
}

func (v *settingsView) onOpenContestUploadPagePressed(_ *gtk.Button) {
v.controller.OpenContestUploadPage()
}

func (v *settingsView) onContestStartTimeTodayPressed(_ *gtk.Button) {
v.controller.SetContestStartTimeToday()
}
Expand All @@ -252,10 +235,6 @@ func (v *settingsView) onClearCallHistoryPressed(_ *gtk.Button) {
v.controller.ClearCallHistory()
}

func (v *settingsView) onOpenConfigurationFilePressed(_ *gtk.Button) {
v.controller.OpenConfigurationFile()
}

func (v *settingsView) onResetPressed(_ *gtk.Button) {
v.controller.Reset()
}
Expand Down Expand Up @@ -331,11 +310,6 @@ func (v *settingsView) SetContestIdentifiers(ids []string, texts []string) {
})
}

func (v *settingsView) SetContestPagesAvailable(rulesPageAvailable bool, uploadPageAvailable bool) {
v.openContestRulesPage.SetSensitive(rulesPageAvailable)
v.openContestUploadPage.SetSensitive(uploadPageAvailable)
}

func (v *settingsView) SelectContestIdentifier(value string) {
v.selectComboField(contestIdentifier, value)
}
Expand Down

0 comments on commit 9563d86

Please sign in to comment.