Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use icons for file dialog favourites #1186

Merged
merged 4 commits into from Jul 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions dialog/file.go
Expand Up @@ -160,13 +160,13 @@ func (f *fileDialog) makeUI() fyne.CanvasObject {
func (f *fileDialog) loadFavorites() []fyne.CanvasObject {
home, _ := os.UserHomeDir()
places := []fyne.CanvasObject{
widget.NewButton("Home", func() {
widget.NewButtonWithIcon("Home", theme.HomeIcon(), func() {
f.setDirectory(home)
}),
widget.NewButton("Documents", func() {
widget.NewButtonWithIcon("Documents", theme.DocumentIcon(), func() {
f.setDirectory(filepath.Join(home, "Documents"))
}),
widget.NewButton("Downloads", func() {
widget.NewButtonWithIcon("Downloads", theme.DownloadIcon(), func() {
f.setDirectory(filepath.Join(home, "Downloads"))
}),
}
Expand Down
3 changes: 2 additions & 1 deletion dialog/file_other.go
Expand Up @@ -4,11 +4,12 @@ package dialog

import (
"fyne.io/fyne"
"fyne.io/fyne/theme"
"fyne.io/fyne/widget"
)

func (f *fileDialog) loadPlaces() []fyne.CanvasObject {
return []fyne.CanvasObject{widget.NewButton("Computer", func() {
return []fyne.CanvasObject{widget.NewButtonWithIcon("Computer", theme.ComputerIcon(), func() {
f.setDirectory("/")
})}
}
Expand Down
3 changes: 2 additions & 1 deletion dialog/file_windows.go
Expand Up @@ -6,6 +6,7 @@ import (
"syscall"

"fyne.io/fyne"
"fyne.io/fyne/theme"
"fyne.io/fyne/widget"
)

Expand Down Expand Up @@ -50,7 +51,7 @@ func (f *fileDialog) loadPlaces() []fyne.CanvasObject {

for _, drive := range listDrives() {
driveRoot := drive + string(os.PathSeparator) // capture loop var
places = append(places, widget.NewButton(drive, func() {
places = append(places, widget.NewButtonWithIcon(drive, theme.StorageIcon(), func() {
f.setDirectory(driveRoot)
}))
}
Expand Down
22 changes: 19 additions & 3 deletions theme/bundled-icons.go

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions theme/gen.go
Expand Up @@ -117,6 +117,7 @@ func main() {
bundleIcon("content-redo", f)
bundleIcon("content-undo", f)

bundleIcon("document", f)
bundleIcon("document-create", f)
bundleIcon("document-print", f)
bundleIcon("document-save", f)
Expand Down Expand Up @@ -174,5 +175,9 @@ func main() {
bundleIcon("visibility", f)
bundleIcon("visibility-off", f)

bundleIcon("download", f)
bundleIcon("computer", f)
bundleIcon("storage", f)

f.Close()
}
51 changes: 38 additions & 13 deletions theme/icons.go
Expand Up @@ -86,19 +86,19 @@ func colorizeResource(res fyne.Resource, clr color.Color) []byte {
}

var (
cancel, confirm, delete, search, searchReplace, menu, menuExpand *ThemedResource
checked, unchecked, radioButton, radioButtonChecked *ThemedResource
contentAdd, contentRemove, contentCut, contentCopy, contentPaste *ThemedResource
contentRedo, contentUndo, info, question, warning *ThemedResource
documentCreate, documentPrint, documentSave *ThemedResource
mailAttachment, mailCompose, mailForward, mailReply, mailReplyAll, mailSend *ThemedResource
mediaFastForward, mediaFastRewind, mediaPause, mediaPlay *ThemedResource
mediaRecord, mediaReplay, mediaSkipNext, mediaSkipPrevious *ThemedResource
arrowBack, arrowDown, arrowForward, arrowUp, arrowDropDown, arrowDropUp *ThemedResource
file, fileApplication, fileAudio, fileImage, fileText, fileVideo *ThemedResource
folder, folderNew, folderOpen, help, home, settings *ThemedResource
viewFullScreen, viewRefresh, viewZoomFit, viewZoomIn, viewZoomOut *ThemedResource
visibility, visibilityOff, volumeDown, volumeMute, volumeUp *ThemedResource
cancel, confirm, delete, search, searchReplace, menu, menuExpand *ThemedResource
checked, unchecked, radioButton, radioButtonChecked *ThemedResource
contentAdd, contentRemove, contentCut, contentCopy, contentPaste *ThemedResource
contentRedo, contentUndo, info, question, warning *ThemedResource
document, documentCreate, documentPrint, documentSave *ThemedResource
mailAttachment, mailCompose, mailForward, mailReply, mailReplyAll, mailSend *ThemedResource
mediaFastForward, mediaFastRewind, mediaPause, mediaPlay *ThemedResource
mediaRecord, mediaReplay, mediaSkipNext, mediaSkipPrevious *ThemedResource
arrowBack, arrowDown, arrowForward, arrowUp, arrowDropDown, arrowDropUp *ThemedResource
file, fileApplication, fileAudio, fileImage, fileText, fileVideo *ThemedResource
folder, folderNew, folderOpen, help, home, settings, storage *ThemedResource
viewFullScreen, viewRefresh, viewZoomFit, viewZoomIn, viewZoomOut *ThemedResource
visibility, visibilityOff, volumeDown, volumeMute, volumeUp, download, computer *ThemedResource
)

func init() {
Expand All @@ -123,6 +123,7 @@ func init() {
contentRedo = NewThemedResource(contentredoIconRes, nil)
contentUndo = NewThemedResource(contentundoIconRes, nil)

document = NewThemedResource(documentIconRes, nil)
documentCreate = NewThemedResource(documentcreateIconRes, nil)
documentPrint = NewThemedResource(documentprintIconRes, nil)
documentSave = NewThemedResource(documentsaveIconRes, nil)
Expand Down Expand Up @@ -179,6 +180,10 @@ func init() {
volumeDown = NewThemedResource(volumedownIconRes, nil)
volumeMute = NewThemedResource(volumemuteIconRes, nil)
volumeUp = NewThemedResource(volumeupIconRes, nil)

download = NewThemedResource(downloadIconRes, nil)
computer = NewThemedResource(computerIconRes, nil)
storage = NewThemedResource(storageIconRes, nil)
}

// FyneLogo returns a resource containing the Fyne logo
Expand Down Expand Up @@ -281,6 +286,11 @@ func ContentUndoIcon() fyne.Resource {
return contentUndo
}

// DocumentIcon returns a resource containing the standard document icon for the current theme
func DocumentIcon() fyne.Resource {
return document
}

// DocumentCreateIcon returns a resource containing the standard document create icon for the current theme
func DocumentCreateIcon() fyne.Resource {
return documentCreate
Expand Down Expand Up @@ -525,3 +535,18 @@ func VolumeMuteIcon() fyne.Resource {
func VolumeUpIcon() fyne.Resource {
return volumeUp
}

// ComputerIcon returns a resource containing the standard computer icon for the current theme
func ComputerIcon() fyne.Resource {
return computer
}

// DownloadIcon returns a resource containing the standard download icon for the current theme
func DownloadIcon() fyne.Resource {
return download
}

// StorageIcon returns a resource containing the standard storage icon for the current theme
func StorageIcon() fyne.Resource {
return storage
}
1 change: 1 addition & 0 deletions theme/icons/computer.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions theme/icons/document.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions theme/icons/download.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions theme/icons/storage.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.