refactor: use iced workspaces applet
This commit is contained in:
parent
67869ba5ac
commit
a7b099b4b3
27 changed files with 3958 additions and 999 deletions
|
|
@ -1,76 +1,28 @@
|
|||
// SPDX-License-Identifier: MPL-2.0-only
|
||||
|
||||
use calloop::channel::SyncSender;
|
||||
use gtk4::{
|
||||
gdk::Display,
|
||||
gio::{self, ApplicationFlags},
|
||||
glib::{self, MainContext, Priority},
|
||||
prelude::*,
|
||||
CssProvider, StyleContext,
|
||||
};
|
||||
use once_cell::sync::OnceCell;
|
||||
use utils::WorkspaceEvent;
|
||||
use window::CosmicWorkspacesWindow;
|
||||
|
||||
mod components;
|
||||
#[rustfmt::skip]
|
||||
mod config;
|
||||
mod localize;
|
||||
mod utils;
|
||||
mod wayland;
|
||||
mod wayland_source;
|
||||
mod window;
|
||||
mod workspace_button;
|
||||
mod workspace_list;
|
||||
mod workspace_object;
|
||||
mod wayland_subscription;
|
||||
|
||||
const ID: &str = "com.system76.CosmicAppletWorkspaces";
|
||||
static TX: OnceCell<SyncSender<WorkspaceEvent>> = OnceCell::new();
|
||||
use config::APP_ID;
|
||||
use log::info;
|
||||
|
||||
pub fn localize() {
|
||||
let localizer = crate::localize::localizer();
|
||||
let requested_languages = i18n_embed::DesktopLanguageRequester::requested_languages();
|
||||
use localize::localize;
|
||||
|
||||
if let Err(error) = localizer.select(&requested_languages) {
|
||||
eprintln!("Error while loading language for App List {}", error);
|
||||
}
|
||||
}
|
||||
|
||||
fn load_css() {
|
||||
let provider = CssProvider::new();
|
||||
provider.load_from_resource("/com/System76/CosmicAppletWorkspaces/style.css");
|
||||
|
||||
StyleContext::add_provider_for_display(
|
||||
&Display::default().unwrap(),
|
||||
&provider,
|
||||
gtk4::STYLE_PROVIDER_PRIORITY_APPLICATION,
|
||||
);
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let _monitors = libcosmic::init();
|
||||
use crate::{
|
||||
components::app,
|
||||
config::{PROFILE, VERSION},
|
||||
};
|
||||
|
||||
fn main() -> cosmic::iced::Result {
|
||||
// Initialize logger
|
||||
pretty_env_logger::init();
|
||||
glib::set_application_name(ID);
|
||||
info!("Iced Workspaces Applet ({})", APP_ID);
|
||||
info!("Version: {} ({})", VERSION, PROFILE);
|
||||
|
||||
// Prepare i18n
|
||||
localize();
|
||||
gio::resources_register_include!("compiled.gresource").unwrap();
|
||||
|
||||
let app = gtk4::Application::new(None, ApplicationFlags::default());
|
||||
|
||||
app.connect_activate(|app| {
|
||||
load_css();
|
||||
let (tx, rx) = MainContext::channel(Priority::default());
|
||||
|
||||
let wayland_tx = wayland::spawn_workspaces(tx.clone());
|
||||
let window = CosmicWorkspacesWindow::new(app);
|
||||
|
||||
TX.set(wayland_tx).unwrap();
|
||||
|
||||
rx.attach(None, glib::clone!(@weak window => @default-return glib::prelude::Continue(true), move |workspace_event| {
|
||||
window.set_workspaces(workspace_event);
|
||||
glib::prelude::Continue(true)
|
||||
}));
|
||||
|
||||
window.show();
|
||||
});
|
||||
app.run();
|
||||
app::run()
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue