cargo: Update dependencies
This commit is contained in:
parent
743577757f
commit
3d6564377a
11 changed files with 574 additions and 271 deletions
|
|
@ -58,32 +58,30 @@ mod imp {
|
|||
PROPERTIES.as_ref()
|
||||
}
|
||||
|
||||
fn property(&self, obj: &Self::Type, _id: usize, pspec: &glib::ParamSpec) -> glib::Value {
|
||||
fn property(&self, _id: usize, pspec: &glib::ParamSpec) -> glib::Value {
|
||||
let obj = self.instance();
|
||||
match pspec.name() {
|
||||
"file" => obj.file().to_value(),
|
||||
_ => unimplemented!(),
|
||||
}
|
||||
}
|
||||
|
||||
fn set_property(
|
||||
&self,
|
||||
obj: &Self::Type,
|
||||
_id: usize,
|
||||
value: &glib::Value,
|
||||
pspec: &glib::ParamSpec,
|
||||
) {
|
||||
fn set_property(&self, _id: usize, value: &glib::Value, pspec: &glib::ParamSpec) {
|
||||
let obj = self.instance();
|
||||
match pspec.name() {
|
||||
"file" => obj.set_file(&value.get().unwrap()),
|
||||
_ => unimplemented!(),
|
||||
}
|
||||
}
|
||||
|
||||
fn constructed(&self, obj: &Self::Type) {
|
||||
fn constructed(&self) {
|
||||
let obj = self.instance();
|
||||
obj.set_hexpand(true);
|
||||
obj.set_vexpand(true);
|
||||
}
|
||||
|
||||
fn dispose(&self, obj: &Self::Type) {
|
||||
fn dispose(&self) {
|
||||
let obj = self.instance();
|
||||
while let Some(child) = obj.first_child() {
|
||||
child.unparent();
|
||||
}
|
||||
|
|
@ -91,14 +89,15 @@ mod imp {
|
|||
}
|
||||
|
||||
impl WidgetImpl for LpImage {
|
||||
fn snapshot(&self, widget: &Self::Type, snapshot: >k::Snapshot) {
|
||||
fn snapshot(&self, snapshot: >k::Snapshot) {
|
||||
if let Some(texture) = self.texture.borrow().as_ref() {
|
||||
let widget = self.instance();
|
||||
let width = widget.width() as f64;
|
||||
let height = widget.height() as f64;
|
||||
let texture_ratio = texture.intrinsic_aspect_ratio();
|
||||
|
||||
if texture_ratio == 0.0 {
|
||||
texture.snapshot(snapshot.upcast_ref(), width, height);
|
||||
texture.snapshot(snapshot, width, height);
|
||||
} else {
|
||||
let widget_ratio = width / height;
|
||||
|
||||
|
|
@ -113,22 +112,17 @@ mod imp {
|
|||
|
||||
snapshot.save();
|
||||
snapshot.translate(&graphene::Point::new(x as f32, y as f32));
|
||||
texture.snapshot(snapshot.upcast_ref(), snapshot_width, snapshot_height);
|
||||
texture.snapshot(snapshot, snapshot_width, snapshot_height);
|
||||
snapshot.restore();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn request_mode(&self, _widget: &Self::Type) -> gtk::SizeRequestMode {
|
||||
fn request_mode(&self) -> gtk::SizeRequestMode {
|
||||
gtk::SizeRequestMode::HeightForWidth
|
||||
}
|
||||
|
||||
fn measure(
|
||||
&self,
|
||||
_widget: &Self::Type,
|
||||
orienation: gtk::Orientation,
|
||||
for_size: i32,
|
||||
) -> (i32, i32, i32, i32) {
|
||||
fn measure(&self, orienation: gtk::Orientation, for_size: i32) -> (i32, i32, i32, i32) {
|
||||
if let Some(texture) = self.texture.borrow().as_ref() {
|
||||
let default_size = 16.0; // Fall back to default icon size; Just a guess since the API GtkPicture uses is private
|
||||
let measurement = if for_size < 0 { 0 } else { for_size };
|
||||
|
|
|
|||
|
|
@ -70,8 +70,10 @@ mod imp {
|
|||
}
|
||||
|
||||
impl ObjectImpl for LpImagePage {
|
||||
fn constructed(&self, obj: &Self::Type) {
|
||||
self.parent_constructed(obj);
|
||||
fn constructed(&self) {
|
||||
let obj = self.instance();
|
||||
|
||||
self.parent_constructed();
|
||||
|
||||
self.click_gesture
|
||||
.connect_pressed(clone!(@weak obj => move |gesture, _, x, y| {
|
||||
|
|
@ -100,7 +102,7 @@ glib::wrapper! {
|
|||
|
||||
impl LpImagePage {
|
||||
pub fn from_file(file: &gio::File) -> Self {
|
||||
let obj = glib::Object::new::<Self>(&[]).unwrap();
|
||||
let obj = glib::Object::new::<Self>(&[]);
|
||||
obj.imp().file.set(file.clone()).unwrap();
|
||||
|
||||
// This doesn't work properly for items not explicitly selected
|
||||
|
|
|
|||
|
|
@ -97,15 +97,18 @@ mod imp {
|
|||
PROPERTIES.as_ref()
|
||||
}
|
||||
|
||||
fn property(&self, obj: &Self::Type, _id: usize, psec: &glib::ParamSpec) -> glib::Value {
|
||||
fn property(&self, _id: usize, psec: &glib::ParamSpec) -> glib::Value {
|
||||
let obj = self.instance();
|
||||
match psec.name() {
|
||||
"active-file" => obj.active_file().to_value(),
|
||||
_ => unimplemented!(),
|
||||
}
|
||||
}
|
||||
|
||||
fn constructed(&self, obj: &Self::Type) {
|
||||
self.parent_constructed(obj);
|
||||
fn constructed(&self) {
|
||||
let obj = self.instance();
|
||||
|
||||
self.parent_constructed();
|
||||
|
||||
let source = gtk::DragSource::new();
|
||||
source.set_exclusive(true);
|
||||
|
|
@ -386,28 +389,38 @@ impl LpImageView {
|
|||
|
||||
pub fn set_background(&self) -> anyhow::Result<()> {
|
||||
let background = self.uri().context("No URI for current file")?;
|
||||
spawn!(clone!(@weak self as view => async move {
|
||||
spawn!(clone!(@weak self as view =>
|
||||
async move {
|
||||
let id = WindowIdentifier::from_native(
|
||||
&view.native().expect("View should have a GtkNative"),
|
||||
)
|
||||
.await;
|
||||
|
||||
let _ = match wallpaper::set_from_uri(
|
||||
&id,
|
||||
&background,
|
||||
true,
|
||||
wallpaper::SetOn::Background,
|
||||
)
|
||||
.await {
|
||||
let _ = match wallpaper::WallpaperRequest::default()
|
||||
.set_on(wallpaper::SetOn::Background)
|
||||
.show_preview(true)
|
||||
.identifier(id)
|
||||
.build_uri(&background)
|
||||
.await
|
||||
{
|
||||
// We use `1` here because we can't pass enums directly as GVariants,
|
||||
// so we need to use the C int value of the enum.
|
||||
// `TOAST_PRIORITY_NORMAL = 0`, and `TOAST_PRIORITY_HIGH = 1`
|
||||
Ok(_) => view.activate_action("win.show-toast", Some(&(i18n("Set as background."), 1).to_variant())).unwrap(),
|
||||
Ok(_) => view
|
||||
.activate_action(
|
||||
"win.show-toast",
|
||||
Some(&(i18n("Set as background."), 1).to_variant()),
|
||||
)
|
||||
.unwrap(),
|
||||
Err(err) => {
|
||||
if !matches!(err, Error::Response(ResponseError::Cancelled)) {
|
||||
view.activate_action("win.show-toast", Some(&(i18n("Could not set background."), 1).to_variant())).unwrap();
|
||||
view.activate_action(
|
||||
"win.show-toast",
|
||||
Some(&(i18n("Could not set background."), 1).to_variant()),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
},
|
||||
}
|
||||
};
|
||||
}));
|
||||
|
||||
|
|
@ -475,8 +488,9 @@ impl LpImageView {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn uri(&self) -> Option<String> {
|
||||
self.active_file().map(|f| f.uri().to_string())
|
||||
pub fn uri(&self) -> Option<url::Url> {
|
||||
self.active_file()
|
||||
.and_then(|f| url::Url::parse(&f.uri()).ok())
|
||||
}
|
||||
|
||||
pub fn active_file(&self) -> Option<gio::File> {
|
||||
|
|
|
|||
|
|
@ -101,7 +101,8 @@ mod imp {
|
|||
PROPERTIES.as_ref()
|
||||
}
|
||||
|
||||
fn property(&self, obj: &Self::Type, _id: usize, pspec: &glib::ParamSpec) -> glib::Value {
|
||||
fn property(&self, _id: usize, pspec: &glib::ParamSpec) -> glib::Value {
|
||||
let obj = self.instance();
|
||||
let prop_name = pspec.name();
|
||||
|
||||
match prop_name {
|
||||
|
|
@ -112,13 +113,8 @@ mod imp {
|
|||
}
|
||||
}
|
||||
|
||||
fn set_property(
|
||||
&self,
|
||||
obj: &Self::Type,
|
||||
_id: usize,
|
||||
value: &glib::Value,
|
||||
pspec: &glib::ParamSpec,
|
||||
) {
|
||||
fn set_property(&self, _id: usize, value: &glib::Value, pspec: &glib::ParamSpec) {
|
||||
let obj = self.instance();
|
||||
let prop_name = pspec.name();
|
||||
|
||||
match prop_name {
|
||||
|
|
@ -127,8 +123,10 @@ mod imp {
|
|||
}
|
||||
}
|
||||
|
||||
fn constructed(&self, obj: &Self::Type) {
|
||||
self.parent_constructed(obj);
|
||||
fn constructed(&self) {
|
||||
let obj = self.instance();
|
||||
|
||||
self.parent_constructed();
|
||||
obj.action_set_enabled("properties.open-folder", false);
|
||||
}
|
||||
}
|
||||
|
|
@ -303,7 +301,7 @@ impl LpPropertiesView {
|
|||
{
|
||||
spawn!(clone!(@weak self as view => async move {
|
||||
let id = WindowIdentifier::from_native(&view.native().expect("No GtkNative for view")).await;
|
||||
if let Err(e) = open_uri::open_directory(&id, &directory).await {
|
||||
if let Err(e) = open_uri::OpenDirectoryRequest::default().identifier(id).build(&directory).await {
|
||||
log::error!("Could not open parent directory: {e}");
|
||||
};
|
||||
}));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue