feat: use libcosmic::init

This commit is contained in:
Ashley Wulber 2022-08-16 14:36:31 -04:00
parent a96decd24b
commit 98813824d4
No known key found for this signature in database
GPG key ID: 5216D4F46A90A820
37 changed files with 396 additions and 295 deletions

View file

@ -9,7 +9,7 @@ use gtk4::{
CssProvider, StyleContext,
};
use once_cell::sync::OnceCell;
use utils::{WorkspaceEvent};
use utils::WorkspaceEvent;
use window::CosmicWorkspacesWindow;
mod localize;
@ -45,9 +45,8 @@ fn load_css() {
}
fn main() {
let _ = gtk4::init();
adw::init();
let _ = libcosmic::init();
// Initialize logger
pretty_env_logger::init();
glib::set_application_name(ID);

View file

@ -5,7 +5,6 @@ use std::path::PathBuf;
use gtk4::glib;
use std::future::Future;
#[derive(Debug, Clone)]
pub enum WorkspaceEvent {
Activate(String),

View file

@ -1,7 +1,4 @@
use crate::{
utils::WorkspaceEvent,
wayland_source::WaylandSource,
};
use crate::{utils::WorkspaceEvent, wayland_source::WaylandSource};
use calloop::channel::*;
use cosmic_panel_config::CosmicPanelOuput;
use cosmic_protocols::workspace::v1::client::{
@ -10,9 +7,7 @@ use cosmic_protocols::workspace::v1::client::{
zcosmic_workspace_manager_v1::{self, ZcosmicWorkspaceManagerV1},
};
use gtk4::glib;
use std::{
env, os::unix::net::UnixStream, path::PathBuf, time::Duration,
};
use std::{env, os::unix::net::UnixStream, path::PathBuf, time::Duration};
use wayland_client::{
event_created_child,
protocol::{
@ -39,11 +34,14 @@ pub fn spawn_workspaces(tx: glib::Sender<State>) -> SyncSender<WorkspaceEvent> {
.and_then(|s| s.map(|s| Connection::from_socket(s).map_err(anyhow::Error::msg)))
{
std::thread::spawn(move || {
let output = std::env::var("COSMIC_PANEL_OUTPUT").ok().and_then(|size| match size.parse::<CosmicPanelOuput>() {
Ok(CosmicPanelOuput::Name(n)) => Some(n),
// TODO handle Active & panic if the space is still configured for All instead of being assigned a named output
_ => Some("".to_string()),
}).unwrap_or_default();
let output = std::env::var("COSMIC_PANEL_OUTPUT")
.ok()
.and_then(|size| match size.parse::<CosmicPanelOuput>() {
Ok(CosmicPanelOuput::Name(n)) => Some(n),
// TODO handle Active & panic if the space is still configured for All instead of being assigned a named output
_ => Some("".to_string()),
})
.unwrap_or_default();
let mut event_loop = calloop::EventLoop::<State>::try_new().unwrap();
let loop_handle = event_loop.handle();

View file

@ -41,7 +41,10 @@ impl WorkspaceList {
fn layout(&self) {
let imp = imp::WorkspaceList::from_instance(self);
let anchor = std::env::var("COSMIC_PANEL_ANCHOR").ok().and_then(|anchor| anchor.parse::<PanelAnchor>().ok()).unwrap_or_default();
let anchor = std::env::var("COSMIC_PANEL_ANCHOR")
.ok()
.and_then(|anchor| anchor.parse::<PanelAnchor>().ok())
.unwrap_or_default();
let list_view = cascade! {
ListView::default();