feat: use libcosmic::init
This commit is contained in:
parent
a96decd24b
commit
98813824d4
37 changed files with 396 additions and 295 deletions
|
|
@ -10,8 +10,8 @@ cosmic-protocols = { git = "https://github.com/pop-os/cosmic-protocols", default
|
|||
cascade = "1.0.0"
|
||||
gtk4 = { git = "https://github.com/gtk-rs/gtk4-rs", features = ["v4_4"] }
|
||||
adw = { git = "https://gitlab.gnome.org/World/Rust/libadwaita-rs", package = "libadwaita"}
|
||||
libcosmic = { git = "https://github.com/pop-os/libcosmic", default-features = false }
|
||||
gio = { git = "https://github.com/gtk-rs/gtk-rs-core" }
|
||||
libcosmic = { git = "https://github.com/pop-os/libcosmic", branch = "relm4-next" }
|
||||
relm4-macros = { git = "https://github.com/Relm4/Relm4.git", branch = "next" }
|
||||
serde_json = "1.0.78"
|
||||
futures = "0.3.19"
|
||||
|
|
|
|||
|
|
@ -54,7 +54,10 @@ impl AppsContainer {
|
|||
imp.active_list.set(active_app_list_view).unwrap();
|
||||
// Setup
|
||||
self_.setup_callbacks();
|
||||
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();
|
||||
self_.set_position(anchor);
|
||||
|
||||
Self::setup_callbacks(&self_);
|
||||
|
|
|
|||
|
|
@ -500,15 +500,18 @@ impl DockList {
|
|||
let factory = SignalListItemFactory::new();
|
||||
let model = imp.model.get().expect("Failed to get saved app model.");
|
||||
|
||||
let icon_size = std::env::var("COSMIC_PANEL_SIZE").ok().and_then(|size| match size.parse::<PanelSize>() {
|
||||
Ok(PanelSize::XL) => Some(64),
|
||||
Ok(PanelSize::L) => Some(48),
|
||||
Ok(PanelSize::M) => Some(36),
|
||||
Ok(PanelSize::S) => Some(24),
|
||||
Ok(PanelSize::XS) => Some(18),
|
||||
Err(_) => Some(36),
|
||||
}).unwrap_or(36);
|
||||
|
||||
let icon_size = std::env::var("COSMIC_PANEL_SIZE")
|
||||
.ok()
|
||||
.and_then(|size| match size.parse::<PanelSize>() {
|
||||
Ok(PanelSize::XL) => Some(64),
|
||||
Ok(PanelSize::L) => Some(48),
|
||||
Ok(PanelSize::M) => Some(36),
|
||||
Ok(PanelSize::S) => Some(24),
|
||||
Ok(PanelSize::XS) => Some(18),
|
||||
Err(_) => Some(36),
|
||||
})
|
||||
.unwrap_or(36);
|
||||
|
||||
factory.connect_setup(
|
||||
glib::clone!(@weak popover_menu_index, @weak model => move |_, list_item| {
|
||||
let dock_item = DockItem::new(icon_size);
|
||||
|
|
|
|||
|
|
@ -49,9 +49,8 @@ fn load_css() {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let _ = gtk4::init();
|
||||
adw::init();
|
||||
|
||||
let _ = libcosmic::init();
|
||||
|
||||
// Initialize logger
|
||||
pretty_env_logger::init();
|
||||
glib::set_application_name("Cosmic Dock App List");
|
||||
|
|
@ -243,7 +242,7 @@ fn main() {
|
|||
dock_obj.set_property("active", BoxedWindowList::default().to_value());
|
||||
saved_app_model.items_changed(saved_i, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
if let Some(cur_app_info) =
|
||||
dock_obj.property::<Option<DesktopAppInfo>>("appinfo")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use crate::config::AppListConfig;
|
||||
use crate::{config::TopLevelFilter, utils::AppListEvent, wayland_source::WaylandSource, TX};
|
||||
use calloop::channel::*;
|
||||
use cosmic_panel_config::{CosmicPanelOuput};
|
||||
use cosmic_panel_config::CosmicPanelOuput;
|
||||
use cosmic_protocols::{
|
||||
toplevel_info::v1::client::{
|
||||
zcosmic_toplevel_handle_v1::{self, ZcosmicToplevelHandleV1},
|
||||
|
|
@ -52,10 +52,12 @@ pub fn spawn_toplevels() -> SyncSender<ToplevelEvent> {
|
|||
.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
|
||||
_ => None,
|
||||
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
|
||||
_ => None,
|
||||
}
|
||||
});
|
||||
|
||||
let mut event_loop = calloop::EventLoop::<State>::try_new().unwrap();
|
||||
|
|
@ -305,26 +307,25 @@ impl Dispatch<ZcosmicToplevelHandleV1, ()> for State {
|
|||
if let Some(i) = state.toplevels.iter().position(|t| &t.toplevel_handle == p) {
|
||||
let removed_toplevel = state.toplevels.remove(i);
|
||||
if match state.config.filter_top_levels {
|
||||
Some(TopLevelFilter::ActiveWorkspace) => {
|
||||
state
|
||||
.workspace_groups
|
||||
.iter()
|
||||
.find(|g| {
|
||||
g.workspaces
|
||||
.iter()
|
||||
.find(|w| {
|
||||
w.states.contains(
|
||||
&zcosmic_workspace_handle_v1::State::Active,
|
||||
) && Some(&w.workspace_handle) == removed_toplevel.workspace.as_ref()
|
||||
})
|
||||
.is_some()
|
||||
})
|
||||
.is_some()
|
||||
},
|
||||
Some(TopLevelFilter::ActiveWorkspace) => state
|
||||
.workspace_groups
|
||||
.iter()
|
||||
.find(|g| {
|
||||
g.workspaces
|
||||
.iter()
|
||||
.find(|w| {
|
||||
w.states
|
||||
.contains(&zcosmic_workspace_handle_v1::State::Active)
|
||||
&& Some(&w.workspace_handle)
|
||||
== removed_toplevel.workspace.as_ref()
|
||||
})
|
||||
.is_some()
|
||||
})
|
||||
.is_some(),
|
||||
Some(TopLevelFilter::ConfiguredOutput) => {
|
||||
state.expected_output == removed_toplevel.output
|
||||
}
|
||||
_ => true
|
||||
_ => true,
|
||||
} {
|
||||
let tx = TX.get().unwrap().clone();
|
||||
let _ = tx.send(AppListEvent::Remove(removed_toplevel));
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@ license = "GPL-3.0-or-later"
|
|||
futures = "0.3.21"
|
||||
futures-util = "0.3.21"
|
||||
libcosmic-applet = { path = "../../libcosmic-applet" }
|
||||
libcosmic-widgets = { git = "https://github.com/pop-os/libcosmic", branch = "relm4-next" }
|
||||
libpulse-binding = "2.26.0"
|
||||
libpulse-glib-binding = "2.25.0"
|
||||
tracker = "0.1.1"
|
||||
|
|
@ -21,6 +20,7 @@ relm4-macros = { git = "https://github.com/relm4/relm4", branch = "next" }
|
|||
once_cell = "1.10.0"
|
||||
gtk4 = { git = "https://github.com/gtk-rs/gtk4-rs", features = ["v4_2"] }
|
||||
adw = { git = "https://gitlab.gnome.org/World/Rust/libadwaita-rs", package = "libadwaita"}
|
||||
libcosmic = { git = "https://github.com/pop-os/libcosmic", default-features = false, features = ["widgets"] }
|
||||
async-io = "1.6.0"
|
||||
|
||||
[features]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
use gtk4::{glib::clone, prelude::*, Button, Label, ListBox};
|
||||
use libcosmic_widgets::{relm4::RelmContainerExt, LabeledItem};
|
||||
use std::rc::Rc;
|
||||
use libcosmic::widgets::{relm4::RelmContainerExt, LabeledItem};
|
||||
|
||||
use crate::pa::{DeviceInfo, PA};
|
||||
|
||||
|
|
|
|||
|
|
@ -36,12 +36,8 @@ use tokio::runtime::Runtime;
|
|||
static RT: Lazy<Runtime> = Lazy::new(|| Runtime::new().expect("failed to build tokio runtime"));
|
||||
|
||||
fn main() {
|
||||
let _ = gtk4::init();
|
||||
adw::init();
|
||||
let application = Application::new(
|
||||
None,
|
||||
ApplicationFlags::default(),
|
||||
);
|
||||
let _ = libcosmic::init();
|
||||
let application = Application::new(None, ApplicationFlags::default());
|
||||
application.connect_activate(app);
|
||||
application.run();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
use gtk4::{glib::clone, prelude::*, Button, Label, ListBox};
|
||||
use libcosmic_widgets::{relm4::RelmContainerExt, LabeledItem};
|
||||
use std::rc::Rc;
|
||||
use libcosmic::widgets::{relm4::RelmContainerExt, LabeledItem};
|
||||
|
||||
use crate::pa::{DeviceInfo, PA};
|
||||
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ edition = "2021"
|
|||
futures = "0.3"
|
||||
gtk4 = { git = "https://github.com/gtk-rs/gtk4-rs" }
|
||||
adw = { git = "https://gitlab.gnome.org/World/Rust/libadwaita-rs", package = "libadwaita"}
|
||||
libcosmic = { git = "https://github.com/pop-os/libcosmic", default-features = false }
|
||||
libcosmic-applet = { path = "../../libcosmic-applet" }
|
||||
relm4 = { git = "https://github.com/relm4/relm4", branch = "next", features = ["macros"] }
|
||||
zbus = { version = "2", no-default-features = true }
|
||||
|
|
|
|||
|
|
@ -2,9 +2,11 @@
|
|||
// TODO: handle dbus service start/stop?
|
||||
|
||||
use futures::prelude::*;
|
||||
use gtk4::{glib, prelude::*, gio::ApplicationFlags, Application};
|
||||
use relm4::{ComponentParts, ComponentSender, RelmApp, SimpleComponent};
|
||||
use std::{process::Command, time::Duration};
|
||||
use gtk4::{gio::ApplicationFlags, glib, prelude::*, Application};
|
||||
use relm4::{
|
||||
component::ComponentSenderInner, ComponentParts, ComponentSender, RelmApp, SimpleComponent,
|
||||
};
|
||||
use std::{process::Command, sync::Arc, time::Duration};
|
||||
|
||||
mod backlight;
|
||||
use backlight::{backlight, Backlight, LogindSessionProxy};
|
||||
|
|
@ -198,7 +200,7 @@ impl SimpleComponent for AppModel {
|
|||
fn init(
|
||||
_params: Self::InitParams,
|
||||
root: &Self::Root,
|
||||
sender: &ComponentSender<Self>,
|
||||
sender: Arc<ComponentSenderInner<AppMsg, (), ()>>,
|
||||
) -> ComponentParts<Self> {
|
||||
let mut model = AppModel {
|
||||
icon_name: "battery-symbolic".to_string(),
|
||||
|
|
@ -253,7 +255,7 @@ impl SimpleComponent for AppModel {
|
|||
ComponentParts { model, widgets }
|
||||
}
|
||||
|
||||
fn update(&mut self, msg: Self::Input, sender: &ComponentSender<Self>) {
|
||||
fn update(&mut self, msg: Self::Input, sender: Arc<ComponentSenderInner<AppMsg, (), ()>>) {
|
||||
match msg {
|
||||
AppMsg::SetDisplayBrightness(value) => {
|
||||
self.display_brightness = value;
|
||||
|
|
@ -357,12 +359,8 @@ impl SimpleComponent for AppModel {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let _ = gtk4::init();
|
||||
adw::init();
|
||||
|
||||
let app = RelmApp::with_app(Application::new(
|
||||
None,
|
||||
ApplicationFlags::default(),
|
||||
));
|
||||
let _ = libcosmic::init();
|
||||
|
||||
let app = RelmApp::with_app(Application::new(None, ApplicationFlags::default()));
|
||||
app.run::<AppModel>(());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ edition = "2021"
|
|||
[dependencies]
|
||||
gtk4 = { git = "https://github.com/gtk-rs/gtk4-rs", features = ["v4_2"] }
|
||||
adw = { git = "https://gitlab.gnome.org/World/Rust/libadwaita-rs", package = "libadwaita"}
|
||||
libcosmic = { git = "https://github.com/pop-os/libcosmic", default-features = false }
|
||||
libcosmic-applet = { path = "../../libcosmic-applet" }
|
||||
once_cell = "1.9.0"
|
||||
relm4-macros = { git = "https://github.com/Relm4/Relm4.git", branch = "next" }
|
||||
|
|
|
|||
|
|
@ -41,9 +41,8 @@ fn row_clicked(_: &ListBox, row: &ListBoxRow) {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let _ = gtk4::init();
|
||||
adw::init();
|
||||
|
||||
let _ = libcosmic::init();
|
||||
|
||||
let provider = gtk4::CssProvider::new();
|
||||
provider.load_from_data(include_bytes!("style.css"));
|
||||
gtk4::StyleContext::add_provider_for_display(
|
||||
|
|
@ -63,7 +62,7 @@ fn main() {
|
|||
set_title: Some("COSMIC Graphics Applet"),
|
||||
#[wrap(Some)]
|
||||
set_child = &libcosmic_applet::AppletButton {
|
||||
set_button_icon_name: "input-gaming",
|
||||
set_button_icon_name: "input-gaming-symbolic",
|
||||
#[wrap(Some)]
|
||||
set_popover_child: main_overlay = &Overlay {
|
||||
add_overlay: loading_box = >k4::Box {
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ cosmic-dbus-networkmanager = { git = "https://github.com/pop-os/dbus-settings-bi
|
|||
futures-util = "0.3.21"
|
||||
gtk4 = { git = "https://github.com/gtk-rs/gtk4-rs" }
|
||||
adw = { git = "https://gitlab.gnome.org/World/Rust/libadwaita-rs", package = "libadwaita"}
|
||||
libcosmic = { git = "https://github.com/pop-os/libcosmic", default-features = false, features = ["widgets"] }
|
||||
itertools = "0.10.3"
|
||||
once_cell = "1.9.0"
|
||||
relm4-macros = { git = "https://github.com/Relm4/Relm4.git", branch = "next" }
|
||||
|
|
@ -16,4 +17,3 @@ slotmap = "1.0.6"
|
|||
tokio = { version = "1.15.0", features = ["full"] }
|
||||
zbus = "2.0.1"
|
||||
libcosmic-applet = { path = "../../libcosmic-applet" }
|
||||
libcosmic-widgets = { git = "https://github.com/pop-os/libcosmic", branch = "relm4-next" }
|
||||
|
|
|
|||
|
|
@ -14,15 +14,14 @@ use tokio::runtime::Runtime;
|
|||
static RT: Lazy<Runtime> = Lazy::new(|| Runtime::new().expect("failed to build tokio runtime"));
|
||||
|
||||
fn main() {
|
||||
let _ = gtk4::init();
|
||||
adw::init();
|
||||
|
||||
let _ = libcosmic::init();
|
||||
|
||||
view! {
|
||||
window = libcosmic_applet::AppletWindow {
|
||||
set_title: Some("COSMIC Network Applet"),
|
||||
#[wrap(Some)]
|
||||
set_child: button = &libcosmic_applet::AppletButton {
|
||||
set_button_icon_name: "preferences-system-network",
|
||||
set_button_icon_name: "network-workgroup-symbolic",
|
||||
#[wrap(Some)]
|
||||
set_popover_child: main_box = >k4::Box {
|
||||
set_orientation: Orientation::Vertical,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use gtk4::{
|
|||
prelude::*,
|
||||
Image, ListBox, ListBoxRow, Separator,
|
||||
};
|
||||
use libcosmic_widgets::{relm4::RelmContainerExt, LabeledItem};
|
||||
use libcosmic::widgets::{relm4::RelmContainerExt, LabeledItem};
|
||||
use std::{
|
||||
cell::RefCell,
|
||||
collections::{BTreeMap, HashMap},
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ cascade = "1"
|
|||
futures = "0.3"
|
||||
gtk4 = { git = "https://github.com/gtk-rs/gtk4-rs" }
|
||||
adw = { git = "https://gitlab.gnome.org/World/Rust/libadwaita-rs", package = "libadwaita"}
|
||||
libcosmic = { git = "https://github.com/pop-os/libcosmic", default-features = false }
|
||||
libcosmic-applet = { path = "../../libcosmic-applet" }
|
||||
once_cell = "1.12"
|
||||
relm4-macros = { git = "https://github.com/Relm4/Relm4.git", branch = "next" }
|
||||
|
|
|
|||
|
|
@ -12,9 +12,8 @@ mod notifications;
|
|||
use notifications::Notifications;
|
||||
|
||||
fn main() {
|
||||
let _ = gtk4::init();
|
||||
adw::init();
|
||||
|
||||
let _ = libcosmic::init();
|
||||
|
||||
// XXX Implement DBus service somewhere other than applet?
|
||||
let notifications = Notifications::new();
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ license = "GPL-3.0-or-later"
|
|||
futures-util = "0.3.21"
|
||||
gtk4 = { git = "https://github.com/gtk-rs/gtk4-rs" }
|
||||
adw = { git = "https://gitlab.gnome.org/World/Rust/libadwaita-rs", package = "libadwaita"}
|
||||
libcosmic = { git = "https://github.com/pop-os/libcosmic", default-features = false }
|
||||
libcosmic-applet = { path = "../../libcosmic-applet" }
|
||||
logind-zbus = "3.0.1"
|
||||
nix = "0.24.1"
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@
|
|||
#[macro_use]
|
||||
extern crate relm4_macros;
|
||||
|
||||
pub mod cosmic_session;
|
||||
pub mod session_manager;
|
||||
pub mod ui;
|
||||
pub mod cosmic_session;
|
||||
|
||||
use gtk4::{gio::ApplicationFlags, prelude::*, Align, Button, Label, Orientation, Separator};
|
||||
use once_cell::sync::Lazy;
|
||||
|
|
@ -15,13 +15,9 @@ use tokio::runtime::Runtime;
|
|||
static RT: Lazy<Runtime> = Lazy::new(|| Runtime::new().expect("failed to build tokio runtime"));
|
||||
|
||||
fn main() {
|
||||
let _ = gtk4::init();
|
||||
adw::init();
|
||||
|
||||
let application = gtk4::Application::new(
|
||||
None,
|
||||
ApplicationFlags::default(),
|
||||
);
|
||||
let _ = libcosmic::init();
|
||||
|
||||
let application = gtk4::Application::new(None, ApplicationFlags::default());
|
||||
application.connect_activate(build_ui);
|
||||
application.run();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ cascade = "1"
|
|||
futures = "0.3"
|
||||
gtk4 = { git = "https://github.com/gtk-rs/gtk4-rs" }
|
||||
adw = { git = "https://gitlab.gnome.org/World/Rust/libadwaita-rs", package = "libadwaita"}
|
||||
libcosmic = { git = "https://github.com/pop-os/libcosmic", default-features = false }
|
||||
libcosmic-applet = { path = "../../libcosmic-applet" }
|
||||
once_cell = "1.12"
|
||||
serde = "1"
|
||||
|
|
|
|||
|
|
@ -10,9 +10,8 @@ mod status_notifier_watcher;
|
|||
use status_area::StatusArea;
|
||||
|
||||
fn main() {
|
||||
let _ = gtk4::init();
|
||||
adw::init();
|
||||
|
||||
let _ = libcosmic::init();
|
||||
|
||||
// XXX Implement DBus service somewhere other than applet?
|
||||
glib::MainContext::default().spawn_local(status_notifier_watcher::start());
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ chrono = "0.4"
|
|||
futures = "0.3"
|
||||
gtk4 = { git = "https://github.com/gtk-rs/gtk4-rs", features = [ "v4_6" ] }
|
||||
adw = { git = "https://gitlab.gnome.org/World/Rust/libadwaita-rs", package = "libadwaita"}
|
||||
libcosmic = { git = "https://github.com/pop-os/libcosmic", default-features = false }
|
||||
libcosmic-applet = { path = "../../libcosmic-applet" }
|
||||
once_cell = "1.12"
|
||||
serde = "1"
|
||||
|
|
|
|||
|
|
@ -6,9 +6,8 @@ mod time_button;
|
|||
use time_button::TimeButton;
|
||||
|
||||
fn main() {
|
||||
let _ = gtk4::init();
|
||||
adw::init();
|
||||
|
||||
let _ = libcosmic::init();
|
||||
|
||||
cascade! {
|
||||
libcosmic_applet::AppletWindow::new();
|
||||
..set_child(Some(&TimeButton::new()));
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ cosmic-panel-config = { git = "https://github.com/pop-os/cosmic-panel", features
|
|||
cascade = "1.0.0"
|
||||
gtk4 = { git = "https://github.com/gtk-rs/gtk4-rs", features = ["v4_4"] }
|
||||
adw = { git = "https://gitlab.gnome.org/World/Rust/libadwaita-rs", package = "libadwaita"}
|
||||
libcosmic = { git = "https://github.com/pop-os/libcosmic", default-features = false }
|
||||
once_cell = "1.9.0"
|
||||
pretty_env_logger = "0.4"
|
||||
anyhow = "1.0.50"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use std::{process::Command};
|
||||
use std::process::Command;
|
||||
|
||||
fn main() {
|
||||
if let Some(output) = Command::new("git")
|
||||
|
|
|
|||
|
|
@ -1,10 +1,3 @@
|
|||
@define-color accent_color #001d6b;
|
||||
@define-color destructive_color #aa3000;
|
||||
@define-color view_bg_color #00000044;
|
||||
@define-color destructive_fg_color white;
|
||||
@define-color accent_fg_color white;
|
||||
@define-color view_fg_color white;
|
||||
|
||||
button.alert {
|
||||
border-radius: 0;
|
||||
padding: 0px;
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ use std::path::PathBuf;
|
|||
use gtk4::glib;
|
||||
use std::future::Future;
|
||||
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum WorkspaceEvent {
|
||||
Activate(String),
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ cosmic-panel-config = {git = "https://github.com/pop-os/cosmic-panel", features
|
|||
cascade = "1.0.0"
|
||||
gtk4 = { git = "https://github.com/gtk-rs/gtk4-rs", features = ["v4_4"] }
|
||||
adw = { git = "https://gitlab.gnome.org/World/Rust/libadwaita-rs", package = "libadwaita"}
|
||||
libcosmic = { git = "https://github.com/pop-os/libcosmic", default-features = false }
|
||||
once_cell = "1.9.0"
|
||||
pretty_env_logger = "0.4"
|
||||
anyhow = "1.0.50"
|
||||
|
|
|
|||
|
|
@ -41,14 +41,17 @@ impl CosmicPanelAppButtonWindow {
|
|||
Button::new();
|
||||
..add_css_class("apps");
|
||||
};
|
||||
let pixels = std::env::var("COSMIC_PANEL_SIZE").ok().and_then(|size| match size.parse::<PanelSize>() {
|
||||
Ok(PanelSize::XL) => Some(64),
|
||||
Ok(PanelSize::L) => Some(48),
|
||||
Ok(PanelSize::M) => Some(36),
|
||||
Ok(PanelSize::S) => Some(24),
|
||||
Ok(PanelSize::XS) => Some(18),
|
||||
Err(_) => Some(36),
|
||||
}).unwrap_or(36);
|
||||
let pixels = std::env::var("COSMIC_PANEL_SIZE")
|
||||
.ok()
|
||||
.and_then(|size| match size.parse::<PanelSize>() {
|
||||
Ok(PanelSize::XL) => Some(64),
|
||||
Ok(PanelSize::L) => Some(48),
|
||||
Ok(PanelSize::M) => Some(36),
|
||||
Ok(PanelSize::S) => Some(24),
|
||||
Ok(PanelSize::XS) => Some(18),
|
||||
Err(_) => Some(36),
|
||||
})
|
||||
.unwrap_or(36);
|
||||
let icon = apps_desktop_info.icon().unwrap_or_else(|| {
|
||||
Icon::for_string("image-missing").expect("Failed to set default icon")
|
||||
});
|
||||
|
|
|
|||
|
|
@ -37,9 +37,8 @@ fn load_css() {
|
|||
}
|
||||
|
||||
fn main() {
|
||||
let _ = gtk4::init();
|
||||
adw::init();
|
||||
|
||||
let _ = libcosmic::init();
|
||||
|
||||
// Initialize logger
|
||||
pretty_env_logger::init();
|
||||
glib::set_application_name("Cosmic Panel App Button");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue