Skip to content

Commit

Permalink
feat: static bar (commands or modules)
Browse files Browse the repository at this point in the history
  • Loading branch information
abenz1267 committed Nov 1, 2024
1 parent 411063a commit 4491287
Show file tree
Hide file tree
Showing 9 changed files with 257 additions and 98 deletions.
2 changes: 1 addition & 1 deletion cmd/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.7.11-git
0.8.0
12 changes: 12 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ var Themes embed.FS

type Config struct {
ActivationMode ActivationMode `mapstructure:"activation_mode"`
Bar Bar `mapstructure:"bar"`
Builtins Builtins `mapstructure:"builtins"`
DisableClickToClose bool `mapstructure:"disable_click_to_close"`
Disabled []string `mapstructure:"disabled"`
Expand All @@ -40,6 +41,17 @@ type Config struct {
IsService bool `mapstructure:"-"`
}

type Bar struct {
Entries []BarEntry `mapstructure:"entries"`
}

type BarEntry struct {
Exec string `mapstructure:"exec"`
Icon string `mapstructure:"icon"`
Label string `mapstructure:"label"`
Module string `mapstructure:"module"`
}

type Builtins struct {
Applications Applications `mapstructure:"applications"`
Calc Calc `mapstructure:"calc"`
Expand Down
39 changes: 39 additions & 0 deletions internal/config/layout.default.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,45 @@
"orientation": "vertical",
"spacing": 0,
"revert": false,
"bar": {
"name": "bar",
"orientation": "vertical",
"position": "start",
"h_align": "fill",
"h_expand": true,
"spacing": 16,
"entry": {
"h_align": "start",
"h_expand": false,
"icon": {
"v_align": "start",
"v_expand": false,
"h_expand": false,
"h_align": "start",
"height": -1,
"width": -1,
"hide": false,
"opacity": 1,
"margins": {
"bottom": 0,
"start": 0,
"end": 0,
"top": 0
},
"icon_size": "large",
"pixel_size": -1,
"theme": ""
},
"label": {
"v_align": "fill",
"v_expand": true,
"y_align": 0.5,
"margins": {
"start": 4
}
}
}
},
"search": {
"name": "search",
"v_align": "start",
Expand Down
13 changes: 13 additions & 0 deletions internal/config/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,19 @@ type Box struct {
Scroll Scroll `mapstructure:"scroll"`
Revert bool `mapstructure:"revert"`
Search SearchWrapper `mapstructure:"search"`
Bar BarWrapper `mapstructure:"bar"`
}

type BarWrapper struct {
BoxWidget `mapstructure:",squash"`
Position string `mapstructure:"position"`
Entry BarEntryWrapper `mapstructure:"entry"`
}

type BarEntryWrapper struct {
BoxWidget `mapstructure:",squash"`
Icon ImageWidget `mapstructure:"icon"`
Label LabelWidget `mapstructure:"label"`
}

type Scroll struct {
Expand Down
51 changes: 30 additions & 21 deletions internal/ui/interactions.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,27 +402,8 @@ func activateItem(keepOpen, selectNext, alt bool) {
}

if entry.Sub == "switcher" {
for _, m := range toUse {
if m.General().Name == entry.Label {
explicits = []modules.Workable{}
explicits = append(explicits, m)

common.items.Splice(0, int(common.items.NItems()))
elements.input.SetObjectProperty("placeholder-text", m.General().Placeholder)
setupSingleModule()

if val, ok := layouts[singleModule.General().Name]; ok {
glib.IdleAdd(func() {
layout = val
setupLayout(singleModule.General().Theme, singleModule.General().ThemeBase)
})
}

elements.input.SetText("")
elements.input.GrabFocus()
return
}
}
handleSwitcher(entry.Label)
return
}

if cfg.Terminal != "" {
Expand Down Expand Up @@ -472,6 +453,34 @@ func activateItem(keepOpen, selectNext, alt bool) {
closeAfterActivation(keepOpen, selectNext)
}

func handleSwitcher(module string) {
for _, m := range toUse {
if m.General().Name == module {
explicits = []modules.Workable{}
explicits = append(explicits, m)

common.items.Splice(0, int(common.items.NItems()))
elements.input.SetObjectProperty("placeholder-text", m.General().Placeholder)
setupSingleModule()

if val, ok := layouts[singleModule.General().Name]; ok {
glib.IdleAdd(func() {
layout = val
setupLayout(singleModule.General().Theme, singleModule.General().ThemeBase)
})
}

if elements.input.Text() != "" {
elements.input.SetText("")
} else {
process()
}

elements.input.GrabFocus()
}
}
}

func handleDmenuResult(result string) {
if appstate.IsService {
for _, v := range toUse {
Expand Down
98 changes: 49 additions & 49 deletions internal/ui/layout.xml
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
<interface>
<object class="GtkApplicationWindow" id="win">
<property name="title">Walker</property>
<property name="name">window</property>
<child>
<object class="GtkBox" id="box">
<property name="orientation">vertical</property>
<property name="name">box</property>
<child>
<object class="GtkBox" id="searchwrapper">
<property name="orientation">horizontal</property>
<property name="name">searchwrapper</property>
<child>
<object class="GtkOverlay">
<child type="overlay">
<object class="GtkSearchEntry" id="search">
<property name="name">search</property>
</object>
</child>
<child>
<object class="GtkSearchEntry" id="typeahead">
<property name="name">typeahead</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkSpinner" id="spinner">
<property name="name">spinner</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkScrolledWindow" id="scroll">
<property name="propagate-natural-height">true</property>
<property name="propagate-natural-width">true</property>
<property name="hscrollbar-policy">never</property>
<property name="overlay-scrolling">true</property>
<child>
<object class="GtkListView" id="list">
<property name="name">list</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
on
<object class="GtkApplicationWindow" id="win">
<property name="title">Walker</property>
<property name="name">window</property>
<child>
<object class="GtkBox" id="box">
<property name="orientation">vertical</property>
<property name="name">box</property>
<child>
<object class="GtkBox" id="searchwrapper">
<property name="orientation">horizontal</property>
<property name="name">searchwrapper</property>
<child>
<object class="GtkOverlay">
<child type="overlay">
<object class="GtkSearchEntry" id="search">
<property name="name">search</property>
</object>
</child>
<child>
<object class="GtkSearchEntry" id="typeahead">
<property name="name">typeahead</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkSpinner" id="spinner">
<property name="name">spinner</property>
</object>
</child>
</object>
</child>
<child>
<object class="GtkScrolledWindow" id="scroll">
<property name="propagate-natural-height">true</property>
<property name="propagate-natural-width">true</property>
<property name="hscrollbar-policy">never</property>
<property name="overlay-scrolling">true</property>
<child>
<object class="GtkListView" id="list">
<property name="name">list</property>
</object>
</child>
</object>
</child>
</object>
</child>
</object>
</interface>
21 changes: 0 additions & 21 deletions internal/ui/layout_password.xml

This file was deleted.

Loading

0 comments on commit 4491287

Please sign in to comment.