Skip to content

Commit 163c0ca

Browse files
git-f0xwash2
authored andcommitted
chore: padding fixes
Also makes the Type to search text translatable.
1 parent 0a3e3f4 commit 163c0ca

File tree

7 files changed

+59
-67
lines changed

7 files changed

+59
-67
lines changed

i18n/en/cosmic_launcher.ftl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
app-name = Cosmic Launcher
2+
type-to-search = Type to search apps or type “?” for more options...

po/LINGUAS

Whitespace-only changes.

po/POTFILES.in

Lines changed: 0 additions & 3 deletions
This file was deleted.

po/meson.build

Lines changed: 0 additions & 1 deletion
This file was deleted.

rust-toolchain

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/app.rs

Lines changed: 55 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,49 @@
1-
use crate::app::iced::event::listen_raw;
2-
use crate::components;
3-
use crate::subscriptions::launcher;
1+
use crate::{app::iced::event::listen_raw, components, fl, subscriptions::launcher};
42
use clap::Parser;
5-
use cosmic::app::{command, Command, Core, CosmicFlags, DbusActivationDetails, Settings};
6-
use cosmic::cctk::sctk;
7-
use cosmic::iced::alignment::{Horizontal, Vertical};
8-
use cosmic::iced::event::Status;
9-
use cosmic::iced::id::Id;
10-
use cosmic::iced::wayland::actions::layer_surface::SctkLayerSurfaceSettings;
11-
use cosmic::iced::wayland::actions::popup::{SctkPopupSettings, SctkPositioner};
12-
use cosmic::iced::wayland::layer_surface::{
13-
destroy_layer_surface, get_layer_surface, Anchor, KeyboardInteractivity,
14-
};
15-
use cosmic::iced::widget::{column, container, Column};
16-
use cosmic::iced::{self, Length, Subscription};
17-
use cosmic::iced_core::keyboard::key::Named;
18-
use cosmic::iced_core::{Border, Padding, Point, Rectangle, Shadow};
19-
use cosmic::iced_runtime::core::event::wayland::LayerEvent;
20-
use cosmic::iced_runtime::core::event::{wayland, PlatformSpecific};
21-
use cosmic::iced_runtime::core::layout::Limits;
22-
use cosmic::iced_runtime::core::window::Id as SurfaceId;
23-
use cosmic::iced_sctk::commands;
24-
use cosmic::iced_sctk::commands::activation::request_token;
25-
use cosmic::iced_style::{application, container::Appearance as ContainerAppearance};
26-
use cosmic::iced_widget::row;
27-
use cosmic::theme::{self, Button, Container};
28-
use cosmic::widget::icon::{from_name, IconFallback};
29-
use cosmic::widget::{
30-
button, divider, horizontal_space, icon, mouse_area, scrollable, text,
31-
text_input::{self, StyleSheet as TextInputStyleSheet},
3+
use cosmic::{
4+
app::{command, Command, Core, CosmicFlags, DbusActivationDetails, Settings},
5+
cctk::sctk,
6+
iced::{
7+
self,
8+
alignment::{Horizontal, Vertical},
9+
event::Status,
10+
id::Id,
11+
wayland::{
12+
actions::{
13+
layer_surface::SctkLayerSurfaceSettings,
14+
popup::{SctkPopupSettings, SctkPositioner},
15+
},
16+
layer_surface::{
17+
destroy_layer_surface, get_layer_surface, Anchor, KeyboardInteractivity,
18+
},
19+
},
20+
widget::{column, container, Column},
21+
Length, Subscription,
22+
},
23+
iced_core::{keyboard::key::Named, Border, Padding, Point, Rectangle, Shadow},
24+
iced_runtime::core::{
25+
event::{wayland, wayland::LayerEvent, PlatformSpecific},
26+
layout::Limits,
27+
window::Id as SurfaceId,
28+
},
29+
iced_sctk::{commands, commands::activation::request_token},
30+
iced_style::{application, container::Appearance as ContainerAppearance},
31+
iced_widget::row,
32+
keyboard_nav,
33+
theme::{self, Button, Container},
34+
widget::{
35+
button, divider, horizontal_space, icon,
36+
icon::{from_name, IconFallback},
37+
mouse_area, scrollable, text,
38+
text_input::{self, StyleSheet as TextInputStyleSheet},
39+
},
40+
Element, Theme,
3241
};
33-
use cosmic::{keyboard_nav, Element, Theme};
34-
use iced::keyboard::Key;
35-
use iced::widget::vertical_space;
36-
use iced::{Alignment, Color};
42+
use iced::{keyboard::Key, widget::vertical_space, Alignment, Color};
3743
use once_cell::sync::Lazy;
3844
use pop_launcher::{ContextOption, GpuPreference, IconSource, SearchResult};
3945
use serde::{Deserialize, Serialize};
40-
use std::collections::HashMap;
41-
use std::rc::Rc;
42-
use std::str::FromStr;
43-
use std::time::Instant;
46+
use std::{collections::HashMap, rc::Rc, str::FromStr, time::Instant};
4447
use tokio::sync::mpsc;
4548
use unicode_truncate::UnicodeTruncateStr;
4649
use unicode_width::UnicodeWidthStr;
@@ -577,22 +580,19 @@ impl cosmic::Application for CosmicLauncher {
577580
#[allow(clippy::too_many_lines)]
578581
fn view_window(&self, id: SurfaceId) -> Element<Self::Message> {
579582
if id == *WINDOW_ID {
580-
let launcher_entry = text_input::search_input(
581-
"Type to search apps or type “?” for more options...",
582-
&self.input_value,
583-
)
584-
.on_input(Message::InputChanged)
585-
.on_paste(Message::InputChanged)
586-
.on_submit(Message::Activate(None))
587-
.style(cosmic::theme::TextInput::Custom {
588-
active: Box::new(|theme| theme.focused(&cosmic::theme::TextInput::Search)),
589-
error: Box::new(|theme| theme.focused(&cosmic::theme::TextInput::Search)),
590-
hovered: Box::new(|theme| theme.focused(&cosmic::theme::TextInput::Search)),
591-
focused: Box::new(|theme| theme.focused(&cosmic::theme::TextInput::Search)),
592-
disabled: Box::new(|theme| theme.disabled(&cosmic::theme::TextInput::Search)),
593-
})
594-
.id(INPUT_ID.clone())
595-
.always_active();
583+
let launcher_entry = text_input::search_input(fl!("type-to-search"), &self.input_value)
584+
.on_input(Message::InputChanged)
585+
.on_paste(Message::InputChanged)
586+
.on_submit(Message::Activate(None))
587+
.style(cosmic::theme::TextInput::Custom {
588+
active: Box::new(|theme| theme.focused(&cosmic::theme::TextInput::Search)),
589+
error: Box::new(|theme| theme.focused(&cosmic::theme::TextInput::Search)),
590+
hovered: Box::new(|theme| theme.focused(&cosmic::theme::TextInput::Search)),
591+
focused: Box::new(|theme| theme.focused(&cosmic::theme::TextInput::Search)),
592+
disabled: Box::new(|theme| theme.disabled(&cosmic::theme::TextInput::Search)),
593+
})
594+
.id(INPUT_ID.clone())
595+
.always_active();
596596

597597
let buttons: Vec<_> = self
598598
.launcher_items
@@ -695,7 +695,6 @@ impl cosmic::Application for CosmicLauncher {
695695
.center_y()
696696
.align_y(Vertical::Center)
697697
.align_x(Horizontal::Right)
698-
.padding([8, 16])
699698
.into(),
700699
);
701700
let is_focused = i == self.focused;
@@ -708,7 +707,7 @@ impl cosmic::Application for CosmicLauncher {
708707
.id(RESULT_IDS[i].clone())
709708
.width(Length::Fill)
710709
.on_press(Message::Activate(Some(i)))
711-
.padding([8, 16])
710+
.padding([8, 24])
712711
.style(Button::Custom {
713712
active: Box::new(move |focused, theme| {
714713
let focused = is_focused || focused;

src/components/list.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,10 @@
44

55
use cosmic::iced_renderer::core::widget::OperationOutputWrapper;
66

7-
use cosmic::iced_core::event::{self, Event};
8-
use cosmic::iced_core::layout;
9-
use cosmic::iced_core::mouse;
10-
use cosmic::iced_core::overlay;
11-
use cosmic::iced_core::renderer;
12-
use cosmic::iced_core::widget::{Operation, Tree};
137
use cosmic::iced_core::{
8+
event::{self, Event},
9+
layout, mouse, overlay, renderer,
10+
widget::{Operation, Tree},
1411
Alignment, Clipboard, Element, Layout, Length, Padding, Pixels, Rectangle, Shell, Size, Widget,
1512
};
1613

0 commit comments

Comments
 (0)