Skip to content

Commit cb595b6

Browse files
committed
Add reload feature
1 parent 7d3d88e commit cb595b6

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

data/resources/ui/window.blp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ template GeopardWindow: Adw.ApplicationWindow {
2121
action-name: "win.next";
2222
}
2323
[start]
24+
Gtk.Button {
25+
icon-name: "view-refresh-symbolic";
26+
action-name: "win.reload";
27+
}
28+
[start]
2429
Gtk.Button {
2530
icon-name: "tab-new-symbolic";
2631
action-name: "win.new-tab";
@@ -109,6 +114,11 @@ template GeopardWindow: Adw.ApplicationWindow {
109114
icon-name: "go-next-symbolic";
110115
action-name: "win.next";
111116
}
117+
[start]
118+
Gtk.Button {
119+
icon-name: "view-refresh-symbolic";
120+
action-name: "win.reload";
121+
}
112122
[title]
113123
Gtk.Button {
114124
icon-name: "system-search-symbolic";

src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ fn main() {
9595
"win.next",
9696
&["<Alt>Right", "<Alt>KP_Right", "Pointer_DfltBtnNext"],
9797
);
98+
application.set_accels_for_action("win.reload", &["<Ctrl>r", "F5"]);
9899
application.set_accels_for_action("win.show-bookmarks", &["<Ctrl>b"]);
99100
application.set_accels_for_action("win.bookmark-current", &["<Ctrl>d"]);
100101
application.set_accels_for_action("win.new-tab", &["<Ctrl>t"]);

src/widgets/tab.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,15 @@ impl Tab {
404404
h.map(|x| self.spawn_request(self.open_history(x)))
405405
.context("retrieving next item from history")
406406
}
407+
pub fn reload(&self) {
408+
let imp = self.imp();
409+
let i = imp.current_hi.get().unwrap();
410+
411+
imp.history.borrow_mut().get(i).map(|h| {
412+
h.cache.replace(None);
413+
self.spawn_request(self.open_history(h.clone()));
414+
});
415+
}
407416
pub fn display_error(&self, error: anyhow::Error) {
408417
let imp = self.imp();
409418
error!("{:?}", error);

src/widgets/window.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ impl Window {
209209
imp.action_previous.borrow_mut().replace(action_previous);
210210
imp.action_next.borrow_mut().replace(action_next);
211211

212+
self_action!(self, "reload", reload);
212213
self_action!(self, "new-tab", new_tab);
213214
self_action!(self, "show-bookmarks", show_bookmarks);
214215
self_action!(self, "bookmark-current", bookmark_current);
@@ -524,6 +525,9 @@ impl Window {
524525
Ok(_) => info!("went forward"),
525526
}
526527
}
528+
fn reload(&self) {
529+
self.current_tab().reload();
530+
}
527531
fn bookmark_current(&self) {
528532
let imp = self.imp();
529533
let url = imp.url_bar.text().to_string();

0 commit comments

Comments
 (0)