Skip to content

Commit

Permalink
set default font size explicitly #623
Browse files Browse the repository at this point in the history
  • Loading branch information
matryer committed Mar 10, 2021
1 parent cdfab60 commit f5cef13
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 12 deletions.
25 changes: 17 additions & 8 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ func (a *app) RefreshAll() {
// Setup plugin
plugin.OnCycle = a.onCycle
plugin.OnRefresh = a.onRefresh
plugin.Stdout = os.Stdout
plugin.Stderr = os.Stderr
if a.Verbose {
plugin.Stdout = os.Stdout
plugin.Stderr = os.Stderr
plugin.Debugf = plugins.DebugfLog
}
a.pluginTrays[plugin.Command] = &menu.TrayMenu{
Expand Down Expand Up @@ -235,6 +235,7 @@ func (a *app) generatePreferencesMenu(plugin *plugins.Plugin) *menu.Menu {
var items []*menu.MenuItem
if plugin != nil {
items = append(items, &menu.MenuItem{
FontSize: defaultMenuFontSize,
Type: menu.TextType,
Label: "Refresh",
Accelerator: keys.CmdOrCtrl("r"),
Expand All @@ -244,6 +245,7 @@ func (a *app) generatePreferencesMenu(plugin *plugins.Plugin) *menu.Menu {
})
}
items = append(items, &menu.MenuItem{
FontSize: defaultMenuFontSize,
Type: menu.TextType,
Label: "Refresh all",
Accelerator: keys.Combo("r", keys.CmdOrCtrlKey, keys.ShiftKey),
Expand All @@ -252,6 +254,7 @@ func (a *app) generatePreferencesMenu(plugin *plugins.Plugin) *menu.Menu {
items = append(items, menu.Separator())
if plugin != nil {
items = append(items, &menu.MenuItem{
FontSize: defaultMenuFontSize,
Type: menu.TextType,
Label: "Open plugin…",
Accelerator: keys.CmdOrCtrl("e"),
Expand All @@ -269,35 +272,41 @@ func (a *app) generatePreferencesMenu(plugin *plugins.Plugin) *menu.Menu {
})
}
items = append(items, &menu.MenuItem{
FontSize: defaultMenuFontSize,
Type: menu.TextType,
Label: "Plugin browser…",
Accelerator: keys.CmdOrCtrl("p"),
Click: a.onPluginsMenuClicked,
})
items = append(items, &menu.MenuItem{
Type: menu.TextType,
Label: "Open plugin folder…",
Click: a.onOpenPluginsFolderClicked,
FontSize: defaultMenuFontSize,
Type: menu.TextType,
Label: "Open plugin folder…",
Click: a.onOpenPluginsFolderClicked,
})
items = append(items, menu.Separator())
items = append(items, &menu.MenuItem{
FontSize: defaultMenuFontSize,
Type: menu.TextType,
Label: fmt.Sprintf("xbar (%s)", version),
Disabled: true,
})
items = append(items, &menu.MenuItem{
Type: menu.TextType,
Label: "Check for updates…",
Click: a.onCheckForUpdatesMenuClick,
FontSize: defaultMenuFontSize,
Type: menu.TextType,
Label: "Check for updates…",
Click: a.onCheckForUpdatesMenuClick,
})
items = append(items, &menu.MenuItem{
FontSize: defaultMenuFontSize,
// todo: remove this item once cmd+R is working #refresh
Type: menu.TextType,
Label: "Clear cache",
Click: a.onClearCacheMenuClicked,
})
items = append(items, menu.Separator())
items = append(items, &menu.MenuItem{
FontSize: defaultMenuFontSize,
Type: menu.TextType,
Label: "Quit xbar",
Accelerator: keys.CmdOrCtrl("q"),
Expand Down
5 changes: 5 additions & 0 deletions app/menu_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import (
"github.com/wailsapp/wails/v2/pkg/menu/keys"
)

const defaultMenuFontSize = 14

// MenuParser translates xbar items into Wails menu items.
type MenuParser struct{}

Expand Down Expand Up @@ -63,6 +65,9 @@ func (m MenuParser) ParseMenuItem(ctx context.Context, item *plugins.Item) *menu
menuItem.Image = item.Params.Image
menuItem.FontName = item.Params.Font
menuItem.FontSize = item.Params.Size
if menuItem.FontSize == 0 {
menuItem.FontSize = defaultMenuFontSize
}
menuItem.RGBA = item.Params.Color
// Check for template image
if item.Params.TemplateImage != "" {
Expand Down
2 changes: 1 addition & 1 deletion pkg/plugins/items_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ three
is.NoErr(err)
is.Equal(len(items.CycleItems), 1)
is.Equal(len(items.ExpandedItems), 5)
is.Equal(items.ExpandedItems[1].Params.Size, 5) // items.ExpandedItems[1].Params.Size
//is.Equal(items.ExpandedItems[1].Params.Size, 5) // items.ExpandedItems[1].Params.Size
}

func TestErrors(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/plugins/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (p *Plugin) parseOutput(ctx context.Context, filename string, r io.Reader)
Text: " ",
Params: params,
}
blankLineItem.Params.Size = 5
//blankLineItem.Params.Size = 5
items.ExpandedItems = append(items.ExpandedItems, blankLineItem)
continue
}
Expand Down
2 changes: 0 additions & 2 deletions pkg/plugins/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,6 @@ func (p *Plugin) Run(ctx context.Context) {

// TriggerRefresh triggers a refresh on this Plugin.
func (p *Plugin) TriggerRefresh() {
log.Println("TriggerRefresh")
// disable the menu
p.CycleIndex = 0 // reset
// just keep the current item
Expand All @@ -242,7 +241,6 @@ func (p *Plugin) TriggerRefresh() {
currentItem,
}
p.CycleIndex = 0 // reset
log.Printf("TriggerRefresh: p.OnRefresh: %+v\n", p.Items)
if p.OnCycle != nil {
p.cycleSignal <- struct{}{}
}
Expand Down

0 comments on commit f5cef13

Please sign in to comment.