diff --git a/applets/cosmic-applet-status-area/Cargo.toml b/applets/cosmic-applet-status-area/Cargo.toml deleted file mode 100644 index 5aa67b04..00000000 --- a/applets/cosmic-applet-status-area/Cargo.toml +++ /dev/null @@ -1,17 +0,0 @@ -[package] -name = "cosmic-applet-status-area" -version = "0.1.0" -edition = "2021" -license = "GPL-3.0-or-later" - -[dependencies] -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" -zbus = "3" -zvariant = "3" diff --git a/applets/cosmic-applet-status-area/data/com.system76.CosmicAppletStatusArea.desktop b/applets/cosmic-applet-status-area/data/com.system76.CosmicAppletStatusArea.desktop deleted file mode 100644 index c60bc271..00000000 --- a/applets/cosmic-applet-status-area/data/com.system76.CosmicAppletStatusArea.desktop +++ /dev/null @@ -1,10 +0,0 @@ -[Desktop Entry] -Name=Cosmic Applet Status Area -Type=Application -Exec=cosmic-applet-status-area -Terminal=false -Categories=GNOME;GTK; -Keywords=Gnome;GTK; -# Translators: Do NOT translate or transliterate this text (this is an icon file name)! -Icon=com.system76.CosmicAppletStatusArea -NoDisplay=true diff --git a/applets/cosmic-applet-status-area/data/icons/com.system76.CosmicAppletStatusArea.svg b/applets/cosmic-applet-status-area/data/icons/com.system76.CosmicAppletStatusArea.svg deleted file mode 100644 index c2bd5b1b..00000000 --- a/applets/cosmic-applet-status-area/data/icons/com.system76.CosmicAppletStatusArea.svg +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/applets/cosmic-applet-status-area/src/deref_cell.rs b/applets/cosmic-applet-status-area/src/deref_cell.rs deleted file mode 100644 index dfdd4936..00000000 --- a/applets/cosmic-applet-status-area/src/deref_cell.rs +++ /dev/null @@ -1,31 +0,0 @@ -use once_cell::unsync::OnceCell; - -/// Wrapper around `OnceCell` implementing `Deref`, and thus also panicking -/// when not set (or set twice). -/// -/// To be used in place of `gtk::TemplateChild`, but without xml. -pub struct DerefCell(OnceCell); - -impl DerefCell { - #[track_caller] - pub fn set(&self, value: T) { - if self.0.set(value).is_err() { - panic!("Initialized twice"); - } - } -} - -impl Default for DerefCell { - fn default() -> Self { - Self(OnceCell::default()) - } -} - -impl std::ops::Deref for DerefCell { - type Target = T; - - #[track_caller] - fn deref(&self) -> &T { - self.0.get().unwrap() - } -} diff --git a/applets/cosmic-applet-status-area/src/main.rs b/applets/cosmic-applet-status-area/src/main.rs deleted file mode 100644 index 6c7557ed..00000000 --- a/applets/cosmic-applet-status-area/src/main.rs +++ /dev/null @@ -1,26 +0,0 @@ -use cascade::cascade; -use gtk4::{glib, prelude::*}; - -mod deref_cell; -mod status_area; -mod status_menu; -mod status_notifier_watcher; - -use status_area::StatusArea; - -fn main() { - let _monitors = libcosmic::init(); - - // XXX Implement DBus service somewhere other than applet? - glib::MainContext::default().spawn_local(status_notifier_watcher::start()); - - let status_area = StatusArea::new(); - cascade! { - libcosmic_applet::AppletWindow::new(); - ..set_child(Some(&status_area)); - ..show(); - }; - - let main_loop = glib::MainLoop::new(None, false); - main_loop.run(); -} diff --git a/applets/cosmic-applet-status-area/src/status_area.rs b/applets/cosmic-applet-status-area/src/status_area.rs deleted file mode 100644 index 8babbf8e..00000000 --- a/applets/cosmic-applet-status-area/src/status_area.rs +++ /dev/null @@ -1,145 +0,0 @@ -use cascade::cascade; -use futures::stream::StreamExt; -use gtk4::{ - glib::{self, clone}, - prelude::*, - subclass::prelude::*, -}; -use once_cell::unsync::OnceCell; -use std::{cell::RefCell, collections::HashMap}; -use zbus::dbus_proxy; - -use crate::deref_cell::DerefCell; -use crate::status_menu::StatusMenu; - -#[derive(Default)] -pub struct StatusAreaInner { - box_: DerefCell, - watcher: OnceCell>, - icons: RefCell>, -} - -#[glib::object_subclass] -impl ObjectSubclass for StatusAreaInner { - const NAME: &'static str = "S76StatusArea"; - type ParentType = gtk4::Widget; - type Type = StatusArea; - - fn class_init(klass: &mut Self::Class) { - klass.set_layout_manager_type::(); - } -} - -impl ObjectImpl for StatusAreaInner { - fn constructed(&self, obj: &StatusArea) { - let box_ = cascade! { - gtk4::Box::new(gtk4::Orientation::Horizontal, 0); - ..set_parent(obj); - }; - - self.box_.set(box_); - - glib::MainContext::default().spawn_local(clone!(@strong obj => async move { - async { - let connection = zbus::Connection::session().await?; - let watcher = StatusNotifierWatcherProxy::new(&connection).await?; - - let name = connection.unique_name().unwrap().as_str(); - if let Err(err) = watcher.register_status_notifier_host(name).await { - eprintln!("Failed to register status notifier host: {}", err); - } - - let mut registered_stream = watcher.receive_status_notifier_item_registered().await?; - let mut unregistered_stream = watcher.receive_status_notifier_item_unregistered().await?; - - for name in watcher.registered_status_notifier_items().await? { - glib::MainContext::default().spawn_local(clone!(@strong obj => async move { - obj.item_registered(&name).await; - })); - } - - glib::MainContext::default().spawn_local(clone!(@strong obj => async move { - if let Some(evt) = registered_stream.next().await { - if let Ok(args) = evt.args() { - obj.item_registered(&args.name).await; - } - } - })); - - glib::MainContext::default().spawn_local(clone!(@strong obj => async move { - if let Some(evt) = unregistered_stream.next().await { - if let Ok(args) = evt.args() { - obj.item_unregistered(&args.name); - } - } - })); - - let _ = obj.inner().watcher.set(watcher); - - Ok::<_, zbus::Error>(()) - }.await.unwrap_or_else(|err| { - eprintln!("Failed to connect to 'org.kde.StatusNotifierWatcher': {}", err); - }); - })); - } - - fn dispose(&self, _obj: &StatusArea) { - self.box_.unparent(); - } -} - -impl WidgetImpl for StatusAreaInner {} - -glib::wrapper! { - pub struct StatusArea(ObjectSubclass) - @extends gtk4::Widget; -} - -impl StatusArea { - pub fn new() -> Self { - glib::Object::new(&[]).unwrap() - } - - fn inner(&self) -> &StatusAreaInner { - StatusAreaInner::from_instance(self) - } - - async fn item_registered(&self, name: &str) { - match StatusMenu::new(&name).await { - Ok(item) => { - self.inner().box_.append(&item); - - self.item_unregistered(name); - self.inner() - .icons - .borrow_mut() - .insert(name.to_owned(), item); - } - Err(err) => eprintln!("Failed to connect to '{}': {}", name, err), - } - } - - fn item_unregistered(&self, name: &str) { - if let Some(icon) = self.inner().icons.borrow_mut().remove(name) { - self.inner().box_.remove(&icon); - } - } -} - -#[dbus_proxy( - interface = "org.kde.StatusNotifierWatcher", - default_service = "org.kde.StatusNotifierWatcher", - default_path = "/StatusNotifierWatcher" -)] -trait StatusNotifierWatcher { - fn register_status_notifier_host(&self, name: &str) -> zbus::Result<()>; - - #[dbus_proxy(property)] - fn registered_status_notifier_items(&self) -> zbus::Result>; - - #[dbus_proxy(signal)] - fn status_notifier_item_registered(&self, name: &str) -> zbus::Result<()>; - - #[dbus_proxy(signal)] - fn status_notifier_item_unregistered(&self, name: &str) -> zbus::Result<()>; -} diff --git a/applets/cosmic-applet-status-area/src/status_menu.rs b/applets/cosmic-applet-status-area/src/status_menu.rs deleted file mode 100644 index 56bf2c72..00000000 --- a/applets/cosmic-applet-status-area/src/status_menu.rs +++ /dev/null @@ -1,345 +0,0 @@ -use cascade::cascade; -use futures::StreamExt; -use gtk4::{ - gdk_pixbuf, - glib::{self, clone}, - prelude::*, - subclass::prelude::*, -}; -use std::{cell::RefCell, collections::HashMap, io}; -use zbus::dbus_proxy; -use zvariant::OwnedValue; - -use crate::deref_cell::DerefCell; - -struct Menu { - box_: gtk4::Box, - children: Vec, -} - -#[derive(Default)] -pub struct StatusMenuInner { - menu_button: DerefCell, - vbox: DerefCell, - item: DerefCell>, - dbus_menu: DerefCell>, - menus: RefCell>, -} - -#[glib::object_subclass] -impl ObjectSubclass for StatusMenuInner { - const NAME: &'static str = "S76StatusMenu"; - type ParentType = gtk4::Widget; - type Type = StatusMenu; - - fn class_init(klass: &mut Self::Class) { - klass.set_layout_manager_type::(); - } -} - -impl ObjectImpl for StatusMenuInner { - fn constructed(&self, obj: &StatusMenu) { - let vbox = cascade! { - gtk4::Box::new(gtk4::Orientation::Vertical, 0); - }; - - let menu_button = cascade! { - libcosmic_applet::AppletButton::new(); - ..set_parent(obj); - ..set_popover_child(Some(&vbox)); - }; - - self.menu_button.set(menu_button); - self.vbox.set(vbox); - } - - fn dispose(&self, _obj: &StatusMenu) { - self.menu_button.unparent(); - } -} - -impl WidgetImpl for StatusMenuInner {} - -glib::wrapper! { - pub struct StatusMenu(ObjectSubclass) - @extends gtk4::Widget; -} - -impl StatusMenu { - pub async fn new(name: &str) -> zbus::Result { - let (dest, path) = if let Some(idx) = name.find('/') { - (&name[..idx], &name[idx..]) - } else { - (name, "/StatusNotifierItem") - }; - - let connection = zbus::Connection::session().await?; - let item = StatusNotifierItemProxy::builder(&connection) - .destination(dest.to_string())? - .path(path.to_string())? - .build() - .await?; - let obj = glib::Object::new::(&[]).unwrap(); - let icon_name = item.icon_name().await?; - obj.inner().menu_button.set_button_icon_name(&icon_name); - - let menu = item.menu().await?; - let menu = DBusMenuProxy::builder(&connection) - .destination(dest.to_string())? - .path(menu)? - .build() - .await?; - let layout = menu.get_layout(0, -1, &[]).await?.1; - - let mut layout_updated_stream = menu.receive_layout_updated().await?; - glib::MainContext::default().spawn_local(clone!(@strong obj => async move { - while let Some(evt) = layout_updated_stream.next().await { - let args = match evt.args() { - Ok(args) => args, - Err(_) => { continue; }, - }; - obj.layout_updated(args.revision, args.parent); - } - })); - - obj.inner().item.set(item); - obj.inner().dbus_menu.set(menu); - - println!("{:#?}", layout); - obj.populate_menu(&obj.inner().vbox, &layout); - - Ok(obj) - } - - fn inner(&self) -> &StatusMenuInner { - StatusMenuInner::from_instance(self) - } - - fn layout_updated(&self, _revision: u32, parent: i32) { - let mut menus = self.inner().menus.borrow_mut(); - - if let Some(Menu { box_, children }) = menus.remove(&parent) { - let mut next_child = box_.first_child(); - while let Some(child) = next_child { - next_child = child.next_sibling(); - box_.remove(&child); - } - - fn remove_child_menus(menus: &mut HashMap, children: Vec) { - for i in children { - if let Some(menu) = menus.remove(&i) { - remove_child_menus(menus, menu.children); - } - } - } - remove_child_menus(&mut menus, children); - - glib::MainContext::default().spawn_local(clone!(@weak self as self_ => async move { - match self_.inner().dbus_menu.get_layout(parent, -1, &[]).await { - Ok((_, layout)) => self_.populate_menu(&box_, &layout), - Err(err) => eprintln!("Failed to call 'GetLayout': {}", err), - } - })); - } - } - - fn populate_menu(&self, box_: >k4::Box, layout: &Layout) { - let mut children = Vec::new(); - - for i in layout.children() { - children.push(i.id()); - - if i.type_().as_deref() == Some("separator") { - let separator = cascade! { - gtk4::Separator::new(gtk4::Orientation::Horizontal); - ..set_visible(i.visible()); - }; - box_.append(&separator); - } else if let Some(label) = i.label() { - let mut label = label.to_string(); - if let Some(toggle_state) = i.toggle_state() { - if toggle_state != 0 { - label = format!("✓ {}", label); - } - } - - let label_widget = cascade! { - gtk4::Label::new(Some(&label)); - ..set_halign(gtk4::Align::Start); - ..set_hexpand(true); - ..set_use_underline(true); - }; - - let hbox = cascade! { - gtk4::Box::new(gtk4::Orientation::Horizontal, 0); - ..append(&label_widget); - }; - - if let Some(icon_data) = i.icon_data() { - let icon_data = io::Cursor::new(icon_data.to_vec()); - let pixbuf = gdk_pixbuf::Pixbuf::from_read(icon_data).unwrap(); // XXX unwrap - let image = cascade! { - gtk4::Image::from_pixbuf(Some(&pixbuf)); - ..set_halign(gtk4::Align::End); - }; - hbox.append(&image); - } - - let id = i.id(); - let close_on_click = i.children_display().as_deref() != Some("submenu"); - let button = cascade! { - gtk4::Button::new(); - ..set_child(Some(&hbox)); - ..style_context().add_class("flat"); - ..set_visible(i.visible()); - ..set_sensitive(i.enabled()); - ..connect_clicked(clone!(@weak self as self_ => move |_| { - // XXX data, timestamp - if close_on_click { - self_.inner().menu_button.popdown(); - } - glib::MainContext::default().spawn_local(clone!(@strong self_ => async move { - let _ = self_.inner().dbus_menu.event(id, "clicked", &0.into(), 0).await; - })); - })); - }; - box_.append(&button); - - if i.children_display().as_deref() == Some("submenu") { - let vbox = cascade! { - gtk4::Box::new(gtk4::Orientation::Vertical, 0); - }; - - let revealer = cascade! { - gtk4::Revealer::new(); - ..set_child(Some(&vbox)); - }; - - self.populate_menu(&vbox, &i); - - box_.append(&revealer); - - button.connect_clicked(move |_| { - revealer.set_reveal_child(!revealer.reveals_child()); - }); - } - } - } - - self.inner().menus.borrow_mut().insert( - layout.id(), - Menu { - box_: box_.clone(), - children, - }, - ); - } -} - -#[dbus_proxy(interface = "org.kde.StatusNotifierItem")] -trait StatusNotifierItem { - #[dbus_proxy(property)] - fn icon_name(&self) -> zbus::Result; - - #[dbus_proxy(property)] - fn menu(&self) -> zbus::Result; -} - -#[derive(Debug)] -pub struct Layout(i32, LayoutProps, Vec); - -impl<'a> serde::Deserialize<'a> for Layout { - fn deserialize>(deserializer: D) -> Result { - let (id, props, children) = - <(i32, LayoutProps, Vec<(zvariant::Signature<'_>, Self)>)>::deserialize(deserializer)?; - Ok(Self(id, props, children.into_iter().map(|x| x.1).collect())) - } -} - -impl zvariant::Type for Layout { - fn signature() -> zvariant::Signature<'static> { - zvariant::Signature::try_from("(ia{sv}av)").unwrap() - } -} - -#[derive(Debug, zvariant::DeserializeDict, zvariant::Type)] -pub struct LayoutProps { - #[zvariant(rename = "accessible-desc")] - accessible_desc: Option, - #[zvariant(rename = "children-display")] - children_display: Option, - label: Option, - enabled: Option, - visible: Option, - #[zvariant(rename = "type")] - type_: Option, - #[zvariant(rename = "toggle-type")] - toggle_type: Option, - #[zvariant(rename = "toggle-state")] - toggle_state: Option, - #[zvariant(rename = "icon-data")] - icon_data: Option>, -} - -#[allow(dead_code)] -impl Layout { - fn id(&self) -> i32 { - self.0 - } - - fn children(&self) -> &[Self] { - &self.2 - } - - fn accessible_desc(&self) -> Option<&str> { - self.1.accessible_desc.as_deref() - } - - fn children_display(&self) -> Option<&str> { - self.1.children_display.as_deref() - } - - fn label(&self) -> Option<&str> { - self.1.label.as_deref() - } - - fn enabled(&self) -> bool { - self.1.enabled.unwrap_or(true) - } - - fn visible(&self) -> bool { - self.1.visible.unwrap_or(true) - } - - fn type_(&self) -> Option<&str> { - self.1.type_.as_deref() - } - - fn toggle_type(&self) -> Option<&str> { - self.1.toggle_type.as_deref() - } - - fn toggle_state(&self) -> Option { - self.1.toggle_state - } - - fn icon_data(&self) -> Option<&[u8]> { - self.1.icon_data.as_deref() - } -} - -#[dbus_proxy(interface = "com.canonical.dbusmenu")] -trait DBusMenu { - fn get_layout( - &self, - parent_id: i32, - recursion_depth: i32, - property_names: &[&str], - ) -> zbus::Result<(u32, Layout)>; - - fn event(&self, id: i32, event_id: &str, data: &OwnedValue, timestamp: u32) - -> zbus::Result<()>; - - #[dbus_proxy(signal)] - fn layout_updated(&self, revision: u32, parent: i32) -> zbus::Result<()>; -} diff --git a/applets/cosmic-applet-status-area/src/status_notifier_watcher.rs b/applets/cosmic-applet-status-area/src/status_notifier_watcher.rs deleted file mode 100644 index cfefcdf2..00000000 --- a/applets/cosmic-applet-status-area/src/status_notifier_watcher.rs +++ /dev/null @@ -1,140 +0,0 @@ -#![allow(non_snake_case)] - -use futures::prelude::*; -use gtk4::glib::{self, clone}; -use std::cell::Cell; -use zbus::{ - dbus_interface, - fdo::{DBusProxy, RequestNameFlags, RequestNameReply}, - names::{BusName, UniqueName, WellKnownName}, - MessageHeader, Result, SignalContext, -}; - -const OBJECT_PATH: &str = "/StatusNotifierWatcher"; - -#[derive(Default)] -struct StatusNotifierWatcher { - items: Vec<(UniqueName<'static>, String)>, -} - -#[dbus_interface(name = "org.kde.StatusNotifierWatcher")] -impl StatusNotifierWatcher { - async fn register_status_notifier_item( - &mut self, - service: &str, - #[zbus(header)] hdr: MessageHeader<'_>, - #[zbus(signal_context)] ctxt: SignalContext<'_>, - ) { - let sender = hdr.sender().unwrap().unwrap(); - let service = if service.starts_with('/') { - format!("{}{}", sender, service) - } else { - service.to_string() - }; - Self::status_notifier_item_registered(&ctxt, &service) - .await - .unwrap(); - - self.items.push((sender.to_owned(), service)); - } - - fn register_status_notifier_host(&self, _service: &str) { - // XXX emit registed/unregistered - } - - #[dbus_interface(property)] - fn registered_status_notifier_items(&self) -> Vec { - self.items.iter().map(|(_, x)| x.clone()).collect() - } - - #[dbus_interface(property)] - fn is_status_notifier_host_registered(&self) -> bool { - true - } - - #[dbus_interface(property)] - fn protocol_version(&self) -> i32 { - 0 - } - - #[dbus_interface(signal)] - async fn status_notifier_item_registered(ctxt: &SignalContext<'_>, service: &str) - -> Result<()>; - - #[dbus_interface(signal)] - async fn status_notifier_item_unregistered( - ctxt: &SignalContext<'_>, - service: &str, - ) -> Result<()>; - - #[dbus_interface(signal)] - async fn status_notifier_host_registered(ctxt: &SignalContext<'_>) -> Result<()>; - - #[dbus_interface(signal)] - async fn status_notifier_host_unregistered(ctxt: &SignalContext<'_>) -> Result<()>; -} - -async fn create_service() -> zbus::Result { - let well_known_name = WellKnownName::try_from("org.kde.StatusNotifierWatcher")?; - - let connection = zbus::ConnectionBuilder::session()?.build().await?; - connection - .object_server() - .at(OBJECT_PATH, StatusNotifierWatcher::default()) - .await?; - let interface = connection - .object_server() - .interface::<_, StatusNotifierWatcher>(OBJECT_PATH) - .await - .unwrap(); - let dbus_proxy = DBusProxy::new(&connection).await?; - let mut name_owner_changed_stream = dbus_proxy.receive_name_owner_changed().await?; - - let flags = RequestNameFlags::AllowReplacement.into(); - match dbus_proxy - .request_name(well_known_name.as_ref(), flags) - .await? - { - RequestNameReply::InQueue => { - eprintln!("Bus name '{}' already owned", well_known_name); - } - _ => {} - } - - glib::MainContext::default().spawn_local(clone!(@strong connection => async move { - let have_bus_name = Cell::new(false); - let unique_name = connection.unique_name().map(|x| x.as_ref()); - while let Some(evt) = name_owner_changed_stream.next().await { - let args = match evt.args() { - Ok(args) => args, - Err(_) => { continue; }, - }; - if args.name.as_ref() == well_known_name { - if args.new_owner.as_ref() == unique_name.as_ref() { - eprintln!("Acquired bus name: {}", well_known_name); - have_bus_name.set(true); - } else if have_bus_name.get() { - eprintln!("Lost bus name: {}", well_known_name); - have_bus_name.set(false); - } - } else if let BusName::Unique(name) = &args.name { - let mut interface = interface.get_mut().await; - if let Some(idx) = interface.items.iter().position(|(unique_name, _)| unique_name == name) { - let ctxt = zbus::SignalContext::new(&connection, OBJECT_PATH).unwrap(); - let service = interface.items.remove(idx).1; - StatusNotifierWatcher::status_notifier_item_unregistered(&ctxt, &service) - .await - .unwrap(); - } - } - } - })); - - Ok(connection) -} - -pub async fn start() { - if let Err(err) = create_service().await { - eprintln!("Failed to start `StatusNotifierWatcher` service: {}", err); - } -} diff --git a/applets/cosmic-panel-button/Cargo.toml b/applets/cosmic-panel-button/Cargo.toml deleted file mode 100644 index b6e3c8cb..00000000 --- a/applets/cosmic-panel-button/Cargo.toml +++ /dev/null @@ -1,21 +0,0 @@ -[package] -name = "cosmic-panel-button" -version = "0.1.0" -edition = "2021" - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html -[dependencies] -cosmic-panel-config = {git = "https://github.com/pop-os/cosmic-panel", features = ["gtk4"] } -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" -i18n-embed = { version = "0.13.4", features = ["fluent-system", "desktop-requester"] } -i18n-embed-fl = "0.6.4" -rust-embed = "6.3.0" - -[build-dependencies] -glib-build-tools = { git = "https://github.com/gtk-rs/gtk-rs-core" } diff --git a/applets/cosmic-panel-button/build.rs b/applets/cosmic-panel-button/build.rs deleted file mode 100644 index 534daf98..00000000 --- a/applets/cosmic-panel-button/build.rs +++ /dev/null @@ -1,7 +0,0 @@ -fn main() { - glib_build_tools::compile_resources( - "data/resources", - "data/resources/resources.gresource.xml", - "compiled.gresource", - ); -} diff --git a/applets/cosmic-panel-button/i18n.toml b/applets/cosmic-panel-button/i18n.toml deleted file mode 100644 index 05c50ba2..00000000 --- a/applets/cosmic-panel-button/i18n.toml +++ /dev/null @@ -1,4 +0,0 @@ -fallback_language = "en" - -[fluent] -assets_dir = "i18n" \ No newline at end of file diff --git a/applets/cosmic-panel-button/i18n/en/cosmic_panel_button.ftl b/applets/cosmic-panel-button/i18n/en/cosmic_panel_button.ftl deleted file mode 100644 index 78cecf6b..00000000 --- a/applets/cosmic-panel-button/i18n/en/cosmic_panel_button.ftl +++ /dev/null @@ -1 +0,0 @@ -cosmic-panel-button = Cosmic Panel Button \ No newline at end of file diff --git a/applets/cosmic-panel-button/i18n/fr/cosmic_panel_button.ftl b/applets/cosmic-panel-button/i18n/fr/cosmic_panel_button.ftl deleted file mode 100644 index 2bce1ee6..00000000 --- a/applets/cosmic-panel-button/i18n/fr/cosmic_panel_button.ftl +++ /dev/null @@ -1 +0,0 @@ -cosmic-panel-button = Bouton du panneau Cosmic \ No newline at end of file diff --git a/applets/cosmic-panel-button/src/apps_window/imp.rs b/applets/cosmic-panel-button/src/apps_window/imp.rs deleted file mode 100644 index 39e74b24..00000000 --- a/applets/cosmic-panel-button/src/apps_window/imp.rs +++ /dev/null @@ -1,28 +0,0 @@ -// SPDX-License-Identifier: MPL-2.0-only - -use gtk4::{glib, subclass::prelude::*}; -// Object holding the state -#[derive(Default)] - -pub struct CosmicPanelAppButtonWindow {} - -// The central trait for subclassing a GObject -#[glib::object_subclass] -impl ObjectSubclass for CosmicPanelAppButtonWindow { - // `NAME` needs to match `class` attribute of template - const NAME: &'static str = "CosmicPanelAppButtonWindow"; - type Type = super::CosmicPanelAppButtonWindow; - type ParentType = gtk4::ApplicationWindow; -} - -// Trait shared by all GObjects -impl ObjectImpl for CosmicPanelAppButtonWindow {} - -// Trait shared by all widgets -impl WidgetImpl for CosmicPanelAppButtonWindow {} - -// Trait shared by all windows -impl WindowImpl for CosmicPanelAppButtonWindow {} - -// Trait shared by all application -impl ApplicationWindowImpl for CosmicPanelAppButtonWindow {} diff --git a/applets/cosmic-panel-button/src/apps_window/mod.rs b/applets/cosmic-panel-button/src/apps_window/mod.rs deleted file mode 100644 index e63fd0b8..00000000 --- a/applets/cosmic-panel-button/src/apps_window/mod.rs +++ /dev/null @@ -1,83 +0,0 @@ -// SPDX-License-Identifier: MPL-2.0-only - -use crate::fl; -use cascade::cascade; -use cosmic_panel_config::{CosmicPanelConfig, PanelSize}; -use gtk4::{ - gio::{self, DesktopAppInfo, Icon}, - glib::{self, Object}, - prelude::*, - Align, Application, Button, Orientation, -}; -use std::process::Command; - -mod imp; - -glib::wrapper! { - pub struct CosmicPanelAppButtonWindow(ObjectSubclass) - @extends gtk4::ApplicationWindow, gtk4::Window, gtk4::Widget, - @implements gio::ActionGroup, gio::ActionMap, gtk4::Accessible, gtk4::Buildable, - gtk4::ConstraintTarget, gtk4::Native, gtk4::Root, gtk4::ShortcutManager; -} - -impl CosmicPanelAppButtonWindow { - pub fn new(app: &Application, app_desktop_file_name: &str) -> Self { - let self_: Self = Object::new(&[("application", app)]) - .expect("Failed to create `CosmicPanelButtonWindow`."); - cascade! { - &self_; - ..set_width_request(1); - ..set_height_request(1); - ..set_decorated(false); - ..set_resizable(false); - ..set_title(Some(app_desktop_file_name)); - ..add_css_class("root_window"); - }; - - if let Some(apps_desktop_info) = - DesktopAppInfo::new(&format!("{}.desktop", app_desktop_file_name)) - { - let app_button = cascade! { - Button::new(); - ..add_css_class("apps"); - }; - let pixels = std::env::var("COSMIC_PANEL_SIZE") - .ok() - .and_then(|size| match size.parse::() { - 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") - }); - let container = gtk4::Box::new(Orientation::Horizontal, 0); - let image = cascade! { - gtk4::Image::from_gicon(&icon); - ..set_hexpand(true); - ..set_halign(Align::Center); - ..set_pixel_size(pixels); - ..set_tooltip_text(Some(&apps_desktop_info.name())); - }; - container.append(&image); - - app_button.set_child(Some(&container)); - let app_id = app_desktop_file_name.to_string(); - app_button.connect_clicked(move |_| { - let _ = Command::new("xdg-shell-wrapper") - .env_remove("WAYLAND_SOCKET") - .arg(&app_id) - .spawn(); - }); - self_.set_child(Some(&app_button)); - } else { - panic!("{} is not installed", app_desktop_file_name); - } - - self_ - } -} diff --git a/applets/cosmic-panel-button/src/localize.rs b/applets/cosmic-panel-button/src/localize.rs deleted file mode 100644 index efb92aa4..00000000 --- a/applets/cosmic-panel-button/src/localize.rs +++ /dev/null @@ -1,38 +0,0 @@ -// SPDX-License-Identifier: MPL-2.0-only - -use i18n_embed::{ - fluent::{fluent_language_loader, FluentLanguageLoader}, - DefaultLocalizer, LanguageLoader, Localizer, -}; -use once_cell::sync::Lazy; -use rust_embed::RustEmbed; - -#[derive(RustEmbed)] -#[folder = "i18n/"] -struct Localizations; - -pub static LANGUAGE_LOADER: Lazy = Lazy::new(|| { - let loader: FluentLanguageLoader = fluent_language_loader!(); - - loader - .load_fallback_language(&Localizations) - .expect("Error while loading fallback language"); - - loader -}); - -#[macro_export] -macro_rules! fl { - ($message_id:literal) => {{ - i18n_embed_fl::fl!($crate::localize::LANGUAGE_LOADER, $message_id) - }}; - - ($message_id:literal, $($args:expr),*) => {{ - i18n_embed_fl::fl!($crate::localize::LANGUAGE_LOADER, $message_id, $($args), *) - }}; -} - -// Get the `Localizer` to be used for localizing this library. -pub fn localizer() -> Box { - Box::from(DefaultLocalizer::new(&*LANGUAGE_LOADER, &Localizations)) -} diff --git a/applets/cosmic-panel-button/src/main.rs b/applets/cosmic-panel-button/src/main.rs deleted file mode 100644 index f1c35b2a..00000000 --- a/applets/cosmic-panel-button/src/main.rs +++ /dev/null @@ -1,73 +0,0 @@ -// SPDX-License-Identifier: MPL-2.0-only - -use apps_window::CosmicPanelAppButtonWindow; -use gtk4::gdk::Display; -use gtk4::{ - gio::{self, ApplicationFlags}, - glib, - prelude::*, - CssProvider, StyleContext, -}; -use once_cell::sync::OnceCell; - -mod apps_window; -mod localize; -mod utils; - -static ID: OnceCell = OnceCell::new(); - -pub fn localize() { - let localizer = crate::localize::localizer(); - let requested_languages = i18n_embed::DesktopLanguageRequester::requested_languages(); - - 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_data(include_bytes!("style.css")); - - StyleContext::add_provider_for_display( - &Display::default().unwrap(), - &provider, - gtk4::STYLE_PROVIDER_PRIORITY_APPLICATION, - ); -} - -fn main() { - let _monitors = libcosmic::init(); - - // Initialize logger - pretty_env_logger::init(); - glib::set_application_name("Cosmic Panel App Button"); - - localize(); - gio::resources_register_include!("compiled.gresource").unwrap(); - let app = gtk4::Application::new(None, ApplicationFlags::default()); - app.add_main_option( - "id", - glib::Char::from(b'i'), - glib::OptionFlags::NONE, - glib::OptionArg::String, - "id of the launched application", - None, - ); - app.connect_handle_local_options(|_app, args| { - if let Ok(Some(id)) = args.lookup::("id") { - ID.set(id).unwrap(); - -1 - } else { - 1 - } - }); - app.connect_activate(|app| { - load_css(); - let id = ID.get().unwrap().clone(); - let window = CosmicPanelAppButtonWindow::new(app, &id); - - window.show(); - }); - app.run(); -} diff --git a/applets/cosmic-panel-button/src/style.css b/applets/cosmic-panel-button/src/style.css deleted file mode 100644 index 794da45a..00000000 --- a/applets/cosmic-panel-button/src/style.css +++ /dev/null @@ -1,28 +0,0 @@ -button { - border-radius: 12px; - transition: 100ms; - padding: 4px; - border-color: transparent; - background: transparent; - outline-color: transparent; -} - -button:hover { - border-radius: 12px; - transition: 100ms; - padding: 4px; - border-color: rgba(255, 255, 255, 0.1); - outline-color: rgba(255, 255, 255, 0.1); - background: rgba(255, 255, 255, 0.1); -} - -image { - border-color: transparent; - background: transparent; - outline-color: transparent; - padding: 0px; -} - -window.root_window { - background: transparent; -} diff --git a/applets/cosmic-panel-button/src/utils.rs b/applets/cosmic-panel-button/src/utils.rs deleted file mode 100644 index c66833d0..00000000 --- a/applets/cosmic-panel-button/src/utils.rs +++ /dev/null @@ -1,26 +0,0 @@ -// SPDX-License-Identifier: MPL-2.0-only - -use std::path::PathBuf; - -use gtk4::glib; -use std::future::Future; - -pub fn data_path(id: &str) -> PathBuf { - let mut path = glib::user_data_dir(); - path.push(id); - std::fs::create_dir_all(&path).expect("Could not create directory."); - path.push("data.json"); - path -} - -pub fn thread_context() -> glib::MainContext { - glib::MainContext::thread_default().unwrap_or_else(|| glib::MainContext::new()) -} - -pub fn block_on(future: F) -> F::Output -where - F: Future, -{ - let ctx = thread_context(); - ctx.with_thread_default(|| ctx.block_on(future)).unwrap() -} diff --git a/applets/cosmic-panel-workspaces-button/data/resources/resources.gresource.xml b/applets/cosmic-panel-workspaces-button/data/resources/resources.gresource.xml deleted file mode 100644 index 3e8c922d..00000000 --- a/applets/cosmic-panel-workspaces-button/data/resources/resources.gresource.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/applets/cosmic-app-list/Cargo.lock b/cosmic-app-list/Cargo.lock similarity index 100% rename from applets/cosmic-app-list/Cargo.lock rename to cosmic-app-list/Cargo.lock diff --git a/applets/cosmic-app-list/Cargo.toml b/cosmic-app-list/Cargo.toml similarity index 100% rename from applets/cosmic-app-list/Cargo.toml rename to cosmic-app-list/Cargo.toml diff --git a/applets/cosmic-app-list/data/com.system76.CosmicAppList.desktop b/cosmic-app-list/data/com.system76.CosmicAppList.desktop similarity index 100% rename from applets/cosmic-app-list/data/com.system76.CosmicAppList.desktop rename to cosmic-app-list/data/com.system76.CosmicAppList.desktop diff --git a/applets/cosmic-app-list/data/com.system76.CosmicAppList.metainfo.xml b/cosmic-app-list/data/com.system76.CosmicAppList.metainfo.xml similarity index 100% rename from applets/cosmic-app-list/data/com.system76.CosmicAppList.metainfo.xml rename to cosmic-app-list/data/com.system76.CosmicAppList.metainfo.xml diff --git a/applets/cosmic-app-list/data/icons/com.system76.CosmicAppList-symbolic.svg b/cosmic-app-list/data/icons/com.system76.CosmicAppList-symbolic.svg similarity index 100% rename from applets/cosmic-app-list/data/icons/com.system76.CosmicAppList-symbolic.svg rename to cosmic-app-list/data/icons/com.system76.CosmicAppList-symbolic.svg diff --git a/applets/cosmic-app-list/data/icons/com.system76.CosmicAppList.Devel.svg b/cosmic-app-list/data/icons/com.system76.CosmicAppList.Devel.svg similarity index 100% rename from applets/cosmic-app-list/data/icons/com.system76.CosmicAppList.Devel.svg rename to cosmic-app-list/data/icons/com.system76.CosmicAppList.Devel.svg diff --git a/applets/cosmic-app-list/data/icons/com.system76.CosmicAppList.svg b/cosmic-app-list/data/icons/com.system76.CosmicAppList.svg similarity index 100% rename from applets/cosmic-app-list/data/icons/com.system76.CosmicAppList.svg rename to cosmic-app-list/data/icons/com.system76.CosmicAppList.svg diff --git a/applets/cosmic-app-list/i18n.toml b/cosmic-app-list/i18n.toml similarity index 100% rename from applets/cosmic-app-list/i18n.toml rename to cosmic-app-list/i18n.toml diff --git a/applets/cosmic-app-list/i18n/en/cosmic_app_list.ftl b/cosmic-app-list/i18n/en/cosmic_app_list.ftl similarity index 100% rename from applets/cosmic-app-list/i18n/en/cosmic_app_list.ftl rename to cosmic-app-list/i18n/en/cosmic_app_list.ftl diff --git a/applets/cosmic-app-list/i18n/fr/cosmic_app_list.ftl b/cosmic-app-list/i18n/fr/cosmic_app_list.ftl similarity index 100% rename from applets/cosmic-app-list/i18n/fr/cosmic_app_list.ftl rename to cosmic-app-list/i18n/fr/cosmic_app_list.ftl diff --git a/applets/cosmic-app-list/i18n/ko/cosmic_app_list.ftl b/cosmic-app-list/i18n/ko/cosmic_app_list.ftl similarity index 100% rename from applets/cosmic-app-list/i18n/ko/cosmic_app_list.ftl rename to cosmic-app-list/i18n/ko/cosmic_app_list.ftl diff --git a/applets/cosmic-app-list/src/app.rs b/cosmic-app-list/src/app.rs similarity index 100% rename from applets/cosmic-app-list/src/app.rs rename to cosmic-app-list/src/app.rs diff --git a/applets/cosmic-app-list/src/config.ron b/cosmic-app-list/src/config.ron similarity index 100% rename from applets/cosmic-app-list/src/config.ron rename to cosmic-app-list/src/config.ron diff --git a/applets/cosmic-app-list/src/config.rs b/cosmic-app-list/src/config.rs similarity index 100% rename from applets/cosmic-app-list/src/config.rs rename to cosmic-app-list/src/config.rs diff --git a/applets/cosmic-app-list/src/localize.rs b/cosmic-app-list/src/localize.rs similarity index 100% rename from applets/cosmic-app-list/src/localize.rs rename to cosmic-app-list/src/localize.rs diff --git a/applets/cosmic-app-list/src/main.rs b/cosmic-app-list/src/main.rs similarity index 100% rename from applets/cosmic-app-list/src/main.rs rename to cosmic-app-list/src/main.rs diff --git a/applets/cosmic-app-list/src/toplevel_handler.rs b/cosmic-app-list/src/toplevel_handler.rs similarity index 100% rename from applets/cosmic-app-list/src/toplevel_handler.rs rename to cosmic-app-list/src/toplevel_handler.rs diff --git a/applets/cosmic-app-list/src/toplevel_subscription.rs b/cosmic-app-list/src/toplevel_subscription.rs similarity index 100% rename from applets/cosmic-app-list/src/toplevel_subscription.rs rename to cosmic-app-list/src/toplevel_subscription.rs diff --git a/applets/cosmic-app-list/src/utils.rs b/cosmic-app-list/src/utils.rs similarity index 100% rename from applets/cosmic-app-list/src/utils.rs rename to cosmic-app-list/src/utils.rs diff --git a/applets/cosmic-applet-audio/Cargo.lock b/cosmic-applet-audio/Cargo.lock similarity index 100% rename from applets/cosmic-applet-audio/Cargo.lock rename to cosmic-applet-audio/Cargo.lock diff --git a/applets/cosmic-applet-audio/Cargo.toml b/cosmic-applet-audio/Cargo.toml similarity index 100% rename from applets/cosmic-applet-audio/Cargo.toml rename to cosmic-applet-audio/Cargo.toml diff --git a/applets/cosmic-applet-audio/data/com.system76.CosmicAppletAudio.desktop b/cosmic-applet-audio/data/com.system76.CosmicAppletAudio.desktop similarity index 100% rename from applets/cosmic-applet-audio/data/com.system76.CosmicAppletAudio.desktop rename to cosmic-applet-audio/data/com.system76.CosmicAppletAudio.desktop diff --git a/applets/cosmic-applet-audio/data/icons/com.system76.CosmicAppletAudio.svg b/cosmic-applet-audio/data/icons/com.system76.CosmicAppletAudio.svg similarity index 100% rename from applets/cosmic-applet-audio/data/icons/com.system76.CosmicAppletAudio.svg rename to cosmic-applet-audio/data/icons/com.system76.CosmicAppletAudio.svg diff --git a/applets/cosmic-applet-audio/data/resources/resources.gresource.xml b/cosmic-applet-audio/data/resources/resources.gresource.xml similarity index 100% rename from applets/cosmic-applet-audio/data/resources/resources.gresource.xml rename to cosmic-applet-audio/data/resources/resources.gresource.xml diff --git a/applets/cosmic-applet-audio/src/main.rs b/cosmic-applet-audio/src/main.rs similarity index 100% rename from applets/cosmic-applet-audio/src/main.rs rename to cosmic-applet-audio/src/main.rs diff --git a/applets/cosmic-applet-audio/src/pulse.rs b/cosmic-applet-audio/src/pulse.rs similarity index 100% rename from applets/cosmic-applet-audio/src/pulse.rs rename to cosmic-applet-audio/src/pulse.rs diff --git a/applets/cosmic-applet-battery/Cargo.lock b/cosmic-applet-battery/Cargo.lock similarity index 100% rename from applets/cosmic-applet-battery/Cargo.lock rename to cosmic-applet-battery/Cargo.lock diff --git a/applets/cosmic-applet-battery/Cargo.toml b/cosmic-applet-battery/Cargo.toml similarity index 100% rename from applets/cosmic-applet-battery/Cargo.toml rename to cosmic-applet-battery/Cargo.toml diff --git a/applets/cosmic-applet-battery/data/com.system76.CosmicAppletBattery.desktop b/cosmic-applet-battery/data/com.system76.CosmicAppletBattery.desktop similarity index 100% rename from applets/cosmic-applet-battery/data/com.system76.CosmicAppletBattery.desktop rename to cosmic-applet-battery/data/com.system76.CosmicAppletBattery.desktop diff --git a/applets/cosmic-applet-battery/data/icons/com.system76.CosmicAppletBattery.svg b/cosmic-applet-battery/data/icons/com.system76.CosmicAppletBattery.svg similarity index 100% rename from applets/cosmic-applet-battery/data/icons/com.system76.CosmicAppletBattery.svg rename to cosmic-applet-battery/data/icons/com.system76.CosmicAppletBattery.svg diff --git a/applets/cosmic-applet-battery/i18n.toml b/cosmic-applet-battery/i18n.toml similarity index 100% rename from applets/cosmic-applet-battery/i18n.toml rename to cosmic-applet-battery/i18n.toml diff --git a/applets/cosmic-applet-battery/i18n/en/cosmic_applet_battery.ftl b/cosmic-applet-battery/i18n/en/cosmic_applet_battery.ftl similarity index 100% rename from applets/cosmic-applet-battery/i18n/en/cosmic_applet_battery.ftl rename to cosmic-applet-battery/i18n/en/cosmic_applet_battery.ftl diff --git a/applets/cosmic-applet-battery/i18n/fr/cosmic_applet_battery.ftl b/cosmic-applet-battery/i18n/fr/cosmic_applet_battery.ftl similarity index 100% rename from applets/cosmic-applet-battery/i18n/fr/cosmic_applet_battery.ftl rename to cosmic-applet-battery/i18n/fr/cosmic_applet_battery.ftl diff --git a/applets/cosmic-applet-battery/src/app.rs b/cosmic-applet-battery/src/app.rs similarity index 100% rename from applets/cosmic-applet-battery/src/app.rs rename to cosmic-applet-battery/src/app.rs diff --git a/applets/cosmic-applet-battery/src/backlight.rs b/cosmic-applet-battery/src/backlight.rs similarity index 100% rename from applets/cosmic-applet-battery/src/backlight.rs rename to cosmic-applet-battery/src/backlight.rs diff --git a/applets/cosmic-applet-battery/src/config.rs b/cosmic-applet-battery/src/config.rs similarity index 100% rename from applets/cosmic-applet-battery/src/config.rs rename to cosmic-applet-battery/src/config.rs diff --git a/applets/cosmic-applet-battery/src/localize.rs b/cosmic-applet-battery/src/localize.rs similarity index 100% rename from applets/cosmic-applet-battery/src/localize.rs rename to cosmic-applet-battery/src/localize.rs diff --git a/applets/cosmic-applet-battery/src/main.rs b/cosmic-applet-battery/src/main.rs similarity index 100% rename from applets/cosmic-applet-battery/src/main.rs rename to cosmic-applet-battery/src/main.rs diff --git a/applets/cosmic-applet-battery/src/power_daemon.rs b/cosmic-applet-battery/src/power_daemon.rs similarity index 100% rename from applets/cosmic-applet-battery/src/power_daemon.rs rename to cosmic-applet-battery/src/power_daemon.rs diff --git a/applets/cosmic-applet-battery/src/upower.rs b/cosmic-applet-battery/src/upower.rs similarity index 100% rename from applets/cosmic-applet-battery/src/upower.rs rename to cosmic-applet-battery/src/upower.rs diff --git a/applets/cosmic-applet-battery/src/upower_device.rs b/cosmic-applet-battery/src/upower_device.rs similarity index 100% rename from applets/cosmic-applet-battery/src/upower_device.rs rename to cosmic-applet-battery/src/upower_device.rs diff --git a/applets/cosmic-applet-battery/src/upower_kbdbacklight.rs b/cosmic-applet-battery/src/upower_kbdbacklight.rs similarity index 100% rename from applets/cosmic-applet-battery/src/upower_kbdbacklight.rs rename to cosmic-applet-battery/src/upower_kbdbacklight.rs diff --git a/applets/cosmic-applet-graphics/Cargo.lock b/cosmic-applet-graphics/Cargo.lock similarity index 100% rename from applets/cosmic-applet-graphics/Cargo.lock rename to cosmic-applet-graphics/Cargo.lock diff --git a/applets/cosmic-applet-graphics/Cargo.toml b/cosmic-applet-graphics/Cargo.toml similarity index 100% rename from applets/cosmic-applet-graphics/Cargo.toml rename to cosmic-applet-graphics/Cargo.toml diff --git a/applets/cosmic-applet-graphics/data/com.system76.CosmicAppletGraphics.desktop b/cosmic-applet-graphics/data/com.system76.CosmicAppletGraphics.desktop similarity index 100% rename from applets/cosmic-applet-graphics/data/com.system76.CosmicAppletGraphics.desktop rename to cosmic-applet-graphics/data/com.system76.CosmicAppletGraphics.desktop diff --git a/applets/cosmic-applet-graphics/data/icons/com.system76.CosmicAppletGraphics.svg b/cosmic-applet-graphics/data/icons/com.system76.CosmicAppletGraphics.svg similarity index 100% rename from applets/cosmic-applet-graphics/data/icons/com.system76.CosmicAppletGraphics.svg rename to cosmic-applet-graphics/data/icons/com.system76.CosmicAppletGraphics.svg diff --git a/applets/cosmic-applet-graphics/data/resources/resources.gresource.xml b/cosmic-applet-graphics/data/resources/resources.gresource.xml similarity index 100% rename from applets/cosmic-applet-graphics/data/resources/resources.gresource.xml rename to cosmic-applet-graphics/data/resources/resources.gresource.xml diff --git a/applets/cosmic-applet-graphics/src/dbus.rs b/cosmic-applet-graphics/src/dbus.rs similarity index 100% rename from applets/cosmic-applet-graphics/src/dbus.rs rename to cosmic-applet-graphics/src/dbus.rs diff --git a/applets/cosmic-applet-graphics/src/graphics.rs b/cosmic-applet-graphics/src/graphics.rs similarity index 100% rename from applets/cosmic-applet-graphics/src/graphics.rs rename to cosmic-applet-graphics/src/graphics.rs diff --git a/applets/cosmic-applet-graphics/src/main.rs b/cosmic-applet-graphics/src/main.rs similarity index 100% rename from applets/cosmic-applet-graphics/src/main.rs rename to cosmic-applet-graphics/src/main.rs diff --git a/applets/cosmic-applet-graphics/src/window.rs b/cosmic-applet-graphics/src/window.rs similarity index 100% rename from applets/cosmic-applet-graphics/src/window.rs rename to cosmic-applet-graphics/src/window.rs diff --git a/applets/cosmic-applet-network/Cargo.lock b/cosmic-applet-network/Cargo.lock similarity index 100% rename from applets/cosmic-applet-network/Cargo.lock rename to cosmic-applet-network/Cargo.lock diff --git a/applets/cosmic-applet-network/Cargo.toml b/cosmic-applet-network/Cargo.toml similarity index 100% rename from applets/cosmic-applet-network/Cargo.toml rename to cosmic-applet-network/Cargo.toml diff --git a/applets/cosmic-applet-network/data/com.system76.CosmicAppletNetwork.desktop b/cosmic-applet-network/data/com.system76.CosmicAppletNetwork.desktop similarity index 100% rename from applets/cosmic-applet-network/data/com.system76.CosmicAppletNetwork.desktop rename to cosmic-applet-network/data/com.system76.CosmicAppletNetwork.desktop diff --git a/applets/cosmic-applet-network/data/icons/com.system76.CosmicAppletNetwork.svg b/cosmic-applet-network/data/icons/com.system76.CosmicAppletNetwork.svg similarity index 100% rename from applets/cosmic-applet-network/data/icons/com.system76.CosmicAppletNetwork.svg rename to cosmic-applet-network/data/icons/com.system76.CosmicAppletNetwork.svg diff --git a/applets/cosmic-applet-network/data/resources/resources.gresource.xml b/cosmic-applet-network/data/resources/resources.gresource.xml similarity index 100% rename from applets/cosmic-applet-network/data/resources/resources.gresource.xml rename to cosmic-applet-network/data/resources/resources.gresource.xml diff --git a/applets/cosmic-applet-network/i18n.toml b/cosmic-applet-network/i18n.toml similarity index 100% rename from applets/cosmic-applet-network/i18n.toml rename to cosmic-applet-network/i18n.toml diff --git a/applets/cosmic-applet-network/i18n/en/cosmic_applet_network.ftl b/cosmic-applet-network/i18n/en/cosmic_applet_network.ftl similarity index 100% rename from applets/cosmic-applet-network/i18n/en/cosmic_applet_network.ftl rename to cosmic-applet-network/i18n/en/cosmic_applet_network.ftl diff --git a/applets/cosmic-applet-network/src/app.rs b/cosmic-applet-network/src/app.rs similarity index 100% rename from applets/cosmic-applet-network/src/app.rs rename to cosmic-applet-network/src/app.rs diff --git a/applets/cosmic-applet-network/src/config.rs b/cosmic-applet-network/src/config.rs similarity index 100% rename from applets/cosmic-applet-network/src/config.rs rename to cosmic-applet-network/src/config.rs diff --git a/applets/cosmic-applet-network/src/localize.rs b/cosmic-applet-network/src/localize.rs similarity index 100% rename from applets/cosmic-applet-network/src/localize.rs rename to cosmic-applet-network/src/localize.rs diff --git a/applets/cosmic-applet-network/src/main.rs b/cosmic-applet-network/src/main.rs similarity index 100% rename from applets/cosmic-applet-network/src/main.rs rename to cosmic-applet-network/src/main.rs diff --git a/applets/cosmic-applet-network/src/network_manager/available_wifi.rs b/cosmic-applet-network/src/network_manager/available_wifi.rs similarity index 100% rename from applets/cosmic-applet-network/src/network_manager/available_wifi.rs rename to cosmic-applet-network/src/network_manager/available_wifi.rs diff --git a/applets/cosmic-applet-network/src/network_manager/current_networks.rs b/cosmic-applet-network/src/network_manager/current_networks.rs similarity index 100% rename from applets/cosmic-applet-network/src/network_manager/current_networks.rs rename to cosmic-applet-network/src/network_manager/current_networks.rs diff --git a/applets/cosmic-applet-network/src/network_manager/mod.rs b/cosmic-applet-network/src/network_manager/mod.rs similarity index 100% rename from applets/cosmic-applet-network/src/network_manager/mod.rs rename to cosmic-applet-network/src/network_manager/mod.rs diff --git a/applets/cosmic-applet-notifications/Cargo.lock b/cosmic-applet-notifications/Cargo.lock similarity index 100% rename from applets/cosmic-applet-notifications/Cargo.lock rename to cosmic-applet-notifications/Cargo.lock diff --git a/applets/cosmic-applet-notifications/Cargo.toml b/cosmic-applet-notifications/Cargo.toml similarity index 100% rename from applets/cosmic-applet-notifications/Cargo.toml rename to cosmic-applet-notifications/Cargo.toml diff --git a/applets/cosmic-applet-notifications/data/com.system76.CosmicAppletNotifications.desktop b/cosmic-applet-notifications/data/com.system76.CosmicAppletNotifications.desktop similarity index 100% rename from applets/cosmic-applet-notifications/data/com.system76.CosmicAppletNotifications.desktop rename to cosmic-applet-notifications/data/com.system76.CosmicAppletNotifications.desktop diff --git a/applets/cosmic-applet-notifications/data/icons/com.system76.CosmicAppletNotifications.svg b/cosmic-applet-notifications/data/icons/com.system76.CosmicAppletNotifications.svg similarity index 100% rename from applets/cosmic-applet-notifications/data/icons/com.system76.CosmicAppletNotifications.svg rename to cosmic-applet-notifications/data/icons/com.system76.CosmicAppletNotifications.svg diff --git a/applets/cosmic-applet-notifications/src/main.rs b/cosmic-applet-notifications/src/main.rs similarity index 100% rename from applets/cosmic-applet-notifications/src/main.rs rename to cosmic-applet-notifications/src/main.rs diff --git a/applets/cosmic-applet-power/Cargo.lock b/cosmic-applet-power/Cargo.lock similarity index 100% rename from applets/cosmic-applet-power/Cargo.lock rename to cosmic-applet-power/Cargo.lock diff --git a/applets/cosmic-applet-power/Cargo.toml b/cosmic-applet-power/Cargo.toml similarity index 100% rename from applets/cosmic-applet-power/Cargo.toml rename to cosmic-applet-power/Cargo.toml diff --git a/applets/cosmic-applet-power/data/com.system76.CosmicAppletPower.desktop b/cosmic-applet-power/data/com.system76.CosmicAppletPower.desktop similarity index 100% rename from applets/cosmic-applet-power/data/com.system76.CosmicAppletPower.desktop rename to cosmic-applet-power/data/com.system76.CosmicAppletPower.desktop diff --git a/applets/cosmic-applet-power/data/icons/com.system76.CosmicAppletPower.svg b/cosmic-applet-power/data/icons/com.system76.CosmicAppletPower.svg similarity index 100% rename from applets/cosmic-applet-power/data/icons/com.system76.CosmicAppletPower.svg rename to cosmic-applet-power/data/icons/com.system76.CosmicAppletPower.svg diff --git a/applets/cosmic-applet-power/data/resources/resources.gresource.xml b/cosmic-applet-power/data/resources/resources.gresource.xml similarity index 100% rename from applets/cosmic-applet-power/data/resources/resources.gresource.xml rename to cosmic-applet-power/data/resources/resources.gresource.xml diff --git a/applets/cosmic-applet-power/src/cosmic_session.rs b/cosmic-applet-power/src/cosmic_session.rs similarity index 100% rename from applets/cosmic-applet-power/src/cosmic_session.rs rename to cosmic-applet-power/src/cosmic_session.rs diff --git a/applets/cosmic-applet-power/src/main.rs b/cosmic-applet-power/src/main.rs similarity index 100% rename from applets/cosmic-applet-power/src/main.rs rename to cosmic-applet-power/src/main.rs diff --git a/applets/cosmic-applet-power/src/session_manager.rs b/cosmic-applet-power/src/session_manager.rs similarity index 100% rename from applets/cosmic-applet-power/src/session_manager.rs rename to cosmic-applet-power/src/session_manager.rs diff --git a/applets/cosmic-applet-time/Cargo.lock b/cosmic-applet-time/Cargo.lock similarity index 100% rename from applets/cosmic-applet-time/Cargo.lock rename to cosmic-applet-time/Cargo.lock diff --git a/applets/cosmic-applet-time/Cargo.toml b/cosmic-applet-time/Cargo.toml similarity index 100% rename from applets/cosmic-applet-time/Cargo.toml rename to cosmic-applet-time/Cargo.toml diff --git a/applets/cosmic-applet-time/data/com.system76.CosmicAppletTime.desktop b/cosmic-applet-time/data/com.system76.CosmicAppletTime.desktop similarity index 100% rename from applets/cosmic-applet-time/data/com.system76.CosmicAppletTime.desktop rename to cosmic-applet-time/data/com.system76.CosmicAppletTime.desktop diff --git a/applets/cosmic-applet-time/data/icons/com.system76.CosmicAppletTime.svg b/cosmic-applet-time/data/icons/com.system76.CosmicAppletTime.svg similarity index 100% rename from applets/cosmic-applet-time/data/icons/com.system76.CosmicAppletTime.svg rename to cosmic-applet-time/data/icons/com.system76.CosmicAppletTime.svg diff --git a/applets/cosmic-applet-time/src/main.rs b/cosmic-applet-time/src/main.rs similarity index 100% rename from applets/cosmic-applet-time/src/main.rs rename to cosmic-applet-time/src/main.rs diff --git a/applets/cosmic-applet-workspaces/Cargo.lock b/cosmic-applet-workspaces/Cargo.lock similarity index 100% rename from applets/cosmic-applet-workspaces/Cargo.lock rename to cosmic-applet-workspaces/Cargo.lock diff --git a/applets/cosmic-applet-workspaces/Cargo.toml b/cosmic-applet-workspaces/Cargo.toml similarity index 100% rename from applets/cosmic-applet-workspaces/Cargo.toml rename to cosmic-applet-workspaces/Cargo.toml diff --git a/applets/cosmic-applet-workspaces/data/com.system76.CosmicAppletWorkspaces.desktop b/cosmic-applet-workspaces/data/com.system76.CosmicAppletWorkspaces.desktop similarity index 100% rename from applets/cosmic-applet-workspaces/data/com.system76.CosmicAppletWorkspaces.desktop rename to cosmic-applet-workspaces/data/com.system76.CosmicAppletWorkspaces.desktop diff --git a/applets/cosmic-applet-workspaces/data/icons/com.system76.CosmicAppletWorkspaces.svg b/cosmic-applet-workspaces/data/icons/com.system76.CosmicAppletWorkspaces.svg similarity index 100% rename from applets/cosmic-applet-workspaces/data/icons/com.system76.CosmicAppletWorkspaces.svg rename to cosmic-applet-workspaces/data/icons/com.system76.CosmicAppletWorkspaces.svg diff --git a/applets/cosmic-applet-workspaces/data/resources/resources.gresource.xml b/cosmic-applet-workspaces/data/resources/resources.gresource.xml similarity index 100% rename from applets/cosmic-applet-workspaces/data/resources/resources.gresource.xml rename to cosmic-applet-workspaces/data/resources/resources.gresource.xml diff --git a/applets/cosmic-applet-workspaces/data/resources/style.css b/cosmic-applet-workspaces/data/resources/style.css similarity index 100% rename from applets/cosmic-applet-workspaces/data/resources/style.css rename to cosmic-applet-workspaces/data/resources/style.css diff --git a/applets/cosmic-applet-workspaces/i18n.toml b/cosmic-applet-workspaces/i18n.toml similarity index 100% rename from applets/cosmic-applet-workspaces/i18n.toml rename to cosmic-applet-workspaces/i18n.toml diff --git a/applets/cosmic-applet-workspaces/i18n/en/cosmic_applet_workspaces.ftl b/cosmic-applet-workspaces/i18n/en/cosmic_applet_workspaces.ftl similarity index 100% rename from applets/cosmic-applet-workspaces/i18n/en/cosmic_applet_workspaces.ftl rename to cosmic-applet-workspaces/i18n/en/cosmic_applet_workspaces.ftl diff --git a/applets/cosmic-applet-workspaces/i18n/fr/cosmic_applet_workspaces.ftl b/cosmic-applet-workspaces/i18n/fr/cosmic_applet_workspaces.ftl similarity index 100% rename from applets/cosmic-applet-workspaces/i18n/fr/cosmic_applet_workspaces.ftl rename to cosmic-applet-workspaces/i18n/fr/cosmic_applet_workspaces.ftl diff --git a/applets/cosmic-applet-workspaces/src/colors.rs b/cosmic-applet-workspaces/src/colors.rs similarity index 100% rename from applets/cosmic-applet-workspaces/src/colors.rs rename to cosmic-applet-workspaces/src/colors.rs diff --git a/applets/cosmic-applet-workspaces/src/components/app.rs b/cosmic-applet-workspaces/src/components/app.rs similarity index 100% rename from applets/cosmic-applet-workspaces/src/components/app.rs rename to cosmic-applet-workspaces/src/components/app.rs diff --git a/applets/cosmic-applet-workspaces/src/components/mod.rs b/cosmic-applet-workspaces/src/components/mod.rs similarity index 100% rename from applets/cosmic-applet-workspaces/src/components/mod.rs rename to cosmic-applet-workspaces/src/components/mod.rs diff --git a/applets/cosmic-applet-workspaces/src/config.rs b/cosmic-applet-workspaces/src/config.rs similarity index 100% rename from applets/cosmic-applet-workspaces/src/config.rs rename to cosmic-applet-workspaces/src/config.rs diff --git a/applets/cosmic-applet-workspaces/src/localize.rs b/cosmic-applet-workspaces/src/localize.rs similarity index 100% rename from applets/cosmic-applet-workspaces/src/localize.rs rename to cosmic-applet-workspaces/src/localize.rs diff --git a/applets/cosmic-applet-workspaces/src/main.rs b/cosmic-applet-workspaces/src/main.rs similarity index 100% rename from applets/cosmic-applet-workspaces/src/main.rs rename to cosmic-applet-workspaces/src/main.rs diff --git a/applets/cosmic-applet-workspaces/src/meson.build b/cosmic-applet-workspaces/src/meson.build similarity index 100% rename from applets/cosmic-applet-workspaces/src/meson.build rename to cosmic-applet-workspaces/src/meson.build diff --git a/applets/cosmic-applet-workspaces/src/wayland.rs b/cosmic-applet-workspaces/src/wayland.rs similarity index 100% rename from applets/cosmic-applet-workspaces/src/wayland.rs rename to cosmic-applet-workspaces/src/wayland.rs diff --git a/applets/cosmic-applet-workspaces/src/wayland_subscription.rs b/cosmic-applet-workspaces/src/wayland_subscription.rs similarity index 100% rename from applets/cosmic-applet-workspaces/src/wayland_subscription.rs rename to cosmic-applet-workspaces/src/wayland_subscription.rs diff --git a/applets/cosmic-panel-app-button/data/com.system76.CosmicPanelAppButton.desktop b/cosmic-panel-app-button/data/com.system76.CosmicPanelAppButton.desktop similarity index 100% rename from applets/cosmic-panel-app-button/data/com.system76.CosmicPanelAppButton.desktop rename to cosmic-panel-app-button/data/com.system76.CosmicPanelAppButton.desktop diff --git a/applets/cosmic-panel-app-button/data/icons/com.system76.CosmicPanelAppButton-symbolic.svg b/cosmic-panel-app-button/data/icons/com.system76.CosmicPanelAppButton-symbolic.svg similarity index 100% rename from applets/cosmic-panel-app-button/data/icons/com.system76.CosmicPanelAppButton-symbolic.svg rename to cosmic-panel-app-button/data/icons/com.system76.CosmicPanelAppButton-symbolic.svg diff --git a/applets/cosmic-panel-app-button/data/icons/com.system76.CosmicPanelAppButton.Devel.svg b/cosmic-panel-app-button/data/icons/com.system76.CosmicPanelAppButton.Devel.svg similarity index 100% rename from applets/cosmic-panel-app-button/data/icons/com.system76.CosmicPanelAppButton.Devel.svg rename to cosmic-panel-app-button/data/icons/com.system76.CosmicPanelAppButton.Devel.svg diff --git a/applets/cosmic-panel-app-button/data/icons/com.system76.CosmicPanelAppButton.svg b/cosmic-panel-app-button/data/icons/com.system76.CosmicPanelAppButton.svg similarity index 100% rename from applets/cosmic-panel-app-button/data/icons/com.system76.CosmicPanelAppButton.svg rename to cosmic-panel-app-button/data/icons/com.system76.CosmicPanelAppButton.svg diff --git a/applets/cosmic-panel-app-button/data/resources/resources.gresource.xml b/cosmic-panel-app-button/data/resources/resources.gresource.xml similarity index 100% rename from applets/cosmic-panel-app-button/data/resources/resources.gresource.xml rename to cosmic-panel-app-button/data/resources/resources.gresource.xml diff --git a/applets/cosmic-panel-workspaces-button/data/com.system76.CosmicPanelWorkspacesButton.desktop b/cosmic-panel-workspaces-button/data/com.system76.CosmicPanelWorkspacesButton.desktop similarity index 100% rename from applets/cosmic-panel-workspaces-button/data/com.system76.CosmicPanelWorkspacesButton.desktop rename to cosmic-panel-workspaces-button/data/com.system76.CosmicPanelWorkspacesButton.desktop diff --git a/applets/cosmic-panel-workspaces-button/data/icons/com.system76.CosmicPanelWorkspacesButton.svg b/cosmic-panel-workspaces-button/data/icons/com.system76.CosmicPanelWorkspacesButton.svg similarity index 100% rename from applets/cosmic-panel-workspaces-button/data/icons/com.system76.CosmicPanelWorkspacesButton.svg rename to cosmic-panel-workspaces-button/data/icons/com.system76.CosmicPanelWorkspacesButton.svg diff --git a/applets/cosmic-panel-button/data/resources/resources.gresource.xml b/cosmic-panel-workspaces-button/data/resources/resources.gresource.xml similarity index 100% rename from applets/cosmic-panel-button/data/resources/resources.gresource.xml rename to cosmic-panel-workspaces-button/data/resources/resources.gresource.xml diff --git a/libcosmic-applet/Cargo.toml b/libcosmic-applet/Cargo.toml deleted file mode 100644 index 509d5871..00000000 --- a/libcosmic-applet/Cargo.toml +++ /dev/null @@ -1,10 +0,0 @@ -[package] -name = "libcosmic-applet" -version = "0.1.0" -edition = "2021" - -[dependencies] -cosmic-panel-config = {git = "https://github.com/pop-os/cosmic-panel", features = ["gtk4"] } -gtk4 = { git = "https://github.com/gtk-rs/gtk4-rs", features = ["v4_6"] } -once_cell = "1.12.0" -relm4-macros = { git = "https://github.com/Relm4/Relm4.git", branch = "next" } diff --git a/libcosmic-applet/src/button.rs b/libcosmic-applet/src/button.rs deleted file mode 100644 index 17a29eaa..00000000 --- a/libcosmic-applet/src/button.rs +++ /dev/null @@ -1,152 +0,0 @@ -use cosmic_panel_config::{PanelSize, PanelAnchor}; -use gtk4::{glib, prelude::*, subclass::prelude::*, PositionType}; -use relm4_macros::view; - -use crate::deref_cell::DerefCell; - -static STYLE: &str = " -button.cosmic_applet_button { - border-radius: 12px; - transition: 100ms; - padding: 4px; - border-color: transparent; - background: transparent; - outline-color: transparent; -} -"; - -#[derive(Default)] -pub struct AppletButtonInner { - menu_button: DerefCell, - popover: DerefCell, -} - -#[glib::object_subclass] -impl ObjectSubclass for AppletButtonInner { - const NAME: &'static str = "CosmicAppletButton"; - type Type = AppletButton; - type ParentType = gtk4::Widget; -} - -impl ObjectImpl for AppletButtonInner { - fn constructed(&self, obj: &AppletButton) { - let position = std::env::var("COSMIC_PANEL_ANCHOR") - .ok() - .and_then(|anchor| anchor.parse::().ok()) - .map(|anchor| match anchor { - PanelAnchor::Left => PositionType::Right, - PanelAnchor::Right => PositionType::Left, - PanelAnchor::Top => PositionType::Bottom, - PanelAnchor::Bottom => PositionType::Top, - }); - view! { - menu_button = gtk4::MenuButton { - set_parent: obj, - add_css_class: "cosmic_applet_button", - set_has_frame: false, - #[wrap(Some)] - set_popover: popover = >k4::Popover { - set_has_arrow: false, - } - }, - provider = gtk4::CssProvider { - load_from_data: STYLE.as_bytes(), - } - } - if let Some(position) = position { - popover.set_position(position); - } - obj.set_layout_manager(Some(>k4::BinLayout::new())); - obj.style_context() - .add_provider(&provider, gtk4::STYLE_PROVIDER_PRIORITY_APPLICATION); - - self.menu_button.set(menu_button); - self.popover.set(popover); - } - - fn dispose(&self, _obj: &AppletButton) { - self.menu_button.unparent(); - } -} - -impl WidgetImpl for AppletButtonInner { - fn compute_expand(&self, _obj: &AppletButton, hexpand: &mut bool, vexpand: &mut bool) { - *hexpand = self - .menu_button - .compute_expand(gtk4::Orientation::Horizontal); - *vexpand = self.menu_button.compute_expand(gtk4::Orientation::Vertical); - } - - fn request_mode(&self, _obj: &AppletButton) -> gtk4::SizeRequestMode { - self.menu_button.request_mode() - } -} - -impl WindowImpl for AppletButtonInner {} - -glib::wrapper! { - pub struct AppletButton(ObjectSubclass) - @extends gtk4::Widget; -} - -impl Default for AppletButton { - fn default() -> Self { - Self::new() - } -} - -impl AppletButton { - pub fn new() -> Self { - glib::Object::new(&[]).unwrap() - } - - fn inner(&self) -> &AppletButtonInner { - AppletButtonInner::from_instance(self) - } - - pub fn set_button_child(&self, child: Option<&impl IsA>) { - self.inner().menu_button.set_child(child); - } - - pub fn set_button_icon_name(&self, name: &str) { - let image = gtk4::Image::from_icon_name(name); - let pixels = std::env::var("COSMIC_PANEL_SIZE") - .ok() - .and_then(|size| match size.parse::() { - 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); - image.set_pixel_size(pixels); - self.set_button_child(Some(&image)); - } - - pub fn set_button_label(&self, label: &str) { - self.inner().menu_button.set_label(label); - } - - pub fn set_popover_child(&self, child: Option<&impl IsA>) { - self.inner().popover.set_child(child); - } - - pub fn popdown(&self) { - self.inner().popover.popdown(); - } - - pub fn popup(&self) { - self.inner().popover.popup(); - } - - // XXX better API? Actual signal - pub fn connect_activate(&self, f: F) -> glib::SignalHandlerId { - self.inner() - .menu_button - .connect_activate(glib::clone!(@weak self as _self => move |_| { - f(&_self) - })) - } -} diff --git a/libcosmic-applet/src/deref_cell.rs b/libcosmic-applet/src/deref_cell.rs deleted file mode 100644 index dfdd4936..00000000 --- a/libcosmic-applet/src/deref_cell.rs +++ /dev/null @@ -1,31 +0,0 @@ -use once_cell::unsync::OnceCell; - -/// Wrapper around `OnceCell` implementing `Deref`, and thus also panicking -/// when not set (or set twice). -/// -/// To be used in place of `gtk::TemplateChild`, but without xml. -pub struct DerefCell(OnceCell); - -impl DerefCell { - #[track_caller] - pub fn set(&self, value: T) { - if self.0.set(value).is_err() { - panic!("Initialized twice"); - } - } -} - -impl Default for DerefCell { - fn default() -> Self { - Self(OnceCell::default()) - } -} - -impl std::ops::Deref for DerefCell { - type Target = T; - - #[track_caller] - fn deref(&self) -> &T { - self.0.get().unwrap() - } -} diff --git a/libcosmic-applet/src/lib.rs b/libcosmic-applet/src/lib.rs deleted file mode 100644 index 6e2b20b6..00000000 --- a/libcosmic-applet/src/lib.rs +++ /dev/null @@ -1,13 +0,0 @@ -mod button; -pub use button::AppletButton; -mod deref_cell; -mod window; -pub use window::AppletWindow; - -// TODO make sure style fits different panel colors? -// TODO abstraction to start main loop? Work with relm4. -// TODO gir bindings -// TODO orientation, etc. -// TODO make image size dependent on CosmicPanelConfig? -// TODO way to have multiple applets with this style, for system tray. -// TODO also handle non-popover button? Is GtkMenuButton particularly special, or just use a toggle button? diff --git a/libcosmic-applet/src/window.rs b/libcosmic-applet/src/window.rs deleted file mode 100644 index 257658b3..00000000 --- a/libcosmic-applet/src/window.rs +++ /dev/null @@ -1,58 +0,0 @@ -use gtk4::{glib, prelude::*, subclass::prelude::*}; -use relm4_macros::view; - -static STYLE: &str = " -window.cosmic_applet_window { - background: transparent; -} -"; - -#[derive(Default)] -pub struct AppletWindowInner; - -#[glib::object_subclass] -impl ObjectSubclass for AppletWindowInner { - const NAME: &'static str = "CosmicAppletWindow"; - type Type = AppletWindow; - type ParentType = gtk4::Window; -} - -impl ObjectImpl for AppletWindowInner { - fn constructed(&self, obj: &AppletWindow) { - let window = || obj; - view! { - window() { - add_css_class: "cosmic_applet_window", - set_decorated: false, - set_resizable: false, - set_width_request: 1, - set_height_request: 1, - }, - provider = gtk4::CssProvider { - load_from_data: STYLE.as_bytes(), - } - } - obj.style_context() - .add_provider(&provider, gtk4::STYLE_PROVIDER_PRIORITY_APPLICATION); - } -} - -impl WidgetImpl for AppletWindowInner {} -impl WindowImpl for AppletWindowInner {} - -glib::wrapper! { - pub struct AppletWindow(ObjectSubclass) - @extends gtk4::Widget, gtk4::Window; -} - -impl Default for AppletWindow { - fn default() -> Self { - Self::new() - } -} - -impl AppletWindow { - pub fn new() -> Self { - glib::Object::new(&[]).unwrap() - } -}