diff --git a/Cargo.lock b/Cargo.lock
index 0d81eb03..eb3a64c7 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -180,12 +180,6 @@ version = "3.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3"
-[[package]]
-name = "byte_string"
-version = "1.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "11aade7a05aa8c3a351cedc44c3fc45806430543382fcc4743a9b757a2a0b4ed"
-
[[package]]
name = "byteorder"
version = "1.4.3"
@@ -408,6 +402,22 @@ dependencies = [
"zvariant",
]
+[[package]]
+name = "cosmic-applet-time"
+version = "0.1.0"
+dependencies = [
+ "cascade",
+ "chrono",
+ "cosmic-panel-config",
+ "futures",
+ "gtk4",
+ "once_cell",
+ "serde",
+ "zbus",
+ "zbus_names",
+ "zvariant",
+]
+
[[package]]
name = "cosmic-applet-workspaces"
version = "0.1.0"
@@ -998,31 +1008,6 @@ dependencies = [
"system-deps",
]
-[[package]]
-name = "gdk4-wayland"
-version = "0.4.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cf81f00824c5f9862764c18ef061efe12b9c4f10614f74d3eaf1f18852c335e2"
-dependencies = [
- "gdk4",
- "gdk4-wayland-sys",
- "gio",
- "glib",
- "libc",
- "wayland-client",
-]
-
-[[package]]
-name = "gdk4-wayland-sys"
-version = "0.4.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "41f2375ec73e2ec6815cdf1da330ff2e020b46fab9057d1e06f44909f1789898"
-dependencies = [
- "glib-sys",
- "libc",
- "system-deps",
-]
-
[[package]]
name = "gdk4-x11"
version = "0.4.8"
@@ -1512,17 +1497,13 @@ version = "0.1.0"
source = "git+https://github.com/pop-os/libcosmic#d004d686bd83e55f8f5058700941284ca84dc579"
dependencies = [
"cascade",
- "derivative",
"gdk4",
- "gdk4-wayland",
"gdk4-x11",
"gio",
"gobject-sys",
"gtk4",
"libcosmic-widgets",
"once_cell",
- "wayland-client",
- "wayland-protocols",
"x11",
]
@@ -1993,31 +1974,6 @@ dependencies = [
"winapi",
]
-[[package]]
-name = "pop-cosmic-panel"
-version = "0.1.0"
-dependencies = [
- "byte_string",
- "cascade",
- "chrono",
- "derivative",
- "enumflags2",
- "futures",
- "futures-channel",
- "gdk4-wayland",
- "gdk4-x11",
- "gobject-sys",
- "gtk4",
- "libcosmic",
- "once_cell",
- "serde",
- "toml",
- "x11",
- "zbus",
- "zbus_names",
- "zvariant",
-]
-
[[package]]
name = "ppv-lite86"
version = "0.2.16"
@@ -2311,12 +2267,6 @@ dependencies = [
"winapi-util",
]
-[[package]]
-name = "scoped-tls"
-version = "1.0.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2"
-
[[package]]
name = "scopeguard"
version = "1.1.0"
@@ -2828,7 +2778,6 @@ dependencies = [
"downcast-rs",
"libc",
"nix 0.22.3",
- "scoped-tls",
"wayland-commons",
"wayland-scanner",
"wayland-sys",
@@ -2886,7 +2835,6 @@ version = "0.29.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d9341df79a8975679188e37dab3889bfa57c44ac2cb6da166f519a81cbe452d4"
dependencies = [
- "dlib",
"pkg-config",
]
diff --git a/Cargo.toml b/Cargo.toml
index 4591550b..631dd191 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -7,7 +7,7 @@ members = [
"applets/cosmic-applet-power",
"applets/cosmic-applet-workspaces",
"applets/cosmic-applet-status-area",
+ "applets/cosmic-applet-time",
"applets/cosmic-app-list",
"applets/cosmic-panel-button",
- "old-panel",
- ]
+]
diff --git a/applets/cosmic-applet-time/Cargo.toml b/applets/cosmic-applet-time/Cargo.toml
new file mode 100644
index 00000000..7fb7aaa5
--- /dev/null
+++ b/applets/cosmic-applet-time/Cargo.toml
@@ -0,0 +1,17 @@
+[package]
+name = "cosmic-applet-time"
+version = "0.1.0"
+edition = "2021"
+license = "GPL-3.0-or-later"
+
+[dependencies]
+cascade = "1"
+chrono = "0.4"
+futures = "0.3"
+gtk4 = { version = "0.4.6", features = [ "v4_6" ] }
+once_cell = "1.12"
+serde = "1"
+zbus = "2.0.1"
+zbus_names = "2"
+zvariant = "3"
+cosmic-panel-config = {git = "https://github.com/pop-os/cosmic-panel", features = ["gtk4"]}
diff --git a/applets/cosmic-applet-time/data/com.system76.CosmicAppletTime.desktop b/applets/cosmic-applet-time/data/com.system76.CosmicAppletTime.desktop
new file mode 100644
index 00000000..ad40faad
--- /dev/null
+++ b/applets/cosmic-applet-time/data/com.system76.CosmicAppletTime.desktop
@@ -0,0 +1,10 @@
+[Desktop Entry]
+Name=Cosmic Applet Time
+Type=Application
+Exec=cosmic-applet-time
+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.CosmicAppletTime
+NoDisplay=true
diff --git a/applets/cosmic-applet-time/data/icons/com.system76.CosmicAppletTime.svg b/applets/cosmic-applet-time/data/icons/com.system76.CosmicAppletTime.svg
new file mode 100644
index 00000000..c2bd5b1b
--- /dev/null
+++ b/applets/cosmic-applet-time/data/icons/com.system76.CosmicAppletTime.svg
@@ -0,0 +1,60 @@
+
+
diff --git a/old-panel/src/deref_cell.rs b/applets/cosmic-applet-time/src/deref_cell.rs
similarity index 100%
rename from old-panel/src/deref_cell.rs
rename to applets/cosmic-applet-time/src/deref_cell.rs
diff --git a/applets/cosmic-applet-time/src/main.rs b/applets/cosmic-applet-time/src/main.rs
new file mode 100644
index 00000000..6233b522
--- /dev/null
+++ b/applets/cosmic-applet-time/src/main.rs
@@ -0,0 +1,32 @@
+use gtk4::{glib, prelude::*};
+
+mod deref_cell;
+mod time_button;
+use time_button::TimeButton;
+
+fn main() {
+ gtk4::init().unwrap();
+
+ let provider = gtk4::CssProvider::new();
+ provider.load_from_data(include_bytes!("style.css"));
+ gtk4::StyleContext::add_provider_for_display(
+ >k4::gdk::Display::default().expect("Could not connect to a display."),
+ &provider,
+ gtk4::STYLE_PROVIDER_PRIORITY_APPLICATION,
+ );
+
+ let time_button = TimeButton::new();
+
+ gtk4::Window::builder()
+ .decorated(false)
+ .child(&time_button)
+ .resizable(false)
+ .width_request(1)
+ .height_request(1)
+ .css_classes(vec!["root_window".to_string()])
+ .build()
+ .show();
+
+ let main_loop = glib::MainLoop::new(None, false);
+ main_loop.run();
+}
diff --git a/applets/cosmic-applet-time/src/style.css b/applets/cosmic-applet-time/src/style.css
new file mode 100644
index 00000000..8a91f3eb
--- /dev/null
+++ b/applets/cosmic-applet-time/src/style.css
@@ -0,0 +1,33 @@
+.loading-overlay {
+ background-color: #2f2f2f;
+ opacity: 0.85;
+}
+
+image.panel_icon {
+ padding-left: 0px;
+ padding-right: 0px;
+ padding-top: 0px;
+ padding-bottom: 0px;
+}
+
+button.panel_icon {
+ border-radius: 12px;
+ transition: 100ms;
+ padding: 4px;
+ border-color: transparent;
+ background: transparent;
+ outline-color: transparent;
+}
+
+button.panel_icon: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);
+}
+
+window.root_window {
+ background: transparent;
+}
\ No newline at end of file
diff --git a/old-panel/src/time_button.rs b/applets/cosmic-applet-time/src/time_button.rs
similarity index 80%
rename from old-panel/src/time_button.rs
rename to applets/cosmic-applet-time/src/time_button.rs
index 027847ff..c05369b2 100644
--- a/old-panel/src/time_button.rs
+++ b/applets/cosmic-applet-time/src/time_button.rs
@@ -6,14 +6,12 @@ use gtk4::{
subclass::prelude::*,
};
-use crate::application::PanelApp;
use crate::deref_cell::DerefCell;
-use crate::popover_container::PopoverContainer;
#[derive(Default)]
pub struct TimeButtonInner {
calendar: DerefCell,
- button: DerefCell,
+ button: DerefCell,
label: DerefCell,
}
@@ -42,21 +40,21 @@ impl ObjectImpl for TimeButtonInner {
}));
};
- let button = cascade! {
- gtk4::ToggleButton::new();
- ..set_has_frame(false);
- ..set_child(Some(&label));
- };
-
- cascade! {
- PopoverContainer::new(&button);
- ..set_parent(obj);
- ..popover().set_child(Some(&cascade! {
+ let popover = cascade! {
+ gtk4::Popover::new();
+ ..set_child(Some(&cascade! {
gtk4::Box::new(gtk4::Orientation::Horizontal, 0);
..append(&calendar);
}));
- ..popover().connect_show(clone!(@strong obj => move |_| obj.opening()));
- ..popover().bind_property("visible", &button, "active").flags(glib::BindingFlags::BIDIRECTIONAL).build();
+ ..connect_show(clone!(@strong obj => move |_| obj.opening()));
+ };
+
+ let button = cascade! {
+ gtk4::MenuButton::new();
+ ..set_child(Some(&label));
+ ..set_has_frame(false);
+ ..set_parent(obj);
+ ..set_popover(Some(&popover));
};
self.calendar.set(calendar);
@@ -87,10 +85,8 @@ glib::wrapper! {
}
impl TimeButton {
- pub fn new(app: &PanelApp) -> Self {
- let obj = glib::Object::new::(&[]).unwrap();
-
- obj
+ pub fn new() -> Self {
+ glib::Object::new::(&[]).unwrap()
}
fn inner(&self) -> &TimeButtonInner {
diff --git a/justfile b/justfile
index 469502d1..15e97ea4 100644
--- a/justfile
+++ b/justfile
@@ -21,6 +21,7 @@ notifications_id := 'com.system76.CosmicAppletNotifications'
power_id := 'com.system76.CosmicAppletPower'
workspaces_id := 'com.system76.CosmicAppletWorkspaces'
status_area_id := 'com.system76.CosmicAppletStatusArea'
+time_id := 'com.system76.CosmicAppletTime'
app_button_id := 'com.system76.CosmicPanelAppButton'
workspaces_button_id := 'com.system76.CosmicPanelWorkspacesButton'
@@ -71,6 +72,11 @@ install:
install -Dm0644 applets/cosmic-applet-status-area/data/{{status_area_id}}.desktop {{sharedir}}/applications/{{status_area_id}}.desktop
install -Dm0755 target/release/cosmic-applet-status-area {{bindir}}/cosmic-applet-status-area
+ # time
+ install -Dm0644 applets/cosmic-applet-time/data/icons/{{time_id}}.svg {{iconsdir}}/{{time_id}}.svg
+ install -Dm0644 applets/cosmic-applet-time/data/{{time_id}}.desktop {{sharedir}}/applications/{{time_id}}.desktop
+ install -Dm0755 target/release/cosmic-applet-time {{bindir}}/cosmic-applet-time
+
# app library button
install -Dm0644 applets/cosmic-panel-app-button/data/icons/{{app_button_id}}.svg {{iconsdir}}/{{app_button_id}}.svg
install -Dm0644 applets/cosmic-panel-app-button/data/{{app_button_id}}.desktop {{sharedir}}/applications/{{app_button_id}}.desktop
diff --git a/old-panel/Cargo.toml b/old-panel/Cargo.toml
deleted file mode 100644
index 21bf53a9..00000000
--- a/old-panel/Cargo.toml
+++ /dev/null
@@ -1,29 +0,0 @@
-[package]
-name = "pop-cosmic-panel"
-version = "0.1.0"
-edition = "2021"
-license = "GPL-3.0-or-later"
-
-[dependencies]
-cascade = "1"
-chrono = "0.4"
-byte_string = "1"
-derivative = "2"
-enumflags2 = "0.7"
-futures = "0.3"
-futures-channel = "0.3"
-gdk4-x11 = { version = "0.4.2", features = ["xlib"] }
-gdk4-wayland = { version = "0.4", optional = true }
-gtk4 = "0.4"
-gobject-sys = "0.15"
-libcosmic = { git = "https://github.com/pop-os/libcosmic" }
-once_cell = "1"
-serde = "1"
-toml = "0.5"
-x11 = { version = "2", features = ["xlib"] }
-zbus = "2"
-zbus_names = "2"
-zvariant = "3"
-
-[features]
-layer-shell = ["gdk4-wayland", "libcosmic/layer-shell"]
diff --git a/old-panel/README.md b/old-panel/README.md
deleted file mode 100644
index 9d7e9bed..00000000
--- a/old-panel/README.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# cosmic-panel
-
-An **experimental** and incomplete panel, currently for X11 systems.
diff --git a/old-panel/src/application.rs b/old-panel/src/application.rs
deleted file mode 100644
index f1b10199..00000000
--- a/old-panel/src/application.rs
+++ /dev/null
@@ -1,81 +0,0 @@
-use gtk4::{
- gdk, gio,
- glib::{self, clone},
- prelude::*,
- subclass::prelude::*,
-};
-use std::cell::Cell;
-
-use crate::window;
-
-#[derive(Default)]
-pub struct PanelAppInner {
- activated: Cell,
-}
-
-#[glib::object_subclass]
-impl ObjectSubclass for PanelAppInner {
- const NAME: &'static str = "S76CosmicPanelApp";
- type ParentType = gtk4::Application;
- type Type = PanelApp;
-}
-
-impl ObjectImpl for PanelAppInner {
- fn constructed(&self, obj: &PanelApp) {
- obj.set_application_id(Some("com.system76.cosmicpanel"));
-
- self.parent_constructed(obj);
- }
-}
-
-impl ApplicationImpl for PanelAppInner {
- fn activate(&self, obj: &PanelApp) {
- self.parent_activate(obj);
-
- if self.activated.get() {
- return;
- }
- self.activated.set(true);
-
- let display = gdk::Display::default().unwrap();
- let monitors = display.monitors();
-
- for i in 0..monitors.n_items() {
- obj.add_window_for_monitor(monitors.item(i).unwrap().downcast().unwrap());
- }
-
- monitors.connect_items_changed(
- clone!(@weak obj => move |monitors, position, _removed, added| {
- for i in position..position + added {
- obj.add_window_for_monitor(monitors
- .item(i)
- .unwrap()
- .downcast::()
- .unwrap());
- }
- }),
- );
- }
-}
-
-impl GtkApplicationImpl for PanelAppInner {}
-
-glib::wrapper! {
- pub struct PanelApp(ObjectSubclass)
- @extends gtk4::Application, gio::Application,
- @implements gio::ActionGroup, gio::ActionMap;
-}
-
-impl PanelApp {
- pub fn new() -> Self {
- glib::Object::new::(&[]).unwrap()
- }
-
- fn inner(&self) -> &PanelAppInner {
- PanelAppInner::from_instance(self)
- }
-
- fn add_window_for_monitor(&self, monitor: gdk::Monitor) {
- window::create(self, monitor);
- }
-}
diff --git a/old-panel/src/main.rs b/old-panel/src/main.rs
deleted file mode 100644
index 0835b9ca..00000000
--- a/old-panel/src/main.rs
+++ /dev/null
@@ -1,15 +0,0 @@
-use gtk4::{glib, prelude::*};
-
-mod application;
-mod deref_cell;
-mod popover_container;
-mod time_button;
-mod window;
-
-use application::PanelApp;
-
-fn main() {
- glib::MainContext::default()
- .with_thread_default(|| PanelApp::new().run())
- .unwrap();
-}
diff --git a/old-panel/src/popover_container.rs b/old-panel/src/popover_container.rs
deleted file mode 100644
index 2e551294..00000000
--- a/old-panel/src/popover_container.rs
+++ /dev/null
@@ -1,89 +0,0 @@
-use cascade::cascade;
-use gtk4::{glib, prelude::*, subclass::prelude::*};
-
-use crate::deref_cell::DerefCell;
-
-/// Unlike gtk4's `MenuButton`, this supports a custom child.
-#[derive(Default)]
-pub struct PopoverContainerInner {
- child: DerefCell,
- popover: DerefCell,
-}
-
-#[glib::object_subclass]
-impl ObjectSubclass for PopoverContainerInner {
- const NAME: &'static str = "S76PopoverContainer";
- type ParentType = gtk4::Widget;
- type Type = PopoverContainer;
-}
-
-impl ObjectImpl for PopoverContainerInner {
- fn constructed(&self, obj: &PopoverContainer) {
- let popover = cascade! {
- gtk4::Popover::new();
- ..set_parent(obj);
- };
-
- self.popover.set(popover);
- }
-
- fn dispose(&self, _obj: &PopoverContainer) {
- self.child.unparent();
- self.popover.unparent();
- }
-}
-
-impl WidgetImpl for PopoverContainerInner {
- fn measure(
- &self,
- _obj: &PopoverContainer,
- orientation: gtk4::Orientation,
- for_size: i32,
- ) -> (i32, i32, i32, i32) {
- self.child.measure(orientation, for_size)
- }
-
- fn size_allocate(&self, _obj: &PopoverContainer, width: i32, height: i32, baseline: i32) {
- self.child
- .size_allocate(>k4::Allocation::new(0, 0, width, height), baseline);
- self.popover.present();
- }
-
- fn focus(&self, _obj: &PopoverContainer, direction: gtk4::DirectionType) -> bool {
- if self.popover.is_visible() {
- self.popover.child_focus(direction)
- } else {
- self.child.child_focus(direction)
- }
- }
-}
-
-glib::wrapper! {
- pub struct PopoverContainer(ObjectSubclass)
- @extends gtk4::Widget;
-}
-
-impl PopoverContainer {
- pub fn new>(child: &T) -> Self {
- let obj = glib::Object::new::(&[]).unwrap();
- child.set_parent(&obj);
- obj.inner().child.set(child.clone().upcast());
- obj
- }
-
- fn inner(&self) -> &PopoverContainerInner {
- PopoverContainerInner::from_instance(self)
- }
-
- pub fn popover(&self) -> >k4::Popover {
- &self.inner().popover
- }
-
- pub fn popup(&self) {
- self.popover().popup();
- }
-
- pub fn popdown(&self) {
- self.popover().popdown();
- }
-}
diff --git a/old-panel/src/window.rs b/old-panel/src/window.rs
deleted file mode 100644
index 171c9db2..00000000
--- a/old-panel/src/window.rs
+++ /dev/null
@@ -1,235 +0,0 @@
-use cascade::cascade;
-use glib::clone;
-use gtk4::{gdk, glib, pango, prelude::*, subclass::prelude::*};
-use libcosmic::x;
-use std::cell::Cell;
-
-use crate::application::PanelApp;
-use crate::deref_cell::DerefCell;
-use crate::time_button::TimeButton;
-
-const BOTTOM: bool = false;
-
-pub fn create(app: &PanelApp, monitor: gdk::Monitor) {
- #[cfg(feature = "layer-shell")]
- if let Some(wayland_monitor) = monitor.downcast_ref() {
- wayland_create(app, wayland_monitor);
- return;
- }
-
- cascade! {
- PanelWindow::new(app, monitor);
- ..show();
- };
-}
-
-#[cfg(feature = "layer-shell")]
-fn wayland_create(app: &PanelApp, monitor: &gdk4_wayland::WaylandMonitor) {
- use libcosmic::wayland::{Anchor, Layer, LayerShellWindow};
-
- let window = LayerShellWindow::new(Some(monitor), Layer::Top, "");
-
- window.connect_realize(|window| {
- let surface = window.surface();
- surface.connect_layout(clone!(@weak window => move |_surface, _width, height| {
- window.set_exclusive_zone(height);
- }));
- });
-
- window.set_child(Some(&window_box(app)));
- window.set_size_request(monitor.geometry().width(), 0);
- window.set_anchor(if BOTTOM { Anchor::Bottom } else { Anchor::Top });
- window.show();
-
- // XXX
- unsafe { window.set_data("cosmic-app-hold", app.hold()) };
-}
-
-// XXX better handle duplication
-#[cfg(feature = "layer-shell")]
-fn window_box(app: &PanelApp) -> gtk4::Widget {
- let widget = cascade! {
- gtk4::CenterBox::new();
- ..set_start_widget(Some(&cascade! {
- gtk4::Box::new(gtk4::Orientation::Horizontal, 0);
- ..append(&button("Workspaces"));
- ..append(&button("Applications"));
- }));
- ..set_center_widget(Some(&TimeButton::new(app)));
- };
- widget.upcast()
-}
-
-fn button(text: &str) -> gtk4::Button {
- let label = cascade! {
- gtk4::Label::new(Some(text));
- ..set_attributes(Some(&cascade! {
- pango::AttrList::new();
- ..insert(pango::AttrInt::new_weight(pango::Weight::Bold));
- }));
- };
-
- cascade! {
- gtk4::Button::new();
- ..set_has_frame(false);
- ..set_child(Some(&label));
- }
-}
-
-#[derive(Default)]
-pub struct PanelWindowInner {
- size: Cell