Skip to content

Commit 95e677d

Browse files
committed
working links
1 parent 641b046 commit 95e677d

File tree

9 files changed

+328
-560
lines changed

9 files changed

+328
-560
lines changed

Cargo.lock

+54-250
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

-4
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@ features = ["v2_60"]
1919
[dependencies.gio]
2020
version = "0.15.1"
2121

22-
[dependencies.gdk]
23-
version = "0.15.1"
24-
2522
[dependencies]
2623
async-net = "1.4.7"
2724
async-fs = "1.5.0"
@@ -36,7 +33,6 @@ async-trait = "0.1.38"
3633
async-native-tls = "0.3.3"
3734
toml = "0.5.6"
3835
serde = { version = "1.0.116", features = ["derive"] }
39-
pango = { version = "0.9.0" }
4036
env_logger = "0.8.1"
4137
log = "0.4.0"
4238
adw = { package = "libadwaita", version = "0.1.0" }

nix/geopard.nix

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
{ stdenv
22
, cargo
33
, glib
4-
, gtk3
4+
, gtk4
5+
, libadwaita
56
, pango
67
, rust
78
, rustc
@@ -27,7 +28,8 @@ rustPlatform.buildRustPackage rec {
2728

2829
buildInputs = [
2930
glib
30-
gtk3
31+
gtk4
32+
libadwaita
3133
pango
3234
openssl
3335
];

shell.nix

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{pkgs ? import <nixos-unstable> {}}:
1+
{pkgs ? import <nixpkgs-unstable> {}}:
22
pkgs.mkShell {
33
buildInputs = with pkgs; [
44
cargo
@@ -9,13 +9,14 @@ pkgs.mkShell {
99
meson
1010
ninja
1111
python3
12+
gtk4
13+
libadwaita
1214
rustc
1315
rustfmt
1416
wrapGAppsHook
1517
dbus
1618
gdk-pixbuf
1719
glib
18-
gtk3
1920
openssl
2021
pkg-config
2122
rust-analyzer

src/common/mod.rs

+14-27
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
use async_trait::async_trait;
22
use futures::prelude::*;
3-
use gdk::prelude::*;
43
use glib::subclass::prelude::*;
54
use glib::Boxed;
5+
use gtk::gdk::prelude::*;
66
use gtk::prelude::*;
77
use log::{debug, info};
88
use std::borrow::Cow;
9+
use std::collections::HashMap;
910
use url::Url;
1011

1112
use crate::config;
@@ -21,15 +22,11 @@ pub static ABOUT_PAGE: &str = std::include_str!("../../README.gemini");
2122

2223
pub const MARGIN: i32 = 20;
2324

24-
pub static DATA_DIR_PATH: Lazy<std::path::PathBuf> = Lazy::new(|| {
25-
glib::user_data_dir()
26-
.join("geopard")
27-
});
25+
pub static DATA_DIR_PATH: Lazy<std::path::PathBuf> =
26+
Lazy::new(|| glib::user_data_dir().join("geopard"));
2827

29-
pub static CONFIG_DIR_PATH: Lazy<std::path::PathBuf> = Lazy::new(|| {
30-
glib::user_config_dir()
31-
.join("geopard")
32-
});
28+
pub static CONFIG_DIR_PATH: Lazy<std::path::PathBuf> =
29+
Lazy::new(|| glib::user_config_dir().join("geopard"));
3330

3431
pub static BOOKMARK_FILE_PATH: Lazy<std::path::PathBuf> =
3532
Lazy::new(|| DATA_DIR_PATH.join("bookmarks.gemini"));
@@ -112,7 +109,6 @@ pub struct HistoryItem {
112109
pub struct RequestCtx {
113110
pub gemini_client: gemini::Client,
114111
pub draw_ctx: DrawCtx,
115-
pub in_chan_tx: flume::Sender<TabMsg>,
116112
pub url: Url,
117113
}
118114

@@ -314,29 +310,20 @@ impl DrawCtx {
314310
let tag_table = self.text_buffer.tag_table();
315311
tag_table.add(&tag);
316312

317-
self.text_buffer.apply_tag(
318-
&tag,
319-
&self.text_buffer.iter_at_offset(start),
320-
&text_iter,
321-
);
313+
self.text_buffer
314+
.apply_tag(&tag, &self.text_buffer.iter_at_offset(start), &text_iter);
322315
}
323316

324-
fn set_linkhandler(tag: &gtk::TextTag, s: Link) {
325-
// I hope using a GBoxed type manages memory for me
326-
// TODO: Ask a glib mantainer if this is true
317+
fn set_linkhandler(tag: &gtk::TextTag, l: Link) {
327318
unsafe {
328-
tag.set_data("linkhandler", GLink(s).to_value());
319+
tag.set_data("linkhandler", l);
329320
}
330321
}
331-
pub fn linkhandler(tag: &gtk::TextTag) -> Option<Link> {
332-
/*FIXME: unsafe {
333-
let handler: Option<&glib::Value> = tag.data("linkhandler");
334-
handler
322+
pub fn linkhandler(tag: &gtk::TextTag) -> Option<&Link> {
323+
unsafe {
324+
let handler: Option<std::ptr::NonNull<Link>> = tag.data("linkhandler");
325+
handler.map(|n| n.as_ref())
335326
}
336-
.and_then(|gl| gl.get::<&GLink>().ok())
337-
.and_then(|l| l.to_owned())
338-
.map(|l| l.0.clone())*/
339-
None
340327
}
341328
pub fn clear(&mut self) {
342329
let b = &self.text_buffer;

src/config.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ pub struct Fonts {
2929
impl Fonts {
3030
pub fn default_heading() -> Font {
3131
Font {
32-
family: String::from("sans-serif"),
32+
family: String::from("Cantarell"),
3333
size: 18,
3434
weight: 800,
3535
}
@@ -45,15 +45,15 @@ impl Fonts {
4545

4646
pub fn default_quote() -> Font {
4747
Font {
48-
family: String::from("sans-serif"),
48+
family: String::from("Cantarell"),
4949
size: 13,
5050
weight: 500,
5151
}
5252
}
5353

5454
pub fn default_paragraph() -> Font {
5555
Font {
56-
family: String::from("sans-serif"),
56+
family: String::from("Cantarell"),
5757
size: 13,
5858
weight: 500,
5959
}

src/gemini/client.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl ClientBuilder {
113113
}
114114
}
115115

116-
#[derive(Debug, Clone)]
116+
#[derive(Debug, Clone, Default)]
117117
pub struct Client {
118118
options: ClientOptions,
119119
}

0 commit comments

Comments
 (0)