Use tracing for logging
This commit is contained in:
parent
f255af9f6a
commit
4d6d771ab4
36 changed files with 260 additions and 223 deletions
10
Cargo.lock
generated
10
Cargo.lock
generated
|
|
@ -1587,9 +1587,9 @@ dependencies = [
|
|||
"libadwaita",
|
||||
"libc",
|
||||
"libgweather",
|
||||
"log",
|
||||
"strum",
|
||||
"thiserror",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
"url",
|
||||
]
|
||||
|
|
@ -2331,9 +2331,9 @@ checksum = "df8b2b54733674ad286d16267dcfc7a71ed5c776e4ac7aa3c3e2561f7c637bf2"
|
|||
|
||||
[[package]]
|
||||
name = "tracing"
|
||||
version = "0.1.43"
|
||||
version = "0.1.44"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2d15d90a0b5c19378952d479dc858407149d7bb45a14de0142f6c534b16fc647"
|
||||
checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100"
|
||||
dependencies = [
|
||||
"pin-project-lite",
|
||||
"tracing-attributes",
|
||||
|
|
@ -2353,9 +2353,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "tracing-core"
|
||||
version = "0.1.35"
|
||||
version = "0.1.36"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a04e24fab5c89c6a36eb8558c9656f30d81de51dfa4d3b45f26b21d61fa0a6c"
|
||||
checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"valuable",
|
||||
|
|
|
|||
|
|
@ -40,8 +40,8 @@ gvdb-macros = "0.1.6"
|
|||
indexmap = "2.0.0"
|
||||
libc = "0.2.158"
|
||||
libgweather = "4.4.0"
|
||||
log = "0.4.17"
|
||||
strum = { version = "0.27.1", features = ["derive"] }
|
||||
thiserror = "2.0.3"
|
||||
tracing = "0.1.44"
|
||||
tracing-subscriber = { version = "0.3.18", features = ["fmt", "env-filter"] }
|
||||
url = "2.3.1"
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ mod imp {
|
|||
|
||||
impl ApplicationImpl for LpApplication {
|
||||
fn startup(&self) {
|
||||
log::trace!("Startup");
|
||||
tracing::trace!("Startup");
|
||||
self.parent_startup();
|
||||
|
||||
// Force dark theme
|
||||
|
|
@ -82,7 +82,7 @@ mod imp {
|
|||
}
|
||||
|
||||
fn activate(&self) {
|
||||
log::debug!("Showing window via 'activate'");
|
||||
tracing::debug!("Showing window via 'activate'");
|
||||
let application = self.obj();
|
||||
let window = LpWindow::new(&*application);
|
||||
window.present();
|
||||
|
|
@ -90,7 +90,7 @@ mod imp {
|
|||
|
||||
// Handles opening files from the command line or other applications
|
||||
fn open(&self, files: &[gio::File], _hint: &str) {
|
||||
log::trace!("Open {} file(s)", files.len());
|
||||
tracing::trace!("Open {} file(s)", files.len());
|
||||
let application = self.obj();
|
||||
let win = LpWindow::new(&*application);
|
||||
win.image_view().set_images_from_files(files.to_vec());
|
||||
|
|
@ -138,7 +138,7 @@ impl LpApplication {
|
|||
gio::ActionEntryBuilder::new("new-window")
|
||||
.activate(|app: &Self, _, _| {
|
||||
let win = LpWindow::new(app);
|
||||
log::debug!("Showing new window");
|
||||
tracing::debug!("Showing new window");
|
||||
win.present();
|
||||
})
|
||||
.build(),
|
||||
|
|
@ -160,7 +160,7 @@ impl LpApplication {
|
|||
if let Err(e) =
|
||||
gio::AppInfo::launch_default_for_uri_future("help:loupe", context.as_ref()).await
|
||||
{
|
||||
log::error!("Failed to launch help: {}", e.message());
|
||||
tracing::error!("Failed to launch help: {}", e.message());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,8 +100,8 @@ impl UpdateSender {
|
|||
let result = self.sender.force_send(update);
|
||||
|
||||
match result {
|
||||
Err(err) => log::error!("Failed to send update: {err}"),
|
||||
Ok(Some(msg)) => log::error!("Unexpectedly replaced the message {msg:?}"),
|
||||
Err(err) => tracing::error!("Failed to send update: {err}"),
|
||||
Ok(Some(msg)) => tracing::error!("Unexpectedly replaced the message {msg:?}"),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
|
@ -171,7 +171,7 @@ impl Decoder {
|
|||
let update_sender = UpdateSender { sender };
|
||||
tiles.set_update_sender(update_sender.clone());
|
||||
|
||||
log::trace!("Setting up loader");
|
||||
tracing::trace!("Setting up loader");
|
||||
let mut loader = glycin::Loader::new(file);
|
||||
loader.apply_transformations(false);
|
||||
|
||||
|
|
@ -229,7 +229,7 @@ impl Decoder {
|
|||
if let FormatDecoder::Glycin(decoder) = &self.decoder {
|
||||
decoder.fill_frame_buffer();
|
||||
} else {
|
||||
log::error!("Trying to fill frame buffer for decoder without animation support");
|
||||
tracing::error!("Trying to fill frame buffer for decoder without animation support");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use gtk::prelude::*;
|
||||
use tracing::Instrument;
|
||||
|
||||
use super::*;
|
||||
use crate::decoder::tiling::{self, SharedFrameBuffer};
|
||||
|
|
@ -47,7 +48,15 @@ impl Glycin {
|
|||
|
||||
let (next_frame_send, next_frame_recv) = async_channel::bounded(2);
|
||||
|
||||
updater.clone().spawn_error_handled(async move {
|
||||
let span = tracing::debug_span!(
|
||||
"proxy",
|
||||
image = image
|
||||
.file()
|
||||
.and_then(|x| x.basename())
|
||||
.map(|x| x.display().to_string())
|
||||
);
|
||||
updater.clone().spawn_error_handled(
|
||||
async move {
|
||||
let mut metadata: Metadata = Metadata::default();
|
||||
metadata.set_image_info(image.details().clone());
|
||||
metadata.set_mime_type(image.mime_type().to_string());
|
||||
|
|
@ -99,7 +108,7 @@ impl Glycin {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
log::debug!("Animation handler gone");
|
||||
tracing::debug!("Animation handler gone");
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
|
|
@ -115,7 +124,9 @@ impl Glycin {
|
|||
}
|
||||
|
||||
Ok(())
|
||||
});
|
||||
}
|
||||
.instrument(span),
|
||||
);
|
||||
|
||||
Self {
|
||||
cancellable,
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ impl Svg {
|
|||
};
|
||||
|
||||
if cancellable.is_cancelled() {
|
||||
log::debug!("Terminating SVG decoder thread");
|
||||
tracing::debug!("Terminating SVG decoder thread");
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ impl Tile {
|
|||
let area_with_bleed = round(&self.area_with_bleed().scale(zoom, zoom));
|
||||
|
||||
if area_with_bleed.width() < 1. || area_with_bleed.height() < 1. {
|
||||
log::warn!("Trying to draw image with dimensions smaller than 1");
|
||||
tracing::warn!("Trying to draw image with dimensions smaller than 1");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -169,7 +169,7 @@ impl FrameBuffer {
|
|||
if let Some(tiling) = self.images.front() {
|
||||
tiling.add_to_snapshot(snapshot, zoom, options);
|
||||
} else {
|
||||
log::error!("Trying to snapshot empty tiling queue");
|
||||
tracing::error!("Trying to snapshot empty tiling queue");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -227,7 +227,7 @@ impl TiledImage {
|
|||
.flat_map(|(_, tiles)| tiles)
|
||||
.collect();
|
||||
|
||||
log::trace!("Rendering {} tiles", tiles.len());
|
||||
tracing::trace!("Rendering {} tiles", tiles.len());
|
||||
|
||||
// Scale from application pixels back to physical pixels
|
||||
snapshot.scale(1. / options.scaling as f32, 1. / options.scaling as f32);
|
||||
|
|
@ -396,11 +396,13 @@ impl TiledImage {
|
|||
|
||||
missing_tiles = next_missing_tiles;
|
||||
} else {
|
||||
log::error!("Images should never have multiple 'Simple' layers: {tile_layer:?}");
|
||||
tracing::error!(
|
||||
"Images should never have multiple 'Simple' layers: {tile_layer:?}"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
log::trace!(
|
||||
tracing::trace!(
|
||||
"Cleanup kept {} tiles",
|
||||
kept_tiles
|
||||
.tile_layers
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ impl Queue {
|
|||
glib::spawn_future_local(async move {
|
||||
let lock: async_lock::MutexGuard<()> = queue.lock.lock().await;
|
||||
if let Err(err) = queue.apply(image).await {
|
||||
log::error!("Err: {err}");
|
||||
tracing::error!("Err: {err}");
|
||||
}
|
||||
drop(lock);
|
||||
});
|
||||
|
|
@ -72,7 +72,7 @@ impl Queue {
|
|||
let edit_instruction = editor.apply_sparse(&operations).await?;
|
||||
|
||||
if edit_instruction.apply_to(file).await? == EditOutcome::Unchanged {
|
||||
log::warn!("Writing new files is not supported yet");
|
||||
tracing::warn!("Writing new files is not supported yet");
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -82,7 +82,10 @@ impl Entry {
|
|||
}
|
||||
|
||||
Err(err) => {
|
||||
log::error!("Failed to obtain information for sorting '{}': {err}", uri);
|
||||
tracing::error!(
|
||||
"Failed to obtain information for sorting '{}': {err}",
|
||||
uri
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -189,7 +192,7 @@ impl LpFileModel {
|
|||
self.imp().monitor.set(monitor).unwrap();
|
||||
}
|
||||
Err(err) => {
|
||||
log::info!("Cannot monitor directory: {err}");
|
||||
tracing::info!("Cannot monitor directory: {err}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -216,7 +219,7 @@ impl LpFileModel {
|
|||
let info = enumerator.next_files_future(1, glib::Priority::LOW).await;
|
||||
match info {
|
||||
Err(err) => {
|
||||
log::warn!("Unreadable entry in directory: {err}");
|
||||
tracing::warn!("Unreadable entry in directory: {err}");
|
||||
break;
|
||||
}
|
||||
Ok(mut info) => {
|
||||
|
|
@ -268,7 +271,7 @@ impl LpFileModel {
|
|||
Self::sort(&mut files);
|
||||
}
|
||||
|
||||
log::debug!(
|
||||
tracing::debug!(
|
||||
"Completed loading list of files of '{}' after {:#?}",
|
||||
directory.uri(),
|
||||
instant.elapsed(),
|
||||
|
|
@ -318,7 +321,7 @@ impl LpFileModel {
|
|||
/// Returns `n` elements before and after given file
|
||||
pub fn files_around(&self, file: &gio::File, n: usize) -> IndexMap<GString, gio::File> {
|
||||
let Some(index) = self.index_of(file) else {
|
||||
log::error!("URI not in model: {}", file.uri());
|
||||
tracing::error!("URI not in model: {}", file.uri());
|
||||
return IndexMap::new();
|
||||
};
|
||||
|
||||
|
|
@ -374,7 +377,7 @@ impl LpFileModel {
|
|||
let Ok(info) =
|
||||
util::query_attributes(file, vec![gio::FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE])
|
||||
else {
|
||||
log::warn!("Could not query file info: {}", file.uri());
|
||||
tracing::warn!("Could not query file info: {}", file.uri());
|
||||
return false;
|
||||
};
|
||||
|
||||
|
|
@ -391,7 +394,7 @@ impl LpFileModel {
|
|||
{
|
||||
f(&file_event);
|
||||
} else {
|
||||
log::error!("Failed to read arguments from 'changed' signal.");
|
||||
tracing::error!("Failed to read arguments from 'changed' signal.");
|
||||
}
|
||||
|
||||
None
|
||||
|
|
@ -432,7 +435,7 @@ impl LpFileModel {
|
|||
// Changing file content could theoretically make it an image
|
||||
// by adding a magic byte
|
||||
|
||||
log::debug!("File added: {uri_a}");
|
||||
tracing::debug!("File added: {uri_a}");
|
||||
|
||||
glib::spawn_future_local(glib::clone!(
|
||||
#[strong(rename_to=obj)]
|
||||
|
|
@ -450,7 +453,7 @@ impl LpFileModel {
|
|||
gio::FileMonitorEvent::Deleted
|
||||
| gio::FileMonitorEvent::MovedOut
|
||||
| gio::FileMonitorEvent::Unmounted => {
|
||||
log::debug!("File removed: {}", file_a.uri());
|
||||
tracing::debug!("File removed: {}", file_a.uri());
|
||||
let removed = self
|
||||
.imp()
|
||||
.files
|
||||
|
|
@ -465,7 +468,7 @@ impl LpFileModel {
|
|||
if let Some(file_b) = file_b {
|
||||
{
|
||||
let uri_b = file_b.uri();
|
||||
log::debug!("File moved from '{uri_a}' to '{uri_b}'");
|
||||
tracing::debug!("File moved from '{uri_a}' to '{uri_b}'");
|
||||
let mut changed =
|
||||
self.imp().files.borrow_mut().shift_remove(&uri_a).is_some();
|
||||
|
||||
|
|
|
|||
|
|
@ -95,19 +95,19 @@ pub fn main() -> glib::ExitCode {
|
|||
.with(tracing_subscriber::fmt::Layer::default().compact())
|
||||
.init();
|
||||
|
||||
log::debug!("Logger initialized");
|
||||
tracing::debug!("Logger initialized");
|
||||
|
||||
setlocale(LocaleCategory::LcAll, "");
|
||||
bindtextdomain("loupe", config::LOCALEDIR).unwrap();
|
||||
textdomain("loupe").unwrap();
|
||||
|
||||
log::trace!("gettext initialized");
|
||||
tracing::trace!("gettext initialized");
|
||||
|
||||
gio::resources_register(
|
||||
&gio::Resource::from_data(&glib::Bytes::from_static(GRESOURCE_BYTES)).unwrap(),
|
||||
);
|
||||
|
||||
log::trace!("Gio resources registered");
|
||||
tracing::trace!("Gio resources registered");
|
||||
|
||||
LpApplication::new().run()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ impl Metadata {
|
|||
let result = self.metadata.add_raw_exif(bytes);
|
||||
|
||||
if let Err(err) = &result {
|
||||
log::warn!("Failed to decode EXIF bytes: {err}");
|
||||
tracing::warn!("Failed to decode EXIF bytes: {err}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -56,7 +56,7 @@ impl Metadata {
|
|||
let result = self.metadata.add_raw_xmp(bytes);
|
||||
|
||||
if let Err(err) = &result {
|
||||
log::warn!("Failed to decode XMP bytes: {err}");
|
||||
tracing::warn!("Failed to decode XMP bytes: {err}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ pub fn datetime_fmt(datetime: &glib::DateTime) -> Option<String> {
|
|||
.format(&datetime_format);
|
||||
|
||||
if let Err(err) = &fmt {
|
||||
log::error!("Could not format DateTime with '{datetime_format}': {err}");
|
||||
tracing::error!("Could not format DateTime with '{datetime_format}': {err}");
|
||||
}
|
||||
|
||||
fmt.ok().map(|x| x.to_string())
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ pub trait ParentWindow: WidgetExt {
|
|||
let result = self.root().and_downcast();
|
||||
|
||||
if result.is_none() {
|
||||
log::error!(
|
||||
tracing::error!(
|
||||
"Couldn't find LpWindow for {self:?}. mapped={}. caller={}",
|
||||
self.is_mapped(),
|
||||
std::panic::Location::caller(),
|
||||
|
|
@ -40,7 +40,7 @@ pub trait ParentWindow: WidgetExt {
|
|||
let result = self.root().and_downcast();
|
||||
|
||||
if result.is_none() {
|
||||
log::error!(
|
||||
tracing::error!(
|
||||
"Couldn't find LpWindow for {self:?}. mapped={}. caller={}",
|
||||
self.is_mapped(),
|
||||
std::panic::Location::caller(),
|
||||
|
|
|
|||
|
|
@ -281,7 +281,7 @@ mod imp {
|
|||
Some(&LpAspectRatio::default().to_variant()),
|
||||
);
|
||||
if let Err(err) = res {
|
||||
log::error!("Failed to call action edit-crop.aspect-ratio: {err}");
|
||||
tracing::error!("Failed to call action edit-crop.aspect-ratio: {err}");
|
||||
}
|
||||
|
||||
let (w, h) = self.image.image_size();
|
||||
|
|
@ -294,7 +294,7 @@ mod imp {
|
|||
.obj()
|
||||
.activate_action("edit-crop.orientation", Some(&orientation.to_variant()));
|
||||
if let Err(err) = res {
|
||||
log::error!("Failed to call action edit-crop.orientation: {err}");
|
||||
tracing::error!("Failed to call action edit-crop.orientation: {err}");
|
||||
}
|
||||
|
||||
self.obj().action_set_enabled("edit-crop.reset", false);
|
||||
|
|
|
|||
|
|
@ -846,7 +846,7 @@ mod imp {
|
|||
/// Set x coordinate of crop selection rectangle origin
|
||||
pub(super) fn set_crop_x(&self, x: f32) {
|
||||
if x < 0. {
|
||||
log::error!("Tried to set x coordinate to {x}");
|
||||
tracing::error!("Tried to set x coordinate to {x}");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -864,7 +864,7 @@ mod imp {
|
|||
/// Set y coordinate of crop selection rectangle origin
|
||||
pub(super) fn set_crop_y(&self, y: f32) {
|
||||
if y < 0. {
|
||||
log::error!("Tried to set y coordinate to {y}");
|
||||
tracing::error!("Tried to set y coordinate to {y}");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -911,7 +911,9 @@ mod imp {
|
|||
fn update_crop_area_image_coord(&self) {
|
||||
let crop_area_image_coord = self.crop_area_image_coord();
|
||||
if self.is_in_user_change() {
|
||||
log::trace!("Setting crop are in image coordinates to {crop_area_image_coord:?}");
|
||||
tracing::trace!(
|
||||
"Setting crop are in image coordinates to {crop_area_image_coord:?}"
|
||||
);
|
||||
self.crop_area_image_coord.replace(crop_area_image_coord);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -234,7 +234,7 @@ mod imp {
|
|||
|
||||
match file_dialog.save_future(obj.try_window().as_ref()).await {
|
||||
Err(err) => {
|
||||
log::error!("{}", err);
|
||||
tracing::error!("{}", err);
|
||||
}
|
||||
Ok(new_file) => {
|
||||
if self
|
||||
|
|
@ -278,7 +278,7 @@ mod imp {
|
|||
.await;
|
||||
|
||||
if written {
|
||||
log::debug!("Moving image to trash '{}'", original_file.uri());
|
||||
tracing::debug!("Moving image to trash '{}'", original_file.uri());
|
||||
let trash_result = gio::CancellableFuture::new(
|
||||
original_file.trash_future(glib::Priority::DEFAULT),
|
||||
cancellable.clone(),
|
||||
|
|
@ -287,7 +287,7 @@ mod imp {
|
|||
|
||||
if trash_result.is_err() {
|
||||
// Canceled
|
||||
log::debug!("Trashing image canceled");
|
||||
tracing::debug!("Trashing image canceled");
|
||||
return;
|
||||
} else if let Ok(Err(err)) = trash_result {
|
||||
obj.window_show_error(
|
||||
|
|
@ -298,7 +298,11 @@ mod imp {
|
|||
return;
|
||||
}
|
||||
|
||||
log::debug!("Moving '{}' to '{}'", tmp_file.uri(), original_file.uri());
|
||||
tracing::debug!(
|
||||
"Moving '{}' to '{}'",
|
||||
tmp_file.uri(),
|
||||
original_file.uri()
|
||||
);
|
||||
let move_result = gio::CancellableFuture::new(
|
||||
tmp_file
|
||||
.move_future(
|
||||
|
|
@ -313,7 +317,7 @@ mod imp {
|
|||
|
||||
if move_result.is_err() {
|
||||
// Canceled
|
||||
log::debug!("Moving image canceled");
|
||||
tracing::debug!("Moving image canceled");
|
||||
return;
|
||||
} else if let Ok(Err(err)) = move_result {
|
||||
obj.window_show_error(
|
||||
|
|
@ -352,17 +356,17 @@ mod imp {
|
|||
editor.cancellable(cancellable.clone());
|
||||
|
||||
if let Some(operations) = obj.operations() {
|
||||
log::debug!("Computing edited image.");
|
||||
tracing::debug!("Computing edited image.");
|
||||
let result = match editor.edit().await {
|
||||
Ok(editable_image) => editable_image.apply_complete(&operations).await,
|
||||
Err(err) => Err(err),
|
||||
};
|
||||
match result {
|
||||
Err(err) if matches!(err.error(), glycin::Error::Canceled(_)) => {
|
||||
log::debug!("Computing edited image canceled");
|
||||
tracing::debug!("Computing edited image canceled");
|
||||
}
|
||||
Err(err) => {
|
||||
log::warn!("Failed to edit image: {err}");
|
||||
tracing::warn!("Failed to edit image: {err}");
|
||||
obj.window_show_error(
|
||||
&gettext("Failed to edit image."),
|
||||
&format!("Failed to edit image:\n\n{err}\n\n{operations:#?}"),
|
||||
|
|
@ -370,7 +374,7 @@ mod imp {
|
|||
)
|
||||
}
|
||||
Ok(edit) => {
|
||||
log::debug!("Saving edited image to '{}'", new_file.uri());
|
||||
tracing::debug!("Saving edited image to '{}'", new_file.uri());
|
||||
match edit.data().get() {
|
||||
Err(err) => {
|
||||
obj.window_show_error(
|
||||
|
|
@ -394,7 +398,7 @@ mod imp {
|
|||
.await;
|
||||
|
||||
if save_result.is_err() {
|
||||
log::debug!("Saving image canceled");
|
||||
tracing::debug!("Saving image canceled");
|
||||
} else if let Ok(Err(err)) = save_result {
|
||||
obj.window_show_error(
|
||||
&gettext("Failed to Save Image"),
|
||||
|
|
@ -402,7 +406,7 @@ mod imp {
|
|||
ErrorType::General,
|
||||
);
|
||||
} else {
|
||||
log::debug!("Image saved");
|
||||
tracing::debug!("Image saved");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ impl LpErrorDetails {
|
|||
}
|
||||
));
|
||||
|
||||
log::debug!("Showing error details");
|
||||
tracing::debug!("Showing error details");
|
||||
obj.present(Some(root));
|
||||
obj
|
||||
}
|
||||
|
|
|
|||
|
|
@ -318,7 +318,7 @@ mod imp {
|
|||
#[weak]
|
||||
obj,
|
||||
move |_, _| {
|
||||
log::debug!("Scale changed signal");
|
||||
tracing::debug!("Scale changed signal");
|
||||
obj.queue_resize();
|
||||
}
|
||||
),
|
||||
|
|
@ -358,7 +358,7 @@ mod imp {
|
|||
}
|
||||
|
||||
fn dispose(&self) {
|
||||
log::debug!("Disposing LpImage");
|
||||
tracing::debug!("Disposing LpImage");
|
||||
|
||||
// remove target from zoom animation because it's property of this object
|
||||
self.rotation_animation()
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ impl imp::LpImage {
|
|||
pub async fn background_color_guess(&self) -> Option<gdk::RGBA> {
|
||||
let obj = self.obj();
|
||||
|
||||
log::debug!("Determining background color");
|
||||
tracing::debug!("Determining background color");
|
||||
|
||||
if self.fixed_background_color.borrow().is_some() {
|
||||
return None;
|
||||
|
|
@ -66,7 +66,7 @@ impl imp::LpImage {
|
|||
|
||||
// Shortcut for formats that don't support transparency
|
||||
if !obj.metadata().is_potentially_transparent() {
|
||||
log::trace!("This format does not support transparency");
|
||||
tracing::trace!("This format does not support transparency");
|
||||
return Some(Self::default_background_color());
|
||||
}
|
||||
|
||||
|
|
@ -151,7 +151,7 @@ impl imp::LpImage {
|
|||
}
|
||||
|
||||
if !has_transparency {
|
||||
log::trace!("This image does not have transparency");
|
||||
tracing::trace!("This image does not have transparency");
|
||||
return Some(default_color);
|
||||
}
|
||||
|
||||
|
|
@ -163,8 +163,8 @@ impl imp::LpImage {
|
|||
1.
|
||||
};
|
||||
|
||||
log::trace!("Total: {n_pixels}, transparent: {completely_transparent}, bad contrast: {bad_contrast}");
|
||||
log::trace!("Amount bad contrast: {part_bad_contrast}");
|
||||
tracing::trace!("Total: {n_pixels}, transparent: {completely_transparent}, bad contrast: {bad_contrast}");
|
||||
tracing::trace!("Amount bad contrast: {part_bad_contrast}");
|
||||
|
||||
if part_bad_contrast > BACKGROUND_GUESS_LOW_CONTRAST_TRHESHOLD {
|
||||
Some(alternate_color)
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ impl LpImage {
|
|||
if let Some(node) = tmp_snapshot.to_node() {
|
||||
imp.apply_operations(node, >k::Snapshot::new())?;
|
||||
} else {
|
||||
log::error!("Render node is empty");
|
||||
tracing::error!("Render node is empty");
|
||||
}
|
||||
|
||||
imp.configure_best_fit();
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ impl imp::LpImage {
|
|||
(f64::exp(-y * f64::ln(ZOOM_FACTOR_SCROLL_SURFACE)), false)
|
||||
}
|
||||
unknown_unit => {
|
||||
log::warn!("Ignoring unknown scroll unit: {unknown_unit:?}");
|
||||
tracing::warn!("Ignoring unknown scroll unit: {unknown_unit:?}");
|
||||
(1., false)
|
||||
}
|
||||
};
|
||||
|
|
@ -142,12 +142,12 @@ impl imp::LpImage {
|
|||
move |gesture, n_press, x, y| {
|
||||
// only handle double clicks
|
||||
if n_press != 2 {
|
||||
log::trace!("Gesture {n_press} click");
|
||||
tracing::trace!("Gesture {n_press} click");
|
||||
gesture.set_state(gtk::EventSequenceState::Denied);
|
||||
return;
|
||||
}
|
||||
|
||||
log::trace!("Gesture double click");
|
||||
tracing::trace!("Gesture double click");
|
||||
|
||||
gesture.set_state(gtk::EventSequenceState::Claimed);
|
||||
if gesture.device().map(|x| x.source()) == Some(gdk::InputSource::Touchscreen) {
|
||||
|
|
@ -175,7 +175,7 @@ impl imp::LpImage {
|
|||
#[weak]
|
||||
obj,
|
||||
move |gesture, _, _| {
|
||||
log::trace!("Drag gesture begin");
|
||||
tracing::trace!("Drag gesture begin");
|
||||
let imp = obj.imp();
|
||||
|
||||
// Allow only left and middle button
|
||||
|
|
@ -216,7 +216,7 @@ impl imp::LpImage {
|
|||
#[weak]
|
||||
obj,
|
||||
move |_, _, _| {
|
||||
log::trace!("Drag gesture end");
|
||||
tracing::trace!("Drag gesture end");
|
||||
obj.set_cursor(None);
|
||||
obj.imp().last_drag_value.set(None);
|
||||
}
|
||||
|
|
@ -230,7 +230,7 @@ impl imp::LpImage {
|
|||
#[weak]
|
||||
obj,
|
||||
move |_, _| {
|
||||
log::trace!("Rotate gesture begin");
|
||||
tracing::trace!("Rotate gesture begin");
|
||||
obj.imp().cancel_deceleration();
|
||||
}
|
||||
));
|
||||
|
|
@ -270,7 +270,7 @@ impl imp::LpImage {
|
|||
#[weak]
|
||||
obj,
|
||||
move |_, _| {
|
||||
log::debug!("Rotate gesture end");
|
||||
tracing::debug!("Rotate gesture end");
|
||||
|
||||
let angle = (obj.rotation() / 90.).round() * 90. - obj.imp().rotation_target.get();
|
||||
obj.rotate_by(angle);
|
||||
|
|
@ -286,7 +286,7 @@ impl imp::LpImage {
|
|||
#[weak]
|
||||
obj,
|
||||
move |gesture, _| {
|
||||
log::trace!("Zoom gesture begin");
|
||||
tracing::trace!("Zoom gesture begin");
|
||||
|
||||
let imp = obj.imp();
|
||||
imp.cancel_deceleration();
|
||||
|
|
@ -309,7 +309,7 @@ impl imp::LpImage {
|
|||
imp.set_hadj_value(imp.hadj_value() + x0 - x1);
|
||||
imp.set_vadj_value(imp.vadj_value() + y0 - y1);
|
||||
} else {
|
||||
log::warn!("Zoom bounding box center: No previous value");
|
||||
tracing::warn!("Zoom bounding box center: No previous value");
|
||||
}
|
||||
|
||||
imp.zoom_gesture_center.set(p1);
|
||||
|
|
@ -336,7 +336,7 @@ impl imp::LpImage {
|
|||
obj,
|
||||
move |_, _| {
|
||||
let imp = obj.imp();
|
||||
log::debug!("Zoom gesture end");
|
||||
tracing::debug!("Zoom gesture end");
|
||||
|
||||
let rotation_target = (obj.rotation() / 90.).round() * 90.;
|
||||
if obj.zoom() < imp.zoom_level_best_fit_for_rotation(rotation_target)
|
||||
|
|
@ -367,7 +367,7 @@ impl imp::LpImage {
|
|||
scrolled_window.set_kinetic_scrolling(false);
|
||||
scrolled_window.set_kinetic_scrolling(true);
|
||||
} else {
|
||||
log::error!("Could not find GtkScrolledWindow parent to cancel deceleration");
|
||||
tracing::error!("Could not find GtkScrolledWindow parent to cancel deceleration");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,9 +78,12 @@ impl imp::LpImage {
|
|||
pub fn update(&self, update: DecoderUpdate) {
|
||||
let obj = self.obj();
|
||||
|
||||
let span = tracing::debug_span!("update", image = obj.basename());
|
||||
let _guard = span.enter();
|
||||
|
||||
match update {
|
||||
DecoderUpdate::Metadata(metadata) => {
|
||||
log::debug!("Received metadata");
|
||||
tracing::debug!("Received metadata");
|
||||
self.metadata.borrow_mut().merge(*metadata);
|
||||
self.emmit_metadata_changed();
|
||||
|
||||
|
|
@ -92,7 +95,7 @@ impl imp::LpImage {
|
|||
));
|
||||
}
|
||||
DecoderUpdate::Dimensions => {
|
||||
log::debug!("Received dimensions: {:?}", self.untransformed_dimensions());
|
||||
tracing::debug!("Received dimensions: {:?}", self.untransformed_dimensions());
|
||||
obj.notify_image_size_available();
|
||||
self.configure_best_fit();
|
||||
self.request_tiles();
|
||||
|
|
@ -141,14 +144,14 @@ impl imp::LpImage {
|
|||
}
|
||||
DecoderUpdate::SpecificError(err) => {
|
||||
if self.obj().is_loaded() {
|
||||
log::warn!("Error occured while loading additional data: {err:?}");
|
||||
tracing::warn!("Error occured while loading additional data: {err:?}");
|
||||
} else {
|
||||
self.set_specific_error(err);
|
||||
}
|
||||
}
|
||||
DecoderUpdate::GenericError(err) => {
|
||||
if self.obj().is_loaded() {
|
||||
log::warn!("Error occured while loading additional data: {err:?}");
|
||||
tracing::warn!("Error occured while loading additional data: {err:?}");
|
||||
} else {
|
||||
self.set_error(Some(err));
|
||||
}
|
||||
|
|
@ -218,12 +221,12 @@ impl imp::LpImage {
|
|||
match event {
|
||||
gio::FileMonitorEvent::Renamed => {
|
||||
if let Some(file) = file_b.cloned() {
|
||||
log::debug!("Moved to {}", file.uri());
|
||||
tracing::debug!("Moved to {}", file.uri());
|
||||
|
||||
// current file got replaced with a new one
|
||||
let file_replace = obj.file().is_some_and(|x| x.equal(&file));
|
||||
if file_replace {
|
||||
log::debug!("Image got replaced {}", file.uri());
|
||||
tracing::debug!("Image got replaced {}", file.uri());
|
||||
glib::spawn_future_local(async move {
|
||||
obj.load(&file).await;
|
||||
});
|
||||
|
|
@ -243,7 +246,7 @@ impl imp::LpImage {
|
|||
}
|
||||
}
|
||||
gio::FileMonitorEvent::MovedIn => {
|
||||
log::debug!("Image got replaced by moving into dir {}", file_a.uri());
|
||||
tracing::debug!("Image got replaced by moving into dir {}", file_a.uri());
|
||||
glib::spawn_future_local(glib::clone!(
|
||||
#[strong]
|
||||
file_a,
|
||||
|
|
@ -255,7 +258,7 @@ impl imp::LpImage {
|
|||
gio::FileMonitorEvent::ChangesDoneHint => {
|
||||
let obj = self.obj().to_owned();
|
||||
let file = file_a.clone();
|
||||
log::debug!("Image was edited {}", file.uri());
|
||||
tracing::debug!("Image was edited {}", file.uri());
|
||||
glib::spawn_future_local(async move {
|
||||
obj.load(&file).await;
|
||||
});
|
||||
|
|
@ -263,7 +266,7 @@ impl imp::LpImage {
|
|||
gio::FileMonitorEvent::Deleted
|
||||
| gio::FileMonitorEvent::MovedOut
|
||||
| gio::FileMonitorEvent::Unmounted => {
|
||||
log::debug!("File no longer available: {event:?} {}", file_a.uri());
|
||||
tracing::debug!("File no longer available: {event:?} {}", file_a.uri());
|
||||
self.is_deleted.set(true);
|
||||
self.obj().notify_is_deleted();
|
||||
}
|
||||
|
|
@ -272,7 +275,7 @@ impl imp::LpImage {
|
|||
}
|
||||
|
||||
fn set_error(&self, err: Option<anyhow::Error>) {
|
||||
log::debug!("Decoding error: {err:?}");
|
||||
tracing::debug!("Decoding error: {err:?}");
|
||||
|
||||
// Keeping first error instead of replacing with new error
|
||||
if err.is_some() && self.error.borrow().is_some() {
|
||||
|
|
@ -342,16 +345,16 @@ impl LpImage {
|
|||
if let Some(file) = self.file() {
|
||||
self.load(&file).await;
|
||||
} else {
|
||||
log::error!("Trying to reload image without file");
|
||||
tracing::error!("Trying to reload image without file");
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn load(&self, file: &gio::File) {
|
||||
let imp = self.imp();
|
||||
log::debug!("Loading file {}", file.uri());
|
||||
tracing::debug!("Loading file {}", file.uri());
|
||||
|
||||
if imp.rotation_animation().state() == adw::AnimationState::Playing {
|
||||
log::debug!("Queueing image reload due to playing rotate animation.");
|
||||
tracing::debug!("Queueing image reload due to playing rotate animation.");
|
||||
self.imp().queued_reload.replace(Some(file.clone()));
|
||||
return;
|
||||
}
|
||||
|
|
@ -380,7 +383,7 @@ impl LpImage {
|
|||
obj.imp().update(update);
|
||||
}
|
||||
}
|
||||
log::debug!("Stopped listening to decoder since sender is gone");
|
||||
tracing::debug!("Stopped listening to decoder since sender is gone");
|
||||
});
|
||||
|
||||
imp.decoder.replace(Some(Arc::new(decoder)));
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ impl imp::LpImage {
|
|||
let file_info = metadata::FileInfo::new(&file).await;
|
||||
match file_info {
|
||||
Ok(file_info) => self.metadata.borrow_mut().set_file_info(file_info),
|
||||
Err(err) => log::warn!("Failed to load file information: {err}"),
|
||||
Err(err) => tracing::warn!("Failed to load file information: {err}"),
|
||||
}
|
||||
self.emmit_metadata_changed();
|
||||
}
|
||||
|
|
@ -101,6 +101,12 @@ impl LpImage {
|
|||
self.imp().file.borrow().clone()
|
||||
}
|
||||
|
||||
pub fn basename(&self) -> Option<String> {
|
||||
self.file()
|
||||
.and_then(|x| x.basename())
|
||||
.map(|x| x.display().to_string())
|
||||
}
|
||||
|
||||
pub fn metadata(&self) -> impl Deref<Target = Metadata> + '_ {
|
||||
self.imp().metadata.borrow()
|
||||
}
|
||||
|
|
@ -136,7 +142,7 @@ impl LpImage {
|
|||
|
||||
match file_info {
|
||||
Err(err) => {
|
||||
log::error!(
|
||||
tracing::error!(
|
||||
"Failed to obtain CAN_TRASH attribute for '{}': {err}",
|
||||
file.uri()
|
||||
);
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ impl LpImage {
|
|||
gtk::PanDirection::Left | gtk::PanDirection::Up => -1.,
|
||||
gtk::PanDirection::Right | gtk::PanDirection::Down => 1.,
|
||||
_ => {
|
||||
log::error!("Unknown pan direction {direction:?}");
|
||||
tracing::error!("Unknown pan direction {direction:?}");
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
|
@ -39,7 +39,7 @@ impl LpImage {
|
|||
(self.vadj(), imp.max_vadjustment_value())
|
||||
}
|
||||
_ => {
|
||||
log::error!("Unknown pan direction {direction:?}");
|
||||
tracing::error!("Unknown pan direction {direction:?}");
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ impl WidgetImpl for imp::LpImage {
|
|||
let nth_snapshot = self.nth_snapshot.get() + 1;
|
||||
if nth_snapshot < 3 {
|
||||
self.nth_snapshot.set(nth_snapshot);
|
||||
log::trace!("Creating snapshot #{nth_snapshot}");
|
||||
tracing::trace!("Creating snapshot #{nth_snapshot}");
|
||||
}
|
||||
|
||||
let scaling_filter = if obj.metadata().is_svg() {
|
||||
|
|
@ -124,10 +124,10 @@ impl WidgetImpl for imp::LpImage {
|
|||
frame_buffer.add_to_snapshot(&tmp_snapshot, applicable_zoom, &render_options);
|
||||
if let Some(node) = tmp_snapshot.to_node() {
|
||||
if let Err(err) = self.apply_operations(node, snapshot) {
|
||||
log::error!("Failed to apply operations to node: {err}");
|
||||
tracing::error!("Failed to apply operations to node: {err}");
|
||||
}
|
||||
} else {
|
||||
log::error!("Render node is empty");
|
||||
tracing::error!("Render node is empty");
|
||||
}
|
||||
} else {
|
||||
// Apply rotation and mirroring
|
||||
|
|
@ -144,12 +144,16 @@ impl WidgetImpl for imp::LpImage {
|
|||
snapshot.restore();
|
||||
|
||||
if nth_snapshot < 3 {
|
||||
log::trace!("Snapshot #{nth_snapshot} created");
|
||||
tracing::trace!("Snapshot #{nth_snapshot} created");
|
||||
}
|
||||
}
|
||||
|
||||
fn measure(&self, orientation: gtk::Orientation, _for_size: i32) -> (i32, i32, i32, i32) {
|
||||
let obj = self.obj();
|
||||
|
||||
let span = tracing::debug_span!("measure", image = obj.basename());
|
||||
let _guard = span.enter();
|
||||
|
||||
let (image_width_i32, image_height_i32) = obj.image_size();
|
||||
let image_width = image_width_i32 as f64;
|
||||
let image_height = image_height_i32 as f64;
|
||||
|
|
@ -157,7 +161,7 @@ impl WidgetImpl for imp::LpImage {
|
|||
if image_width_i32 > 0 && image_height_i32 > 0 {
|
||||
if let Some((monitor_width, monitor_height)) = self.monitor_size() {
|
||||
let hidpi_scale = self.scaling();
|
||||
log::trace!("Physical monitor dimensions: {monitor_width} x {monitor_height}");
|
||||
tracing::trace!("Physical monitor dimensions: {monitor_width} x {monitor_height}");
|
||||
|
||||
// areas
|
||||
let monitor_area = monitor_width * monitor_height;
|
||||
|
|
@ -165,10 +169,12 @@ impl WidgetImpl for imp::LpImage {
|
|||
let image_area = image_width * image_height;
|
||||
|
||||
let occupy_area_factor = if logical_monitor_area <= SMALL_SCREEN_AREA {
|
||||
log::trace!("Small monitor detected: Using {SMALL_OCCUPY_SCREEN} screen area");
|
||||
tracing::trace!(
|
||||
"Small monitor detected: Using {SMALL_OCCUPY_SCREEN} screen area"
|
||||
);
|
||||
SMALL_OCCUPY_SCREEN
|
||||
} else {
|
||||
log::trace!(
|
||||
tracing::trace!(
|
||||
"Sufficiently large monitor detected: Using {DEFAULT_OCCUPY_SCREEN} screen area"
|
||||
);
|
||||
DEFAULT_OCCUPY_SCREEN
|
||||
|
|
@ -218,7 +224,7 @@ impl WidgetImpl for imp::LpImage {
|
|||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
log::warn!("Not enough information available to calculate fitting window size");
|
||||
tracing::warn!("Not enough information available to calculate fitting window size");
|
||||
|
||||
(0, size, -1, -1)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ impl imp::LpImage {
|
|||
let imp = obj.imp();
|
||||
if let Some(new_file) = imp.queued_reload.replace(None) {
|
||||
glib::spawn_future_local(async move {
|
||||
log::debug!("Animation finished: Executing delayed reload");
|
||||
tracing::debug!("Animation finished: Executing delayed reload");
|
||||
obj.load(&new_file).await;
|
||||
});
|
||||
}
|
||||
|
|
@ -74,7 +74,7 @@ impl imp::LpImage {
|
|||
impl LpImage {
|
||||
/// Set rotation and mirroring to the state would have after loading
|
||||
pub fn reset_rotation(&self) {
|
||||
log::debug!("Resetting rotation");
|
||||
tracing::debug!("Resetting rotation");
|
||||
let orientation = self.metadata().orientation();
|
||||
self.imp()
|
||||
.rotation_target
|
||||
|
|
@ -86,7 +86,7 @@ impl LpImage {
|
|||
pub fn rotate_by(&self, angle: f64) {
|
||||
let imp = self.imp();
|
||||
|
||||
log::debug!("Rotate by {} degrees", angle);
|
||||
tracing::debug!("Rotate by {} degrees", angle);
|
||||
let target = &self.imp().rotation_target;
|
||||
target.set(target.get() + angle);
|
||||
|
||||
|
|
@ -106,7 +106,7 @@ impl LpImage {
|
|||
|
||||
if let Ok(r) = gufo_common::orientation::Rotation::try_from(angle) {
|
||||
if r != gufo_common::orientation::Rotation::_0 {
|
||||
log::debug!("Editing image to rotate by {r:?}");
|
||||
tracing::debug!("Editing image to rotate by {r:?}");
|
||||
let operation = glycin::Operation::Rotate(r);
|
||||
let editing_queue = &self.imp().editing_queue;
|
||||
editing_queue.push(operation);
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ impl imp::LpImage {
|
|||
}
|
||||
|
||||
pub fn set_ignore_scroll_policy(&self, scroll_policy: gtk::ScrollablePolicy) {
|
||||
log::error!("Ignored setting new scroll policy {scroll_policy:?}");
|
||||
tracing::error!("Ignored setting new scroll policy {scroll_policy:?}");
|
||||
}
|
||||
|
||||
pub fn scroll_policy(&self) -> gtk::ScrollablePolicy {
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ impl imp::LpImage {
|
|||
|
||||
/// Sets respective output values if best-fit is active
|
||||
pub(super) fn configure_best_fit(&self) {
|
||||
log::trace!("Configure best fit");
|
||||
tracing::trace!("Configure best fit");
|
||||
// calculate new zoom value for best fit
|
||||
if self.obj().is_best_fit() {
|
||||
// LpImage can get measured during pinch zoom gesture, when scrollbars appear
|
||||
|
|
@ -193,7 +193,7 @@ impl imp::LpImage {
|
|||
}
|
||||
|
||||
pub(super) fn set_zoom_target(&self, zoom_target: f64) {
|
||||
log::trace!("Setting zoom target {zoom_target}");
|
||||
tracing::trace!("Setting zoom target {zoom_target}");
|
||||
|
||||
self.zoom_target.set(zoom_target);
|
||||
self.obj().notify_zoom_target();
|
||||
|
|
@ -243,13 +243,13 @@ impl imp::LpImage {
|
|||
obj.set_best_fit(false);
|
||||
}
|
||||
|
||||
log::trace!("Zoom to {zoom:.3}");
|
||||
tracing::trace!("Zoom to {zoom:.3}");
|
||||
|
||||
self.set_zoom_target(zoom);
|
||||
|
||||
// abort if already at correct zoom level
|
||||
if zoom == obj.zoom() {
|
||||
log::trace!("Already at correct zoom level");
|
||||
tracing::trace!("Already at correct zoom level");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ mod imp {
|
|||
#[weak]
|
||||
obj,
|
||||
move |gesture, x, y| {
|
||||
log::debug!("Long press triggered");
|
||||
tracing::debug!("Long press triggered");
|
||||
obj.show_popover_at(x, y);
|
||||
gesture.set_state(gtk::EventSequenceState::Claimed);
|
||||
}
|
||||
|
|
@ -128,7 +128,7 @@ mod imp {
|
|||
obj,
|
||||
move |_| {
|
||||
if obj.image().is_loaded() {
|
||||
log::debug!("Showing image");
|
||||
tracing::debug!("Showing image");
|
||||
obj.imp()
|
||||
.stack
|
||||
.set_visible_child(&*obj.imp().image_stack_page);
|
||||
|
|
|
|||
|
|
@ -257,7 +257,7 @@ mod imp {
|
|||
} else if row == &*imp.zoom_to_50 {
|
||||
0.5
|
||||
} else {
|
||||
log::error!("Activated unknown entry in zoom to popover.");
|
||||
tracing::error!("Activated unknown entry in zoom to popover.");
|
||||
return;
|
||||
};
|
||||
|
||||
|
|
@ -445,7 +445,7 @@ impl LpImageView {
|
|||
}
|
||||
));
|
||||
} else {
|
||||
log::error!("File list was empty");
|
||||
tracing::error!("File list was empty");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -464,7 +464,7 @@ impl LpImageView {
|
|||
};
|
||||
|
||||
if is_same_directory {
|
||||
log::debug!("Re-using old model and navigating to the current file");
|
||||
tracing::debug!("Re-using old model and navigating to the current file");
|
||||
self.navigate_to_file(&file);
|
||||
return;
|
||||
}
|
||||
|
|
@ -475,14 +475,14 @@ impl LpImageView {
|
|||
async move {
|
||||
let model = LpFileModel::from_file(file.clone()).await;
|
||||
obj.set_model(model);
|
||||
log::debug!("New model created");
|
||||
tracing::debug!("New model created");
|
||||
|
||||
obj.update_sliding_view(&file);
|
||||
|
||||
// List other files in directory
|
||||
if let Some(directory) = directory {
|
||||
if let Err(err) = obj.model().load_directory(directory.clone()).await {
|
||||
log::warn!("Failed to load directory: {}", err.root_cause());
|
||||
tracing::warn!("Failed to load directory: {}", err.root_cause());
|
||||
obj.window_show_toast(
|
||||
&format!("{} {}", err, err.root_cause()),
|
||||
adw::ToastPriority::High,
|
||||
|
|
@ -534,7 +534,7 @@ impl LpImageView {
|
|||
}
|
||||
|
||||
let Some(new_index) = self.model().index_of(new_file) else {
|
||||
log::debug!(
|
||||
tracing::debug!(
|
||||
"Could not navigate to file that's not in model '{}': Delaying insertion",
|
||||
new_file.uri()
|
||||
);
|
||||
|
|
@ -561,7 +561,7 @@ impl LpImageView {
|
|||
page
|
||||
};
|
||||
|
||||
log::debug!("Scrolling to page for {}", new_file.uri());
|
||||
tracing::debug!("Scrolling to page for {}", new_file.uri());
|
||||
self.imp().preserve_content.set(true);
|
||||
sliding_view.animate_to(&page);
|
||||
|
||||
|
|
@ -570,7 +570,7 @@ impl LpImageView {
|
|||
|
||||
/// Ensures the sliding view contains the correct images
|
||||
fn update_sliding_view(&self, current_file: &gio::File) {
|
||||
log::debug!(
|
||||
tracing::debug!(
|
||||
"Updating sliding_view neighbors for current path {}",
|
||||
current_file.uri()
|
||||
);
|
||||
|
|
@ -603,7 +603,7 @@ impl LpImageView {
|
|||
|
||||
fn scroll_sliding_view(&self, file: &gio::File, animated: bool) {
|
||||
let Some(current_page) = self.sliding_view().pages().swap_remove(&file.uri()) else {
|
||||
log::error!(
|
||||
tracing::error!(
|
||||
"Current path not available in sliding_view for scrolling: {}",
|
||||
file.uri()
|
||||
);
|
||||
|
|
@ -653,14 +653,14 @@ impl LpImageView {
|
|||
move |image| {
|
||||
if image.specific_error() == DecoderError::UnsupportedFormat {
|
||||
if obj.current_image().as_ref() == Some(image) {
|
||||
log::debug!(
|
||||
tracing::debug!(
|
||||
"Image format unsupported but not removing since current image"
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if let Some(file) = image.file() {
|
||||
log::debug!("Removing image with unsupported format {:?}", file.uri());
|
||||
tracing::debug!("Removing image with unsupported format {:?}", file.uri());
|
||||
obj.model().remove(&file);
|
||||
if let Some(current_file) = obj.current_file() {
|
||||
obj.update_sliding_view(¤t_file);
|
||||
|
|
@ -772,7 +772,7 @@ impl LpImageView {
|
|||
self.notify_is_previous_available();
|
||||
|
||||
let Some(new_page) = self.current_page() else {
|
||||
log::debug!("Page changed but no current page");
|
||||
tracing::debug!("Page changed but no current page");
|
||||
return;
|
||||
};
|
||||
|
||||
|
|
@ -789,7 +789,7 @@ impl LpImageView {
|
|||
if let Some(new_page) = ¤t_page {
|
||||
self.update_sliding_view(&new_page.file());
|
||||
} else {
|
||||
log::error!("No LpImagePage");
|
||||
tracing::error!("No LpImagePage");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ mod imp {
|
|||
#[weak]
|
||||
obj,
|
||||
move |gesture, _, _, _| {
|
||||
log::trace!("Mouse forward button clicked");
|
||||
tracing::trace!("Mouse forward button clicked");
|
||||
gesture.set_state(gtk::EventSequenceState::Claimed);
|
||||
obj.image_view().navigate(Direction::Forward, false);
|
||||
}
|
||||
|
|
@ -173,7 +173,7 @@ mod imp {
|
|||
#[weak]
|
||||
obj,
|
||||
move |gesture, _, _, _| {
|
||||
log::trace!("Mouse back button clicked");
|
||||
tracing::trace!("Mouse back button clicked");
|
||||
gesture.set_state(gtk::EventSequenceState::Claimed);
|
||||
obj.image_view().navigate(Direction::Back, false);
|
||||
}
|
||||
|
|
@ -186,7 +186,7 @@ mod imp {
|
|||
// TODO: We can't claim the gesture here, right? Otherwise we suppress the
|
||||
// double-click
|
||||
if n_press == 1 {
|
||||
log::trace!("General 1 click event");
|
||||
tracing::trace!("General 1 click event");
|
||||
obj.on_click();
|
||||
}
|
||||
}
|
||||
|
|
@ -424,7 +424,7 @@ mod imp {
|
|||
let files = match value.get::<gdk::FileList>() {
|
||||
Ok(list) => list.files(),
|
||||
Err(err) => {
|
||||
log::error!("Issue with drop value: {err}");
|
||||
tracing::error!("Issue with drop value: {err}");
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
|
@ -432,12 +432,12 @@ mod imp {
|
|||
if !files.is_empty() {
|
||||
obj.image_view().set_images_from_files(files);
|
||||
} else {
|
||||
log::error!("Dropped FileList was empty");
|
||||
tracing::error!("Dropped FileList was empty");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Maybe one day this will actually work
|
||||
log::debug!("Trying to focus window after drag and drop");
|
||||
tracing::debug!("Trying to focus window after drag and drop");
|
||||
obj.window_inspect(|w| w.present());
|
||||
|
||||
true
|
||||
|
|
@ -553,7 +553,7 @@ impl LpImageWindow {
|
|||
.collect();
|
||||
self.image_view().set_images_from_files(images);
|
||||
} else {
|
||||
log::debug!("File dialog canceled or file not readable");
|
||||
tracing::debug!("File dialog canceled or file not readable");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -565,11 +565,11 @@ impl LpImageWindow {
|
|||
launcher.set_always_ask(true);
|
||||
if let Err(e) = launcher.launch_future(self.try_window().as_ref()).await {
|
||||
if !e.matches(gtk::DialogError::Dismissed) {
|
||||
log::error!("Could not open image in external program: {}", e);
|
||||
tracing::error!("Could not open image in external program: {}", e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log::error!("Could not load a path for the current image.")
|
||||
tracing::error!("Could not load a path for the current image.")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -581,7 +581,7 @@ impl LpImageWindow {
|
|||
let imp = self.imp();
|
||||
|
||||
if let Err(e) = imp.image_view.set_background().await {
|
||||
log::error!("Failed to set background: {}", e);
|
||||
tracing::error!("Failed to set background: {}", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -589,7 +589,7 @@ impl LpImageWindow {
|
|||
let imp = self.imp();
|
||||
|
||||
if let Err(e) = imp.image_view.print() {
|
||||
log::error!("Failed to print file: {}", e);
|
||||
tracing::error!("Failed to print file: {}", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -615,7 +615,7 @@ impl LpImageWindow {
|
|||
let imp = self.imp();
|
||||
|
||||
if let Err(e) = imp.image_view.copy() {
|
||||
log::error!("Failed to copy to clipboard: {}", e);
|
||||
tracing::error!("Failed to copy to clipboard: {}", e);
|
||||
} else {
|
||||
self.window_show_toast(
|
||||
&gettext("Image copied to clipboard"),
|
||||
|
|
@ -630,7 +630,7 @@ impl LpImageWindow {
|
|||
image_view.current_file(),
|
||||
image_view.current_file().and_then(|x| x.path()),
|
||||
) else {
|
||||
log::error!("No file to trash");
|
||||
tracing::error!("No file to trash");
|
||||
return;
|
||||
};
|
||||
|
||||
|
|
@ -653,7 +653,7 @@ impl LpImageWindow {
|
|||
.set_trash_restore(Some(gio::File::for_path(&path)));
|
||||
let result = crate::util::untrash(&path).await;
|
||||
if let Err(err) = result {
|
||||
log::error!("Failed to untrash {path:?}: {err}");
|
||||
tracing::error!("Failed to untrash {path:?}: {err}");
|
||||
obj.window_show_toast(
|
||||
&gettext("Failed to restore image from trash"),
|
||||
adw::ToastPriority::High,
|
||||
|
|
@ -668,7 +668,7 @@ impl LpImageWindow {
|
|||
if Some(gio::IOErrorEnum::NotSupported) == err.kind::<gio::IOErrorEnum>() {
|
||||
self.delete_future(&path).await;
|
||||
} else {
|
||||
log::error!("Failed to delete file {path:?}: {err}");
|
||||
tracing::error!("Failed to delete file {path:?}: {err}");
|
||||
self.window_show_toast(
|
||||
&gettext("Failed to move image to trash"),
|
||||
adw::ToastPriority::Normal,
|
||||
|
|
@ -682,7 +682,7 @@ impl LpImageWindow {
|
|||
async fn delete(&self) {
|
||||
let image_view = self.image_view();
|
||||
let Some(path) = image_view.current_file().and_then(|x| x.path()) else {
|
||||
log::error!("No file to delete");
|
||||
tracing::error!("No file to delete");
|
||||
return;
|
||||
};
|
||||
|
||||
|
|
@ -714,7 +714,7 @@ impl LpImageWindow {
|
|||
let result = file.delete_future(glib::Priority::default()).await;
|
||||
|
||||
if let Err(err) = result {
|
||||
log::error!("Failed to delete file {path:?}: {err}");
|
||||
tracing::error!("Failed to delete file {path:?}: {err}");
|
||||
self.window_show_toast(
|
||||
&gettext("Failed to delete image"),
|
||||
adw::ToastPriority::Normal,
|
||||
|
|
@ -873,7 +873,7 @@ impl LpImageWindow {
|
|||
let settings = LpApplication::default().settings();
|
||||
let result = settings.set_boolean("show-properties", imp.properties_button.is_active());
|
||||
if let Err(err) = result {
|
||||
log::warn!("Failed to save show-properties state, {}", err);
|
||||
tracing::warn!("Failed to save show-properties state, {}", err);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -901,7 +901,7 @@ impl LpImageWindow {
|
|||
.map(|page| page.image());
|
||||
|
||||
if image.is_some_and(|img| img.image_size_available()) {
|
||||
log::debug!("Showing window because image size is ready");
|
||||
tracing::debug!("Showing window because image size is ready");
|
||||
self.window().present();
|
||||
}
|
||||
}
|
||||
|
|
@ -916,7 +916,7 @@ impl LpImageWindow {
|
|||
let current_page = self.imp().image_view.current_page();
|
||||
|
||||
if current_page.is_some_and(|page| page.image().error().is_some()) {
|
||||
log::debug!("Showing window because loading image failed");
|
||||
tracing::debug!("Showing window because loading image failed");
|
||||
self.window_inspect(|w| w.present());
|
||||
}
|
||||
}
|
||||
|
|
@ -958,7 +958,7 @@ impl LpImageWindow {
|
|||
};
|
||||
|
||||
let Some(application) = window.application() else {
|
||||
log::error!("No application for window found");
|
||||
tracing::error!("No application for window found");
|
||||
return;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -282,7 +282,7 @@ impl Action {
|
|||
if let Some(current_page) = win.imp().image_view.current_page() {
|
||||
current_page.image().reload().await;
|
||||
} else {
|
||||
log::error!("No current image to reload");
|
||||
tracing::error!("No current image to reload");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ impl From<&str> for PageAlignment {
|
|||
"left" => (HAlignment::Left, VAlignment::Middle),
|
||||
"right" => (HAlignment::Right, VAlignment::Middle),
|
||||
pos => {
|
||||
log::error!("Unknown alignment '{pos}'");
|
||||
tracing::error!("Unknown alignment '{pos}'");
|
||||
(HAlignment::default(), VAlignment::default())
|
||||
}
|
||||
};
|
||||
|
|
@ -134,7 +134,7 @@ impl<T: AsRef<str>> From<T> for Unit {
|
|||
"px" => Self::Pixel,
|
||||
"%" => Self::Percent,
|
||||
unit => {
|
||||
log::error!("Unknown unit '{unit}'");
|
||||
tracing::error!("Unknown unit '{unit}'");
|
||||
Self::default()
|
||||
}
|
||||
}
|
||||
|
|
@ -408,7 +408,7 @@ mod imp {
|
|||
obj.set_orientation(orientation);
|
||||
drop(ui_updates_disabled);
|
||||
|
||||
log::debug!("Showing print dialog");
|
||||
tracing::debug!("Showing print dialog");
|
||||
obj.present();
|
||||
}
|
||||
|
||||
|
|
@ -460,7 +460,7 @@ impl LpPrint {
|
|||
print_setup: Option<gtk::PrintSetup>,
|
||||
) {
|
||||
let Some(file) = image.file() else {
|
||||
log::error!("Tried to print LpImage without GFile");
|
||||
tracing::error!("Tried to print LpImage without GFile");
|
||||
return;
|
||||
};
|
||||
|
||||
|
|
@ -496,7 +496,7 @@ impl LpPrint {
|
|||
let print_setup = match print_dialog.setup_future(Some(&parent)).await {
|
||||
Err(err) => {
|
||||
// TODO: show error
|
||||
log::warn!("Failed to print: {err}");
|
||||
tracing::warn!("Failed to print: {err}");
|
||||
return;
|
||||
}
|
||||
Ok(print_setup) => print_setup,
|
||||
|
|
@ -897,21 +897,21 @@ impl LpPrint {
|
|||
|
||||
let draw_result = match result {
|
||||
Err(err) => {
|
||||
log::warn!("Print error: {err}");
|
||||
tracing::warn!("Print error: {err}");
|
||||
return;
|
||||
}
|
||||
Ok(output_stream) => obj.draw_page(output_stream).await,
|
||||
};
|
||||
|
||||
if let Err(err) = draw_result {
|
||||
log::warn!("Print error: {err}");
|
||||
tracing::warn!("Print error: {err}");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// Draw PDF for printing
|
||||
async fn draw_page(&self, output_stream: gio::OutputStream) -> anyhow::Result<()> {
|
||||
log::debug!("Drawing image to print");
|
||||
tracing::debug!("Drawing image to print");
|
||||
let image = self.image();
|
||||
|
||||
let (orig_width, orig_height) = self.original_size();
|
||||
|
|
|
|||
|
|
@ -311,7 +311,7 @@ mod imp {
|
|||
let launcher = gtk::FileLauncher::new(self.file().as_ref());
|
||||
let win = obj.native().and_downcast::<gtk::Window>();
|
||||
if let Err(e) = launcher.open_containing_folder_future(win.as_ref()).await {
|
||||
log::error!("Could not open parent directory: {e}");
|
||||
tracing::error!("Could not open parent directory: {e}");
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -344,7 +344,7 @@ mod imp {
|
|||
gio::Cancellable::NONE,
|
||||
|result| {
|
||||
if let Err(err) = result {
|
||||
log::error!("Failed to show geo URI: {err}")
|
||||
tracing::error!("Failed to show geo URI: {err}")
|
||||
}
|
||||
},
|
||||
);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ use adw::prelude::*;
|
|||
use adw::subclass::prelude::*;
|
||||
use glib::Properties;
|
||||
use indexmap::IndexMap;
|
||||
use log::error;
|
||||
use tracing::error;
|
||||
|
||||
use crate::deps::*;
|
||||
use crate::widgets::LpImagePage;
|
||||
|
|
@ -76,7 +76,7 @@ impl PositionTracking {
|
|||
fn set_progress(&mut self, progress: f64) {
|
||||
match self {
|
||||
Self::Position(_) => {
|
||||
log::error!("Trying to set StackedCards progress while not in animation state.")
|
||||
tracing::error!("Trying to set StackedCards progress while not in animation state.")
|
||||
}
|
||||
Self::StackedCards(cards) => cards.progress = progress,
|
||||
};
|
||||
|
|
@ -471,7 +471,7 @@ impl LpSlidingView {
|
|||
/// Add page to the specified position
|
||||
pub fn insert(&self, page: &LpImagePage, pos: usize) {
|
||||
if pos > self.n_pages() {
|
||||
log::error!("Invalid insert position {pos} for {}", page.file().uri());
|
||||
tracing::error!("Invalid insert position {pos} for {}", page.file().uri());
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -499,7 +499,7 @@ impl LpSlidingView {
|
|||
}
|
||||
self.shift_position(current_index);
|
||||
} else {
|
||||
log::error!("Page to move not found: {}", page.file().uri());
|
||||
tracing::error!("Page to move not found: {}", page.file().uri());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -523,7 +523,7 @@ impl LpSlidingView {
|
|||
self.clear(false);
|
||||
}
|
||||
} else {
|
||||
log::error!("Trying to remove non-existent page.");
|
||||
tracing::error!("Trying to remove non-existent page.");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -589,7 +589,7 @@ impl LpSlidingView {
|
|||
self.set_current_page(Some(page));
|
||||
self.emit_target_page_reached();
|
||||
} else {
|
||||
log::error!("Page not in LpSlidingView {}", page.file().uri());
|
||||
tracing::error!("Page not in LpSlidingView {}", page.file().uri());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -605,7 +605,7 @@ impl LpSlidingView {
|
|||
self.scroll_to(page, 0.);
|
||||
}
|
||||
} else {
|
||||
log::error!("Page not in LpSlidingView {}", page.file().uri());
|
||||
tracing::error!("Page not in LpSlidingView {}", page.file().uri());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -640,7 +640,7 @@ impl LpSlidingView {
|
|||
self.set_current_page(Some(page));
|
||||
animation.play();
|
||||
} else {
|
||||
log::error!("Page not in LpSlidingView {}", page.file().uri());
|
||||
tracing::error!("Page not in LpSlidingView {}", page.file().uri());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -691,7 +691,7 @@ impl LpSlidingView {
|
|||
match &*self.imp().position_tracking.borrow() {
|
||||
PositionTracking::Position(position) => *position,
|
||||
PositionTracking::StackedCards(_) => {
|
||||
log::error!("Using SlidindView position while in StackedCards animation");
|
||||
tracing::error!("Using SlidindView position while in StackedCards animation");
|
||||
0.
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,7 +122,7 @@ mod imp {
|
|||
#[weak]
|
||||
obj,
|
||||
move || if !obj.is_visible() {
|
||||
log::debug!("Showing window after timeout");
|
||||
tracing::debug!("Showing window after timeout");
|
||||
obj.present()
|
||||
}
|
||||
),
|
||||
|
|
@ -227,7 +227,7 @@ impl LpWindow {
|
|||
|
||||
pub async fn show_about(&self) {
|
||||
let about = crate::about::dialog().await;
|
||||
log::debug!("Showing about dialog");
|
||||
tracing::debug!("Showing about dialog");
|
||||
about.present(Some(self));
|
||||
}
|
||||
|
||||
|
|
@ -238,7 +238,7 @@ impl LpWindow {
|
|||
}
|
||||
|
||||
pub fn show_specific_image(&self, file: gio::File) {
|
||||
log::debug!("Showing specific image: {}", file.uri());
|
||||
tracing::debug!("Showing specific image: {}", file.uri());
|
||||
self.image_view().set_images_from_files(vec![file]);
|
||||
self.show_image();
|
||||
}
|
||||
|
|
@ -251,7 +251,7 @@ impl LpWindow {
|
|||
self.imp().stack.set_visible_child(edit_child);
|
||||
self.set_fullscreened(false);
|
||||
} else {
|
||||
log::error!("Can't open image editor since no current image exists");
|
||||
tracing::error!("Can't open image editor since no current image exists");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue