Skip to content

Commit

Permalink
update libcosmic
Browse files Browse the repository at this point in the history
  • Loading branch information
wiiznokes committed Nov 27, 2024
1 parent 9f1f140 commit 05dcab7
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 43 deletions.
36 changes: 21 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ derive_more = { version = "1", default-features = false, features = [
] }
# strum = { version = "0.25", features = ["derive"] }

# [patch."https://github.com/pop-os/libcosmic"]
# libcosmic = { path = "../libcosmic" }
[patch."https://github.com/pop-os/libcosmic"]
libcosmic = { path = "../libcosmic" }
# libcosmic = { git = "https://github.com/wiiznokes/libcosmic", rev = "2dff73b8b2871afca6c65c861954c196818f960f" }
# libcosmic = { git = "https://github.com/edfloreshz-ext/libcosmic" }

Expand Down
2 changes: 1 addition & 1 deletion ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ features = [
"multi-window",
"single-instance",
"markdown",
"desktop"
"about"
# todo: re enable when it works on Flatpak
# "dbus-config",
#"a11y",
Expand Down
5 changes: 5 additions & 0 deletions ui/src/settings_drawer.rs → ui/src/drawer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ use crate::{
message::{AppMsg, SettingsMsg, ToogleMsg},
};

pub enum Drawer {
Settings,
About,
}

pub fn settings_drawer(dir_manager: &DirManager) -> Element<'_, AppMsg> {
widget::settings::view_column(vec![widget::settings::section()
.add(
Expand Down
66 changes: 42 additions & 24 deletions ui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,20 @@ use data::{
AppState,
};
use dialogs::Dialog;
use drawer::{about, Drawer};
use graph::GraphWindow;
use hardware::{HardwareBridge, Mode};
use item::items_view;
use message::{ConfigMsg, ModifNodeMsg, SettingsMsg, ToogleMsg};
use node_cache::{NodeC, NodesC};

use crate::{graph::graph_window_view, settings_drawer::settings_drawer};
use crate::{drawer::settings_drawer, graph::graph_window_view};

use cosmic::{
app::{Core, CosmicFlags, Task},
app::{
context_drawer::{context_drawer, ContextDrawer},
Core, CosmicFlags, Task,
},
executor,
iced::{self, time, window},
iced_core::Length,
Expand All @@ -42,6 +46,7 @@ pub mod localize;

mod add_node;
mod dialogs;
mod drawer;
mod graph;
mod headers;
mod icon;
Expand All @@ -51,7 +56,6 @@ mod message;
mod my_widgets;
mod node_cache;
mod pick_list_utils;
mod settings_drawer;

impl<H: HardwareBridge> CosmicFlags for Flags<H> {
type SubCommand = String;
Expand Down Expand Up @@ -86,7 +90,7 @@ struct Ui<H: HardwareBridge> {
graph_window: Option<GraphWindow>,
toasts: Toasts<AppMsg>,
dialog: Option<Dialog>,
about: bool,
drawer: Option<Drawer>,
}

impl<H: HardwareBridge + 'static> cosmic::Application for Ui<H> {
Expand Down Expand Up @@ -132,7 +136,7 @@ impl<H: HardwareBridge + 'static> cosmic::Application for Ui<H> {
graph_window: None,
toasts: Toasts::new(AppMsg::RemoveToast),
dialog,
about: false,
drawer: None,
};

let commands = Task::batch([cosmic::app::command::message(cosmic::app::message::app(
Expand Down Expand Up @@ -368,11 +372,22 @@ impl<H: HardwareBridge + 'static> cosmic::Application for Ui<H> {
}
AppMsg::Toggle(ui_msg) => match ui_msg {
ToogleMsg::CreateButton(expanded) => self.create_button_expanded = expanded,
ToogleMsg::Settings => {
self.core.window.show_context = !self.core.window.show_context;
self.about = false;
self.set_context_title(fl!("settings"));
}
ToogleMsg::Settings => match &self.drawer {
Some(drawer) => match drawer {
Drawer::Settings => {
self.drawer = None;
self.set_show_context(false);
}
Drawer::About => {
self.drawer = Some(Drawer::Settings);
self.set_show_context(true);
}
},
None => {
self.drawer = Some(Drawer::Settings);
self.set_show_context(true);
}
},
ToogleMsg::ChooseConfig(expanded) => {
self.choose_config_expanded = expanded;
}
Expand All @@ -381,9 +396,12 @@ impl<H: HardwareBridge + 'static> cosmic::Application for Ui<H> {
node_c.context_menu_expanded = expanded;
}
ToogleMsg::About => {
self.set_context_title(fl!("about"));
self.core.window.show_context = true;
self.about = true;
self.drawer = Some(Drawer::About);
self.set_show_context(true)
}
ToogleMsg::CloseDrawer => {
self.set_show_context(false);
self.drawer = None;
}
},
AppMsg::Config(config_msg) => match config_msg {
Expand Down Expand Up @@ -589,17 +607,17 @@ impl<H: HardwareBridge + 'static> cosmic::Application for Ui<H> {
headers::header_end()
}

fn context_drawer(&self) -> Option<Element<Self::Message>> {
if self.core.window.show_context {
let drawer = if self.about {
settings_drawer::about()
} else {
settings_drawer(&self.app_state.dir_manager)
};
Some(drawer)
} else {
None
}
fn context_drawer(&self) -> Option<ContextDrawer<Self::Message>> {
self.drawer.as_ref().map(|drawer| match drawer {
Drawer::Settings => context_drawer(
settings_drawer(&self.app_state.dir_manager),
AppMsg::Toggle(ToogleMsg::CloseDrawer),
)
.title(fl!("settings")),
Drawer::About => {
context_drawer(about(), AppMsg::Toggle(ToogleMsg::CloseDrawer)).title(fl!("about"))
}
})
}

fn subscription(&self) -> iced::Subscription<Self::Message> {
Expand Down
3 changes: 2 additions & 1 deletion ui/src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,11 @@ pub enum SettingsMsg {
#[derive(Debug, Clone)]
pub enum ToogleMsg {
CreateButton(bool),
Settings,
ChooseConfig(bool),
NodeContextMenu(Id, bool),
Settings,
About,
CloseDrawer,
}

#[derive(Debug, Clone)]
Expand Down

0 comments on commit 05dcab7

Please sign in to comment.