Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/access.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ pub(crate) fn view(portal: &CosmicPortal) -> cosmic::Element<Msg> {
.active_choices
.get(id)
.and_then(|choice_id| choices.iter().position(|(x, _)| x == choice_id));
let dropdown = dropdown(&choice_labels, active_choice, move |j| Msg::Choice(i, j));
let dropdown = dropdown(choice_labels, active_choice, move |j| Msg::Choice(i, j));
options.push(row![label, dropdown].into());
}

Expand Down
3 changes: 1 addition & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,8 +299,7 @@ impl cosmic::Application for CosmicPortal {
_ => None,
}),
];
for (id, (_args, dialog)) in self.file_choosers.iter() {
let id = id.clone();
for (&id, (_args, dialog)) in self.file_choosers.iter() {
subscriptions.push(dialog.subscription().map(move |x| Msg::FileChooser(id, x)));
}
Subscription::batch(subscriptions)
Expand Down
19 changes: 6 additions & 13 deletions src/file_chooser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,9 @@ impl FileChooser {
return PortalResponse::Other;
}
if let Some(res) = rx.recv().await {
return res;
res
} else {
return PortalResponse::Cancelled;
PortalResponse::Cancelled
}
}
}
Expand Down Expand Up @@ -373,12 +373,10 @@ pub fn update_args(portal: &mut CosmicPortal, args: Args) -> cosmic::Task<app::M
} else {
DialogKind::OpenFolder
}
} else if options.multiple.unwrap_or(false) {
DialogKind::OpenMultipleFiles
} else {
if options.multiple.unwrap_or(false) {
DialogKind::OpenMultipleFiles
} else {
DialogKind::OpenFile
}
DialogKind::OpenFile
}
}
FileChooserOptions::SaveFile(options) => DialogKind::SaveFile {
Expand All @@ -391,12 +389,7 @@ pub fn update_args(portal: &mut CosmicPortal, args: Args) -> cosmic::Task<app::M
};
let path_opt = args.options.current_folder();

let (mut dialog, command) = Dialog::new(
kind,
path_opt,
|x| Msg::DialogMessage(x),
|x| Msg::DialogResult(x),
);
let (mut dialog, command) = Dialog::new(kind, path_opt, Msg::DialogMessage, Msg::DialogResult);
cmds.push(command);
cmds.push(dialog.set_title(args.title.clone()));
if let Some(accept_label) = args.options.accept_label() {
Expand Down
6 changes: 3 additions & 3 deletions src/screencast_dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ async fn load_desktop_entries(locales: &[String]) -> Vec<DesktopEntry<'static>>
let mut entries = Vec::new();
for p in fde::Iter::new(fde::default_paths()) {
if let Ok(data) = tokio::fs::read_to_string(&p).await {
if let Ok(entry) = DesktopEntry::from_str(&p, &data, Some(&locales)) {
if let Ok(entry) = DesktopEntry::from_str(&p, &data, Some(locales)) {
entries.push(entry.to_owned());
}
}
Expand All @@ -116,7 +116,7 @@ fn get_desktop_entry<'a>(
entries: &'a [DesktopEntry<'a>],
id: &str,
) -> Option<&'a DesktopEntry<'a>> {
fde::matching::get_best_match(&[id], &entries, fde::matching::MatchAppIdOptions::default())
fde::matching::get_best_match(&[id], entries, fde::matching::MatchAppIdOptions::default())
}

fn create_dialog() -> cosmic::Task<crate::app::Msg> {
Expand Down Expand Up @@ -441,7 +441,7 @@ pub(crate) fn view(portal: &CosmicPortal) -> cosmic::Element<Msg> {
let unknown = fl!("unknown-application");
let app_name = args.app_name.as_deref().unwrap_or(&unknown);

let control = widget::column::with_children(vec![tabs.into(), list.into()]).spacing(8);
let control = widget::column::with_children(vec![tabs.into(), list]).spacing(8);
autosize::autosize(
KeyboardWrapper::new(
widget::dialog()
Expand Down
34 changes: 16 additions & 18 deletions src/screenshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl Rect {
}
}

pub fn dimensions(self: Self) -> Option<RectDimension> {
pub fn dimensions(self) -> Option<RectDimension> {
let width = NonZeroU32::new((self.right - self.left).unsigned_abs())?;
let height = NonZeroU32::new((self.bottom - self.top).unsigned_abs())?;
Some(RectDimension { width, height })
Expand Down Expand Up @@ -142,7 +142,7 @@ impl Screenshot {
let mut map: HashMap<String, _> = HashMap::with_capacity(outputs.len());
for Output { output, name, .. } in outputs {
let frame = wayland_helper
.capture_output_toplevels_shm(&output, false)
.capture_output_toplevels_shm(output, false)
.await
.into_iter()
.filter_map(|img| img.image_transformed().ok())
Expand Down Expand Up @@ -253,8 +253,8 @@ impl Screenshot {
let rect = Rect {
left: output_x,
top: output_y,
right: output_x.saturating_add(output_w.try_into().unwrap_or_default()),
bottom: output_y.saturating_add(output_h.try_into().unwrap_or_default()),
right: output_x.saturating_add(output_w),
bottom: output_y.saturating_add(output_h),
};
bounds_opt = Some(match bounds_opt.take() {
Some(bounds) => Rect {
Expand Down Expand Up @@ -624,19 +624,17 @@ pub fn update_msg(portal: &mut CosmicPortal, msg: Msg) -> cosmic::Task<crate::ap
log::error!("Failed to produce rgba image for screenshot");
success = false;
}
} else {
if let Some(img) = RgbaImage::from_raw(width, height, buf.into()) {
let mut buffer = Vec::new();
if let Err(e) = Screenshot::save_rgba_to_buffer(&img, &mut buffer) {
log::error!("Failed to save screenshot to buffer: {:?}", e);
success = false;
} else {
cmds.push(clipboard::write_data(ScreenshotBytes::new(buffer)))
};
} else {
log::error!("Failed to produce rgba image for screenshot");
} else if let Some(img) = RgbaImage::from_raw(width, height, buf.into()) {
let mut buffer = Vec::new();
if let Err(e) = Screenshot::save_rgba_to_buffer(&img, &mut buffer) {
log::error!("Failed to save screenshot to buffer: {:?}", e);
success = false;
}
} else {
cmds.push(clipboard::write_data(ScreenshotBytes::new(buffer)))
};
} else {
log::error!("Failed to produce rgba image for screenshot");
success = false;
}
} else {
log::error!("Failed to find output {}", name);
Expand Down Expand Up @@ -689,7 +687,7 @@ pub fn update_msg(portal: &mut CosmicPortal, msg: Msg) -> cosmic::Task<crate::ap
.unsigned_abs(),
);

if img.width() != output.logical_size.0 as u32 {
if img.width() != output.logical_size.0 {
let overlay = image::imageops::resize(
&overlay.to_image(),
(intersect.right - intersect.left) as u32,
Expand Down Expand Up @@ -774,7 +772,7 @@ pub fn update_msg(portal: &mut CosmicPortal, msg: Msg) -> cosmic::Task<crate::ap
})
} else if success && image_path.is_none() {
PortalResponse::Success(ScreenshotResult {
uri: format!("clipboard:///"),
uri: "clipboard:///".to_string(),
})
} else {
PortalResponse::Other
Expand Down
11 changes: 3 additions & 8 deletions src/wayland/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,9 @@ impl AppData {
.unwrap();
*guard = toplevels
.filter_map(|toplevel| {
let Some(info) = toplevel.1 else {
return None;
};
let info = toplevel.1?;

let Some(o) = self
let o = self
.workspace_state
.workspace_groups()
.iter()
Expand All @@ -145,10 +143,7 @@ impl AppData {
})
.then(|| info.output.iter().cloned().collect::<Vec<_>>())
})
})
else {
return None;
};
})?;

Some((o, toplevel.0))
})
Expand Down
2 changes: 1 addition & 1 deletion src/widget/keyboard_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ where
renderer: &cosmic::Renderer,
dnd_rectangles: &mut cosmic::iced_core::clipboard::DndDestinationRectangles,
) {
if let Some(state) = state.children.iter().next() {
if let Some(state) = state.children.first() {
self.content
.as_widget()
.drag_destinations(state, layout, renderer, dnd_rectangles);
Expand Down
2 changes: 1 addition & 1 deletion src/widget/rectangle_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use cosmic::{

use crate::screenshot::Rect;

pub const MIME: &'static str = "X-COSMIC-PORTAL-MyData";
pub const MIME: &str = "X-COSMIC-PORTAL-MyData";
pub struct MyData;

impl TryFrom<(Vec<u8>, String)> for MyData {
Expand Down
1 change: 1 addition & 0 deletions src/widget/screenshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ impl<'a, Msg> ScreenshotSelection<'a, Msg>
where
Msg: 'static + Clone,
{
#[allow(clippy::too_many_arguments)]
pub fn new(
choice: Choice,
image_handle: image::Handle,
Expand Down