Skip to content

Commit 2c32ba5

Browse files
committed
GNOME sdk 48, fix narrow text view
1 parent 7b996f7 commit 2c32ba5

File tree

7 files changed

+215
-144
lines changed

7 files changed

+215
-144
lines changed

build-aux/com.ranfdev.Geopard.Devel.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"app-id" : "com.ranfdev.Geopard.Devel",
33
"runtime" : "org.gnome.Platform",
4-
"runtime-version" : "47",
4+
"runtime-version" : "48",
55
"sdk" : "org.gnome.Sdk",
66
"sdk-extensions" : [
77
"org.freedesktop.Sdk.Extension.rust-stable",
8-
"org.freedesktop.Sdk.Extension.llvm18"
8+
"org.freedesktop.Sdk.Extension.llvm19"
99
],
1010
"command" : "geopard",
1111
"tags" : [
@@ -20,7 +20,7 @@
2020
"--filesystem=xdg-download"
2121
],
2222
"build-options" : {
23-
"append-path" : "/usr/lib/sdk/rust-stable/bin:/usr/lib/sdk/llvm18/bin",
23+
"append-path" : "/usr/lib/sdk/rust-stable/bin:/usr/lib/sdk/llvm19/bin",
2424
"build-args" : [
2525
"--share=network"
2626
],

data/resources/ui/tab.blp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ template $Tab: Adw.Bin {
77
vexpand: true;
88

99
Adw.ClampScrollable clamp {
10-
halign: center;
1110
maximum-size: 768;
1211
tightening-threshold: 720;
1312
}

src/common/mod.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use gtk::{glib, gio};
1+
use gtk::{gio, glib};
22
use once_cell::sync::Lazy;
33
use url::Url;
44

@@ -68,9 +68,13 @@ pub fn open_uri_externally(uri: &str) {
6868

6969
pub fn open_file_externally(path: &std::path::Path) {
7070
let file = gio::File::for_path(path);
71-
gtk::FileLauncher::new(Some(&file)).launch(None::<&gtk::Window>, None::<&gio::Cancellable>, |res| {
72-
if let Err(e) = res {
73-
log::error!("error opening external file {:?}", e);
74-
}
75-
});
71+
gtk::FileLauncher::new(Some(&file)).launch(
72+
None::<&gtk::Window>,
73+
None::<&gio::Cancellable>,
74+
|res| {
75+
if let Err(e) = res {
76+
log::error!("error opening external file {:?}", e);
77+
}
78+
},
79+
);
7680
}

src/macros.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
#[macro_export]
22
macro_rules! self_action {
3-
($self:ident, $name:literal, $method:ident) => {
4-
{
5-
let this = &$self;
6-
let action = gio::SimpleAction::new($name, None);
7-
action.connect_activate(clone!(#[weak] this, move |_,_| this.$method()));
8-
$self.add_action(&action);
9-
action
10-
}
11-
}
3+
($self:ident, $name:literal, $method:ident) => {{
4+
let this = &$self;
5+
let action = gio::SimpleAction::new($name, None);
6+
action.connect_activate(clone!(
7+
#[weak]
8+
this,
9+
move |_, _| this.$method()
10+
));
11+
$self.add_action(&action);
12+
action
13+
}};
1214
}
1315

1416
#[macro_export]

src/widgets/pages/hypertext.rs

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -236,25 +236,33 @@ impl Hypertext {
236236
let right_click_ctrl = gtk::GestureClick::builder().button(3).build();
237237
let motion_ctrl = gtk::EventControllerMotion::new();
238238

239-
left_click_ctrl.connect_released(
240-
clone!(#[strong] this, move |ctrl, _n_press, x, y| {
239+
left_click_ctrl.connect_released(clone!(
240+
#[strong]
241+
this,
242+
move |ctrl, _n_press, x, y| {
241243
if let Err(e) = this.handle_click(ctrl, x, y) {
242244
log::info!("{}", e);
243245
};
244-
}),
245-
);
246+
}
247+
));
246248

247-
right_click_ctrl.connect_pressed(
248-
clone!(#[strong] this, move |_ctrl, _n_press, x, y| {
249+
right_click_ctrl.connect_pressed(clone!(
250+
#[strong]
251+
this,
252+
move |_ctrl, _n_press, x, y| {
249253
if let Err(e) = this.handle_right_click(x, y) {
250254
log::info!("{}", e);
251255
};
252-
}),
253-
);
256+
}
257+
));
254258

255-
motion_ctrl.connect_motion(clone!(#[strong] this, move |_ctrl, x, y| {
256-
let _ = this.handle_motion(x, y);
257-
}));
259+
motion_ctrl.connect_motion(clone!(
260+
#[strong]
261+
this,
262+
move |_ctrl, x, y| {
263+
let _ = this.handle_motion(x, y);
264+
}
265+
));
258266

259267
text_view.add_controller(left_click_ctrl);
260268
text_view.add_controller(right_click_ctrl);

src/widgets/tab.rs

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use url::Url;
2222

2323
use super::pages::{self, hypertext};
2424
use crate::common;
25-
use crate::common::{glibctx, open_uri_externally, open_file_externally};
25+
use crate::common::{glibctx, open_file_externally, open_uri_externally};
2626
use crate::lossy_text_read::*;
2727
use crate::session_provider::SessionProvider;
2828

@@ -615,16 +615,21 @@ impl Tab {
615615
p.connect_local(
616616
"open",
617617
false,
618-
clone!(#[weak(rename_to = this)] self, #[upgrade_or_panic] move |s| {
619-
let s: String = s[1].get().unwrap();
620-
let url = Url::parse(&s);
621-
if let Ok(url) = url {
622-
this.spawn_open_url(url);
623-
} else {
624-
log::error!("Invalid url {:?}", url);
618+
clone!(
619+
#[weak(rename_to = this)]
620+
self,
621+
#[upgrade_or_panic]
622+
move |s| {
623+
let s: String = s[1].get().unwrap();
624+
let url = Url::parse(&s);
625+
if let Ok(url) = url {
626+
this.spawn_open_url(url);
627+
} else {
628+
log::error!("Invalid url {:?}", url);
629+
}
630+
None
625631
}
626-
None
627-
}),
632+
),
628633
);
629634
p
630635
}
@@ -705,12 +710,18 @@ impl Tab {
705710
p.set_icon_name(Some("dialog-error-symbolic"));
706711

707712
let override_btn = gtk::Button::with_label("Trust New Certificate");
708-
override_btn.connect_clicked(clone!(#[weak(rename_to = this)] self, move |_| {
709-
let url = Url::parse(&this.url()).unwrap();
710-
711-
this.session().validator().remove_known(url.host_str().unwrap());
712-
this.reload();
713-
}));
713+
override_btn.connect_clicked(clone!(
714+
#[weak(rename_to = this)]
715+
self,
716+
move |_| {
717+
let url = Url::parse(&this.url()).unwrap();
718+
719+
this.session()
720+
.validator()
721+
.remove_known(url.host_str().unwrap());
722+
this.reload();
723+
}
724+
));
714725
override_btn.set_halign(gtk::Align::Center);
715726
override_btn.add_css_class("destructive-action");
716727
override_btn.add_css_class("pill");
@@ -733,12 +744,18 @@ impl Tab {
733744
p.set_icon_name(Some("dialog-error-symbolic"));
734745

735746
let override_btn = gtk::Button::with_label("Continue");
736-
override_btn.connect_clicked(clone!(#[weak(rename_to = this)] self, move |_| {
737-
let url = Url::parse(&this.url()).unwrap();
738-
739-
this.session().validator().override_trust(url.host_str().unwrap());
740-
this.reload();
741-
}));
747+
override_btn.connect_clicked(clone!(
748+
#[weak(rename_to = this)]
749+
self,
750+
move |_| {
751+
let url = Url::parse(&this.url()).unwrap();
752+
753+
this.session()
754+
.validator()
755+
.override_trust(url.host_str().unwrap());
756+
this.reload();
757+
}
758+
));
742759
override_btn.set_halign(gtk::Align::Center);
743760
override_btn.add_css_class("destructive-action");
744761
override_btn.add_css_class("pill");

0 commit comments

Comments
 (0)