v0.26.1 75cd777

deps.go RawHistoryFolder

1// Package ui provides the GTK4 presentation layer for the dumber browser.
2package ui
3
4import (
5	"context"
6
7	"github.com/bnema/dumber/internal/application/port"
8	"github.com/bnema/dumber/internal/application/usecase"
9	"github.com/bnema/dumber/internal/domain/entity"
10	"github.com/bnema/dumber/internal/domain/repository"
11	"github.com/bnema/dumber/internal/infrastructure/colorscheme"
12	"github.com/bnema/dumber/internal/infrastructure/config"
13	"github.com/bnema/dumber/internal/infrastructure/favicon"
14	"github.com/bnema/dumber/internal/infrastructure/filtering"
15	"github.com/bnema/dumber/internal/infrastructure/webkit"
16	"github.com/bnema/dumber/internal/ui/theme"
17)
18
19// Dependencies holds all injected dependencies for the UI layer.
20// This struct is created once at startup and passed to UI components.
21type Dependencies struct {
22	// Core context and configuration
23	Ctx                 context.Context
24	Config              *config.Config
25	InitialURL          string // URL to open on startup (optional)
26	RestoreSessionID    string // Session ID to restore on startup (optional)
27	OnFirstWebViewShown func(context.Context)
28	OnSessionPersisted  func() // Called by main after session is persisted to DB
29
30	// Theme and color scheme management
31	Theme           *theme.Manager
32	ColorResolver   port.ColorSchemeResolver
33	AdwaitaDetector *colorscheme.AdwaitaDetector
34
35	// XDG paths
36	XDG port.XDGPaths
37
38	// WebKit infrastructure
39	WebContext    *webkit.WebKitContext
40	Pool          *webkit.WebViewPool
41	Factory       port.WebViewFactory
42	Settings      *webkit.SettingsManager
43	Injector      *webkit.ContentInjector
44	MessageRouter *webkit.MessageRouter
45
46	// Repositories
47	HistoryRepo  repository.HistoryRepository
48	FavoriteRepo repository.FavoriteRepository
49	ZoomRepo     repository.ZoomRepository
50	FilterRepo   repository.ContentWhitelistRepository
51
52	// Use Cases
53	TabsUC      *usecase.ManageTabsUseCase
54	PanesUC     *usecase.ManagePanesUseCase
55	NavigateUC  *usecase.NavigateUseCase
56	ZoomUC      *usecase.ManageZoomUseCase
57	FavoritesUC *usecase.ManageFavoritesUseCase
58	HistoryUC   *usecase.SearchHistoryUseCase
59	CopyURLUC   *usecase.CopyURLUseCase
60
61	// Infrastructure Adapters
62	Clipboard      port.Clipboard
63	FaviconService *favicon.Service
64	FilterManager  *filtering.Manager
65	IdleInhibitor  port.IdleInhibitor
66
67	// Accent picker for dead keys support
68	InsertAccentUC *usecase.InsertAccentUseCase
69
70	// Session management
71	SessionStateRepo repository.SessionStateRepository
72	SessionRepo      repository.SessionRepository
73	CurrentSessionID entity.SessionID
74	SnapshotUC       *usecase.SnapshotSessionUseCase
75
76	// Update management
77	CheckUpdateUC *usecase.CheckUpdateUseCase
78	ApplyUpdateUC *usecase.ApplyUpdateUseCase
79}
80
81// Validate checks that all required dependencies are set.
82func (d *Dependencies) Validate() error {
83	if d.Ctx == nil {
84		return ErrMissingDependency("Ctx")
85	}
86	if d.Config == nil {
87		return ErrMissingDependency("Config")
88	}
89	// WebKit dependencies are optional for testing without WebViews
90	// Use cases are optional - can be nil if not needed
91	return nil
92}
93
94// DependencyError indicates a missing required dependency.
95type DependencyError struct {
96	Name string
97}
98
99func (e DependencyError) Error() string {
100	return "missing required dependency: " + e.Name
101}
102
103// ErrMissingDependency creates a new DependencyError.
104func ErrMissingDependency(name string) error {
105	return DependencyError{Name: name}
106}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 8

Tags 42

↑↓ moveenter openesc close