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

Adding a feature for desktop files #251

Draft
wants to merge 48 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
f584396
Expose (and use) desktop root window
Feb 19, 2023
65c9ecd
First pass incorporating Fyles to a desktop files module
Feb 19, 2023
6bc4280
Update latest Fyles to hide and size nicely
andydotxyz Mar 3, 2023
21426e6
Merge branch 'develop' into feature/desktopfiles
andydotxyz Oct 14, 2023
a79946e
Update Fyles and fix tapping
andydotxyz Oct 14, 2023
27f2dbc
Merge branch 'develop' into feature/desktopfiles
andydotxyz Oct 15, 2023
6683bed
We don't vendor any more
andydotxyz Oct 15, 2023
eedd0c5
Show Trash on the desktop
andydotxyz Jan 5, 2024
913267f
Set the Trash icon using new URIWithIcon
andydotxyz Jan 5, 2024
66404e8
Also add a settings desktop icon
andydotxyz Jan 5, 2024
9021568
Merge branch 'develop' into feature/desktopfiles
andydotxyz Jan 5, 2024
94d4b51
Add missing comment
andydotxyz Jan 5, 2024
9917ffa
Use the landed feature to avoid replace
andydotxyz Jan 7, 2024
9cb6b78
Merge branch 'develop' into feature/desktopfiles
andydotxyz Feb 2, 2024
e1058c1
Updated docs and embed video of release
andydotxyz Mar 2, 2024
c54cb41
Don't try to logout whilst our shutdown dialog is still open
andydotxyz Feb 4, 2024
0cba7d6
prepare metadata for release
andydotxyz Feb 11, 2024
5d15cdd
dim iconified
andydotxyz Feb 11, 2024
03e0905
Fix glitch with date/time layout
andydotxyz Feb 11, 2024
0fa8d87
latest Fyne release
andydotxyz Feb 13, 2024
9bef669
Add quake mode terminal module
andydotxyz Feb 11, 2024
0bb4c5b
Don't load the UI if the terminal is not used
andydotxyz Feb 20, 2024
1032169
Prep for release
andydotxyz Feb 24, 2024
f9d69e0
Add a shiny new about screen
andydotxyz Feb 24, 2024
dfde53e
Move about window to current destop
andydotxyz Feb 24, 2024
54ddbfb
Update name, doc and release date
andydotxyz Mar 2, 2024
0aafac8
Better error handling for background load errors
andydotxyz Mar 18, 2024
da10f03
Ensure we show the item in launcher that is highlighted
andydotxyz May 26, 2024
2868348
Simplify menu overlay code and support multiple menus appearing
andydotxyz May 26, 2024
4025eda
Open bar menu as an overlay so it is above windows
andydotxyz May 26, 2024
4c47e78
Don't reshuffle windows on iconify
andydotxyz Jun 2, 2024
83a70a9
Add pinned windows which stick to the position when moving desktops
andydotxyz Jun 2, 2024
f383242
Update launcher icons to show transparent if iconified
andydotxyz Jun 11, 2024
64cdab3
Include pinned windows in the switcher
andydotxyz Jun 11, 2024
bce3204
support checks in the menu
andydotxyz Jun 17, 2024
a412547
Updating to Fyne release
andydotxyz Aug 2, 2024
63e5c68
Add basic UI for theme selection
andydotxyz Jun 29, 2024
aa8fc05
Avoid deprecated API
andydotxyz Jun 29, 2024
ac5eb02
Fix issue of icons overlapping or clipping titlebar when shorter than…
andydotxyz Aug 5, 2024
c81627a
That's not a public method
andydotxyz Aug 5, 2024
88bc07b
Fix possible nil crash
andydotxyz Aug 5, 2024
7bb05ae
Remove usage of an old API and fix possible nil crash
andydotxyz Aug 6, 2024
a854465
More robust lookup for Linux wireless name
andydotxyz Aug 17, 2024
abf646b
Updating to get more bug fixes
andydotxyz Aug 17, 2024
38074e6
Fix more deprecations
andydotxyz Aug 17, 2024
a04363e
Additional colour deprecations removed
andydotxyz Aug 17, 2024
a6b9e8b
fix bad merge
andydotxyz Aug 17, 2024
9673b85
Merge branch 'develop' into feature/desktopfiles
andydotxyz Oct 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/fynedesk/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

_ "fyshos.com/fynedesk/modules/composit"
_ "fyshos.com/fynedesk/modules/desktops"
_ "fyshos.com/fynedesk/modules/fyles"
_ "fyshos.com/fynedesk/modules/launcher"
_ "fyshos.com/fynedesk/modules/quaketerm"
_ "fyshos.com/fynedesk/modules/status"
Expand Down
2 changes: 2 additions & 0 deletions desk.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ type Desktop interface {

AddShortcut(shortcut *Shortcut, handler func())
ShowMenuAt(menu *fyne.Menu, pos fyne.Position)
Root() fyne.Window

Desktop() int
SetDesktop(int)
ShowSettings()
}

var instance Desktop
Expand Down
6 changes: 4 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ require (
github.com/Knetic/govaluate v3.0.0+incompatible
github.com/disintegration/imaging v1.6.2
github.com/fyne-io/image v0.0.0-20240417123036-dc0ee9e7c964
github.com/fyshos/fyles v0.0.0-20240105185750-ba0c41e1f720
github.com/godbus/dbus/v5 v5.1.0
github.com/jackmordaunt/icns v1.0.1-0.20200413110149-9e181b441ab2
github.com/mafik/pulseaudio v0.0.0-20200511091429-8449222912dd
Expand All @@ -18,6 +19,8 @@ require (
howett.net/plist v0.0.0-20181124034731-591f970eefbb
)

require github.com/creack/pty v1.1.21 // indirect

require (
github.com/BurntSushi/toml v1.4.0 // indirect
github.com/jeandeaual/go-locale v0.0.0-20240223122105-ce5225dcaa49 // indirect
Expand All @@ -31,7 +34,6 @@ require (
github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78 // indirect
github.com/BurntSushi/freetype-go v0.0.0-20160129220410-b763ddbfe298 // indirect
github.com/BurntSushi/graphics-go v0.0.0-20160129215708-b43f31a4a966 // indirect
github.com/creack/pty v1.1.21 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/fredbi/uri v1.1.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
Expand All @@ -52,7 +54,7 @@ require (
golang.org/x/image v0.18.0 // indirect
golang.org/x/mobile v0.0.0-20231127183840-76ac6878050a // indirect
golang.org/x/net v0.25.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/sys v0.20.0
golang.org/x/text v0.16.0
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ github.com/fyne-io/terminal v0.0.0-20240728203942-56c3b98b9208 h1:ZMTEq3IAv6EQv6
github.com/fyne-io/terminal v0.0.0-20240728203942-56c3b98b9208/go.mod h1:uTxDe2dNdJWfmUAgWwG+leivgNxSfCY50t+AiNdPmiM=
github.com/fyne-io/xgbutil v0.0.0-20191220152344-7d838166824d h1:8+poQtDqiRfAZmeyYRlInuaIBsQEflmxtpJeZklvNuE=
github.com/fyne-io/xgbutil v0.0.0-20191220152344-7d838166824d/go.mod h1:vPqYMuTmTyrLNDQWQXy9lqdnV+WRQn6jhaSon8TppBs=
github.com/fyshos/fyles v0.0.0-20240105185750-ba0c41e1f720 h1:vxPbMYBDz3sA9Cv1+06yF24p/HssWP2jJjf2u0tNgik=
github.com/fyshos/fyles v0.0.0-20240105185750-ba0c41e1f720/go.mod h1:1g01pnfrasGx2mvHz69XwmgswxWncg41UMzyrqh7b6M=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6 h1:zDw5v7qm4yH7N8C8uWd+8Ii9rROdgWxQuGoJ9WDXxfk=
github.com/go-gl/gl v0.0.0-20211210172815-726fda9656d6/go.mod h1:9YTyiznxEY1fVinfM7RvRcjRHbw2xLBJ3AAGIT0I4Nw=
Expand Down
15 changes: 11 additions & 4 deletions internal/ui/desk.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ import (
"os/exec"
"strconv"

"fyshos.com/fynedesk/internal/notify"

"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
deskDriver "fyne.io/fyne/v2/driver/desktop"

"fyshos.com/fynedesk"
"fyshos.com/fynedesk/internal/notify"
wmtheme "fyshos.com/fynedesk/theme"
"fyshos.com/fynedesk/wm"
)
Expand Down Expand Up @@ -86,11 +85,15 @@ func (l *desktop) SetDesktop(id int) {
}
}

func (l *desktop) ShowSettings() {
l.widgets.showSettings()
}

func (l *desktop) Layout(objects []fyne.CanvasObject, size fyne.Size) {
bg := objects[0].(*background)
bg.Resize(size)
if l.Settings().NarrowLeftLauncher() {
l.bar.Resize(size)
l.bar.Resize(fyne.NewSize(wmtheme.NarrowBarWidth, size.Height))
l.bar.Move(fyne.NewPos(0, 0))
} else {
barHeight := l.bar.MinSize().Height
Expand All @@ -109,6 +112,10 @@ func (l *desktop) MinSize(_ []fyne.CanvasObject) fyne.Size {
return fyne.NewSize(640, 480) // tiny - window manager will scale up to screen size
}

func (l *desktop) Root() fyne.Window {
return l.root
}

func (l *desktop) ShowMenuAt(menu *fyne.Menu, pos fyne.Position) {
l.showMenu(menu, pos)
}
Expand Down Expand Up @@ -186,7 +193,7 @@ func (l *desktop) ContentBoundsPixels(screen *fynedesk.Screen) (x, y, w, h uint3
screenW := uint32(screen.Width)
screenH := uint32(screen.Height)
pad := wmtheme.WidgetPanelWidth
if fynedesk.Instance().Settings().NarrowWidgetPanel() {
if l.Settings().NarrowWidgetPanel() {
pad = wmtheme.NarrowBarWidth
}
if l.screens.Primary() == screen {
Expand Down
2 changes: 1 addition & 1 deletion internal/ui/notifications.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func (n *notification) show(list *fyne.Container) {
n.popup = fyne.CurrentApp().Driver().(deskDriver.Driver).CreateSplashWindow()
n.popup.SetContent(n.renderer)

winSize := fynedesk.Instance().(*desktop).root.Canvas().Size()
winSize := fynedesk.Instance().Root().Canvas().Size()
pos := fyne.NewPos(winSize.Width-280-wmtheme.NarrowBarWidth, 10)
fynedesk.Instance().WindowManager().ShowOverlay(n.popup, fyne.NewSize(270, 120), pos)
} else {
Expand Down
1 change: 1 addition & 0 deletions internal/ui/settings_ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ func (d *settingsUI) loadThemeScreen() fyne.CanvasObject {
list, err := storage.List(themes)
if err != nil {
fyne.LogError("Unable to list themes - missing?", err)
themeList = make([]string, 1)
} else {
for _, l := range list {
themeList = append(themeList, l.Name())
Expand Down
129 changes: 129 additions & 0 deletions modules/fyles/fyles.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
package fyles

import (
"image/color"
"log"
"os"
"path/filepath"

"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/storage"
"fyne.io/fyne/v2/theme"

lib "github.com/fyshos/fyles/pkg/fyles"
"golang.org/x/sys/execabs"

"fyshos.com/fynedesk"
wmtheme "fyshos.com/fynedesk/theme"
)

var fylesMeta = fynedesk.ModuleMetadata{
Name: "Desktop Files",
NewInstance: newFyles,
}

type fyles struct{}

func (f *fyles) Destroy() {
}

func (f *fyles) ScreenAreaWidget() fyne.CanvasObject {
icons := lib.NewFylesPanel(f.tapped, fynedesk.Instance().Root())
icons.HideParent = true
icons.Filter = filterHidden()
f.setDesktopDir(icons)

desk := fynedesk.Instance()
var barPad fyne.CanvasObject
if desk.Settings().NarrowLeftLauncher() {
r := canvas.NewRectangle(color.Transparent)
r.SetMinSize(fyne.NewSize(wmtheme.NarrowBarWidth, 1))
barPad = r
}

rightIndent := wmtheme.WidgetPanelWidth
if desk.Settings().NarrowWidgetPanel() {
rightIndent = wmtheme.NarrowBarWidth
}
widgetPad := canvas.NewRectangle(color.Transparent)
widgetPad.SetMinSize(fyne.NewSize(rightIndent, 1))

return container.NewBorder(nil, nil, barPad, widgetPad, container.NewPadded(icons))
}

func (f *fyles) Metadata() fynedesk.ModuleMetadata {
return fylesMeta
}

func (f *fyles) setDesktopDir(p *lib.Panel) {
home, _ := os.UserHomeDir()
u := storage.NewFileURI(filepath.Join(home, "Desktop"))
settings := newCustomURI("settings://", "Settings", theme.SettingsIcon())
trash := newCustomURI("file://"+filepath.Join(home, ".local", "share", "Trash", "files"), "Trash", theme.DeleteIcon())

list, err := storage.List(u)
list = append([]fyne.URI{settings, trash}, list...)
if err != nil {
fyne.LogError("Could not read Desktop dir", err)
} else {
p.SetListing(list)
}
}

func (f *fyles) tapped(u fyne.URI) {
if u.Scheme() == "settings" {
fynedesk.Instance().ShowSettings()
return
}
p, err := execabs.LookPath("fyles")
if p != "" && err == nil {
if ok, _ := storage.CanList(u); ok {
err := execabs.Command(p, u.Path()).Start()
if err != nil {
log.Println("Error opening Fyles", err)
}
return
}
} else {
log.Println(">>> dir", u)
return
}
log.Println(">>> open", u)
}

// newFyles creates a new module that will manage desktop file icons.
func newFyles() fynedesk.Module {
return &fyles{}
}

type filter struct{}

func (f *filter) Matches(u fyne.URI) bool {
return u.Name()[0] != '.'
}

func filterHidden() storage.FileFilter {
return &filter{}
}

type trashURI struct {
fyne.URI

name string
icon fyne.Resource
}

func newCustomURI(str, name string, icon fyne.Resource) fyne.URI {
u, _ := storage.ParseURI(str)
return &trashURI{URI: u, name: name, icon: icon}
}

func (t *trashURI) Name() string {
return t.name
}

func (t *trashURI) Icon() fyne.Resource {
return t.icon
}
7 changes: 7 additions & 0 deletions modules/fyles/init.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package fyles

import "fyshos.com/fynedesk"

func init() {
fynedesk.RegisterModule(fylesMeta)
}
3 changes: 3 additions & 0 deletions test/desktop.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ func (*Desktop) Desktop() int {
func (*Desktop) SetDesktop(int) {
}

// ShowSettings does nothing for the test package
func (*Desktop) ShowSettings() {}

// IconProvider returns the icon provider, by default it uses a simple in-memory implementation
func (td *Desktop) IconProvider() fynedesk.ApplicationProvider {
return td.icons
Expand Down