code: Reformat with new rules

This commit is contained in:
Sophie Herold 2023-11-29 21:15:36 +01:00
parent 4b510412e1
commit b56d650086
14 changed files with 68 additions and 45 deletions

View file

@ -1,6 +1,7 @@
// Copyright (c) 2021-2023 Christopher Davis
// Copyright (c) 2022-2023 Sophie Herold
// Copyright (c) 2022 Maximiliano Sandoval R
// Copyright (c) 2023 Julian Hofer
// Copyright (c) 2023 Lubosz Sarnecki
//
// This program is free software: you can redistribute it and/or modify
@ -36,7 +37,8 @@ use crate::decoder::{self, tiling, Decoder, DecoderUpdate};
use crate::image_metadata::LpImageMetadata;
use crate::util::Gesture;
use adw::{prelude::*, subclass::prelude::*};
use adw::prelude::*;
use adw::subclass::prelude::*;
use arc_swap::ArcSwap;
use futures::prelude::*;
use once_cell::sync::Lazy;
@ -49,8 +51,8 @@ use std::sync::Arc;
/// `#242424`
static BACKGROUND_COLOR_DEFAULT: Lazy<gdk::RGBA> =
Lazy::new(|| gdk::RGBA::new(36. / 255., 36. / 255., 36. / 255., 1.));
/// Background color if the default does not give enough contrast for transparent images
/// `#e8e7e6`
/// Background color if the default does not give enough contrast for
/// transparent images `#e8e7e6`
static BACKGROUND_COLOR_ALTERNATE: Lazy<gdk::RGBA> =
Lazy::new(|| gdk::RGBA::new(232. / 255., 231. / 255., 230. / 255., 1.));
@ -61,7 +63,8 @@ static BACKGROUND_COLOR_ALTERNATE_LIGHT_MODE: Lazy<gdk::RGBA> =
/// Consider 3.5:1 contrast and worse to be bad contrast for a pixel
static BACKGROUND_GUESS_LOW_CONTRAST_RATIO: f32 = 3.5;
/// Consider transparent images with more than 90% pixels bad contrast as bad contrast
/// Consider transparent images with more than 90% pixels bad contrast as bad
/// contrast
///
/// Bad contrast image will use the `BACKGROUND_COLOR_ALTERNATE`.
static BACKGROUND_GUESS_LOW_CONTRAST_TRHESHOLD: f64 = 0.90;
@ -145,7 +148,8 @@ mod imp {
#[property(get, set = Self::set_zoom, explicit_notify)]
pub(super) zoom: Cell<f64>,
pub(super) zoom_animation: OnceCell<adw::TimedAnimation>,
/// Targeted zoom level, might differ from `zoom` when animation is running
/// Targeted zoom level, might differ from `zoom` when animation is
/// running
pub(super) zoom_target: Cell<f64>,
/// Current animation is transitioning from having horizontal scrollbars
/// to not having them or vice versa.
@ -730,10 +734,10 @@ mod imp {
let hidpi_scale = self.obj().scale_factor() as f64;
let monitor_geometry = monitor.geometry();
// TODO: Per documentation those dimensions should not be physical pixels.
// But on Wayland they are physical pixels and on X11 not.
// Taking the version that works on Wayland for now.
// <https://gitlab.gnome.org/GNOME/gtk/-/issues/5391>
// TODO: Per documentation those dimensions should not be physical
// pixels. But on Wayland they are physical
// pixels and on X11 not. Taking the version
// that works on Wayland for now. <https://gitlab.gnome.org/GNOME/gtk/-/issues/5391>
let monitor_width = monitor_geometry.width() as f64 - 40.;
let monitor_height = monitor_geometry.height() as f64 - 60.;
@ -749,8 +753,8 @@ mod imp {
0.3
};
// factor for width and height that will achieve the desired area occupation
// derived from:
// factor for width and height that will achieve the desired area
// occupation derived from:
// monitor_area * occupy_area_factor ==
// (image_width * size_scale) * (image_height * size_scale)
let size_scale =
@ -1684,9 +1688,11 @@ impl LpImage {
}
}
/// Returns a background color that should give suitable contrast with transparent images
/// Returns a background color that should give suitable contrast with
/// transparent images
///
/// For non-transparent images this always returns `BACKGROUND_COLOR_DEFAULT`
/// For non-transparent images this always returns
/// `BACKGROUND_COLOR_DEFAULT`
pub async fn background_color_guess(&self) -> Option<gdk::RGBA> {
// Shortcut for formats that don't support transparency
if !self

View file

@ -1,5 +1,6 @@
// Copyright (c) 2022-2023 Sophie Herold
// Copyright (c) 2022 Christopher Davis
// Copyright (c) 2023 Julian Hofer
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@ -24,8 +25,7 @@ use crate::deps::*;
use crate::widgets::LpImage;
use adw::subclass::prelude::*;
use glib::clone;
use glib::Properties;
use glib::{clone, Properties};
use gtk::prelude::*;
use gtk::CompositeTemplate;

View file

@ -1,7 +1,8 @@
// Copyright (c) 2020-2023 Christopher Davis
// Copyright (c) 2022-2023 Sophie Herold
// Copyright (c) 2022 Elton A Rodrigues
// Copyright (c) 2022 Maximiliano Sandoval R
// Copyright (c) 2023 Julian Hofer
// Copyright (c) 2023 Starccy
// Copyright (c) 2023 FineFindus
// Copyright (c) 2023 Huan Nguyen
// Copyright (c) 2023 Philipp Kiemle
@ -39,15 +40,13 @@ use adw::prelude::*;
use adw::subclass::prelude::*;
use anyhow::Context;
use ashpd::desktop::{wallpaper, ResponseError};
use ashpd::Error;
use ashpd::WindowIdentifier;
use glib::clone;
use ashpd::{Error, WindowIdentifier};
use glib::translate::IntoGlib;
use glib::Properties;
use glib::{clone, Properties};
use gtk::CompositeTemplate;
use std::cell::{Cell, RefCell};
use std::{cell::OnceCell, marker::PhantomData};
use std::cell::{Cell, OnceCell, RefCell};
use std::marker::PhantomData;
// The number of pages we want to buffer
// on either side of the current page.
@ -208,7 +207,8 @@ mod imp {
}
impl WidgetImpl for LpImageView {
/// This manual implementation makes sure left an right overlay both fit into the window
/// This manual implementation makes sure left an right overlay both fit
/// into the window
fn measure(&self, orientation: gtk::Orientation, for_size: i32) -> (i32, i32, i32, i32) {
// Measure child of AdwBin
let (child_min, child_natural, _, _) = self.bin_child.measure(orientation, for_size);
@ -670,7 +670,8 @@ impl LpImageView {
"win.show-toast",
Some(
&(
// Translators: This is a toast notification, informing the user that an image has been set as background.
// Translators: This is a toast notification, informing the user that
// an image has been set as background.
gettext("Set as background."),
adw::ToastPriority::High.into_glib(),
)

View file

@ -1,4 +1,5 @@
// Copyright (c) 2023 Sophie Herold
// Copyright (c) 2023 Julian Hofer
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@ -63,8 +64,8 @@ enum Status {
/// Scope guard for non user ui changes
///
/// Creates a context in which other signals know that changes are not user input.
/// This avoids things like loops between value change signals.
/// Creates a context in which other signals know that changes are not user
/// input. This avoids things like loops between value change signals.
#[derive(Default, Clone, Debug)]
struct UiUpdates {
disabled: Rc<Cell<bool>>,

View file

@ -1,5 +1,6 @@
// Copyright (c) 2022-2023 Sophie Herold
// Copyright (c) 2022-2023 Christopher Davis
// Copyright (c) 2023 Julian Hofer
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@ -297,7 +298,8 @@ impl LpPropertiesView {
fn folder_name(&self, file: Option<gio::File>) -> String {
file.and_then(|f| f.parent()) // If the file exists, get the parent
.and_then(|p| util::get_file_display_name(&p)) // if that exists, the display name
.unwrap_or_else(|| FALLBACK.to_owned()) // and if we get nothing, use `FALLBACK`
.unwrap_or_else(|| FALLBACK.to_owned()) // and if we get nothing,
// use `FALLBACK`
}
#[template_callback]

View file

@ -457,8 +457,8 @@ impl LpSlidingView {
/// Sets position shift to correct page insert or removal
///
/// Takes the old position of the current page and calculates and sets the shift
/// to keep the current page optically at the same position.
/// Takes the old position of the current page and calculates and sets the
/// shift to keep the current page optically at the same position.
fn shift_position(&self, old_index: Option<usize>) {
if let (Some(old_index), Some(new_index)) = (old_index, self.current_index()) {
let shift = new_index as f64 - old_index as f64;