Skip to content

Commit de3306e

Browse files
committed
fmt
1 parent 8776cfc commit de3306e

File tree

3 files changed

+64
-45
lines changed

3 files changed

+64
-45
lines changed

src/draw_ctx.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,11 @@ impl DrawCtx {
121121
.build()
122122
}
123123
pub fn set_link_color(&self, color: &gtk::gdk::RGBA) {
124-
self.text_buffer.tag_table().lookup("a").unwrap().set_foreground_rgba(Some(color));
124+
self.text_buffer
125+
.tag_table()
126+
.lookup("a")
127+
.unwrap()
128+
.set_foreground_rgba(Some(color));
125129
}
126130
pub fn insert_heading(&self, text_iter: &mut gtk::TextIter, line: &str) {
127131
let n = line.chars().filter(|c| *c == '#').count();
@@ -188,7 +192,12 @@ impl DrawCtx {
188192
.weight(config.weight)
189193
.build();
190194

191-
tag.set_foreground_rgba(self.text_view.style_context().lookup_color("accent_color").as_ref());
195+
tag.set_foreground_rgba(
196+
self.text_view
197+
.style_context()
198+
.lookup_color("accent_color")
199+
.as_ref(),
200+
);
192201
tag.set_underline(gtk::pango::Underline::Low);
193202

194203
Self::set_linkhandler(&tag, link.clone());

src/tab.rs

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ use futures::future::RemoteHandle;
44
use futures::io::BufReader;
55
use futures::prelude::*;
66
use futures::task::LocalSpawnExt;
7+
use glib::{clone, Properties};
78
use gtk::gdk::prelude::*;
89
use gtk::gio;
910
use gtk::glib;
@@ -16,7 +17,6 @@ use std::marker::PhantomData;
1617
use std::pin::Pin;
1718
use std::rc::Rc;
1819
use url::Url;
19-
use glib::{clone, Properties};
2020

2121
use crate::common;
2222
use crate::common::{glibctx, HistoryItem, LossyTextRead, PageElement, RequestCtx};
@@ -384,25 +384,23 @@ impl Tab {
384384
};
385385
});
386386

387-
388387
imp.right_click_ctrl
389388
.borrow()
390389
.as_ref()
391390
.unwrap()
392-
.connect_pressed(clone!(@weak self as this => @default-panic, move |_ctrl, _n_press, x, y| {
393-
if let Err(e) = this.handle_right_click(x, y) {
394-
info!("{}", e);
395-
};
396-
}));
397-
398-
399-
imp.motion_ctrl
400-
.borrow()
401-
.as_ref()
402-
.unwrap()
403-
.connect_motion(clone!(@weak self as this => @default-panic,move |_ctrl, x, y| {
391+
.connect_pressed(
392+
clone!(@weak self as this => @default-panic, move |_ctrl, _n_press, x, y| {
393+
if let Err(e) = this.handle_right_click(x, y) {
394+
info!("{}", e);
395+
};
396+
}),
397+
);
398+
399+
imp.motion_ctrl.borrow().as_ref().unwrap().connect_motion(
400+
clone!(@weak self as this => @default-panic,move |_ctrl, x, y| {
404401
let _ = this.handle_motion(x, y);
405-
}));
402+
}),
403+
);
406404
}
407405
fn extract_linkhandler(draw_ctx: &DrawCtx, x: f64, y: f64) -> Result<String> {
408406
info!("Extracting linkhandler from clicked text");
@@ -495,8 +493,7 @@ impl Tab {
495493
}
496494
fn parse_link(&self, link: &str) -> Result<Url, url::ParseError> {
497495
let imp = self.imp();
498-
let current_url = Url::parse(&imp
499-
.url.borrow())?;
496+
let current_url = Url::parse(&imp.url.borrow())?;
500497
let link_url = Url::options().base_url(Some(&current_url)).parse(link)?;
501498
Ok(link_url)
502499
}
@@ -548,7 +545,6 @@ impl Tab {
548545
ctx.insert_paragraph(
549546
&mut text_iter,
550547
"to interrupt the download, leave this page\n",
551-
552548
);
553549

554550
let mark = ctx.text_buffer.create_mark(None, &text_iter, true);
@@ -688,7 +684,8 @@ click on the button below\n",
688684
draw_ctx.insert_heading(&mut text_iter, &line);
689685
if !title_updated {
690686
title_updated = true;
691-
imp.title.replace(line.trim_end().trim_start_matches("#").to_string());
687+
imp.title
688+
.replace(line.trim_end().trim_start_matches("#").to_string());
692689
self.notify("title");
693690
}
694691
}

src/window.rs

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ use gtk::subclass::prelude::*;
1111
use gtk::CompositeTemplate;
1212
use gtk::TemplateChild;
1313
use log::{error, info, warn};
14+
use std::cell::Cell;
1415
use std::cell::RefCell;
1516
use std::hash::{Hash, Hasher};
1617
use std::marker::PhantomData;
1718
use url::Url;
18-
use std::cell::Cell;
1919

2020
use crate::common::{bookmarks_url, glibctx, BOOKMARK_FILE_PATH};
2121
use crate::config;
@@ -224,20 +224,21 @@ impl Window {
224224
this.squeezer_changed();
225225
}),
226226
);
227-
imp.url_bar.connect_activate(
228-
clone!(@weak self as this => @default-panic, move |_sq| {
227+
imp.url_bar
228+
.connect_activate(clone!(@weak self as this => @default-panic, move |_sq| {
229229
this.open_omni(this.imp().url_bar.text().as_str());
230-
})
231-
);
230+
}));
232231
imp.small_url_bar.connect_activate(
233232
clone!(@weak self as this => @default-panic, move |_sq| {
234233
this.open_omni(this.imp().small_url_bar.text().as_str());
235-
})
234+
}),
236235
);
237236

238-
adw::StyleManager::default().connect_dark_notify(clone!(@weak self as this => @default-panic, move |_| {
239-
this.set_special_color_from_hash();
240-
}));
237+
adw::StyleManager::default().connect_dark_notify(
238+
clone!(@weak self as this => @default-panic, move |_| {
239+
this.set_special_color_from_hash();
240+
}),
241+
);
241242
}
242243
fn add_tab(&self) -> adw::TabPage {
243244
let imp = self.imp();
@@ -358,7 +359,8 @@ impl Window {
358359
});
359360
}
360361
fn open_omni(&self, v: &str) {
361-
let url = Url::parse(v).or_else(|_| Url::parse(&format!("gemini://geminispace.info/search?{}", v)));
362+
let url = Url::parse(v)
363+
.or_else(|_| Url::parse(&format!("gemini://geminispace.info/search?{}", v)));
362364
match url {
363365
Ok(url) => self.current_tab().spawn_open_url(url),
364366
Err(e) => error!("Failed to open from omni bar"),
@@ -403,34 +405,41 @@ impl Window {
403405
s.finish()
404406
};
405407
let hue = hash % 360;
406-
let stylesheet =
407-
if adw::StyleManager::default().is_dark() {
408-
format!("
408+
let stylesheet = if adw::StyleManager::default().is_dark() {
409+
format!(
410+
"
409411
@define-color view_bg_color hsl({hue}, 20%, 8%);
410412
@define-color view_fg_color hsl({hue}, 100%, 98%);
411413
@define-color window_bg_color hsl({hue}, 20%, 8%);
412414
@define-color window_fg_color hsl({hue}, 100%, 98%);
413415
@define-color headerbar_bg_color hsl({hue}, 80%, 10%);
414416
@define-color headerbar_fg_color hsl({hue}, 100%, 98%);
415-
")
416-
} else {
417-
format!(
418-
"
417+
"
418+
)
419+
} else {
420+
format!(
421+
"
419422
@define-color view_bg_color hsl({hue}, 100%, 99%);
420423
@define-color view_fg_color hsl({hue}, 100%, 12%);
421424
@define-color window_bg_color hsl({hue}, 100%, 99%);
422425
@define-color window_fg_color hsl({hue}, 100%, 12%);
423426
@define-color headerbar_bg_color hsl({hue}, 100%, 96%);
424427
@define-color headerbar_fg_color hsl({hue}, 100%, 12%);
425428
"
426-
)
427-
};
429+
)
430+
};
428431

429-
imp.style_provider.borrow().load_from_data(stylesheet.as_bytes());
432+
imp.style_provider
433+
.borrow()
434+
.load_from_data(stylesheet.as_bytes());
430435
// FIXME: Should add a method on `Tab`...
431-
self.current_tab().imp().draw_ctx.borrow().as_ref().unwrap().set_link_color(
432-
&self.style_context().lookup_color("accent_color").unwrap()
433-
);
436+
self.current_tab()
437+
.imp()
438+
.draw_ctx
439+
.borrow()
440+
.as_ref()
441+
.unwrap()
442+
.set_link_color(&self.style_context().lookup_color("accent_color").unwrap());
434443
}
435444

436445
fn is_small_screen(&self) -> bool {
@@ -454,7 +463,11 @@ impl Window {
454463
self.open_url_str("about://help");
455464
}
456465
fn donate(&self) {
457-
gtk::show_uri(None::<&gtk::Window>, "https://github.com/sponsors/ranfdev", 0);
466+
gtk::show_uri(
467+
None::<&gtk::Window>,
468+
"https://github.com/sponsors/ranfdev",
469+
0,
470+
);
458471
}
459472
fn focus_tab_next(&self) {
460473
let imp = self.imp();

0 commit comments

Comments
 (0)