Skip to content

Commit 6ed2043

Browse files
committed
small refactor around open_url
1 parent 3d4430b commit 6ed2043

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

src/tab.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ impl Tab {
276276
}
277277
Ok(())
278278
}
279-
fn display_error(ctx: &mut DrawCtx, error: anyhow::Error) {
279+
pub fn display_error(ctx: &mut DrawCtx, error: anyhow::Error) {
280280
error!("{:?}", error);
281281
let error_text = format!("Geopard experienced an error:\n {:?}", error);
282282
ctx.insert_paragraph(&mut ctx.text_buffer.end_iter(), &error_text);

src/window.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,6 @@ impl Window {
230230
animation.play();
231231
imp.progress_animation.replace(Some(animation));
232232
}
233-
fn open_url(&self, url: Url) {
234-
self.current_tab().spawn_open_url(url);
235-
}
236233
fn back(&self) {
237234
match self.current_tab().back() {
238235
Err(e) => warn!("{}", e),
@@ -253,14 +250,17 @@ impl Window {
253250
fn open_omni(&self, v: &str) {
254251
let url = Url::parse(v);
255252
match url {
256-
Ok(url) => self.open_url(url),
257-
Err(e) => error!("Failed to parse url: {:?}", e),
253+
Ok(url) => self.current_tab().spawn_open_url(url),
254+
Err(e) => error!(
255+
"Failed to parse url (will trigger a search in the future): {:?}",
256+
e
257+
),
258258
}
259259
}
260260
fn open_url_str(&self, v: &str) {
261261
let url = Url::parse(v);
262262
match url {
263-
Ok(url) => self.open_url(url),
263+
Ok(url) => self.current_tab().spawn_open_url(url),
264264
Err(e) => error!("Failed to parse url: {:?}", e),
265265
}
266266
}
@@ -275,10 +275,6 @@ impl Window {
275275
fn set_clipboard(&self, v: &str) {
276276
gdk::Display::default().unwrap().clipboard().set_text(v);
277277
}
278-
fn tab_page(&self, tab: &Tab) -> adw::TabPage {
279-
let imp = self.imp();
280-
imp.tab_view.page(tab)
281-
}
282278
fn inner_tab(&self, tab: &adw::TabPage) -> Tab {
283279
tab.child().downcast().unwrap()
284280
}

0 commit comments

Comments
 (0)