Skip to content

Commit 4ce2d8d

Browse files
committed
Add descriptions to commands
1 parent d835797 commit 4ce2d8d

File tree

3 files changed

+31
-16
lines changed

3 files changed

+31
-16
lines changed

src/app.rs

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,12 @@ use std::time::Duration;
3030
pub const WINDOW_WIDTH: f32 = 500.;
3131
pub const DEFAULT_WINDOW_HEIGHT: f32 = 65.;
3232

33+
pub const RUSTCAST_DESC_NAME: &str = "RustCast";
34+
3335
#[derive(Debug, Clone)]
3436
pub struct App {
3537
pub open_command: Function,
38+
pub desc: String,
3639
pub icons: Option<iced::widget::image::Handle>,
3740
pub name: String,
3841
pub name_lc: String,
@@ -43,12 +46,14 @@ impl App {
4346
vec![
4447
App {
4548
open_command: Function::Quit,
49+
desc: RUSTCAST_DESC_NAME.to_string(),
4650
icons: None,
4751
name: "Quit RustCast".to_string(),
4852
name_lc: "quit".to_string(),
4953
},
5054
App {
5155
open_command: Function::OpenPrefPane,
56+
desc: RUSTCAST_DESC_NAME.to_string(),
5257
icons: None,
5358
name: "Open RustCast Preferences".to_string(),
5459
name_lc: "settings".to_string(),
@@ -72,26 +77,32 @@ impl App {
7277
}
7378
}
7479

80+
tile = tile.push(
81+
Button::new(
82+
Text::new(&self.name)
83+
.height(Fill)
84+
.width(Fill)
85+
.align_y(Vertical::Center),
86+
)
87+
.on_press(Message::RunFunction(self.open_command.clone()))
88+
.style(|_, _| iced::widget::button::Style {
89+
background: Some(iced::Background::Color(
90+
Theme::KanagawaDragon.palette().background,
91+
)),
92+
text_color: Theme::KanagawaDragon.palette().text,
93+
..Default::default()
94+
})
95+
.width(Fill)
96+
.height(55),
97+
);
98+
7599
tile = tile
76100
.push(
77-
Button::new(
78-
Text::new(self.name.clone())
79-
.height(Fill)
80-
.width(Fill)
81-
.align_y(Vertical::Center),
82-
)
83-
.on_press(Message::RunFunction(self.open_command.clone()))
84-
.style(|_, _| iced::widget::button::Style {
85-
background: Some(iced::Background::Color(
86-
Theme::KanagawaDragon.palette().background,
87-
)),
88-
text_color: Theme::KanagawaDragon.palette().text,
89-
..Default::default()
90-
})
91-
.width(Fill)
92-
.height(55),
101+
container(Text::new(&self.desc))
102+
.padding(15),
93103
)
94104
.width(Fill);
105+
95106
container(tile)
96107
.style(|_| iced::widget::container::Style {
97108
text_color: Some(Theme::KanagawaDragon.palette().text),
@@ -228,6 +239,7 @@ impl Tile {
228239
let rand_num = rand::random_range(0..100);
229240
self.results = vec![App {
230241
open_command: Function::RandomVar(rand_num),
242+
desc: "Easter egg".to_string(),
231243
icons: None,
232244
name: rand_num.to_string(),
233245
name_lc: String::new(),
@@ -243,6 +255,7 @@ impl Tile {
243255
self.results = vec![App {
244256
open_command: Function::GoogleSearch(self.query.clone()),
245257
icons: None,
258+
desc: "Search".to_string(),
246259
name: format!("Search for: {}", self.query),
247260
name_lc: String::new(),
248261
}];

src/config.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ impl Shelly {
144144
self_clone.command,
145145
self_clone.alias_lc.clone(),
146146
),
147+
desc: "Shell Command".to_string(),
147148
icons: icon,
148149
name: self_clone.alias,
149150
name_lc: self_clone.alias_lc,

src/utils.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ pub(crate) fn get_installed_apps(dir: impl AsRef<Path>, store_icons: bool) -> Ve
154154
let name = file_name.strip_suffix(".app").unwrap().to_string();
155155
Some(App {
156156
open_command: Function::OpenApp(path_str),
157+
desc: "Application".to_string(),
157158
icons,
158159
name_lc: name.to_lowercase(),
159160
name,

0 commit comments

Comments
 (0)