Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Z-Bolt/OctoScreen.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffB42 <10328858+JeffB42@users.noreply.github.com>2021-03-13 20:07:23 +0300
committerJeffB42 <10328858+JeffB42@users.noreply.github.com>2021-03-13 20:07:23 +0300
commitfcf2c9b832c2fabfa5ef07dcb7f1e71a378f9f27 (patch)
tree4a3375b34b0a536127952bea22ab41110e7de8e5
parent513dacbc13dfa82f541a29412e59d0986387a5d3 (diff)
seperated out the refreshButton and backButton, added displayRootLocations()
-rwxr-xr-xui/FilesPanel.go31
1 files changed, 22 insertions, 9 deletions
diff --git a/ui/FilesPanel.go b/ui/FilesPanel.go
index 24d9e21..b5439ac 100755
--- a/ui/FilesPanel.go
+++ b/ui/FilesPanel.go
@@ -16,12 +16,15 @@ import (
"github.com/Z-Bolt/OctoScreen/utils"
)
+
var filesPanelInstance *filesPanel
type filesPanel struct {
CommonPanel
listBox *gtk.Box
+ refreshButton *gtk.Button
+ backButton *gtk.Button
locationHistory utils.LocationHistory
}
@@ -61,7 +64,7 @@ func (this *filesPanel) initialize() {
this.doLoadFiles()
}
-func (this *filesPanel) createActionFooter() gtk.IWidget {
+func (this *filesPanel) createActionFooter() *gtk.Box {
actionBar := utils.MustBox(gtk.ORIENTATION_HORIZONTAL, 5)
actionBar.SetHAlign(gtk.ALIGN_END)
actionBar.SetHExpand(true)
@@ -69,18 +72,21 @@ func (this *filesPanel) createActionFooter() gtk.IWidget {
actionBar.SetMarginBottom(5)
actionBar.SetMarginEnd(5)
- actionBar.Add(this.createRefreshButton())
- actionBar.Add(this.createBackButton())
+ this.refreshButton = this.createRefreshButton()
+ actionBar.Add(this.refreshButton)
+
+ this.backButton = this.createBackButton()
+ actionBar.Add(this.backButton)
return actionBar
}
-func (this *filesPanel) createRefreshButton() gtk.IWidget {
+func (this *filesPanel) createRefreshButton() *gtk.Button {
image := utils.MustImageFromFileWithSize("refresh.svg", this.Scaled(40), this.Scaled(40))
return utils.MustButton(image, this.doLoadFiles)
}
-func (this *filesPanel) createBackButton() gtk.IWidget {
+func (this *filesPanel) createBackButton() *gtk.Button {
image := utils.MustImageFromFileWithSize("back.svg", this.Scaled(40), this.Scaled(40))
return utils.MustButton(image, func() {
if this.locationHistory.Length() < 1 {
@@ -98,21 +104,28 @@ func (this *filesPanel) createBackButton() gtk.IWidget {
func (this *filesPanel) doLoadFiles() {
utils.EmptyTheContainer(&this.listBox.Container)
- sortedFiles := this.getSortedFiles()
- if sortedFiles == nil {
+ if this.displayRootLocations() {
this.addRootLocations()
} else {
+ sortedFiles := this.getSortedFiles()
this.addSortedFiles(sortedFiles)
}
this.listBox.ShowAll()
}
+func (this *filesPanel) displayRootLocations() bool {
+ if this.locationHistory.Length() < 1 {
+ return true
+ } else {
+ return false
+ }
+}
+
func (this *filesPanel) getSortedFiles() []*dataModels.FileResponse {
var files []*dataModels.FileResponse
- length := this.locationHistory.Length()
- if length < 1 {
+ if this.displayRootLocations() {
return nil
}