Skip to content

Commit 194bba9

Browse files
git-f0xwash2
authored andcommitted
chore: migrate to Rust 2024 edition
1 parent 3c56c83 commit 194bba9

File tree

7 files changed

+68
-69
lines changed

7 files changed

+68
-69
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "cosmic-app-library"
33
version = "0.1.0"
44
authors = ["Ashley Wulber <[email protected]>"]
5-
edition = "2021"
5+
edition = "2024"
66
[features]
77
default = ["wgpu"]
88
wgpu = ["libcosmic/wgpu"]
@@ -21,7 +21,6 @@ libcosmic = { git = "https://github.com/pop-os/libcosmic/", features = [
2121
tokio = { version = "1.45", features = ["sync", "rt", "process"] }
2222
pretty_env_logger = "0.5"
2323
log = "0.4"
24-
once_cell = "1.20"
2524
futures = "0.3.31"
2625
xdg = "2.5.2"
2726
# Application i18n

src/app.rs

Lines changed: 55 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@ use std::{
33
fmt::{Debug, Display},
44
path::{Path, PathBuf},
55
rc::Rc,
6+
sync::{Arc, LazyLock},
67
time::{Duration, Instant},
78
};
89

910
use clap::Parser;
1011
use cosmic::{
12+
Element,
1113
app::{Core, CosmicFlags, Settings, Task},
1214
cctk::sctk::{
1315
self,
@@ -17,9 +19,9 @@ use cosmic::{
1719
cosmic_config::{Config, CosmicConfigEntry},
1820
cosmic_theme::Spacing,
1921
dbus_activation,
20-
desktop::{load_desktop_file, DesktopEntryData},
22+
desktop::{DesktopEntryData, load_desktop_file},
2123
iced::{
22-
self,
24+
self, Alignment, Color, Length, Limits, Size, Subscription,
2325
alignment::Horizontal,
2426
event::{listen_with, wayland::OverlapNotifyEvent},
2527
executor,
@@ -29,23 +31,22 @@ use cosmic::{
2931
},*/
3032
widget::{column, container, horizontal_rule, row, scrollable, text},
3133
window::Event as WindowEvent,
32-
Alignment, Color, Length, Limits, Size, Subscription,
3334
},
3435
iced_core::{
36+
Border, Padding, Rectangle, Shadow,
3537
alignment::Vertical,
36-
keyboard::{key::Named, Key},
38+
keyboard::{Key, key::Named},
3739
widget::operation::{
3840
self,
3941
focusable::{find_focused, focus},
4042
},
41-
Border, Padding, Rectangle, Shadow,
4243
},
4344
iced_runtime::{
4445
self,
4546
core::{
4647
event::{
47-
wayland::{self, LayerEvent},
4848
PlatformSpecific,
49+
wayland::{self, LayerEvent},
4950
},
5051
window::Id as SurfaceId,
5152
},
@@ -66,25 +67,22 @@ use cosmic::{
6667
keyboard_nav, surface,
6768
theme::{self, Button, TextInput},
6869
widget::{
69-
self,
70+
self, Column,
7071
autosize::autosize,
7172
button::{self, Catalog as ButtonStyleSheet},
7273
divider,
7374
dnd_destination::dnd_destination_for_data,
7475
icon::{self, from_name},
7576
search_input, svg,
7677
text::body,
77-
text_input, tooltip, Column,
78+
text_input, tooltip,
7879
},
79-
Element,
8080
};
8181
use cosmic_app_list_config::AppListConfig;
8282
use freedesktop_desktop_entry::PathSource;
8383
use itertools::Itertools;
8484
use log::error;
85-
use once_cell::sync::Lazy;
8685
use serde::{Deserialize, Serialize};
87-
use std::sync::Arc;
8886
use switcheroo_control::Gpu;
8987

9088
use crate::{
@@ -98,34 +96,35 @@ use crate::{
9896
// should be a way to add apps to groups
9997
// should be a way to remove apps from groups
10098

101-
static SEARCH_ID: Lazy<Id> = Lazy::new(|| Id::new("search"));
102-
static EDIT_GROUP_ID: Lazy<Id> = Lazy::new(|| Id::new("edit_group"));
103-
static NEW_GROUP_ID: Lazy<Id> = Lazy::new(|| Id::new("new_group"));
104-
static SUBMIT_DELETE_ID: Lazy<Id> = Lazy::new(|| Id::new("cancel_delete"));
105-
106-
static CREATE_NEW: Lazy<String> = Lazy::new(|| fl!("create-new"));
107-
static ADD_GROUP: Lazy<String> = Lazy::new(|| fl!("add-group"));
108-
static SEARCH_PLACEHOLDER: Lazy<String> = Lazy::new(|| fl!("search-placeholder"));
109-
static NEW_GROUP_PLACEHOLDER: Lazy<String> = Lazy::new(|| fl!("new-group-placeholder"));
110-
static SAVE: Lazy<String> = Lazy::new(|| fl!("save"));
111-
static CANCEL: Lazy<String> = Lazy::new(|| fl!("cancel"));
112-
static RUN: Lazy<String> = Lazy::new(|| fl!("run"));
113-
static REMOVE: Lazy<String> = Lazy::new(|| fl!("remove"));
114-
static FLATPAK: Lazy<String> = Lazy::new(|| fl!("flatpak"));
115-
static LOCAL: Lazy<String> = Lazy::new(|| fl!("local"));
116-
static NIX: Lazy<String> = Lazy::new(|| fl!("nix"));
117-
static SNAP: Lazy<String> = Lazy::new(|| fl!("snap"));
118-
static SYSTEM: Lazy<String> = Lazy::new(|| fl!("system"));
119-
120-
pub(crate) static WINDOW_ID: Lazy<SurfaceId> = Lazy::new(|| SurfaceId::unique());
121-
static NEW_GROUP_WINDOW_ID: Lazy<SurfaceId> = Lazy::new(|| SurfaceId::unique());
122-
static NEW_GROUP_AUTOSIZE_ID: Lazy<cosmic::widget::Id> = Lazy::new(|| cosmic::widget::Id::unique());
123-
static DELETE_GROUP_WINDOW_ID: Lazy<SurfaceId> = Lazy::new(|| SurfaceId::unique());
124-
static DELETE_GROUP_AUTOSIZE_ID: Lazy<cosmic::widget::Id> =
125-
Lazy::new(|| cosmic::widget::Id::unique());
126-
pub(crate) static MENU_ID: Lazy<SurfaceId> = Lazy::new(|| SurfaceId::unique());
127-
pub(crate) static MENU_AUTOSIZE_ID: Lazy<cosmic::widget::Id> =
128-
Lazy::new(|| cosmic::widget::Id::unique());
99+
static SEARCH_ID: LazyLock<Id> = LazyLock::new(|| Id::new("search"));
100+
static EDIT_GROUP_ID: LazyLock<Id> = LazyLock::new(|| Id::new("edit_group"));
101+
static NEW_GROUP_ID: LazyLock<Id> = LazyLock::new(|| Id::new("new_group"));
102+
static SUBMIT_DELETE_ID: LazyLock<Id> = LazyLock::new(|| Id::new("cancel_delete"));
103+
104+
static CREATE_NEW: LazyLock<String> = LazyLock::new(|| fl!("create-new"));
105+
static ADD_GROUP: LazyLock<String> = LazyLock::new(|| fl!("add-group"));
106+
static SEARCH_PLACEHOLDER: LazyLock<String> = LazyLock::new(|| fl!("search-placeholder"));
107+
static NEW_GROUP_PLACEHOLDER: LazyLock<String> = LazyLock::new(|| fl!("new-group-placeholder"));
108+
static SAVE: LazyLock<String> = LazyLock::new(|| fl!("save"));
109+
static CANCEL: LazyLock<String> = LazyLock::new(|| fl!("cancel"));
110+
static RUN: LazyLock<String> = LazyLock::new(|| fl!("run"));
111+
static REMOVE: LazyLock<String> = LazyLock::new(|| fl!("remove"));
112+
static FLATPAK: LazyLock<String> = LazyLock::new(|| fl!("flatpak"));
113+
static LOCAL: LazyLock<String> = LazyLock::new(|| fl!("local"));
114+
static NIX: LazyLock<String> = LazyLock::new(|| fl!("nix"));
115+
static SNAP: LazyLock<String> = LazyLock::new(|| fl!("snap"));
116+
static SYSTEM: LazyLock<String> = LazyLock::new(|| fl!("system"));
117+
118+
pub(crate) static WINDOW_ID: LazyLock<SurfaceId> = LazyLock::new(|| SurfaceId::unique());
119+
static NEW_GROUP_WINDOW_ID: LazyLock<SurfaceId> = LazyLock::new(|| SurfaceId::unique());
120+
static NEW_GROUP_AUTOSIZE_ID: LazyLock<cosmic::widget::Id> =
121+
LazyLock::new(|| cosmic::widget::Id::unique());
122+
static DELETE_GROUP_WINDOW_ID: LazyLock<SurfaceId> = LazyLock::new(|| SurfaceId::unique());
123+
static DELETE_GROUP_AUTOSIZE_ID: LazyLock<cosmic::widget::Id> =
124+
LazyLock::new(|| cosmic::widget::Id::unique());
125+
pub(crate) static MENU_ID: LazyLock<SurfaceId> = LazyLock::new(|| SurfaceId::unique());
126+
pub(crate) static MENU_AUTOSIZE_ID: LazyLock<cosmic::widget::Id> =
127+
LazyLock::new(|| cosmic::widget::Id::unique());
129128

130129
#[derive(Parser, Debug, Serialize, Deserialize, Clone)]
131130
#[command(author, version, about, long_about = None)]
@@ -1037,9 +1036,9 @@ impl cosmic::Application for CosmicAppLibrary {
10371036
_ => {}
10381037
},
10391038
Message::Surface(a) => {
1040-
return cosmic::task::message(cosmic::Action::Cosmic(cosmic::app::Action::Surface(
1041-
a,
1042-
)))
1039+
return cosmic::task::message(cosmic::Action::Cosmic(
1040+
cosmic::app::Action::Surface(a),
1041+
));
10431042
}
10441043
}
10451044
Task::none()
@@ -1325,18 +1324,20 @@ impl cosmic::Application for CosmicAppLibrary {
13251324

13261325
let cur_group = self.config.groups()[self.cur_group];
13271326
let top_row = if self.cur_group == 0 {
1328-
row![container(
1329-
search_input(SEARCH_PLACEHOLDER.as_str(), self.search_value.as_str())
1330-
.on_input(Message::InputChanged)
1331-
.on_paste(Message::InputChanged)
1332-
.on_submit(|_| Message::StartCurAppFocus)
1333-
.style(TextInput::Search)
1334-
.width(Length::Fixed(400.0))
1335-
.size(14)
1336-
.id(SEARCH_ID.clone())
1337-
)
1338-
.align_y(Vertical::Center)
1339-
.height(Length::Fixed(96.0))]
1327+
row![
1328+
container(
1329+
search_input(SEARCH_PLACEHOLDER.as_str(), self.search_value.as_str())
1330+
.on_input(Message::InputChanged)
1331+
.on_paste(Message::InputChanged)
1332+
.on_submit(|_| Message::StartCurAppFocus)
1333+
.style(TextInput::Search)
1334+
.width(Length::Fixed(400.0))
1335+
.size(14)
1336+
.id(SEARCH_ID.clone())
1337+
)
1338+
.align_y(Vertical::Center)
1339+
.height(Length::Fixed(96.0))
1340+
]
13401341
.align_y(Alignment::Center)
13411342
.spacing(space_xxs)
13421343
} else {

src/app_group.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
use std::{sync::Arc, vec};
22

33
use cosmic::{
4-
cosmic_config::{self, cosmic_config_derive::CosmicConfigEntry, CosmicConfigEntry},
4+
cosmic_config::{self, CosmicConfigEntry, cosmic_config_derive::CosmicConfigEntry},
55
desktop::DesktopEntryData,
66
};
7-
use once_cell::sync::Lazy;
87
use serde::{Deserialize, Serialize};
8+
use std::sync::LazyLock;
99

1010
use crate::{config::APP_ID, fl};
1111

12-
static HOME: Lazy<[AppGroup; 1]> = Lazy::new(|| {
12+
static HOME: LazyLock<[AppGroup; 1]> = LazyLock::new(|| {
1313
[AppGroup {
1414
name: "cosmic-library-home".to_string(),
1515
icon: "user-home-symbolic".to_string(),

src/localize.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
// SPDX-License-Identifier: GPL-3.0-only
33

44
use i18n_embed::{
5-
fluent::{fluent_language_loader, FluentLanguageLoader},
65
DefaultLocalizer, LanguageLoader, Localizer,
6+
fluent::{FluentLanguageLoader, fluent_language_loader},
77
};
8-
use once_cell::sync::Lazy;
98
use rust_embed::RustEmbed;
9+
use std::sync::LazyLock;
1010

1111
#[derive(RustEmbed)]
1212
#[folder = "i18n/"]
1313
struct Localizations;
1414

15-
pub static LANGUAGE_LOADER: Lazy<FluentLanguageLoader> = Lazy::new(|| {
15+
pub static LANGUAGE_LOADER: LazyLock<FluentLanguageLoader> = LazyLock::new(|| {
1616
let loader: FluentLanguageLoader = fluent_language_loader!();
1717

1818
loader

src/subscriptions/desktop_files.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use cosmic::{
2-
iced::{stream, Subscription},
2+
iced::{Subscription, stream},
33
iced_futures::futures::{self, SinkExt},
44
};
55
use notify::{Config, EventKind, RecommendedWatcher, RecursiveMode, Watcher};

src/widgets/application.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,26 @@ use std::{borrow::Cow, cell::RefCell, iter, path::PathBuf, str::FromStr};
66
use cosmic::desktop::IconSourceExt;
77
use cosmic::{
88
iced::{
9+
Size, Vector,
910
alignment::Vertical,
1011
clipboard::mime::{AllowedMimeTypes, AsMimeTypes},
11-
Size, Vector,
1212
},
1313
iced_core::alignment::Horizontal,
1414
widget::dnd_source,
1515
};
1616

1717
use cosmic::iced_core::{
18-
event, layout, mouse, overlay, renderer, widget, Alignment, Clipboard, Event, Length,
19-
Rectangle, Shell, Widget,
18+
Alignment, Clipboard, Event, Length, Rectangle, Shell, Widget, event, layout, mouse, overlay,
19+
renderer, widget,
2020
};
2121

2222
use cosmic::{
23+
Element,
2324
desktop::DesktopEntryData,
2425
iced::widget::{column, text},
25-
iced_core::widget::{tree, Operation, Tree},
26+
iced_core::widget::{Operation, Tree, tree},
2627
theme,
2728
widget::{button, container},
28-
Element,
2929
};
3030

3131
use crate::app::AppSource;

0 commit comments

Comments
 (0)