detached e6af2b6

refactor(webkit): enable FaviconDatabase, fix glib object handling

- Add GetFaviconDatabase() to WebView wrapper
- Remove favicon signal registration (now in FaviconService)
- Fix coreglib.InternObject() → glib.BaseObject() in NewBareRelatedWebView
- Update setupFaviconHandlers to enable favicon collection only
- Update TLS certificate struct alignment (formatting)
commit
e6af2b64880472dc6053103da1f92d3652bfe65c
author
bnema · · 2025-10-18 10:55 UTC
parent
0acc806
signature
GPG Unverified2B82207D370127A0 The key is unknown
3 files · +30 -26
M pkg/webkit/tls_handler.go +2 -2
@@ -18,8 +18,8 @@ import (
1818
1919 // TLSCertificateInfo holds information about a TLS certificate for display
2020 type TLSCertificateInfo struct {
21- Subject string
22- Issuer string
21+ Subject string
22+ Issuer string
2323 NotBefore string
2424 NotAfter string
2525 IsExpired bool
@@ -18,8 +18,8 @@ import (
18 18
19 // TLSCertificateInfo holds information about a TLS certificate for display19 // TLSCertificateInfo holds information about a TLS certificate for display
20 type TLSCertificateInfo struct {20 type TLSCertificateInfo struct {
21- Subject string21+ Subject string
22- Issuer string22+ Issuer string
23 NotBefore string23 NotBefore string
24 NotAfter string24 NotAfter string
25 IsExpired bool25 IsExpired bool
M pkg/webkit/webview.go +26 -23
@@ -726,6 +726,29 @@ func (w *WebView) Window() *Window {
726726 return w.window
727727 }
728728
729+// GetFaviconDatabase returns the WebKit FaviconDatabase for this WebView
730+// Returns nil if the favicon database is not available
731+func (w *WebView) GetFaviconDatabase() *webkit.FaviconDatabase {
732+ w.mu.RLock()
733+ defer w.mu.RUnlock()
734+
735+ if w.destroyed || w.view == nil {
736+ return nil
737+ }
738+
739+ session := w.view.NetworkSession()
740+ if session == nil {
741+ return nil
742+ }
743+
744+ dataManager := session.WebsiteDataManager()
745+ if dataManager == nil {
746+ return nil
747+ }
748+
749+ return dataManager.FaviconDatabase()
750+}
751+
729752 // UpdateContentFilters updates the content filtering rules
730753 func (w *WebView) UpdateContentFilters(rules string) error {
731754 w.mu.RLock()
@@ -784,7 +807,9 @@ func (w *WebView) RegisterPaneModeHandler(handler func(action string) bool, isAc
784807 w.isPaneModeActive = isActiveChecker
785808 }
786809
787-// setupFaviconHandlers connects to the FaviconDatabase signals
810+// setupFaviconHandlers enables favicons for this WebView
811+// Note: The actual favicon-changed handler is registered ONCE at the FaviconService level
812+// to avoid duplicate handlers when multiple WebViews exist
788813 func (w *WebView) setupFaviconHandlers() {
789814 // Get the NetworkSession from the WebView
790815 session := w.view.NetworkSession()
@@ -806,28 +831,6 @@ func (w *WebView) setupFaviconHandlers() {
806831 log.Printf("[webkit] Enabled favicons for WebView ID %d", w.id)
807832 }
808833
809- // Get the FaviconDatabase
810- faviconDB := dataManager.FaviconDatabase()
811- if faviconDB == nil {
812- log.Printf("[webkit] Warning: No FaviconDatabase available")
813- return
814- }
815-
816- // Connect to the favicon-changed signal
817- faviconDB.ConnectFaviconChanged(func(pageURI, faviconURI string) {
818- log.Printf("[favicon] Favicon changed for %s: %s", pageURI, faviconURI)
819-
820- // Call the URI handler if registered
821- w.mu.RLock()
822- handler := w.onFaviconURIChanged
823- w.mu.RUnlock()
824-
825- if handler != nil {
826- handler(pageURI, faviconURI)
827- }
828- })
829-
830- log.Printf("[webkit] Connected to FaviconDatabase for WebView ID %d", w.id)
831834 }
832835
833836 // GtkWebView returns the underlying gotk4 WebView for advanced operations
@@ -726,6 +726,29 @@ func (w *WebView) Window() *Window {
726 return w.window726 return w.window
727 }727 }
728 728
729+// GetFaviconDatabase returns the WebKit FaviconDatabase for this WebView
730+// Returns nil if the favicon database is not available
731+func (w *WebView) GetFaviconDatabase() *webkit.FaviconDatabase {
732+ w.mu.RLock()
733+ defer w.mu.RUnlock()
734+
735+ if w.destroyed || w.view == nil {
736+ return nil
737+ }
738+
739+ session := w.view.NetworkSession()
740+ if session == nil {
741+ return nil
742+ }
743+
744+ dataManager := session.WebsiteDataManager()
745+ if dataManager == nil {
746+ return nil
747+ }
748+
749+ return dataManager.FaviconDatabase()
750+}
751+
729 // UpdateContentFilters updates the content filtering rules752 // UpdateContentFilters updates the content filtering rules
730 func (w *WebView) UpdateContentFilters(rules string) error {753 func (w *WebView) UpdateContentFilters(rules string) error {
731 w.mu.RLock()754 w.mu.RLock()
@@ -784,7 +807,9 @@ func (w *WebView) RegisterPaneModeHandler(handler func(action string) bool, isAc
784 w.isPaneModeActive = isActiveChecker807 w.isPaneModeActive = isActiveChecker
785 }808 }
786 809
787-// setupFaviconHandlers connects to the FaviconDatabase signals810+// setupFaviconHandlers enables favicons for this WebView
811+// Note: The actual favicon-changed handler is registered ONCE at the FaviconService level
812+// to avoid duplicate handlers when multiple WebViews exist
788 func (w *WebView) setupFaviconHandlers() {813 func (w *WebView) setupFaviconHandlers() {
789 // Get the NetworkSession from the WebView814 // Get the NetworkSession from the WebView
790 session := w.view.NetworkSession()815 session := w.view.NetworkSession()
@@ -806,28 +831,6 @@ func (w *WebView) setupFaviconHandlers() {
806 log.Printf("[webkit] Enabled favicons for WebView ID %d", w.id)831 log.Printf("[webkit] Enabled favicons for WebView ID %d", w.id)
807 }832 }
808 833
809- // Get the FaviconDatabase
810- faviconDB := dataManager.FaviconDatabase()
811- if faviconDB == nil {
812- log.Printf("[webkit] Warning: No FaviconDatabase available")
813- return
814- }
815-
816- // Connect to the favicon-changed signal
817- faviconDB.ConnectFaviconChanged(func(pageURI, faviconURI string) {
818- log.Printf("[favicon] Favicon changed for %s: %s", pageURI, faviconURI)
819-
820- // Call the URI handler if registered
821- w.mu.RLock()
822- handler := w.onFaviconURIChanged
823- w.mu.RUnlock()
824-
825- if handler != nil {
826- handler(pageURI, faviconURI)
827- }
828- })
829-
830- log.Printf("[webkit] Connected to FaviconDatabase for WebView ID %d", w.id)
831 }834 }
832 835
833 // GtkWebView returns the underlying gotk4 WebView for advanced operations836 // GtkWebView returns the underlying gotk4 WebView for advanced operations
M pkg/webkit/webview_related.go +2 -1
@@ -25,6 +25,7 @@ import (
2525
2626 webkit "github.com/diamondburned/gotk4-webkitgtk/pkg/webkit/v6"
2727 coreglib "github.com/diamondburned/gotk4/pkg/core/glib"
28+ "github.com/diamondburned/gotk4/pkg/glib/v2"
2829 "github.com/diamondburned/gotk4/pkg/gtk/v4"
2930 )
3031
@@ -41,7 +42,7 @@ func NewBareRelatedWebView(parentView *webkit.WebView) *webkit.WebView {
4142 }
4243
4344 // Get the native C pointer from the gotk4 WebView
44- parentObj := coreglib.InternObject(parentView)
45+ parentObj := glib.BaseObject(parentView)
4546 if parentObj == nil {
4647 log.Printf("[webkit] NewBareRelatedWebView: failed to get parent object, creating unrelated WebView")
4748 return webkit.NewWebView()
@@ -25,6 +25,7 @@ import (
25 25
26 webkit "github.com/diamondburned/gotk4-webkitgtk/pkg/webkit/v6"26 webkit "github.com/diamondburned/gotk4-webkitgtk/pkg/webkit/v6"
27 coreglib "github.com/diamondburned/gotk4/pkg/core/glib"27 coreglib "github.com/diamondburned/gotk4/pkg/core/glib"
28+ "github.com/diamondburned/gotk4/pkg/glib/v2"
28 "github.com/diamondburned/gotk4/pkg/gtk/v4"29 "github.com/diamondburned/gotk4/pkg/gtk/v4"
29 )30 )
30 31
@@ -41,7 +42,7 @@ func NewBareRelatedWebView(parentView *webkit.WebView) *webkit.WebView {
41 }42 }
42 43
43 // Get the native C pointer from the gotk4 WebView44 // Get the native C pointer from the gotk4 WebView
44- parentObj := coreglib.InternObject(parentView)45+ parentObj := glib.BaseObject(parentView)
45 if parentObj == nil {46 if parentObj == nil {
46 log.Printf("[webkit] NewBareRelatedWebView: failed to get parent object, creating unrelated WebView")47 log.Printf("[webkit] NewBareRelatedWebView: failed to get parent object, creating unrelated WebView")
47 return webkit.NewWebView()48 return webkit.NewWebView()

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