summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNamilskyy <alive6863@gmail.com>2025-12-04 16:47:12 +0300
committerNamilskyy <alive6863@gmail.com>2025-12-04 16:47:12 +0300
commitb5cd950218d6deadd46bd3d1529a3cabeac2220f (patch)
tree1a6381e1dada971c7634d993cc8db1abc41ced0d /src
parentd70de444665cb79bc36f9acc807aef5d9706dac1 (diff)
Fixes in main window, started settings window. Added CI workflow.
Diffstat (limited to 'src')
-rw-r--r--src/main.rs26
-rw-r--r--src/settings_window.rs61
2 files changed, 70 insertions, 17 deletions
diff --git a/src/main.rs b/src/main.rs
index 9bae187..a74f0bd 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,15 +1,12 @@
use gtk4::prelude::*;
-use gtk4::{Application,
- ApplicationWindow,
- Box,
- Button,
- Entry,
- HeaderBar,
- Orientation,
- ScrolledWindow};
+use gtk4::{
+ Application, ApplicationWindow, Box, Button, Entry, HeaderBar, Orientation, ScrolledWindow,
+};
-use webkit6::prelude::*;
use webkit6::WebView;
+use webkit6::prelude::*;
+
+mod settings_window;
const APP_ID: &str = "com.namilsk.i2p-browser";
@@ -50,9 +47,7 @@ fn build_ui(app: &Application) {
let web_view = WebView::new();
- let scrolled_window = ScrolledWindow::builder()
- .child(&web_view)
- .build();
+ let scrolled_window = ScrolledWindow::builder().child(&web_view).build();
main_box.append(&scrolled_window);
@@ -74,7 +69,6 @@ fn build_ui(app: &Application) {
url_entry_for_entry.set_text(&full_url);
});
-
let web_view_for_back = web_view.clone();
button_back.connect_clicked(move |_| {
if web_view_for_back.can_go_back() {
@@ -82,7 +76,6 @@ fn build_ui(app: &Application) {
}
});
-
let web_view_for_forward = web_view.clone();
button_forward.connect_clicked(move |_| {
if web_view_for_forward.can_go_forward() {
@@ -95,11 +88,10 @@ fn build_ui(app: &Application) {
web_view_for_reload.reload();
});
-
let web_view_for_home = web_view.clone();
let url_entry_for_home = url_entry.clone();
button_home.connect_clicked(move |_| {
- let home_url = "http://reg.i2p/";
+ let home_url = "http://reg.i2p/";
web_view_for_home.load_uri(home_url);
url_entry_for_home.set_text(home_url);
});
@@ -114,4 +106,4 @@ fn build_ui(app: &Application) {
web_view.load_uri("http://legwork.i2p/");
window.present();
-} \ No newline at end of file
+}
diff --git a/src/settings_window.rs b/src/settings_window.rs
new file mode 100644
index 0000000..fbab489
--- /dev/null
+++ b/src/settings_window.rs
@@ -0,0 +1,61 @@
+
+use gtk4::prelude::*;
+use gtk4::{
+ ApplicationWindow,
+ Box,
+ Entry,
+ Label,
+ Orientation,
+ HeaderBar,
+ CheckButton
+};
+use toml;
+use serde::Serialize;
+
+#[allow(dead_code)]
+#[derive(Debug, Serialize)]
+struct Settings {
+ js: bool,
+ outproxy: bool,
+ i2p_proxy: bool,
+ web_rtc: bool,
+ home_addr: str,
+
+}
+
+#[allow(dead_code, unused_variables)]
+pub fn window() -> ApplicationWindow {
+ let app = ApplicationWindow::builder()
+ .title("Settings")
+ .default_width(400)
+ .default_height(300)
+ .build();
+
+ let header_bar = HeaderBar::new();
+ window().set_titlebar(Some(&header_bar));
+
+ let main_box = Box::new(Orientation::Vertical, 0);
+ window().set_child(Some(&main_box));
+
+ Label::new(Some("Settings")).set_markup("Settings");
+
+ let javascript = CheckButton::new().set_label(Some("Enable JS"));
+ let outproxy = CheckButton::new().set_label(Some("Enable outproxy"));
+ let i2pproxy = CheckButton::new().set_label(Some("Enable i2p proxy"));
+ let webrtc = CheckButton::new().set_label(Some("Enable WebRTC"));
+ let homeaddr = Entry::new();
+
+ app
+}
+
+#[allow(dead_code)]
+impl Settings {
+ pub fn serialize_write(path: &std::path::Path,
+ setts: &Settings) -> Result<(), toml::ser::Error> {
+
+ let toml: String = toml::to_string(setts)?;
+ std::fs::write(path, toml).expect("Some error occured, is permission granted to ~/.config?");
+
+ Ok(())
+ }
+} \ No newline at end of file