code: Reformat with new rules
This commit is contained in:
parent
4b510412e1
commit
b56d650086
14 changed files with 68 additions and 45 deletions
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright (c) 2020-2023 Christopher Davis
|
||||
// Copyright (c) 2022-2023 Sophie Herold
|
||||
// Copyright (c) 2022-2023 Sabri Ünal
|
||||
// Copyright (c) 2023 Julian Hofer
|
||||
// Copyright (c) 2023 Huan Nguyen
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -32,8 +32,7 @@ use crate::deps::*;
|
|||
use arc_swap::ArcSwap;
|
||||
use gtk::prelude::*;
|
||||
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::VecDeque;
|
||||
use std::collections::{BTreeMap, VecDeque};
|
||||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
|
|
@ -335,8 +334,8 @@ impl TiledImage {
|
|||
|
||||
/// Viewport within zoom coordinates
|
||||
///
|
||||
/// preserve_area: Slightly larger than the viewport, area for which we want tiles
|
||||
/// TODO: This is the most buggy function ever
|
||||
/// preserve_area: Slightly larger than the viewport, area for which we want
|
||||
/// tiles TODO: This is the most buggy function ever
|
||||
pub fn cleanup(&mut self, zoom: f64, preserve_area: graphene::Rect) {
|
||||
let zoom = zoom_normalize(zoom);
|
||||
let mut kept_tiles = Self::default();
|
||||
|
|
@ -584,7 +583,8 @@ pub trait FrameBufferExt {
|
|||
fn push_frame(&self, tile: Tile, dimensions: Coordinates, delay: Duration);
|
||||
fn reset(&self);
|
||||
fn get_layer_tiling_or_default(&self, zoom: f64, viewport: graphene::Rect) -> Tiling;
|
||||
/// Return true if the next frame should be shown and removes the outdated frame
|
||||
/// Return true if the next frame should be shown and removes the outdated
|
||||
/// frame
|
||||
fn frame_timeout(&self, elapsed: Duration) -> bool;
|
||||
/// Returns the number of currently buffered frames
|
||||
fn n_frames(&self) -> usize;
|
||||
|
|
|
|||
|
|
@ -36,8 +36,8 @@ mod imp {
|
|||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct LpFileModel {
|
||||
/// Use and IndexMap such that we can put the elements into an arbitrary order
|
||||
/// while still having fast hash access via file URI.
|
||||
/// Use and IndexMap such that we can put the elements into an arbitrary
|
||||
/// order while still having fast hash access via file URI.
|
||||
pub(super) files: RefCell<IndexMap<GString, gio::File>>,
|
||||
pub(super) directory: OnceCell<gio::File>,
|
||||
/// Track file changes.
|
||||
|
|
@ -150,7 +150,8 @@ impl LpFileModel {
|
|||
let mut new_files = new_files?;
|
||||
|
||||
{
|
||||
// Here we use a nested scope so that the mutable borrow only lasts as long as we need it
|
||||
// Here we use a nested scope so that the mutable borrow only lasts as long as
|
||||
// we need it
|
||||
|
||||
let mut files = self.imp().files.borrow_mut();
|
||||
for (uri, file) in files.iter() {
|
||||
|
|
|
|||
|
|
@ -46,7 +46,8 @@ Simplified widget arrangement including the most important widgets.
|
|||
*/
|
||||
|
||||
use gettextrs::*;
|
||||
use gtk::gio::{self, prelude::*};
|
||||
use gtk::gio::prelude::*;
|
||||
use gtk::gio::{self};
|
||||
|
||||
mod about;
|
||||
mod application;
|
||||
|
|
|
|||
|
|
@ -32,7 +32,8 @@ use std::path::{Path, PathBuf};
|
|||
pub fn datetime_fmt(datetime: &glib::DateTime) -> Option<String> {
|
||||
// Translators: This is the date and time format we use in metadata output etc.
|
||||
// The format has to follow <https://docs.gtk.org/glib/method.DateTime.format.html>
|
||||
// The default is already translated. Don't change if you are not sure what to use.
|
||||
// The default is already translated. Don't change if you are not sure what to
|
||||
// use.
|
||||
let datetime_format = gettext("%x %X");
|
||||
|
||||
let local_datetime = datetime.to_local();
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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>>,
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
// 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 FineFindus
|
||||
// Copyright (c) 2023 qwel
|
||||
// Copyright (c) 2023 Huan Thieu Nguyen
|
||||
|
|
@ -819,7 +820,8 @@ impl LpWindow {
|
|||
})
|
||||
}
|
||||
|
||||
/// Queue a fade animation to play after `HIDE_CONTROLS_IDLE_TIMEOUT` of inactivity
|
||||
/// Queue a fade animation to play after `HIDE_CONTROLS_IDLE_TIMEOUT` of
|
||||
/// inactivity
|
||||
fn queue_hide_controls(&self) {
|
||||
self.dequeue_hide_controls();
|
||||
|
||||
|
|
@ -895,7 +897,9 @@ impl LpWindow {
|
|||
.image_view
|
||||
.current_file()
|
||||
.and_then(|f| util::get_file_display_name(&f)) // If the file exists, get display name
|
||||
.unwrap_or_else(|| gettext("Image Viewer")) // Return that or the default if there's nothing
|
||||
.unwrap_or_else(|| gettext("Image Viewer")) // Return that or
|
||||
// the default if
|
||||
// there's nothing
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -912,9 +916,9 @@ impl LpWindow {
|
|||
fn on_motion(&self, pointer_position: (f64, f64)) {
|
||||
let imp = self.imp();
|
||||
|
||||
// Check if position really changed since swipe gesture sends change event with same position.
|
||||
// Also, don't connect this to "leave" because swipe also sends fake "leave" events when
|
||||
// the widget under the cursor changes.
|
||||
// Check if position really changed since swipe gesture sends change event with
|
||||
// same position. Also, don't connect this to "leave" because swipe also
|
||||
// sends fake "leave" events when the widget under the cursor changes.
|
||||
if imp.pointer_position.get() == pointer_position {
|
||||
return;
|
||||
}
|
||||
|
|
@ -929,7 +933,8 @@ impl LpWindow {
|
|||
}
|
||||
}
|
||||
|
||||
/// Only hide controls if cursor not over controls and there is an image shown
|
||||
/// Only hide controls if cursor not over controls and there is an image
|
||||
/// shown
|
||||
fn can_hide_controls(&self) -> bool {
|
||||
!self
|
||||
.image_view()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue