fix(history): polish sidebar review follow-ups
- commit
- 217c6f08bad24a633caf707592f0d61c4988db79
- author
- brice · · 2026-06-13 09:33 UTC
- parent
- 1ee4e97
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
2 files · +10 -6
M internal/ui/browser_window_history_sidebar.go +4 -2
| @@ -28,10 +28,12 @@ func (bw *browserWindow) initHistorySidebar(ctx context.Context, a *App) { | |||
| 28 | 28 | } | |
| 29 | 29 | ||
| 30 | 30 | bw.historySidebar = sidebar | |
| 31 | - | bw.sidebarVisible = false | |
| 32 | 31 | ||
| 33 | - | // Mount into the main window's sidebar box | |
| 32 | + | // Mount into the main window's sidebar box. | |
| 34 | 33 | bw.mainWindow.SetSidebarWidget(sidebar.Widget()) | |
| 34 | + | bw.historySidebar.Hide() | |
| 35 | + | bw.mainWindow.SetSidebarVisible(false) | |
| 36 | + | bw.sidebarVisible = false | |
| 35 | 37 | ||
| 36 | 38 | // Apply sidebar width from config, falling back to the default 320px. | |
| 37 | 39 | // The width is clamped to [280, 380] by SetSidebarWidth internally. | |
| @@ -28,10 +28,12 @@ func (bw *browserWindow) initHistorySidebar(ctx context.Context, a *App) { | |||||
| 28 | } | 28 | } | ||
| 29 | 29 | ||||
| 30 | bw.historySidebar = sidebar | 30 | bw.historySidebar = sidebar | ||
| 31 | - | bw.sidebarVisible = false | |||
| 32 | 31 | ||||
| 33 | - | // Mount into the main window's sidebar box | 32 | + | // Mount into the main window's sidebar box. |
| 34 | bw.mainWindow.SetSidebarWidget(sidebar.Widget()) | 33 | bw.mainWindow.SetSidebarWidget(sidebar.Widget()) | ||
| 34 | + | bw.historySidebar.Hide() | |||
| 35 | + | bw.mainWindow.SetSidebarVisible(false) | |||
| 36 | + | bw.sidebarVisible = false | |||
| 35 | 37 | ||||
| 36 | // Apply sidebar width from config, falling back to the default 320px. | 38 | // Apply sidebar width from config, falling back to the default 320px. | ||
| 37 | // The width is clamped to [280, 380] by SetSidebarWidth internally. | 39 | // The width is clamped to [280, 380] by SetSidebarWidth internally. | ||
M internal/ui/component/history_sidebar_rendering.go +6 -4
| @@ -1,8 +1,6 @@ | |||
| 1 | 1 | package component | |
| 2 | 2 | ||
| 3 | 3 | import ( | |
| 4 | - | "fmt" | |
| 5 | - | ||
| 6 | 4 | "github.com/bnema/puregotk/v4/gtk" | |
| 7 | 5 | "github.com/bnema/puregotk/v4/pango" | |
| 8 | 6 | ||
| @@ -78,7 +76,7 @@ func (hs *HistorySidebar) showLoadingOrEmpty(query string, searchDone bool) { | |||
| 78 | 76 | case query != "" && !searchDone: | |
| 79 | 77 | label.SetText("Searching...") | |
| 80 | 78 | case query != "": | |
| 81 | - | label.SetText(fmt.Sprintf("No results for %q", query)) | |
| 79 | + | label.SetText(noResultsText(query)) | |
| 82 | 80 | default: | |
| 83 | 81 | label.SetText("No browsing history") | |
| 84 | 82 | } | |
| @@ -97,6 +95,10 @@ func (hs *HistorySidebar) showLoadingOrEmpty(query string, searchDone bool) { | |||
| 97 | 95 | hs.listBox.Append(&row.Widget) | |
| 98 | 96 | } | |
| 99 | 97 | ||
| 98 | + | func noResultsText(query string) string { | |
| 99 | + | return "No results for \"" + query + "\"" | |
| 100 | + | } | |
| 101 | + | ||
| 100 | 102 | func (hs *HistorySidebar) showEmptyState(query string) { | |
| 101 | 103 | label := gtk.NewLabel(nil) | |
| 102 | 104 | if label == nil { | |
| @@ -105,7 +107,7 @@ func (hs *HistorySidebar) showEmptyState(query string) { | |||
| 105 | 107 | label.AddCssClass("history-sidebar-empty") | |
| 106 | 108 | ||
| 107 | 109 | if query != "" { | |
| 108 | - | label.SetText(fmt.Sprintf("No results for %q", query)) | |
| 110 | + | label.SetText(noResultsText(query)) | |
| 109 | 111 | } else { | |
| 110 | 112 | label.SetText("No browsing history") | |
| 111 | 113 | } | |
| @@ -1,8 +1,6 @@ | |||||
| 1 | package component | 1 | package component | ||
| 2 | 2 | ||||
| 3 | import ( | 3 | import ( | ||
| 4 | - | "fmt" | |||
| 5 | - | ||||
| 6 | "github.com/bnema/puregotk/v4/gtk" | 4 | "github.com/bnema/puregotk/v4/gtk" | ||
| 7 | "github.com/bnema/puregotk/v4/pango" | 5 | "github.com/bnema/puregotk/v4/pango" | ||
| 8 | 6 | ||||
| @@ -78,7 +76,7 @@ func (hs *HistorySidebar) showLoadingOrEmpty(query string, searchDone bool) { | |||||
| 78 | case query != "" && !searchDone: | 76 | case query != "" && !searchDone: | ||
| 79 | label.SetText("Searching...") | 77 | label.SetText("Searching...") | ||
| 80 | case query != "": | 78 | case query != "": | ||
| 81 | - | label.SetText(fmt.Sprintf("No results for %q", query)) | 79 | + | label.SetText(noResultsText(query)) |
| 82 | default: | 80 | default: | ||
| 83 | label.SetText("No browsing history") | 81 | label.SetText("No browsing history") | ||
| 84 | } | 82 | } | ||
| @@ -97,6 +95,10 @@ func (hs *HistorySidebar) showLoadingOrEmpty(query string, searchDone bool) { | |||||
| 97 | hs.listBox.Append(&row.Widget) | 95 | hs.listBox.Append(&row.Widget) | ||
| 98 | } | 96 | } | ||
| 99 | 97 | ||||
| 98 | + | func noResultsText(query string) string { | |||
| 99 | + | return "No results for \"" + query + "\"" | |||
| 100 | + | } | |||
| 101 | + | ||||
| 100 | func (hs *HistorySidebar) showEmptyState(query string) { | 102 | func (hs *HistorySidebar) showEmptyState(query string) { | ||
| 101 | label := gtk.NewLabel(nil) | 103 | label := gtk.NewLabel(nil) | ||
| 102 | if label == nil { | 104 | if label == nil { | ||
| @@ -105,7 +107,7 @@ func (hs *HistorySidebar) showEmptyState(query string) { | |||||
| 105 | label.AddCssClass("history-sidebar-empty") | 107 | label.AddCssClass("history-sidebar-empty") | ||
| 106 | 108 | ||||
| 107 | if query != "" { | 109 | if query != "" { | ||
| 108 | - | label.SetText(fmt.Sprintf("No results for %q", query)) | 110 | + | label.SetText(noResultsText(query)) |
| 109 | } else { | 111 | } else { | ||
| 110 | label.SetText("No browsing history") | 112 | label.SetText("No browsing history") | ||
| 111 | } | 113 | } | ||