Add context menu to text fields and Selectable Text widget (#1815)

- Adds context menu to text input fields
- Adds selectable text to context drawer, but only to file name,
created/modified/accessed date. I'm sure more places could use the
selectable text.
- Also pulls the latest changes in Iced and libcosmic that removes
"redraw on any message", which means moving the cursor doesn't
automatically call a redraw, widgets need to ask for it. I have found
all places that previously was working normally because we were
redrawing almost unconditionally. But it is possible that a custom
widget somewhere still isn't asking for a redraw explicitly when its
state changes. So, for QA I'd keep an eye on that.

Depends on:
- [x] https://github.com/pop-os/libcosmic/pull/1288
- [x] https://github.com/pop-os/iced/pull/378
- [x] https://github.com/pop-os/libcosmic/pull/1384
- [x] https://github.com/pop-os/libcosmic/pull/1388


https://github.com/user-attachments/assets/caf8f940-0793-4665-844a-b6153b35d7bb



___
- [x] I have disclosed use of any AI generated code in my commit
messages.
- If you are using an LLM, and do not fully understand the changes it is
making to the code base, do not create a PR.
- In our experience, AI generated code often results in overly complex
code that lacks enough context for a proper fix or feature inclusion.
This results in considerably longer code reviews. Due to this, AI
authored or partially authored PRs may be closed without comment.
- [x] I understand these changes in full and will be able to respond to
review comments.
- [x] My change is accurately described in the commit message.
- [x] My contribution is tested and working as described.
- [x] I have read the [Developer Certificate of
Origin](https://developercertificate.org/) and certify my contribution
under its conditions.
This commit is contained in:
Jeremy Soller 2026-08-18 07:22:09 -06:00 • committed by GitHub
commit 6e210a3753
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 31 additions and 31 deletions

40
Cargo.lock generated
View file

@ -826,7 +826,7 @@ dependencies = [
[[package]] [[package]]
name = "build_helpers" name = "build_helpers"
version = "0.14.0" version = "0.14.0"
source = "git+https://github.com/pop-os/libcosmic.git#0ca1b784c931c946517379795ce87328c6a902b8" source = "git+https://github.com/pop-os/libcosmic.git#1f8d8786940cc6db59d412153c5a03f69a20375c"
dependencies = [ dependencies = [
"cfg_aliases", "cfg_aliases",
] ]
@ -1359,7 +1359,7 @@ dependencies = [
[[package]] [[package]]
name = "cosmic-config" name = "cosmic-config"
version = "1.0.0" version = "1.0.0"
source = "git+https://github.com/pop-os/libcosmic.git#0ca1b784c931c946517379795ce87328c6a902b8" source = "git+https://github.com/pop-os/libcosmic.git#1f8d8786940cc6db59d412153c5a03f69a20375c"
dependencies = [ dependencies = [
"atomicwrites", "atomicwrites",
"cosmic-config-derive", "cosmic-config-derive",
@ -1380,7 +1380,7 @@ dependencies = [
[[package]] [[package]]
name = "cosmic-config-derive" name = "cosmic-config-derive"
version = "1.0.0" version = "1.0.0"
source = "git+https://github.com/pop-os/libcosmic.git#0ca1b784c931c946517379795ce87328c6a902b8" source = "git+https://github.com/pop-os/libcosmic.git#1f8d8786940cc6db59d412153c5a03f69a20375c"
dependencies = [ dependencies = [
"quote", "quote",
"syn 2.0.119", "syn 2.0.119",
@ -1551,7 +1551,7 @@ dependencies = [
[[package]] [[package]]
name = "cosmic-theme" name = "cosmic-theme"
version = "1.0.0" version = "1.0.0"
source = "git+https://github.com/pop-os/libcosmic.git#0ca1b784c931c946517379795ce87328c6a902b8" source = "git+https://github.com/pop-os/libcosmic.git#1f8d8786940cc6db59d412153c5a03f69a20375c"
dependencies = [ dependencies = [
"almost", "almost",
"configparser", "configparser",
@ -2871,7 +2871,7 @@ dependencies = [
"log", "log",
"presser", "presser",
"thiserror 2.0.19", "thiserror 2.0.19",
"windows 0.62.2", "windows 0.56.0",
] ]
[[package]] [[package]]
@ -3105,7 +3105,7 @@ dependencies = [
"js-sys", "js-sys",
"log", "log",
"wasm-bindgen", "wasm-bindgen",
"windows-core 0.62.2", "windows-core 0.56.0",
] ]
[[package]] [[package]]
@ -3120,7 +3120,7 @@ dependencies = [
[[package]] [[package]]
name = "iced" name = "iced"
version = "0.14.0" version = "0.14.0"
source = "git+https://github.com/pop-os/libcosmic.git#0ca1b784c931c946517379795ce87328c6a902b8" source = "git+https://github.com/pop-os/libcosmic.git#1f8d8786940cc6db59d412153c5a03f69a20375c"
dependencies = [ dependencies = [
"build_helpers", "build_helpers",
"dnd", "dnd",
@ -3142,7 +3142,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_accessibility" name = "iced_accessibility"
version = "0.1.0" version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic.git#0ca1b784c931c946517379795ce87328c6a902b8" source = "git+https://github.com/pop-os/libcosmic.git#1f8d8786940cc6db59d412153c5a03f69a20375c"
dependencies = [ dependencies = [
"accesskit", "accesskit",
"accesskit_winit", "accesskit_winit",
@ -3151,7 +3151,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_core" name = "iced_core"
version = "0.14.0" version = "0.14.0"
source = "git+https://github.com/pop-os/libcosmic.git#0ca1b784c931c946517379795ce87328c6a902b8" source = "git+https://github.com/pop-os/libcosmic.git#1f8d8786940cc6db59d412153c5a03f69a20375c"
dependencies = [ dependencies = [
"bitflags 2.13.1", "bitflags 2.13.1",
"build_helpers", "build_helpers",
@ -3177,7 +3177,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_debug" name = "iced_debug"
version = "0.14.0" version = "0.14.0"
source = "git+https://github.com/pop-os/libcosmic.git#0ca1b784c931c946517379795ce87328c6a902b8" source = "git+https://github.com/pop-os/libcosmic.git#1f8d8786940cc6db59d412153c5a03f69a20375c"
dependencies = [ dependencies = [
"iced_core", "iced_core",
"iced_futures", "iced_futures",
@ -3187,7 +3187,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_futures" name = "iced_futures"
version = "0.14.0" version = "0.14.0"
source = "git+https://github.com/pop-os/libcosmic.git#0ca1b784c931c946517379795ce87328c6a902b8" source = "git+https://github.com/pop-os/libcosmic.git#1f8d8786940cc6db59d412153c5a03f69a20375c"
dependencies = [ dependencies = [
"futures", "futures",
"iced_core", "iced_core",
@ -3201,7 +3201,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_graphics" name = "iced_graphics"
version = "0.14.0" version = "0.14.0"
source = "git+https://github.com/pop-os/libcosmic.git#0ca1b784c931c946517379795ce87328c6a902b8" source = "git+https://github.com/pop-os/libcosmic.git#1f8d8786940cc6db59d412153c5a03f69a20375c"
dependencies = [ dependencies = [
"bitflags 2.13.1", "bitflags 2.13.1",
"bytemuck", "bytemuck",
@ -3222,7 +3222,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_program" name = "iced_program"
version = "0.14.0" version = "0.14.0"
source = "git+https://github.com/pop-os/libcosmic.git#0ca1b784c931c946517379795ce87328c6a902b8" source = "git+https://github.com/pop-os/libcosmic.git#1f8d8786940cc6db59d412153c5a03f69a20375c"
dependencies = [ dependencies = [
"iced_graphics", "iced_graphics",
"iced_runtime", "iced_runtime",
@ -3231,7 +3231,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_renderer" name = "iced_renderer"
version = "0.14.0" version = "0.14.0"
source = "git+https://github.com/pop-os/libcosmic.git#0ca1b784c931c946517379795ce87328c6a902b8" source = "git+https://github.com/pop-os/libcosmic.git#1f8d8786940cc6db59d412153c5a03f69a20375c"
dependencies = [ dependencies = [
"iced_graphics", "iced_graphics",
"iced_tiny_skia", "iced_tiny_skia",
@ -3243,7 +3243,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_runtime" name = "iced_runtime"
version = "0.14.0" version = "0.14.0"
source = "git+https://github.com/pop-os/libcosmic.git#0ca1b784c931c946517379795ce87328c6a902b8" source = "git+https://github.com/pop-os/libcosmic.git#1f8d8786940cc6db59d412153c5a03f69a20375c"
dependencies = [ dependencies = [
"build_helpers", "build_helpers",
"bytes", "bytes",
@ -3259,7 +3259,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_tiny_skia" name = "iced_tiny_skia"
version = "0.14.0" version = "0.14.0"
source = "git+https://github.com/pop-os/libcosmic.git#0ca1b784c931c946517379795ce87328c6a902b8" source = "git+https://github.com/pop-os/libcosmic.git#1f8d8786940cc6db59d412153c5a03f69a20375c"
dependencies = [ dependencies = [
"bytemuck", "bytemuck",
"cosmic-text", "cosmic-text",
@ -3276,7 +3276,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_wgpu" name = "iced_wgpu"
version = "0.14.0" version = "0.14.0"
source = "git+https://github.com/pop-os/libcosmic.git#0ca1b784c931c946517379795ce87328c6a902b8" source = "git+https://github.com/pop-os/libcosmic.git#1f8d8786940cc6db59d412153c5a03f69a20375c"
dependencies = [ dependencies = [
"as-raw-xcb-connection", "as-raw-xcb-connection",
"bitflags 2.13.1", "bitflags 2.13.1",
@ -3308,7 +3308,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_widget" name = "iced_widget"
version = "0.14.2" version = "0.14.2"
source = "git+https://github.com/pop-os/libcosmic.git#0ca1b784c931c946517379795ce87328c6a902b8" source = "git+https://github.com/pop-os/libcosmic.git#1f8d8786940cc6db59d412153c5a03f69a20375c"
dependencies = [ dependencies = [
"build_helpers", "build_helpers",
"cosmic-client-toolkit", "cosmic-client-toolkit",
@ -3327,7 +3327,7 @@ dependencies = [
[[package]] [[package]]
name = "iced_winit" name = "iced_winit"
version = "0.14.0" version = "0.14.0"
source = "git+https://github.com/pop-os/libcosmic.git#0ca1b784c931c946517379795ce87328c6a902b8" source = "git+https://github.com/pop-os/libcosmic.git#1f8d8786940cc6db59d412153c5a03f69a20375c"
dependencies = [ dependencies = [
"build_helpers", "build_helpers",
"cosmic-client-toolkit", "cosmic-client-toolkit",
@ -4449,7 +4449,7 @@ checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2"
[[package]] [[package]]
name = "libcosmic" name = "libcosmic"
version = "1.0.0" version = "1.0.0"
source = "git+https://github.com/pop-os/libcosmic.git#0ca1b784c931c946517379795ce87328c6a902b8" source = "git+https://github.com/pop-os/libcosmic.git#1f8d8786940cc6db59d412153c5a03f69a20375c"
dependencies = [ dependencies = [
"apply", "apply",
"ashpd 0.12.3", "ashpd 0.12.3",

View file

@ -2386,10 +2386,8 @@ impl Item {
widget::image(handle.clone()).into() widget::image(handle.clone()).into()
} }
ItemThumbnail::Svg(handle) => widget::svg(handle.clone()).into(), ItemThumbnail::Svg(handle) => widget::svg(handle.clone()).into(),
ItemThumbnail::Text(content) => widget::text_editor(content) ItemThumbnail::Text(content) => widget::text_editor::text_editor(content)
.class(cosmic::theme::iced::TextEditor::Custom(Box::new( .style(text_editor_class)
text_editor_class,
)))
.width(THUMBNAIL_SIZE as f32) .width(THUMBNAIL_SIZE as f32)
.height(Length::Fixed(THUMBNAIL_SIZE as f32)) .height(Length::Fixed(THUMBNAIL_SIZE as f32))
.padding(spacing.space_xxs) .padding(spacing.space_xxs)
@ -2440,7 +2438,7 @@ impl Item {
); );
let mut details = widget::column::with_capacity(8).spacing(space_xxxs); let mut details = widget::column::with_capacity(8).spacing(space_xxxs);
details = details.push(widget::text::heading(self.name.clone())); details = details.push(widget::selectable_text::heading(self.name.clone()));
details = details.push(widget::text::body(fl!( details = details.push(widget::text::body(fl!(
"type", "type",
mime = self.mime.to_string() mime = self.mime.to_string()
@ -2497,21 +2495,21 @@ impl Item {
let time_formatter = time_formatter(military_time); let time_formatter = time_formatter(military_time);
if let Ok(time) = metadata.created() { if let Ok(time) = metadata.created() {
details = details.push(widget::text::body(fl!( details = details.push(widget::selectable_text::body(fl!(
"item-created", "item-created",
created = format_time(time, &date_time_formatter, &time_formatter).to_string() created = format_time(time, &date_time_formatter, &time_formatter).to_string()
))); )));
} }
if let Ok(time) = metadata.modified() { if let Ok(time) = metadata.modified() {
details = details.push(widget::text::body(fl!( details = details.push(widget::selectable_text::body(fl!(
"item-modified", "item-modified",
modified = format_time(time, &date_time_formatter, &time_formatter).to_string() modified = format_time(time, &date_time_formatter, &time_formatter).to_string()
))); )));
} }
if let Ok(time) = metadata.accessed() { if let Ok(time) = metadata.accessed() {
details = details.push(widget::text::body(fl!( details = details.push(widget::selectable_text::body(fl!(
"item-accessed", "item-accessed",
accessed = format_time(time, &date_time_formatter, &time_formatter).to_string() accessed = format_time(time, &date_time_formatter, &time_formatter).to_string()
))); )));
@ -5178,9 +5176,11 @@ impl Tab {
} }
ItemThumbnail::Text(text) => { ItemThumbnail::Text(text) => {
element_opt = Some( element_opt = Some(
widget::container(widget::text_editor(text).padding(space_xxs).class( widget::container(
cosmic::theme::iced::TextEditor::Custom(Box::new(text_editor_class)), widget::text_editor::text_editor(text)
)) .padding(space_xxs)
.style(text_editor_class),
)
.center(Length::Fill) .center(Length::Fill)
.into(), .into(),
); );