Skip to content

Commit

Permalink
minor: changed default catppuccin theme, added empty list placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
abenz1267 committed Nov 1, 2024
1 parent 86799f9 commit 6369fa7
Show file tree
Hide file tree
Showing 12 changed files with 102 additions and 51 deletions.
2 changes: 1 addition & 1 deletion cmd/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.8.1-git
0.8.1
3 changes: 2 additions & 1 deletion internal/config/config.default.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"max_entries": 50,
"show_initial_entries": true,
"single_click": true,
"visibility_threshold": 20
"visibility_threshold": 20,
"placeholder": "No Results"
},
"search": {
"placeholder": "Search...",
Expand Down
11 changes: 6 additions & 5 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,11 +197,12 @@ type Search struct {
}

type List struct {
Cycle bool `mapstructure:"cycle"`
MaxEntries int `mapstructure:"max_entries"`
ShowInitialEntries bool `mapstructure:"show_initial_entries"`
SingleClick bool `mapstructure:"single_click"`
VisibilityThreshold int `mapstructure:"visibility_threshold"`
Cycle bool `mapstructure:"cycle"`
MaxEntries int `mapstructure:"max_entries"`
Placeholder string `mapstructure:"placeholder"`
ShowInitialEntries bool `mapstructure:"show_initial_entries"`
SingleClick bool `mapstructure:"single_click"`
VisibilityThreshold int `mapstructure:"visibility_threshold"`
}

func Get(config string) *Config {
Expand Down
14 changes: 13 additions & 1 deletion internal/config/layout.default.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"h_expand": false,
"h_align": "start",
"height": -1,
"width": 500,
"width": 400,
"hide": false,
"opacity": 1,
"margins": {
Expand Down Expand Up @@ -186,6 +186,18 @@
"width": -1,
"hide": false,
"opacity": 1,
"placeholder": {
"name": "listplaceholder",
"h_align": "fill",
"h_expand": true,
"x_align": 0.5,
"margins": {
"bottom": 0,
"start": 0,
"end": 0,
"top": 10
}
},
"margins": {
"bottom": 0,
"start": 0,
Expand Down
2 changes: 2 additions & 0 deletions internal/config/themes/bare.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ child,
scrollbar,
slider,
#item,
#bar,
#listplaceholder,
#text,
#label,
#sub,
Expand Down
9 changes: 8 additions & 1 deletion internal/config/themes/catppuccin.css
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ slider,
#item,
#text,
#label,
#bar,
#listplaceholder,
#sub,
#activationlabel {
all: unset;
Expand All @@ -24,6 +26,7 @@ slider,
#box {
background: #303446;
padding: 16px;
padding-top: 0px;
border-radius: 8px;
box-shadow:
0 19px 38px rgba(0, 0, 0, 0.3),
Expand Down Expand Up @@ -69,7 +72,7 @@ slider {

#input > *:last-child,
#typeahead > *:last-child {
color: #7f849c;
opacity: 0;
}

#spinner {
Expand All @@ -86,6 +89,10 @@ slider {
#list {
}

#listplaceholder {
color: #cad3f5;
}

child {
border-radius: 8px;
color: #cad3f5;
Expand Down
18 changes: 7 additions & 11 deletions internal/config/themes/catppuccin.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"ui": {
"anchors": {
"top": true,
"bottom": true,
"left": true,
"right": true,
"top": true
"right": true
},
"window": {
"box": {
Expand All @@ -13,33 +13,29 @@
"bottom": 200,
"top": 200
},
"orientation": "horizontal",
"orientation": "vertical",
"width": 400,
"scroll": {
"list": {
"always_show": true,
"item": {
"activation_label": {
"h_align": "end",
"h_expand": true,
"justify": "right",
"width": 20,
"x_align": 1
},
"icon": {
"theme": "Papirus"
},
"spacing": 5,
"text": {
"revert": true,
"h_align": "fill",
"h_expand": true
"revert": true
}
},
"max_height": 300,
"max_width": 400,
"min_width": 400,
"width": 400
},
"overlay_scrolling": false
}
},
"search": {
"spacing": 10,
Expand Down
2 changes: 2 additions & 0 deletions internal/config/themes/kanagawa.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ scrollbar,
slider,
#item,
#text,
#bar,
#listplaceholder,
#label,
#sub,
#activationlabel {
Expand Down
11 changes: 6 additions & 5 deletions internal/config/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,16 @@ type SpinnerWidget struct {
}

type ListWrapper struct {
Widget `mapstructure:",squash"`
Item ListItemWidget `mapstructure:"item"`
AlwaysShow bool `mapstructure:"always_show"`
Grid bool `mapstructure:"grid"`
Orientation string `mapstructure:"orientation"`
MinHeight int `mapstructure:"min_height"`
Item ListItemWidget `mapstructure:"item"`
MaxHeight int `mapstructure:"max_height"`
MaxWidth int `mapstructure:"max_width"`
MinHeight int `mapstructure:"min_height"`
MinWidth int `mapstructure:"min_width"`
AlwaysShow bool `mapstructure:"always_show"`
Orientation string `mapstructure:"orientation"`
Placeholder LabelWidget `mapstructure:"placeholder"`
Widget `mapstructure:",squash"`
}

type ListItemWidget struct {
Expand Down
8 changes: 8 additions & 0 deletions internal/ui/interactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,10 @@ func closeAfterActivation(keepOpen, next bool) {
var cancel context.CancelFunc

func process() {
if cfg.List.Placeholder != "" {
elements.listPlaceholder.SetVisible(false)
}

if cancel != nil {
cancel()
}
Expand Down Expand Up @@ -763,6 +767,10 @@ func processAsync(ctx context.Context, text string) {
}
}

if cfg.List.Placeholder != "" && len(entries) == 0 {
elements.listPlaceholder.SetVisible(true)
}

glib.IdleAdd(func() {
common.items.Splice(0, int(common.items.NItems()), entries...)
})
Expand Down
12 changes: 12 additions & 0 deletions internal/ui/theme.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,19 @@ func setupBoxTheme() {
return
}

if cfg.List.Placeholder != "" {
setupLabelWidgetStyle(elements.listPlaceholder, &layout.Window.Box.Scroll.List.Placeholder)
}

if layout.Window.Box.Revert {
if layout.Window.Box.Bar.Position == "start" {
elements.box.Append(elements.bar)
}

if cfg.List.Placeholder != "" {
elements.box.Append(elements.listPlaceholder)
}

elements.box.Append(elements.scroll)

if layout.Window.Box.Bar.Position == "between" {
Expand All @@ -186,6 +194,10 @@ func setupBoxTheme() {

elements.box.Append(elements.scroll)

if cfg.List.Placeholder != "" {
elements.box.Append(elements.listPlaceholder)
}

if layout.Window.Box.Bar.Position == "end" {
elements.box.Append(elements.bar)
}
Expand Down
61 changes: 35 additions & 26 deletions internal/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,21 @@ type Common struct {
}

type Elements struct {
scroll *gtk.ScrolledWindow
overlay *gtk.Overlay
spinner *gtk.Spinner
search *gtk.Box
bar *gtk.Box
prompt *gtk.Label
box *gtk.Box
appwin *gtk.ApplicationWindow
typeahead *gtk.SearchEntry
input *gtk.SearchEntry
grid *gtk.GridView
prefixClasses map[string][]string
iconTheme *gtk.IconTheme
password *gtk.PasswordEntry
scroll *gtk.ScrolledWindow
overlay *gtk.Overlay
spinner *gtk.Spinner
search *gtk.Box
bar *gtk.Box
prompt *gtk.Label
box *gtk.Box
appwin *gtk.ApplicationWindow
typeahead *gtk.SearchEntry
input *gtk.SearchEntry
grid *gtk.GridView
prefixClasses map[string][]string
iconTheme *gtk.IconTheme
password *gtk.PasswordEntry
listPlaceholder *gtk.Label
}

func Activate(state *state.AppState) func(app *gtk.Application) {
Expand Down Expand Up @@ -272,19 +273,27 @@ func setupElements(app *gtk.Application) *Elements {

bar := gtk.NewBox(gtk.OrientationVertical, 0)

var listPlaceholder *gtk.Label

if cfg.List.Placeholder != "" {
listPlaceholder = gtk.NewLabel(cfg.List.Placeholder)
listPlaceholder.SetVisible(false)
}

ui := &Elements{
bar: bar,
overlay: overlay,
spinner: spinner,
search: search,
prompt: prompt,
typeahead: typeahead,
scroll: scroll,
box: box,
appwin: appwin,
input: input,
grid: grid,
prefixClasses: make(map[string][]string),
listPlaceholder: listPlaceholder,
bar: bar,
overlay: overlay,
spinner: spinner,
search: search,
prompt: prompt,
typeahead: typeahead,
scroll: scroll,
box: box,
appwin: appwin,
input: input,
grid: grid,
prefixClasses: make(map[string][]string),
}

if cfg.List.SingleClick {
Expand Down

0 comments on commit 6369fa7

Please sign in to comment.