Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warnings #733

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
1 change: 1 addition & 0 deletions cosmic-theme/src/model/mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ impl ThemeMode {
config.get::<bool>("is_dark")
}

/// Get the configuration version.
pub const fn version() -> u64 {
Self::VERSION
}
Expand Down
3 changes: 3 additions & 0 deletions cosmic-theme/src/output/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ pub enum OutputError {
}

impl Theme {
/// Apply the theme exports.
pub fn apply_exports(&self) -> Result<(), OutputError> {
let gtk_res = Theme::apply_gtk(self.is_dark);
let vs_res = self.clone().apply_vs_code();
Expand All @@ -27,12 +28,14 @@ impl Theme {
Ok(())
}

/// Write the exports to the config directory.
pub fn write_exports(&self) -> Result<(), OutputError> {
let gtk_res = self.write_gtk4();
gtk_res?;
Ok(())
}

/// Reset the exports to the default values.
pub fn reset_exports() -> Result<(), OutputError> {
let gtk_res = Theme::reset_gtk();
let vs_res = Theme::reset_vs_code();
Expand Down
2 changes: 2 additions & 0 deletions cosmic-theme/src/output/vs_code.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ impl From<Theme> for VsTheme {
}

impl Theme {
/// Apply the current theme to VS Code.
pub fn apply_vs_code(self) -> Result<(), OutputError> {
let vs_theme = VsTheme::from(self);
let config_dir = dirs::config_dir().ok_or(OutputError::MissingConfigDir)?;
Expand All @@ -289,6 +290,7 @@ impl Theme {
Ok(())
}

/// Reset the VS Code theme to the default.
pub fn reset_vs_code() -> Result<(), OutputError> {
let config_dir = dirs::config_dir().ok_or(OutputError::MissingConfigDir)?;
let vs_code_dir = config_dir.join("Code").join("User");
Expand Down
1 change: 0 additions & 1 deletion src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use crate::cosmic_theme::Density;
use cosmic_config::cosmic_config_derive::CosmicConfigEntry;
use cosmic_config::{Config, CosmicConfigEntry};
use iced::font::Family;
use serde::{Deserialize, Serialize};
use std::sync::{LazyLock, RwLock};
use ustr::Ustr;
Expand Down
1 change: 0 additions & 1 deletion src/task/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
use iced::window;
use iced::Task;
use iced_core::window::Mode;
use iced_runtime::{task, Action};
use std::future::Future;

/// Yields a task which contains a batch of tasks.
Expand Down
36 changes: 13 additions & 23 deletions src/theme/style/iced.rs
Original file line number Diff line number Diff line change
Expand Up @@ -738,11 +738,9 @@ impl slider::Catalog for Theme {
impl menu::Catalog for Theme {
type Class<'a> = ();

fn default<'a>() -> <Self as menu::Catalog>::Class<'a> {
()
}
fn default<'a>() -> <Self as menu::Catalog>::Class<'a> {}

fn style(&self, class: &<Self as menu::Catalog>::Class<'_>) -> menu::Style {
fn style(&self, _class: &<Self as menu::Catalog>::Class<'_>) -> menu::Style {
let cosmic = self.cosmic();

menu::Style {
Expand All @@ -764,13 +762,11 @@ impl menu::Catalog for Theme {
impl pick_list::Catalog for Theme {
type Class<'a> = ();

fn default<'a>() -> <Self as pick_list::Catalog>::Class<'a> {
()
}
fn default<'a>() -> <Self as pick_list::Catalog>::Class<'a> {}

fn style(
&self,
class: &<Self as pick_list::Catalog>::Class<'_>,
_class: &<Self as pick_list::Catalog>::Class<'_>,
status: pick_list::Status,
) -> pick_list::Style {
let cosmic = &self.cosmic();
Expand Down Expand Up @@ -803,11 +799,9 @@ impl pick_list::Catalog for Theme {
impl radio::Catalog for Theme {
type Class<'a> = ();

fn default<'a>() -> Self::Class<'a> {
()
}
fn default<'a>() -> Self::Class<'a> {}

fn style(&self, class: &Self::Class<'_>, status: radio::Status) -> radio::Style {
fn style(&self, _class: &Self::Class<'_>, status: radio::Status) -> radio::Style {
let theme = self.cosmic();
let mut neutral_10 = theme.palette.neutral_10;
neutral_10.alpha = 0.1;
Expand Down Expand Up @@ -857,11 +851,9 @@ impl radio::Catalog for Theme {
impl toggler::Catalog for Theme {
type Class<'a> = ();

fn default<'a>() -> Self::Class<'a> {
()
}
fn default<'a>() -> Self::Class<'a> {}

fn style(&self, class: &Self::Class<'_>, status: toggler::Status) -> toggler::Style {
fn style(&self, _class: &Self::Class<'_>, status: toggler::Status) -> toggler::Style {
let cosmic = self.cosmic();
const HANDLE_MARGIN: f32 = 2.0;
let mut neutral_10 = cosmic.palette.neutral_10;
Expand All @@ -886,8 +878,8 @@ impl toggler::Catalog for Theme {
foreground_border_color: Color::TRANSPARENT,
};
match status {
toggler::Status::Active { is_toggled } => active,
toggler::Status::Hovered { is_toggled } => {
toggler::Status::Active { is_toggled: _ } => active,
toggler::Status::Hovered { is_toggled: _ } => {
let is_active = matches!(status, toggler::Status::Hovered { is_toggled: true });
toggler::Style {
background: if is_active {
Expand All @@ -914,11 +906,9 @@ impl toggler::Catalog for Theme {
impl pane_grid::Catalog for Theme {
type Class<'a> = ();

fn default<'a>() -> <Self as pane_grid::Catalog>::Class<'a> {
()
}
fn default<'a>() -> <Self as pane_grid::Catalog>::Class<'a> {}

fn style(&self, class: &<Self as pane_grid::Catalog>::Class<'_>) -> pane_grid::Style {
fn style(&self, _class: &<Self as pane_grid::Catalog>::Class<'_>) -> pane_grid::Style {
let theme = self.cosmic();

pane_grid::Style {
Expand Down Expand Up @@ -1199,7 +1189,7 @@ impl svg::Catalog for Theme {
Svg::default()
}

fn style(&self, class: &Self::Class<'_>, status: svg::Status) -> svg::Style {
fn style(&self, class: &Self::Class<'_>, _status: svg::Status) -> svg::Style {
#[allow(clippy::match_same_arms)]
match class {
Svg::Default => svg::Style::default(),
Expand Down
4 changes: 2 additions & 2 deletions src/theme/style/segmented_button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ mod horizontal {

pub fn selection_active(
cosmic: &cosmic_theme::Theme,
component: &Component,
_component: &Component,
) -> ItemStatusAppearance {
let mut color = cosmic.palette.neutral_5;
color.alpha = 0.2;
Expand Down Expand Up @@ -221,7 +221,7 @@ pub fn focus(

pub fn hover(
cosmic: &cosmic_theme::Theme,
component: &Component,
_component: &Component,
default: &ItemStatusAppearance,
) -> ItemStatusAppearance {
let mut color = cosmic.palette.neutral_8;
Expand Down
1 change: 0 additions & 1 deletion src/widget/aspect_ratio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ use iced_core::{
Alignment, Clipboard, Element, Layout, Length, Padding, Rectangle, Shell, Vector, Widget,
};

use iced_widget::container;
pub use iced_widget::container::{Catalog, Style};

pub fn aspect_ratio_container<'a, Message: 'static, T>(
Expand Down
2 changes: 1 addition & 1 deletion src/widget/button/image.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2023 System76 <info@system76.com>
// SPDX-License-Identifier: MPL-2.0

use super::{Builder, Style};
use super::Builder;
use crate::{
widget::{self, image::Handle},
Element,
Expand Down
10 changes: 8 additions & 2 deletions src/widget/button/text.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright 2023 System76 <info@system76.com>
// SPDX-License-Identifier: MPL-2.0

use super::{Builder, ButtonClass, Style};
use super::{Builder, ButtonClass};
use crate::widget::{icon, row, tooltip};
use crate::{ext::CollectionWidget, Element};
use crate::Element;
use apply::Apply;
use iced_core::{font::Weight, text::LineHeight, widget::Id, Alignment, Length, Padding};
use std::borrow::Cow;
Expand Down Expand Up @@ -42,6 +42,12 @@ pub struct Text {
pub(super) trailing_icon: Option<icon::Handle>,
}

impl Default for Text {
fn default() -> Self {
Self::new()
}
}

impl Text {
pub const fn new() -> Self {
Self {
Expand Down
8 changes: 2 additions & 6 deletions src/widget/button/widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,12 +583,7 @@ impl<'a, Message: 'a + Clone> Widget<Message, crate::Theme, crate::Renderer>
}
match self.description.as_ref() {
Some(iced_accessibility::Description::Id(id)) => {
node.set_described_by(
id.iter()
.cloned()
.map(|id| NodeId::from(id))
.collect::<Vec<_>>(),
);
node.set_described_by(id.iter().cloned().map(NodeId::from).collect::<Vec<_>>());
}
Some(iced_accessibility::Description::Text(text)) => {
node.set_description(text.clone());
Expand Down Expand Up @@ -655,6 +650,7 @@ impl State {
}

/// Returns whether the [`Button`] is currently hovered or not.
#[allow(dead_code)]
pub fn is_hovered(self) -> bool {
self.is_hovered
}
Expand Down
4 changes: 2 additions & 2 deletions src/widget/calendar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ where
.push(
button::icon(icon::from_name("go-previous-symbolic"))
.padding([0, 12])
.on_press((this.on_select)(set_prev_month(this.selected.clone()))),
.on_press((this.on_select)(set_prev_month(*this.selected))),
)
.push(
button::icon(icon::from_name("go-next-symbolic"))
.padding([0, 12])
.on_press((this.on_select)(set_next_month(this.selected.clone()))),
.on_press((this.on_select)(set_next_month(*this.selected))),
);

// Calender
Expand Down
6 changes: 6 additions & 0 deletions src/widget/dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ pub struct Dialog<'a, Message> {
tertiary_action: Option<Element<'a, Message>>,
}

impl<'a, Message> Default for Dialog<'a, Message> {
fn default() -> Self {
Self::new()
}
}

impl<'a, Message> Dialog<'a, Message> {
pub fn new() -> Self {
Self {
Expand Down
2 changes: 1 addition & 1 deletion src/widget/dnd_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ impl<
clipboard,
false,
if let Some(window) = self.window.as_ref() {
Some(iced_core::clipboard::DndSource::Surface(window.clone()))
Some(iced_core::clipboard::DndSource::Surface(*window))
} else {
Some(iced_core::clipboard::DndSource::Widget(self.id.clone()))
},
Expand Down
6 changes: 3 additions & 3 deletions src/widget/dropdown/menu/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -401,12 +401,12 @@ impl<'a, S: AsRef<str>, Message> Widget<Message, crate::Theme, crate::Renderer>

fn draw(
&self,
state: &Tree,
_state: &Tree,
renderer: &mut crate::Renderer,
theme: &crate::Theme,
style: &renderer::Style,
_style: &renderer::Style,
layout: Layout<'_>,
cursor: mouse::Cursor,
_cursor: mouse::Cursor,
viewport: &Rectangle,
) {
let appearance = theme.appearance(&());
Expand Down
12 changes: 6 additions & 6 deletions src/widget/dropdown/multi/widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use super::menu::{self, Menu};
use crate::widget::icon;
use derive_setters::Setters;
use iced_core::event::{self, Event};
use iced_core::text::{self, Paragraph, Text};
use iced_core::text::{self, Text};
use iced_core::widget::tree::{self, Tree};
use iced_core::{alignment, keyboard, layout, mouse, overlay, renderer, svg, touch, Shadow};
use iced_core::{
Expand Down Expand Up @@ -159,7 +159,7 @@ impl<'a, S: AsRef<str>, Message: 'a, Item: Clone + PartialEq + 'static>
cursor: mouse::Cursor,
viewport: &Rectangle,
) {
let font = self.font.unwrap_or_else(|| crate::font::default());
let font = self.font.unwrap_or_else(crate::font::default);

draw(
renderer,
Expand Down Expand Up @@ -256,7 +256,7 @@ impl<Item: Clone + PartialEq + 'static> Default for State<Item> {
/// Computes the layout of a [`Dropdown`].
#[allow(clippy::too_many_arguments)]
pub fn layout(
renderer: &crate::Renderer,
_renderer: &crate::Renderer,
limits: &layout::Limits,
width: Length,
gap: f32,
Expand All @@ -278,7 +278,7 @@ pub fn layout(
bounds: Size::new(f32::MAX, f32::MAX),
size: iced::Pixels(text_size),
line_height: text_line_height,
font: font.unwrap_or_else(|| crate::font::default()),
font: font.unwrap_or_else(crate::font::default),
horizontal_alignment: alignment::Horizontal::Left,
vertical_alignment: alignment::Vertical::Top,
shaping: text::Shaping::Advanced,
Expand Down Expand Up @@ -384,7 +384,7 @@ pub fn mouse_interaction(layout: Layout<'_>, cursor: mouse::Cursor) -> mouse::In
#[allow(clippy::too_many_arguments)]
pub fn overlay<'a, S: AsRef<str>, Message: 'a, Item: Clone + PartialEq + 'static>(
layout: Layout<'_>,
renderer: &crate::Renderer,
_renderer: &crate::Renderer,
state: &'a mut State<Item>,
gap: f32,
padding: Padding,
Expand Down Expand Up @@ -422,7 +422,7 @@ pub fn overlay<'a, S: AsRef<str>, Message: 'a, Item: Clone + PartialEq + 'static
bounds: Size::new(f32::MAX, f32::MAX),
size: iced::Pixels(text_size),
line_height,
font: font.unwrap_or_else(|| crate::font::default()),
font: font.unwrap_or_else(crate::font::default),
horizontal_alignment: alignment::Horizontal::Left,
vertical_alignment: alignment::Vertical::Top,
shaping: text::Shaping::Advanced,
Expand Down
7 changes: 3 additions & 4 deletions src/widget/dropdown/widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use super::menu::{self, Menu};
use crate::widget::icon;
use derive_setters::Setters;
use iced::Radians;
use iced_core::event::{self, Event};
use iced_core::text::{self, Paragraph, Text};
use iced_core::widget::tree::{self, Tree};
Expand Down Expand Up @@ -186,7 +185,7 @@ impl<'a, S: AsRef<str>, Message: 'a> Widget<Message, crate::Theme, crate::Render
cursor: mouse::Cursor,
viewport: &Rectangle,
) {
let font = self.font.unwrap_or_else(|| crate::font::default());
let font = self.font.unwrap_or_else(crate::font::default);
draw(
renderer,
theme,
Expand Down Expand Up @@ -293,7 +292,7 @@ impl Default for State {
/// Computes the layout of a [`Dropdown`].
#[allow(clippy::too_many_arguments)]
pub fn layout(
renderer: &crate::Renderer,
_renderer: &crate::Renderer,
limits: &layout::Limits,
width: Length,
gap: f32,
Expand All @@ -316,7 +315,7 @@ pub fn layout(
bounds: Size::new(f32::MAX, f32::MAX),
size: iced::Pixels(text_size),
line_height: text_line_height,
font: font.unwrap_or_else(|| crate::font::default()),
font: font.unwrap_or_else(crate::font::default),
horizontal_alignment: alignment::Horizontal::Left,
vertical_alignment: alignment::Vertical::Top,
shaping: text::Shaping::Advanced,
Expand Down
Loading
Loading