v0.27.0 dcb4c51

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	StartupCrashReports    []string
28	OnFirstWebViewShown    func(context.Context)
29	OnSessionPersisted     func() // Called by main after session is persisted to DB
30	OnCrashReportsDetected func([]string)
31
32	// Theme and color scheme management
33	Theme           *theme.Manager
34	ColorResolver   port.ColorSchemeResolver
35	AdwaitaDetector *colorscheme.AdwaitaDetector
36
37	// XDG paths
38	XDG port.XDGPaths
39
40	// WebKit infrastructure
41	WebContext    *webkit.WebKitContext
42	Pool          *webkit.WebViewPool
43	Factory       port.WebViewFactory
44	Settings      *webkit.SettingsManager
45	Injector      *webkit.ContentInjector
46	MessageRouter *webkit.MessageRouter
47
48	// Repositories
49	HistoryRepo    repository.HistoryRepository
50	FavoriteRepo   repository.FavoriteRepository
51	ZoomRepo       repository.ZoomRepository
52	PermissionRepo port.PermissionRepository
53	FilterRepo     repository.ContentWhitelistRepository
54
55	// Use Cases
56	TabsUC       *usecase.ManageTabsUseCase
57	PanesUC      *usecase.ManagePanesUseCase
58	NavigateUC   *usecase.NavigateUseCase
59	ZoomUC       *usecase.ManageZoomUseCase
60	PermissionUC *usecase.HandlePermissionUseCase
61	FavoritesUC  *usecase.ManageFavoritesUseCase
62	HistoryUC    *usecase.SearchHistoryUseCase
63	CopyURLUC    *usecase.CopyURLUseCase
64
65	// Infrastructure Adapters
66	Clipboard      port.Clipboard
67	FaviconService *favicon.Service
68	FilterManager  *filtering.Manager
69	IdleInhibitor  port.IdleInhibitor
70
71	// Accent picker for dead keys support
72	InsertAccentUC *usecase.InsertAccentUseCase
73
74	// Session management
75	SessionStateRepo repository.SessionStateRepository
76	SessionRepo      repository.SessionRepository
77	CurrentSessionID entity.SessionID
78	SnapshotUC       *usecase.SnapshotSessionUseCase
79
80	// Update management
81	CheckUpdateUC *usecase.CheckUpdateUseCase
82	ApplyUpdateUC *usecase.ApplyUpdateUseCase
83}
84
85// Validate checks that all required dependencies are set.
86func (d *Dependencies) Validate() error {
87	if d.Ctx == nil {
88		return ErrMissingDependency("Ctx")
89	}
90	if d.Config == nil {
91		return ErrMissingDependency("Config")
92	}
93	// WebKit dependencies are optional for testing without WebViews
94	// Use cases are optional - can be nil if not needed
95	return nil
96}
97
98// DependencyError indicates a missing required dependency.
99type DependencyError struct {
100	Name string
101}
102
103func (e DependencyError) Error() string {
104	return "missing required dependency: " + e.Name
105}
106
107// ErrMissingDependency creates a new DependencyError.
108func ErrMissingDependency(name string) error {
109	return DependencyError{Name: name}
110}

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