v0.9.0 636c44c

webview_callbacks.h RawHistoryFolder

1#ifndef WEBVIEW_CALLBACKS_H
2#define WEBVIEW_CALLBACKS_H
3
4#include <gtk/gtk.h>
5#include <webkit/webkit.h>
6#include <glib-object.h>
7
8// Forward declarations for Go callbacks
9extern void goOnTitleChanged(unsigned long id, char* title);
10extern void goOnURIChanged(unsigned long id, char* uri);
11extern void goOnThemeChanged(unsigned long id, int prefer_dark);
12extern void* goResolveURIScheme(char* uri, size_t* out_len, char** out_mime);
13extern void goQuitMainLoop();
14
15// Static inline functions to avoid multiple definition errors
16static inline void on_title_notify(GObject* obj, GParamSpec* pspec, gpointer user_data) {
17    (void)pspec;
18    WebKitWebView* view = WEBKIT_WEB_VIEW(obj);
19    const gchar* title = webkit_web_view_get_title(view);
20    GtkWindow* win = GTK_WINDOW(user_data);
21    if (title && win) {
22        gtk_window_set_title(win, title);
23    }
24}
25
26static inline void on_title_notify_id(GObject* obj, GParamSpec* pspec, gpointer user_data) {
27    (void)pspec; (void)obj;
28    const gchar* title = webkit_web_view_get_title(WEBKIT_WEB_VIEW(obj));
29    if (title) { goOnTitleChanged((unsigned long)user_data, (char*)title); }
30}
31
32static inline void on_uri_notify(GObject* obj, GParamSpec* pspec, gpointer user_data) {
33    (void)pspec; (void)obj;
34    const gchar* uri = webkit_web_view_get_uri(WEBKIT_WEB_VIEW(obj));
35    if (uri) { goOnURIChanged((unsigned long)user_data, (char*)uri); }
36}
37
38static inline void on_theme_changed(GObject* obj, GParamSpec* pspec, gpointer user_data) {
39    (void)pspec;
40    GtkSettings* settings = GTK_SETTINGS(obj);
41    if (!settings) return;
42    gboolean prefer = FALSE;
43    g_object_get(settings, "gtk-application-prefer-dark-theme", &prefer, NULL);
44    goOnThemeChanged((unsigned long)user_data, prefer ? 1 : 0);
45}
46
47static inline void on_uri_scheme(WebKitURISchemeRequest* request, gpointer user_data) {
48    (void)user_data;
49    const gchar* uri = webkit_uri_scheme_request_get_uri(request);
50    size_t n = 0;
51    char* mime = NULL;
52    void* buf = goResolveURIScheme((char*)uri, &n, &mime);
53    if (buf && n > 0 && mime) {
54        GInputStream* stream = g_memory_input_stream_new_from_data(buf, (gssize)n, g_free);
55        webkit_uri_scheme_request_finish(request, stream, (gint64)n, mime);
56        g_object_unref(stream);
57        g_free(mime);
58    } else {
59        GError* err = g_error_new_literal(g_quark_from_string("dumber"), 404, "Not found");
60        webkit_uri_scheme_request_finish_error(request, err);
61        g_error_free(err);
62    }
63}
64
65// GTK4 close-request signal handler
66static inline gboolean on_close_request(GtkWindow* window, gpointer user_data) {
67    (void)window; (void)user_data;
68    goQuitMainLoop();
69    return FALSE; // Allow the window to close
70}
71
72#endif // WEBVIEW_CALLBACKS_H

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