From a007eb49c850d8e1a746b93707e3dbd622baa30a Mon Sep 17 00:00:00 2001 From: ranfdev Date: Mon, 4 Jan 2021 12:28:13 +0100 Subject: [PATCH] Make clippy happy,Tag v1.0.0-alpha --- Cargo.lock | 2 +- Cargo.toml | 2 +- README.gemini | 7 ++++++- data/com.ranfdev.Geopard.metainfo.xml.in.in | 4 ++++ meson.build | 2 +- nix/geopard.nix | 2 +- src/common/mod.rs | 20 ++++++++++---------- src/component.rs | 6 +++--- src/gemini/parser.rs | 4 ++-- src/main.rs | 3 +-- src/tab.rs | 12 +++++------- src/window.rs | 6 +++--- 12 files changed, 38 insertions(+), 32 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index aa03ae1..c56794b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -518,7 +518,7 @@ dependencies = [ [[package]] name = "geopard" -version = "0.1.0" +version = "1.0.0-alpha" dependencies = [ "anyhow", "async-fs", diff --git a/Cargo.toml b/Cargo.toml index de30ae8..8798640 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "geopard" -version = "0.1.0" +version = "1.0.0-alpha" authors = ["ranfdev "] edition = "2018" diff --git a/README.gemini b/README.gemini index a4e4baf..5e629f2 100644 --- a/README.gemini +++ b/README.gemini @@ -22,9 +22,14 @@ Under the hood, it uses gtk3 and rust. Everything related to IO is asynchronous. To do that, it makes use of rust async/await capabilities and the async-std crate. # How to change settings -You should find the configuration file in ~/.config/geopard/config.toml +You should find the configuration files in ~/.config/geopard/ +If you use flatpak, they are in ~/.var/app/com.ranfdev.Geopard/config/geopard/ ## How to build +### With Flatpak +If you have gnome-builder installed, use it to the open the folder of the source +code and hit the run button. + ### Build with Nix If you have the => https://nixos.org/ nix diff --git a/data/com.ranfdev.Geopard.metainfo.xml.in.in b/data/com.ranfdev.Geopard.metainfo.xml.in.in index 73a539b..adc1daa 100644 --- a/data/com.ranfdev.Geopard.metainfo.xml.in.in +++ b/data/com.ranfdev.Geopard.metainfo.xml.in.in @@ -14,6 +14,10 @@ https://github.com/ranfdev/Geopard/issues/ + + This is the first working flatpak release. Some features (colors, caching) + are missing. + diff --git a/meson.build b/meson.build index 7f4c460..d5b424f 100644 --- a/meson.build +++ b/meson.build @@ -1,6 +1,6 @@ project('geopard', 'rust', - version: '0.0.1', + version: '1.0.0', license: 'MIT', meson_version: '>= 0.50') diff --git a/nix/geopard.nix b/nix/geopard.nix index 31dc4ec..11fbc5f 100644 --- a/nix/geopard.nix +++ b/nix/geopard.nix @@ -13,7 +13,7 @@ rustPlatform.buildRustPackage rec { pname = "geopard"; - version = "0.1.0"; + version = "1.0.0-alpha"; src = lib.cleanSource ../.; cargoSha256 = "0b77w95bj6avnxgs5ia93hhq3jr9cmbpa5zw8i37s688633il15x"; diff --git a/src/common/mod.rs b/src/common/mod.rs index 8e242bd..a6d4b5f 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -146,7 +146,7 @@ impl DrawCtx { .fonts .heading .as_ref() - .or(default_config.fonts.heading.as_ref()) + .or_else(|| default_config.fonts.heading.as_ref()) .unwrap() }); tag_h1.set_property_size_points(tag_h1.get_property_size_points() * 1.4); @@ -156,7 +156,7 @@ impl DrawCtx { .fonts .heading .as_ref() - .or(default_config.fonts.heading.as_ref()) + .or_else(|| default_config.fonts.heading.as_ref()) .unwrap() }); tag_h1.set_property_size_points(tag_h1.get_property_size_points() * 1.2); @@ -167,7 +167,7 @@ impl DrawCtx { .fonts .heading .as_ref() - .or(default_config.fonts.heading.as_ref()) + .or_else(|| default_config.fonts.heading.as_ref()) .unwrap(), ); let tag_pre = DrawCtx::create_tag( @@ -176,7 +176,7 @@ impl DrawCtx { .fonts .preformatted .as_ref() - .or(default_config.fonts.preformatted.as_ref()) + .or_else(|| default_config.fonts.preformatted.as_ref()) .unwrap(), ); let tag_p = DrawCtx::create_tag( @@ -185,7 +185,7 @@ impl DrawCtx { .fonts .paragraph .as_ref() - .or(default_config.fonts.paragraph.as_ref()) + .or_else(|| default_config.fonts.paragraph.as_ref()) .unwrap(), ); let tag_q = DrawCtx::create_tag( @@ -194,7 +194,7 @@ impl DrawCtx { .fonts .quote .as_ref() - .or(default_config.fonts.quote.as_ref()) + .or_else(|| default_config.fonts.quote.as_ref()) .unwrap(), ); tag_q.set_property_style(pango::Style::Italic); @@ -205,7 +205,7 @@ impl DrawCtx { .fonts .quote .as_ref() - .or(default_config.fonts.paragraph.as_ref()) + .or_else(|| default_config.fonts.paragraph.as_ref()) .unwrap(), ); @@ -235,7 +235,7 @@ impl DrawCtx { let tag_name = match n { 1 => "h1", 2 => "h2", - 3 | _ => "h3", + _ => "h3", }; let start = text_iter.get_offset(); @@ -291,7 +291,7 @@ impl DrawCtx { .fonts .paragraph .as_ref() - .or(default_config.fonts.paragraph.as_ref()) + .or_else(|| default_config.fonts.paragraph.as_ref()) .unwrap(); let tag = gtk::TextTagBuilder::new() @@ -305,7 +305,7 @@ impl DrawCtx { Self::set_linkhandler(&tag, link.clone()); - let label = label.unwrap_or(link.url()); + let label = label.unwrap_or_else(|| link.url()); info!("Setted url {:?} to tag", Self::get_linkhandler(&tag)); debug!("Link set successfully"); self.insert_paragraph(&mut text_iter, &label); diff --git a/src/component.rs b/src/component.rs index d73929d..16cc4f6 100644 --- a/src/component.rs +++ b/src/component.rs @@ -30,12 +30,12 @@ impl, M> Component { } } pub fn id(&self) -> usize { - return self.id; + self.id } pub fn widget(&self) -> &T { - return &self.widget; + &self.widget } pub fn chan(&self) -> flume::Sender { - return self.chan.clone(); + self.chan.clone() } } diff --git a/src/gemini/parser.rs b/src/gemini/parser.rs index ec2c879..20c16b6 100644 --- a/src/gemini/parser.rs +++ b/src/gemini/parser.rs @@ -18,9 +18,9 @@ impl Parser { PageElement::Empty } else if self.inside_pre { PageElement::Preformatted(line.to_string()) - } else if line.starts_with("#") { + } else if line.starts_with('#') { PageElement::Heading(line.to_string()) - } else if line.starts_with(">") { + } else if line.starts_with('>') { PageElement::Quote(line.to_string()) } else if let Some(captures) = R_GEMINI_LINK.captures(&line) { match (captures.name("href"), captures.name("label")) { diff --git a/src/main.rs b/src/main.rs index 6409170..c982c8b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -78,12 +78,11 @@ fn main() { let app_clone = application.clone(); let windows = Rc::new(RefCell::new(vec![])); - let windows_clone = windows.clone(); application.connect_activate(move |_| { let window = window::Window::new(&app_clone, config.clone()); window.widget().show_all(); window.widget().present(); - windows_clone.borrow_mut().push(window); + windows.borrow_mut().push(window); }); let ret = application.run(&std::env::args().collect::>()); diff --git a/src/tab.rs b/src/tab.rs index 0b87c90..992a886 100644 --- a/src/tab.rs +++ b/src/tab.rs @@ -57,7 +57,7 @@ impl Tab { let (in_chan_tx, in_chan_rx) = flume::unbounded(); - let draw_ctx = DrawCtx::new(text_view.clone(), config.clone()); + let draw_ctx = DrawCtx::new(text_view.clone(), config); let gemini_client = gemini::ClientBuilder::new().redirect(true).build(); let links = HashMap::new(); let req_handle = None; @@ -67,7 +67,7 @@ impl Tab { scroll_win.set_vexpand(true); scroll_win.add(&text_view); - let this = Self { + Self { draw_ctx, gemini_client, req_handle, @@ -79,9 +79,7 @@ impl Tab { scroll_win, load_progress: 0.0, id: new_component_id(), - }; - - this + } } pub fn build_request_ctx(&self, url: Url) -> RequestCtx { RequestCtx { @@ -312,7 +310,7 @@ impl Tab { for tag in iter.get_tags() { if let Some(url) = DrawCtx::get_linkhandler(&tag) { - return Ok(url.clone()); + return Ok(url); } } @@ -472,7 +470,7 @@ impl Tab { continue; } Err(e) => { - Err(e)?; + return Err(e.into()) } } } diff --git a/src/window.rs b/src/window.rs index 5d04a08..8b64e15 100644 --- a/src/window.rs +++ b/src/window.rs @@ -102,7 +102,7 @@ impl Window { this.bind_signals(); this.add_tab(); - let receiver: flume::Receiver = receiver.clone(); + let receiver: flume::Receiver = receiver; let handle = glibctx() .spawn_local_with_handle(async move { while let Ok(msg) = receiver.recv_async().await { @@ -111,7 +111,7 @@ impl Window { }) .unwrap(); - Component::new(new_component_id(), window, sender.clone(), handle) + Component::new(new_component_id(), window, sender, handle) } fn gen_tab_label(&self, id: usize, url: Url) -> gtk::Box { @@ -142,7 +142,7 @@ impl Window { fn add_tab(&mut self) -> flume::Sender { let tab = Tab::new(self.config.clone(), self.sender.clone()); let handler = tab.run(); - let sender = handler.chan().clone(); + let sender = handler.chan(); let widget = handler.widget().clone(); self.tabs.push(handler);