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

Update libcosmic jammy #54

Merged
merged 8 commits into from
Sep 29, 2023
Merged
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
676 changes: 403 additions & 273 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ edition = "2021"

[dependencies]
libcosmic = { git = "https://github.com/pop-os/libcosmic/", default-features = false, features = ["wayland", "tokio"] }
# libcosmic = { path = "../libcosmic", default-features = false, features = ["wayland", "tokio"] }
tokio = { version = "1.17.0", features = ["sync", "rt", "process"] }
pretty_env_logger = "0.5"
log = "0.4"
Expand Down
1 change: 1 addition & 0 deletions debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Build-Depends:
just,
pkg-config,
libxkbcommon-dev,
libwayland-dev,
Standards-Version: 4.3.0
Homepage: https://github.com/pop-os/cosmic-app-library

Expand Down
6 changes: 6 additions & 0 deletions i18n/en/cosmic_app_library.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ cosmic-utilities = Utilities
new-group = Create Folder
name = Name
ok = Ok
save = Save
cancel = Cancel
search-placeholder = Type to search apps...
new-group-placeholder = Folder Name
run = Run
remove = Remove
create-new = Create new folder
delete = Delete
rename = Rename
delete-folder = Delete folder?
.msg = Deleting this folder will move the application icons to Library home.
564 changes: 400 additions & 164 deletions src/app.rs

Large diffs are not rendered by default.

20 changes: 9 additions & 11 deletions src/app_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use itertools::Itertools;
use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize};

use crate::config::APP_ID;
use crate::fl;

static HOME: Lazy<[AppGroup; 1]> = Lazy::new(|| {
Expand Down Expand Up @@ -51,12 +52,7 @@ pub struct AppGroup {
}

impl AppGroup {
pub fn filtered(
&self,
locale: Option<&str>,
input_value: &str,
exceptions: &Vec<Self>,
) -> Vec<DesktopEntryData> {
pub fn filtered(&self, locale: Option<&str>, input_value: &str) -> Vec<DesktopEntryData> {
freedesktop_desktop_entry::Iter::new(freedesktop_desktop_entry::default_paths())
.filter_map(|path| {
std::fs::read_to_string(&path).ok().and_then(|input| {
Expand All @@ -68,9 +64,7 @@ impl AppGroup {
let Some(exec) = de.exec() else {
return None;
};
let mut keep_de = !de.no_display()
&& self.matches(&de)
&& !exceptions.iter().any(|x| x.matches(&de));
let mut keep_de = !de.no_display() && self.matches(&de);
if keep_de && input_value.len() > 0 {
keep_de = name.to_lowercase().contains(&input_value.to_lowercase())
|| de
Expand Down Expand Up @@ -233,6 +227,10 @@ impl AppLibraryConfig {
1
}

pub fn helper() -> Option<cosmic_config::Config> {
cosmic_config::Config::new(APP_ID, Self::version()).ok()
}

pub fn add(&mut self, name: String) {
self.groups.push(AppGroup {
name,
Expand Down Expand Up @@ -302,7 +300,7 @@ impl AppLibraryConfig {
input_value: &str,
) -> Vec<DesktopEntryData> {
if i == 0 {
HOME[0].filtered(locale, input_value, &self.groups)
HOME[0].filtered(locale, input_value)
} else {
self._filtered(i - 1, locale, input_value)
}
Expand All @@ -316,7 +314,7 @@ impl AppLibraryConfig {
) -> Vec<DesktopEntryData> {
self.groups
.get(i)
.map(|g| g.filtered(locale, input_value, &Vec::new()))
.map(|g| g.filtered(locale, input_value))
.unwrap_or_default()
}
}
Expand Down
15 changes: 9 additions & 6 deletions src/widgets/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use std::mem;
use std::path::PathBuf;

use cosmic::cosmic_theme::Spacing;
use cosmic::iced::wayland::actions::data_device::{DataFromMimeType, DndIcon};
use cosmic::iced_core::alignment::Horizontal;
use cosmic::iced_core::event::{wayland, PlatformSpecific};
Expand All @@ -15,13 +16,14 @@ use cosmic::iced_core::{
};

use cosmic::iced_core::widget::{operation::OperationOutputWrapper, tree, Operation, Tree};
use cosmic::widget::icon::from_path;
use cosmic::{
iced::{
self,
widget::{column, text},
},
theme,
widget::icon,
widget::{button, icon},
};

use crate::app::{DND_ICON_ID, WINDOW_ID};
Expand Down Expand Up @@ -73,15 +75,16 @@ impl<'a, Message: Clone + 'static> ApplicationButton<'a, Message> {
ignore_button: Message,
on_right_release: impl Fn(Rectangle) -> Message + 'a,
on_pressed: Option<Message>,
spacing: &Spacing,
) -> Self {
let name = if name.len() > 27 {
format!("{:.24}...", name)
} else {
name.to_string()
};
let content = iced::widget::button(
let content = button(
column![
icon(image.as_path(), 72)
icon(from_path(image.clone()))
.width(Length::Fixed(72.0))
.height(Length::Fixed(72.0)),
text(name)
Expand All @@ -91,13 +94,13 @@ impl<'a, Message: Clone + 'static> ApplicationButton<'a, Message> {
]
.width(Length::Fixed(120.0))
.height(Length::Fixed(120.0))
.spacing(8)
.spacing(spacing.space_xxs)
.align_items(Alignment::Center)
.width(Length::Fill),
)
.width(Length::FillPortion(1))
.style(theme::Button::Text)
.padding(16);
.style(theme::Button::IconVertical)
.padding(spacing.space_s);
let content = if on_pressed.is_some() {
content.on_press(ignore_button.clone())
} else {
Expand Down
35 changes: 22 additions & 13 deletions src/widgets/group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@ use std::mem;

use std::str::FromStr;

use cosmic::cosmic_theme::Spacing;
use cosmic::iced_core::alignment::Horizontal;
use cosmic::iced_core::event::{wayland, PlatformSpecific};
use cosmic::iced_runtime::command::platform_specific;
use cosmic::iced_widget::graphics::image::image_rs::EncodableLayout;
use cosmic::sctk::reexports::client::protocol::wl_data_device_manager::DndAction;

use cosmic::iced_core::{
event, layout, mouse, overlay, renderer, Alignment, Clipboard, Element, Event, Length, Point,
Rectangle, Shell, Widget,
event, layout, mouse, overlay, renderer, Alignment, Clipboard, Element, Event, Length, Padding,
Point, Rectangle, Shell, Widget,
};

use cosmic::iced_core::widget::{operation::OperationOutputWrapper, tree, Operation, Tree};
use cosmic::widget::container;
use cosmic::widget::icon::from_name;
use cosmic::{
iced::{
self,
widget::{column, text},
},
iced::widget::{column, text},
theme,
widget::icon,
widget::{button, icon},
};

use crate::app_group::DesktopEntryData;
Expand Down Expand Up @@ -62,20 +62,29 @@ impl<'a, Message: Clone + 'static> GroupButton<'a, Message> {
icon_name: &'a str,
on_pressed: Option<Message>,
style: theme::Button,
icon_size: f32,
padding: impl Into<Padding>,
width: f32,
height: f32,
spacing: &Spacing,
) -> Self {
let content = iced::widget::button(
let content = button(
column![
icon(icon_name, 32),
container(
icon(from_name(icon_name).into())
.width(Length::Fixed(icon_size))
.height(Length::Fixed(icon_size))
)
.padding(spacing.space_xxs),
text(name).horizontal_alignment(Horizontal::Center)
]
.spacing(8)
.align_items(Alignment::Center)
.width(Length::Fill),
)
.height(Length::Fill)
.width(Length::Fixed(128.0))
.height(Length::Fixed(height))
.width(Length::Fixed(width))
.style(style)
.padding([16, 8]);
.padding(padding);

let content = if let Some(on_pressed) = on_pressed {
content.on_press(on_pressed)
Expand Down
Loading