Skip to content

Commit

Permalink
finder: added preview_images [default: false]
Browse files Browse the repository at this point in the history
  • Loading branch information
abenz1267 committed Jan 12, 2025
1 parent bb0c156 commit a2e4838
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions internal/config/config.default.toml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ ignore_gitignore = true
refresh = true
concurrency = 8
show_icon_when_single = true
preview_images = false

[builtins.runner]
weight = 5
Expand Down
1 change: 1 addition & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ type Finder struct {
IgnoreGitIgnore bool `koanf:"ignore_gitignore"`
Concurrency int `koanf:"concurrency"`
EagerLoading bool `koanf:"eager_loading"`
PreviewImages bool `koanf:"preview_images"`
}

type Commands struct {
Expand Down
11 changes: 11 additions & 0 deletions internal/modules/finder.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import (
"golang.org/x/exp/slog"
)

var imgExtensions = []string{".png", ".jpg", ".jpeg", ".gif", ".bmp", ".webp"}

type Finder struct {
config config.Finder
files []string
Expand Down Expand Up @@ -103,6 +105,15 @@ func (f *Finder) Entries(term string) []util.Entry {
Matching: util.Fuzzy,
}

if f.config.PreviewImages {
ext := filepath.Ext(v)

if slices.Contains(imgExtensions, ext) {
path := filepath.Join(f.homedir, v)
entry.Image = path
}
}

res := ""

if f.MarkerColor != "" {
Expand Down
2 changes: 1 addition & 1 deletion internal/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ func setupFactory() *gtk.SignalListItemFactory {
icon = gtk.NewImageFromPaintable(t)
}

if !layout.Window.Box.Scroll.List.Item.Icon.Hide {
if !layout.Window.Box.Scroll.List.Item.Icon.Hide && icon == nil {
if singleModule == nil || singleModule.General().ShowIconWhenSingle {
ii := val.Icon

Expand Down

0 comments on commit a2e4838

Please sign in to comment.