debug: Add more tracing for initial operations

This commit is contained in:
Sophie Herold 2024-02-08 00:32:09 +01:00
parent 23918bf31e
commit a7116925bf
5 changed files with 24 additions and 0 deletions

View file

@ -75,11 +75,13 @@ mod imp {
// Overrides GApplication vfuncs
impl ApplicationImpl for LpApplication {
fn startup(&self) {
log::trace!("Startup");
self.parent_startup();
LpShyBin::ensure_type();
}
fn activate(&self) {
log::trace!("Activate");
let application = self.obj();
let window = LpWindow::new(&*application);
window.present();
@ -87,6 +89,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());
let application = self.obj();
let win = LpWindow::new(&*application);
win.image_view().set_images_from_files(files.to_vec());

View file

@ -48,6 +48,7 @@ impl Glycin {
let (next_frame_send, next_frame_recv) = async_channel::bounded(2);
updater.clone().spawn_error_handled(async move {
log::trace!("Setting up loader");
let mut image_request = glycin::Loader::new(file);
#[cfg(feature = "disable-glycin-sandbox")]
@ -56,6 +57,7 @@ impl Glycin {
image_request.cancellable(cancellable_);
let image = image_request.request().await?;
log::trace!("Image info received");
let mut metadata: Metadata = Metadata::default();
metadata.set_image_info(image.info().details.clone());

View file

@ -81,13 +81,19 @@ fn main() -> glib::ExitCode {
log_builder.init();
log::debug!("Logger initialized");
setlocale(LocaleCategory::LcAll, "");
bindtextdomain("loupe", config::LOCALEDIR).unwrap();
textdomain("loupe").unwrap();
log::trace!("gettext initialized");
gio::resources_register(
&gio::Resource::from_data(&glib::Bytes::from_static(GRESOURCE_BYTES)).unwrap(),
);
log::trace!("Gio resources registered");
LpApplication::new().run()
}

View file

@ -232,6 +232,9 @@ mod imp {
pub(super) widget_dimensions: Cell<(i32, i32)>,
pub(super) scaling: Cell<f64>,
pub(super) surface_signals: OnceCell<SignalGroup>,
/// Number of snapshots created, debug only
pub(super) nth_snapshot: Cell<u8>,
}
#[glib::object_subclass]

View file

@ -65,6 +65,12 @@ impl WidgetImpl for imp::LpImage {
let applicable_zoom = self.applicable_zoom();
let nth_snaphot = self.nth_snapshot.get() + 1;
if nth_snaphot < 3 {
self.nth_snapshot.set(nth_snaphot);
log::trace!("Creating snapshot #{nth_snaphot}");
}
let scaling_filter = if obj.metadata().is_svg() {
// Looks better in SVG animations and avoids rendering issues
gsk::ScalingFilter::Linear
@ -125,6 +131,10 @@ impl WidgetImpl for imp::LpImage {
.add_to_snapshot(snapshot, applicable_zoom, &render_options);
snapshot.restore();
if nth_snaphot < 3 {
log::trace!("Snapshot #{nth_snaphot} created");
}
}
fn measure(&self, orientation: gtk::Orientation, _for_size: i32) -> (i32, i32, i32, i32) {