general: Iv* to Lp*
We're probably going to be keeping `loupe` as the codename and binary name going forward.
This commit is contained in:
parent
4d1141a675
commit
d4fca8aae3
8 changed files with 78 additions and 78 deletions
|
|
@ -29,7 +29,7 @@ mod imp {
|
|||
use super::*;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct IvImage {
|
||||
pub struct LpImage {
|
||||
pub file: RefCell<Option<gio::File>>,
|
||||
pub image_width: Cell<i32>,
|
||||
pub image_height: Cell<i32>,
|
||||
|
|
@ -37,10 +37,10 @@ mod imp {
|
|||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for IvImage {
|
||||
const NAME: &'static str = "IvImage";
|
||||
impl ObjectSubclass for LpImage {
|
||||
const NAME: &'static str = "LpImage";
|
||||
type ParentType = gtk::Widget;
|
||||
type Type = super::IvImage;
|
||||
type Type = super::LpImage;
|
||||
|
||||
fn new() -> Self {
|
||||
Self {
|
||||
|
|
@ -52,7 +52,7 @@ mod imp {
|
|||
}
|
||||
}
|
||||
|
||||
impl ObjectImpl for IvImage {
|
||||
impl ObjectImpl for LpImage {
|
||||
fn properties() -> &'static [glib::ParamSpec] {
|
||||
static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| {
|
||||
vec![glib::ParamSpec::new_object(
|
||||
|
|
@ -93,7 +93,7 @@ mod imp {
|
|||
}
|
||||
}
|
||||
|
||||
impl WidgetImpl for IvImage {
|
||||
impl WidgetImpl for LpImage {
|
||||
fn snapshot(&self, widget: &Self::Type, snapshot: >k::Snapshot) {
|
||||
if let Some(texture) = self.texture.borrow().as_ref() {
|
||||
let width = widget.width() as f64;
|
||||
|
|
@ -168,18 +168,18 @@ mod imp {
|
|||
}
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct IvImage(ObjectSubclass<imp::IvImage>) @extends gtk::Widget;
|
||||
pub struct LpImage(ObjectSubclass<imp::LpImage>) @extends gtk::Widget;
|
||||
}
|
||||
|
||||
impl IvImage {
|
||||
impl LpImage {
|
||||
pub fn file(&self) -> Option<gio::File> {
|
||||
let imp = imp::IvImage::from_instance(self);
|
||||
let imp = imp::LpImage::from_instance(self);
|
||||
|
||||
imp.file.borrow().clone()
|
||||
}
|
||||
|
||||
pub fn set_file(&self, file: &gio::File) {
|
||||
let imp = imp::IvImage::from_instance(self);
|
||||
let imp = imp::LpImage::from_instance(self);
|
||||
|
||||
match gdk::Texture::from_file(file) {
|
||||
Ok(texture) => {
|
||||
|
|
@ -197,12 +197,12 @@ impl IvImage {
|
|||
}
|
||||
|
||||
pub fn image_width(&self) -> i32 {
|
||||
let imp = imp::IvImage::from_instance(&self);
|
||||
let imp = imp::LpImage::from_instance(&self);
|
||||
imp.image_width.get()
|
||||
}
|
||||
|
||||
pub fn image_height(&self) -> i32 {
|
||||
let imp = imp::IvImage::from_instance(&self);
|
||||
let imp = imp::LpImage::from_instance(&self);
|
||||
imp.image_height.get()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,16 +32,16 @@ use once_cell::sync::Lazy;
|
|||
use std::cell::{Cell, RefCell};
|
||||
|
||||
use crate::util;
|
||||
use crate::widgets::IvImage;
|
||||
use crate::widgets::LpImage;
|
||||
|
||||
mod imp {
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Default, CompositeTemplate)]
|
||||
#[template(resource = "/org/gnome/Loupe/gtk/image_view.ui")]
|
||||
pub struct IvImageView {
|
||||
pub struct LpImageView {
|
||||
#[template_child]
|
||||
pub picture: TemplateChild<IvImage>,
|
||||
pub picture: TemplateChild<LpImage>,
|
||||
#[template_child]
|
||||
pub controls: TemplateChild<gtk::Box>,
|
||||
#[template_child]
|
||||
|
|
@ -65,9 +65,9 @@ mod imp {
|
|||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for IvImageView {
|
||||
const NAME: &'static str = "IvImageView";
|
||||
type Type = super::IvImageView;
|
||||
impl ObjectSubclass for LpImageView {
|
||||
const NAME: &'static str = "LpImageView";
|
||||
type Type = super::LpImageView;
|
||||
type ParentType = libadwaita::Bin;
|
||||
|
||||
fn class_init(klass: &mut Self::Class) {
|
||||
|
|
@ -87,7 +87,7 @@ mod imp {
|
|||
}
|
||||
}
|
||||
|
||||
impl ObjectImpl for IvImageView {
|
||||
impl ObjectImpl for LpImageView {
|
||||
fn properties() -> &'static [glib::ParamSpec] {
|
||||
static PROPERTIES: Lazy<Vec<glib::ParamSpec>> = Lazy::new(|| {
|
||||
vec![
|
||||
|
|
@ -134,19 +134,19 @@ mod imp {
|
|||
}
|
||||
}
|
||||
|
||||
impl WidgetImpl for IvImageView {}
|
||||
impl BinImpl for IvImageView {}
|
||||
impl WidgetImpl for LpImageView {}
|
||||
impl BinImpl for LpImageView {}
|
||||
}
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct IvImageView(ObjectSubclass<imp::IvImageView>)
|
||||
pub struct LpImageView(ObjectSubclass<imp::LpImageView>)
|
||||
@extends gtk::Widget, libadwaita::Bin,
|
||||
@implements gtk::Buildable, gtk::ConstraintTarget, gtk::Orientable;
|
||||
}
|
||||
|
||||
impl IvImageView {
|
||||
impl LpImageView {
|
||||
pub fn set_image_from_file(&self, file: &gio::File) -> anyhow::Result<(i32, i32)> {
|
||||
let imp = imp::IvImageView::from_instance(&self);
|
||||
let imp = imp::LpImageView::from_instance(&self);
|
||||
|
||||
if let Some(current_file) = imp.picture.file() {
|
||||
if current_file.path().as_deref() == file.path().as_deref() {
|
||||
|
|
@ -170,7 +170,7 @@ impl IvImageView {
|
|||
}
|
||||
|
||||
fn set_parent_from_file(&self, file: &gio::File) {
|
||||
let imp = imp::IvImageView::from_instance(&self);
|
||||
let imp = imp::LpImageView::from_instance(&self);
|
||||
|
||||
if let Some(parent) = file.parent() {
|
||||
let parent_path = parent.path().map(|p| p.to_str().unwrap().to_string());
|
||||
|
|
@ -231,7 +231,7 @@ impl IvImageView {
|
|||
}
|
||||
|
||||
fn update_image(&self) {
|
||||
let imp = imp::IvImageView::from_instance(&self);
|
||||
let imp = imp::LpImageView::from_instance(&self);
|
||||
|
||||
let path = &format!(
|
||||
"{}/{}",
|
||||
|
|
@ -248,21 +248,21 @@ impl IvImageView {
|
|||
}
|
||||
|
||||
pub fn next(&self) {
|
||||
let imp = imp::IvImageView::from_instance(&self);
|
||||
let imp = imp::LpImageView::from_instance(&self);
|
||||
// TODO: Replace with `Cell::update()` once stabilized
|
||||
imp.index.set(imp.index.get() + 1);
|
||||
self.update_image();
|
||||
}
|
||||
|
||||
pub fn previous(&self) {
|
||||
let imp = imp::IvImageView::from_instance(&self);
|
||||
let imp = imp::LpImageView::from_instance(&self);
|
||||
// TODO: Replace with `Cell::update()` once stabilized
|
||||
imp.index.set(imp.index.get() - 1);
|
||||
self.update_image();
|
||||
}
|
||||
|
||||
pub fn update_action_state(&self) {
|
||||
let imp = imp::IvImageView::from_instance(&self);
|
||||
let imp = imp::LpImageView::from_instance(&self);
|
||||
let index = imp.index.get();
|
||||
self.action_set_enabled("iv.next", index < imp.directory_pictures.borrow().len() - 1);
|
||||
self.action_set_enabled("iv.previous", index > 0);
|
||||
|
|
@ -279,7 +279,7 @@ impl IvImageView {
|
|||
}
|
||||
|
||||
pub fn print(&self) -> anyhow::Result<()> {
|
||||
let imp = imp::IvImageView::from_instance(&self);
|
||||
let imp = imp::LpImageView::from_instance(&self);
|
||||
|
||||
let operation = gtk::PrintOperation::new();
|
||||
let path = &format!(
|
||||
|
|
@ -320,17 +320,17 @@ impl IvImageView {
|
|||
}
|
||||
|
||||
pub fn uri(&self) -> Option<String> {
|
||||
let imp = imp::IvImageView::from_instance(&self);
|
||||
let imp = imp::LpImageView::from_instance(&self);
|
||||
imp.uri.borrow().to_owned()
|
||||
}
|
||||
|
||||
pub fn filename(&self) -> Option<String> {
|
||||
let imp = imp::IvImageView::from_instance(&self);
|
||||
let imp = imp::LpImageView::from_instance(&self);
|
||||
imp.filename.borrow().to_owned()
|
||||
}
|
||||
|
||||
pub fn show_popover_at(&self, x: f64, y: f64) {
|
||||
let imp = imp::IvImageView::from_instance(&self);
|
||||
let imp = imp::LpImageView::from_instance(&self);
|
||||
|
||||
let rect = gdk::Rectangle {
|
||||
x: x as i32,
|
||||
|
|
|
|||
|
|
@ -20,5 +20,5 @@
|
|||
mod image;
|
||||
mod image_view;
|
||||
|
||||
pub use image::IvImage;
|
||||
pub use image_view::IvImageView;
|
||||
pub use image::LpImage;
|
||||
pub use image_view::LpImageView;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue