Skip to content

Commit 5f04a73

Browse files
committed
chore: we so back
1 parent 030c908 commit 5f04a73

File tree

5 files changed

+96
-36
lines changed

5 files changed

+96
-36
lines changed

flake.nix

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
pkgs.libadwaita
3333
pkgs.libsoup_3
3434
pkgs.gobject-introspection
35+
pkgs.webkitgtk_6_0
3536
pkgs.glib-networking
3637
pkgs.p11-kit
3738
pkgs.gst_all_1.gst-libav

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"devDependencies": {
44
"@girs/adw-1": "1.4.3-3.2.9",
55
"@girs/gjs": "^3.2.3",
6-
"@girs/gtk-4.0": "4.10.5-3.2.3"
6+
"@girs/gtk-4.0": "4.10.5-3.2.3",
7+
"@girs/webkit-6.0": "2.41.90-3.2.9"
78
}
89
}
Loading

src/main.js

+44-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/// <reference types="gjs/dom" />
2+
import WebKit2 from "gi://WebKit?version=6.0"
23
import GObject from "gi://GObject"
34
import Gio from "gi://Gio"
45
import Gtk from "gi://Gtk?version=4.0"
@@ -24,26 +25,58 @@ const Tangent = GObject.registerClass(
2425

2526
vfunc_startup() {
2627
super.vfunc_startup()
28+
29+
const about_action = new Gio.SimpleAction({
30+
name: "about",
31+
parameterType: null
32+
})
33+
about_action.connect("activate", () => {
34+
const about = Adw.AboutWindow.new_from_appdata(
35+
meta.replace("resource://", ""),
36+
""
37+
)
38+
about.set_transient_for(this.get_active_window())
39+
about.present()
40+
})
41+
this.add_action(about_action)
2742
}
2843

2944
vfunc_activate() {
3045
super.vfunc_activate()
3146

32-
/*** @type {{window: Gtk.ApplicationWindow, search: Gtk.SearchEntry}} */
33-
const { window } = build(Interface, {
34-
about: () => {
35-
const about = Adw.AboutWindow.new_from_appdata(
36-
meta.replace("resource://", ""),
37-
""
38-
)
39-
about.set_transient_for(window)
40-
about.present()
41-
},
42-
})
47+
/*** @type {{window: Gtk.ApplicationWindow, content: Gtk.Box, urlbar: Gtk.Entry}} */
48+
const { window, content, urlbar } = build(Interface)
4349
window.set_application(this)
4450
window.set_icon_name("surf.tangent.Tangent")
4551
window.present()
4652
window.connect("close-request", win => win.run_dispose())
53+
const webview = new WebKit2.WebView({
54+
settings:
55+
new WebKit2.Settings({
56+
enableDeveloperExtras: true
57+
})
58+
59+
})
60+
61+
62+
content.append(webview)
63+
webview.vexpand = true
64+
webview.hexpand = true
65+
webview.load_uri("https://tangent.surf")
66+
webview.bind_property(
67+
"uri",
68+
urlbar.buffer,
69+
"text",
70+
GObject.BindingFlags.DEFAULT,
71+
);
72+
webview.connect("notify::estimated-load-progress", () => {
73+
urlbar.progressFraction = webview.estimatedLoadProgress;
74+
if (urlbar.progressFraction === 1) {
75+
setTimeout(() => {
76+
urlbar.progressFraction = 0;
77+
}, 500);
78+
}
79+
});
4780
}
4881
}
4982
)

src/window.blp

+48-19
Original file line numberDiff line numberDiff line change
@@ -4,30 +4,59 @@ using Adw 1;
44
Adw.Window window {
55
default-width: 800;
66
default-height: 600;
7-
title: "Methodsave";
8-
Box {
9-
orientation: vertical;
10-
Adw.HeaderBar {
11-
styles ["flat"]
12-
[title]
13-
Adw.Clamp {
14-
tightening-threshold: 400;
15-
hexpand: true;
16-
Gtk.SearchEntry search {
17-
placeholder-text: "Wave smiley.";
18-
}
7+
title: "Tangent";
8+
9+
Adw.OverlaySplitView {
10+
sidebar-position: end;
11+
12+
[sidebar]
13+
Box {
14+
orientation: vertical;
15+
WindowHandle {
16+
Box {
17+
styles ["toolbar"]
18+
orientation: horizontal;
19+
MenuButton button_menu {
20+
menu-model: menu_app;
21+
icon-name: "open-menu-symbolic";
22+
primary: true;
23+
halign: start;
24+
}
25+
// Button {
26+
// icon-name: "about-symbolic";
27+
// clicked => $about();
28+
// halign: end;
29+
// }
30+
WindowControls {
31+
decoration-layout: "close";
32+
hexpand: true;
33+
halign: end;
34+
}
35+
}
1936
}
2037

21-
[end]
22-
Gtk.Button {
23-
icon-name: "about-symbolic";
24-
clicked => $about();
38+
Entry urlbar {
39+
input-purpose: url;
40+
hexpand: true;
41+
}
42+
Label {
43+
label: "hi! :3";
2544
}
2645
}
27-
Adw.StatusPage {
28-
icon-name: "uk.cetera.Methodsave";
29-
title: "Method is coming.";
46+
47+
[content]
48+
Box content {
3049
vexpand: true;
3150
}
3251
}
3352
}
53+
54+
55+
menu menu_app {
56+
section {
57+
item {
58+
label: _("About");
59+
action: "app.about";
60+
}
61+
}
62+
}

0 commit comments

Comments
 (0)