Skip to content

Commit

Permalink
remove: multi-window feature
Browse files Browse the repository at this point in the history
  • Loading branch information
edfloreshz committed Nov 20, 2024
1 parent 982fc08 commit 55dad06
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 30 deletions.
12 changes: 0 additions & 12 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ tokio = { version = "1.37.0", features = ["full"] }
[dependencies.libcosmic]
git = "https://github.com/pop-os/libcosmic.git"
default-features = false
features = ["dbus-config", "tokio", "winit", "wgpu", "multi-window", "about"]
features = ["tokio", "winit", "wgpu", "about"]

[dependencies.i18n-embed]
version = "0.14"
Expand Down
18 changes: 9 additions & 9 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,9 @@
use std::any::TypeId;
use std::collections::HashMap;

use crate::calculation::Calculation;
use crate::config;
use crate::config::CONFIG_VERSION;
use crate::app::{calculation::Calculation, config::CONFIG_VERSION, operator::Operator};
use crate::core::{icons, key_binds::key_binds};
use crate::fl;
use crate::operator::Operator;
use cosmic::app::context_drawer;
use cosmic::app::{self, Core, Message as CosmicMessage, Task};
use cosmic::cosmic_config::Update;
Expand All @@ -24,6 +21,11 @@ use cosmic::widget::menu::{Action, ItemHeight, ItemWidth};
use cosmic::widget::{self, menu, nav_bar, ToastId};
use cosmic::{cosmic_config, cosmic_theme, theme, Application, ApplicationExt, Element};

mod calculation;
mod config;
mod operator;
pub mod settings;

pub struct Calculator {
core: Core,
about: About,
Expand Down Expand Up @@ -171,9 +173,7 @@ impl Application for Calculator {

let mut tasks = vec![];

if let Some(id) = app.core.main_window_id() {
tasks.push(app.set_window_title(fl!("app-title"), id));
}
tasks.push(app.set_window_title(fl!("app-title")));

(app, Task::batch(tasks))
}
Expand Down Expand Up @@ -411,7 +411,7 @@ impl Application for Calculator {
Message::Number(num) => self.calculation.on_number_press(num),
Message::Input(input) => self.calculation.on_input(input),
Message::Operator(operator) => match self.calculation.on_operator_press(&operator) {
crate::calculation::Message::Continue => {
crate::app::calculation::Message::Continue => {
if operator == Operator::Equal {
let mut history = self.config.history.clone();
history.push(self.calculation.clone());
Expand All @@ -423,7 +423,7 @@ impl Application for Calculator {
self.calculation.display = self.calculation.result.to_string();
}
}
crate::calculation::Message::Error(message) => {
crate::app::calculation::Message::Error(message) => {
let command = self.update(Message::ShowToast(message));
commands.push(command);
}
Expand Down
2 changes: 1 addition & 1 deletion src/calculation.rs → src/app/calculation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use calculator_rs::{Calculate, Value};
use serde::{Deserialize, Serialize};
use std::{error::Error, fmt::Display};

use crate::operator::Operator;
use crate::app::operator::Operator;

#[derive(Debug, Clone, Default, PartialEq, Deserialize, Serialize)]
pub struct Calculation {
Expand Down
2 changes: 1 addition & 1 deletion src/config.rs → src/app/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use cosmic::{
};
use serde::{Deserialize, Serialize};

use crate::{app::Calculator, calculation::Calculation};
use crate::app::{calculation::Calculation, Calculator};

pub const CONFIG_VERSION: u64 = 1;

Expand Down
File renamed without changes.
3 changes: 1 addition & 2 deletions src/settings.rs → src/app/settings.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
use std::sync::Mutex;

use crate::{
app::Flags,
config::CalculatorConfig,
app::{config::CalculatorConfig, Flags},
core::{
icons::{IconCache, ICON_CACHE},
localization::localize,
Expand Down
2 changes: 2 additions & 0 deletions src/core/icons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ impl IconCache {
Self { cache }
}

#[allow(dead_code)]
pub fn get(&mut self, name: &'static str, size: u16) -> icon::Icon {
let handle = self
.cache
Expand All @@ -61,6 +62,7 @@ impl IconCache {
}
}

#[allow(dead_code)]
pub fn get_icon(name: &'static str, size: u16) -> icon::Icon {
let mut icon_cache = ICON_CACHE.get().unwrap().lock().unwrap();
icon_cache.get(name, size)
Expand Down
6 changes: 2 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@

use app::Calculator;
mod app;
mod calculation;
mod config;
mod core;
mod operator;
mod settings;

use app::settings;

fn main() -> cosmic::iced::Result {
settings::init();
Expand Down

0 comments on commit 55dad06

Please sign in to comment.