window: Add reload button and F5 shortcut
Reloading makes sense for out of memory situations or filesystems that don't support inotify.
This commit is contained in:
parent
c3547f82fc
commit
053aa5da7e
6 changed files with 56 additions and 7 deletions
1
news.d/47.beta/added-reload-action
Normal file
1
news.d/47.beta/added-reload-action
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
Add reload button to errors and F5 as reload shortcut
|
||||||
|
|
@ -56,13 +56,19 @@
|
||||||
</property>
|
</property>
|
||||||
<child type="bottom">
|
<child type="bottom">
|
||||||
<object class="GtkButton" id="report">
|
<object class="GtkButton" id="report">
|
||||||
<property name="label" translatable="yes">Report Issue…</property>
|
|
||||||
<property name="halign">center</property>
|
<property name="halign">center</property>
|
||||||
<property name="margin-bottom">24</property>
|
<property name="margin-bottom">24</property>
|
||||||
<style>
|
<style>
|
||||||
<class name="suggested-action" />
|
<class name="suggested-action" />
|
||||||
<class name="pill" />
|
<class name="pill" />
|
||||||
</style>
|
</style>
|
||||||
|
<child>
|
||||||
|
<object class="AdwButtonContent">
|
||||||
|
<property name="icon-name">external-link-symbolic</property>
|
||||||
|
<property name="label" translatable="yes">Report _Issue</property>
|
||||||
|
<property name="use-underline">true</property>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|
|
||||||
|
|
@ -290,6 +290,15 @@ impl LpImage {
|
||||||
self.imp().file.replace(Some(file.clone()));
|
self.imp().file.replace(Some(file.clone()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn reload(&self) {
|
||||||
|
dbg!("reloadking");
|
||||||
|
if let Some(file) = self.file() {
|
||||||
|
self.load(&file).await;
|
||||||
|
} else {
|
||||||
|
log::error!("Trying to reload image without file");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn load(&self, file: &gio::File) {
|
pub async fn load(&self, file: &gio::File) {
|
||||||
let imp = self.imp();
|
let imp = self.imp();
|
||||||
log::debug!("Loading file {}", file.uri());
|
log::debug!("Loading file {}", file.uri());
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
<property name="hexpand">true</property>
|
<property name="hexpand">true</property>
|
||||||
<property name="vexpand">true</property>
|
<property name="vexpand">true</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="AdwSpinner" id="spinner"/>
|
<object class="AdwSpinner" id="spinner" />
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
|
@ -56,12 +56,30 @@
|
||||||
<property name="icon-name">image-missing-symbolic</property>
|
<property name="icon-name">image-missing-symbolic</property>
|
||||||
<property name="title" translatable="yes">Could not Load Image</property>
|
<property name="title" translatable="yes">Could not Load Image</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="error_more_info">
|
<object class="GtkBox">
|
||||||
<property name="label" translatable="true">More Information…</property>
|
<property name="orientation">vertical</property>
|
||||||
|
<property name="spacing">12</property>
|
||||||
<property name="halign">center</property>
|
<property name="halign">center</property>
|
||||||
<style>
|
<child>
|
||||||
<class name="pill" />
|
<object class="GtkButton" id="error_more_info">
|
||||||
</style>
|
<property name="label" translatable="true">More _Information</property>
|
||||||
|
<property name="use-underline">true</property>
|
||||||
|
<style>
|
||||||
|
<class name="suggested-action" />
|
||||||
|
<class name="pill" />
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton">
|
||||||
|
<property name="label" translatable="true">_Reload</property>
|
||||||
|
<property name="use-underline">true</property>
|
||||||
|
<property name="action-name">win.reload</property>
|
||||||
|
<style>
|
||||||
|
<class name="pill" />
|
||||||
|
</style>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|
|
||||||
|
|
@ -758,6 +758,8 @@ impl LpWindow {
|
||||||
for action in ACTIONS {
|
for action in ACTIONS {
|
||||||
self.action_set_enabled(action, enabled);
|
self.action_set_enabled(action, enabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.action_set_enabled(Action::Reload.as_ref(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Handles change in image and availability of images
|
/// Handles change in image and availability of images
|
||||||
|
|
|
||||||
|
|
@ -194,6 +194,8 @@ pub enum Action {
|
||||||
ToggleProperties,
|
ToggleProperties,
|
||||||
#[strum(to_string = "win.about")]
|
#[strum(to_string = "win.about")]
|
||||||
About,
|
About,
|
||||||
|
#[strum(to_string = "win.reload")]
|
||||||
|
Reload,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Action {
|
impl Action {
|
||||||
|
|
@ -467,6 +469,17 @@ impl Action {
|
||||||
win.show_about().await
|
win.show_about().await
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Action::Reload => {
|
||||||
|
klass.install_action_async(&action, None, move |win, _, _| async move {
|
||||||
|
if let Some(current_page) = win.imp().image_view.current_page() {
|
||||||
|
current_page.image().reload().await;
|
||||||
|
} else {
|
||||||
|
log::error!("No current image to reload");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
klass.add_binding_action(gdk::Key::F5, gdk::ModifierType::empty(), &action);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue