Move time code from old-panel into an applet
Removes the last of `old-panel`.
This commit is contained in:
parent
fb321a2e05
commit
9b58739a96
16 changed files with 191 additions and 541 deletions
84
Cargo.lock
generated
84
Cargo.lock
generated
|
|
@ -180,12 +180,6 @@ version = "3.10.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3"
|
checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "byte_string"
|
|
||||||
version = "1.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "11aade7a05aa8c3a351cedc44c3fc45806430543382fcc4743a9b757a2a0b4ed"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "byteorder"
|
name = "byteorder"
|
||||||
version = "1.4.3"
|
version = "1.4.3"
|
||||||
|
|
@ -408,6 +402,22 @@ dependencies = [
|
||||||
"zvariant",
|
"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]]
|
[[package]]
|
||||||
name = "cosmic-applet-workspaces"
|
name = "cosmic-applet-workspaces"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
@ -998,31 +1008,6 @@ dependencies = [
|
||||||
"system-deps",
|
"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]]
|
[[package]]
|
||||||
name = "gdk4-x11"
|
name = "gdk4-x11"
|
||||||
version = "0.4.8"
|
version = "0.4.8"
|
||||||
|
|
@ -1512,17 +1497,13 @@ version = "0.1.0"
|
||||||
source = "git+https://github.com/pop-os/libcosmic#d004d686bd83e55f8f5058700941284ca84dc579"
|
source = "git+https://github.com/pop-os/libcosmic#d004d686bd83e55f8f5058700941284ca84dc579"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cascade",
|
"cascade",
|
||||||
"derivative",
|
|
||||||
"gdk4",
|
"gdk4",
|
||||||
"gdk4-wayland",
|
|
||||||
"gdk4-x11",
|
"gdk4-x11",
|
||||||
"gio",
|
"gio",
|
||||||
"gobject-sys",
|
"gobject-sys",
|
||||||
"gtk4",
|
"gtk4",
|
||||||
"libcosmic-widgets",
|
"libcosmic-widgets",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"wayland-client",
|
|
||||||
"wayland-protocols",
|
|
||||||
"x11",
|
"x11",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -1993,31 +1974,6 @@ dependencies = [
|
||||||
"winapi",
|
"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]]
|
[[package]]
|
||||||
name = "ppv-lite86"
|
name = "ppv-lite86"
|
||||||
version = "0.2.16"
|
version = "0.2.16"
|
||||||
|
|
@ -2311,12 +2267,6 @@ dependencies = [
|
||||||
"winapi-util",
|
"winapi-util",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "scoped-tls"
|
|
||||||
version = "1.0.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ea6a9290e3c9cf0f18145ef7ffa62d68ee0bf5fcd651017e586dc7fd5da448c2"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "scopeguard"
|
name = "scopeguard"
|
||||||
version = "1.1.0"
|
version = "1.1.0"
|
||||||
|
|
@ -2828,7 +2778,6 @@ dependencies = [
|
||||||
"downcast-rs",
|
"downcast-rs",
|
||||||
"libc",
|
"libc",
|
||||||
"nix 0.22.3",
|
"nix 0.22.3",
|
||||||
"scoped-tls",
|
|
||||||
"wayland-commons",
|
"wayland-commons",
|
||||||
"wayland-scanner",
|
"wayland-scanner",
|
||||||
"wayland-sys",
|
"wayland-sys",
|
||||||
|
|
@ -2886,7 +2835,6 @@ version = "0.29.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d9341df79a8975679188e37dab3889bfa57c44ac2cb6da166f519a81cbe452d4"
|
checksum = "d9341df79a8975679188e37dab3889bfa57c44ac2cb6da166f519a81cbe452d4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dlib",
|
|
||||||
"pkg-config",
|
"pkg-config",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ members = [
|
||||||
"applets/cosmic-applet-power",
|
"applets/cosmic-applet-power",
|
||||||
"applets/cosmic-applet-workspaces",
|
"applets/cosmic-applet-workspaces",
|
||||||
"applets/cosmic-applet-status-area",
|
"applets/cosmic-applet-status-area",
|
||||||
|
"applets/cosmic-applet-time",
|
||||||
"applets/cosmic-app-list",
|
"applets/cosmic-app-list",
|
||||||
"applets/cosmic-panel-button",
|
"applets/cosmic-panel-button",
|
||||||
"old-panel",
|
]
|
||||||
]
|
|
||||||
|
|
|
||||||
17
applets/cosmic-applet-time/Cargo.toml
Normal file
17
applets/cosmic-applet-time/Cargo.toml
Normal file
|
|
@ -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"]}
|
||||||
|
|
@ -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
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="128px" height="128px" viewBox="0 0 128 128" version="1.1">
|
||||||
|
<defs>
|
||||||
|
<filter id="alpha" filterUnits="objectBoundingBox" x="0%" y="0%" width="100%" height="100%">
|
||||||
|
<feColorMatrix type="matrix" in="SourceGraphic" values="0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0"/>
|
||||||
|
</filter>
|
||||||
|
<mask id="mask0">
|
||||||
|
<g filter="url(#alpha)">
|
||||||
|
<rect x="0" y="0" width="128" height="128" style="fill:rgb(0%,0%,0%);fill-opacity:0.1;stroke:none;"/>
|
||||||
|
</g>
|
||||||
|
</mask>
|
||||||
|
<clipPath id="clip1">
|
||||||
|
<rect x="0" y="0" width="192" height="152"/>
|
||||||
|
</clipPath>
|
||||||
|
<g id="surface10632" clip-path="url(#clip1)">
|
||||||
|
<path style="fill:none;stroke-width:0.99;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-dasharray:0.99,0.99;stroke-miterlimit:4;" d="M 123.503906 236 C 123.503906 268.863281 96.863281 295.503906 64 295.503906 C 31.136719 295.503906 4.496094 268.863281 4.496094 236 C 4.496094 203.136719 31.136719 176.496094 64 176.496094 C 96.863281 176.496094 123.503906 203.136719 123.503906 236 Z M 123.503906 236 " transform="matrix(1,0,0,1,8,-156)"/>
|
||||||
|
</g>
|
||||||
|
<mask id="mask1">
|
||||||
|
<g filter="url(#alpha)">
|
||||||
|
<rect x="0" y="0" width="128" height="128" style="fill:rgb(0%,0%,0%);fill-opacity:0.1;stroke:none;"/>
|
||||||
|
</g>
|
||||||
|
</mask>
|
||||||
|
<clipPath id="clip2">
|
||||||
|
<rect x="0" y="0" width="192" height="152"/>
|
||||||
|
</clipPath>
|
||||||
|
<g id="surface10635" clip-path="url(#clip2)">
|
||||||
|
<path style="fill:none;stroke-width:0.99;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-dasharray:0.99,0.99;stroke-miterlimit:4;" d="M 29.195312 180.496094 L 98.804688 180.496094 C 103.609375 180.496094 107.503906 184.046875 107.503906 188.425781 L 107.503906 283.574219 C 107.503906 287.953125 103.609375 291.503906 98.804688 291.503906 L 29.195312 291.503906 C 24.390625 291.503906 20.496094 287.953125 20.496094 283.574219 L 20.496094 188.425781 C 20.496094 184.046875 24.390625 180.496094 29.195312 180.496094 Z M 29.195312 180.496094 " transform="matrix(1,0,0,1,8,-156)"/>
|
||||||
|
</g>
|
||||||
|
<mask id="mask2">
|
||||||
|
<g filter="url(#alpha)">
|
||||||
|
<rect x="0" y="0" width="128" height="128" style="fill:rgb(0%,0%,0%);fill-opacity:0.1;stroke:none;"/>
|
||||||
|
</g>
|
||||||
|
</mask>
|
||||||
|
<clipPath id="clip3">
|
||||||
|
<rect x="0" y="0" width="192" height="152"/>
|
||||||
|
</clipPath>
|
||||||
|
<g id="surface10638" clip-path="url(#clip3)">
|
||||||
|
<path style="fill:none;stroke-width:0.99;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-dasharray:0.99,0.99;stroke-miterlimit:4;" d="M 20.417969 184.496094 L 107.582031 184.496094 C 111.957031 184.496094 115.503906 188.042969 115.503906 192.417969 L 115.503906 279.582031 C 115.503906 283.957031 111.957031 287.503906 107.582031 287.503906 L 20.417969 287.503906 C 16.042969 287.503906 12.496094 283.957031 12.496094 279.582031 L 12.496094 192.417969 C 12.496094 188.042969 16.042969 184.496094 20.417969 184.496094 Z M 20.417969 184.496094 " transform="matrix(1,0,0,1,8,-156)"/>
|
||||||
|
</g>
|
||||||
|
<mask id="mask3">
|
||||||
|
<g filter="url(#alpha)">
|
||||||
|
<rect x="0" y="0" width="128" height="128" style="fill:rgb(0%,0%,0%);fill-opacity:0.1;stroke:none;"/>
|
||||||
|
</g>
|
||||||
|
</mask>
|
||||||
|
<clipPath id="clip4">
|
||||||
|
<rect x="0" y="0" width="192" height="152"/>
|
||||||
|
</clipPath>
|
||||||
|
<g id="surface10641" clip-path="url(#clip4)">
|
||||||
|
<path style="fill:none;stroke-width:0.99;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-dasharray:0.99,0.99;stroke-miterlimit:4;" d="M 16.425781 200.496094 L 111.574219 200.496094 C 115.953125 200.496094 119.503906 204.390625 119.503906 209.195312 L 119.503906 278.804688 C 119.503906 283.609375 115.953125 287.503906 111.574219 287.503906 L 16.425781 287.503906 C 12.046875 287.503906 8.496094 283.609375 8.496094 278.804688 L 8.496094 209.195312 C 8.496094 204.390625 12.046875 200.496094 16.425781 200.496094 Z M 16.425781 200.496094 " transform="matrix(1,0,0,1,8,-156)"/>
|
||||||
|
</g>
|
||||||
|
</defs>
|
||||||
|
<g id="surface10578">
|
||||||
|
<rect x="0" y="0" width="128" height="128" style="fill:rgb(94.117647%,94.117647%,94.117647%);fill-opacity:1;stroke:none;"/>
|
||||||
|
<use xlink:href="#surface10632" transform="matrix(1,0,0,1,-8,-16)" mask="url(#mask0)"/>
|
||||||
|
<use xlink:href="#surface10635" transform="matrix(1,0,0,1,-8,-16)" mask="url(#mask1)"/>
|
||||||
|
<use xlink:href="#surface10638" transform="matrix(1,0,0,1,-8,-16)" mask="url(#mask2)"/>
|
||||||
|
<use xlink:href="#surface10641" transform="matrix(1,0,0,1,-8,-16)" mask="url(#mask3)"/>
|
||||||
|
<path style="fill:none;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(38.431373%,62.7451%,91.764706%);stroke-opacity:1;stroke-miterlimit:4;" d="M 0 289 L 128 289 " transform="matrix(1,0,0,1,0,-172)"/>
|
||||||
|
</g>
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 4.5 KiB |
32
applets/cosmic-applet-time/src/main.rs
Normal file
32
applets/cosmic-applet-time/src/main.rs
Normal file
|
|
@ -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();
|
||||||
|
}
|
||||||
33
applets/cosmic-applet-time/src/style.css
Normal file
33
applets/cosmic-applet-time/src/style.css
Normal file
|
|
@ -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;
|
||||||
|
}
|
||||||
|
|
@ -6,14 +6,12 @@ use gtk4::{
|
||||||
subclass::prelude::*,
|
subclass::prelude::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::application::PanelApp;
|
|
||||||
use crate::deref_cell::DerefCell;
|
use crate::deref_cell::DerefCell;
|
||||||
use crate::popover_container::PopoverContainer;
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct TimeButtonInner {
|
pub struct TimeButtonInner {
|
||||||
calendar: DerefCell<gtk4::Calendar>,
|
calendar: DerefCell<gtk4::Calendar>,
|
||||||
button: DerefCell<gtk4::ToggleButton>,
|
button: DerefCell<gtk4::MenuButton>,
|
||||||
label: DerefCell<gtk4::Label>,
|
label: DerefCell<gtk4::Label>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -42,21 +40,21 @@ impl ObjectImpl for TimeButtonInner {
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
let button = cascade! {
|
let popover = cascade! {
|
||||||
gtk4::ToggleButton::new();
|
gtk4::Popover::new();
|
||||||
..set_has_frame(false);
|
..set_child(Some(&cascade! {
|
||||||
..set_child(Some(&label));
|
|
||||||
};
|
|
||||||
|
|
||||||
cascade! {
|
|
||||||
PopoverContainer::new(&button);
|
|
||||||
..set_parent(obj);
|
|
||||||
..popover().set_child(Some(&cascade! {
|
|
||||||
gtk4::Box::new(gtk4::Orientation::Horizontal, 0);
|
gtk4::Box::new(gtk4::Orientation::Horizontal, 0);
|
||||||
..append(&calendar);
|
..append(&calendar);
|
||||||
}));
|
}));
|
||||||
..popover().connect_show(clone!(@strong obj => move |_| obj.opening()));
|
..connect_show(clone!(@strong obj => move |_| obj.opening()));
|
||||||
..popover().bind_property("visible", &button, "active").flags(glib::BindingFlags::BIDIRECTIONAL).build();
|
};
|
||||||
|
|
||||||
|
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);
|
self.calendar.set(calendar);
|
||||||
|
|
@ -87,10 +85,8 @@ glib::wrapper! {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TimeButton {
|
impl TimeButton {
|
||||||
pub fn new(app: &PanelApp) -> Self {
|
pub fn new() -> Self {
|
||||||
let obj = glib::Object::new::<Self>(&[]).unwrap();
|
glib::Object::new::<Self>(&[]).unwrap()
|
||||||
|
|
||||||
obj
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn inner(&self) -> &TimeButtonInner {
|
fn inner(&self) -> &TimeButtonInner {
|
||||||
6
justfile
6
justfile
|
|
@ -21,6 +21,7 @@ notifications_id := 'com.system76.CosmicAppletNotifications'
|
||||||
power_id := 'com.system76.CosmicAppletPower'
|
power_id := 'com.system76.CosmicAppletPower'
|
||||||
workspaces_id := 'com.system76.CosmicAppletWorkspaces'
|
workspaces_id := 'com.system76.CosmicAppletWorkspaces'
|
||||||
status_area_id := 'com.system76.CosmicAppletStatusArea'
|
status_area_id := 'com.system76.CosmicAppletStatusArea'
|
||||||
|
time_id := 'com.system76.CosmicAppletTime'
|
||||||
app_button_id := 'com.system76.CosmicPanelAppButton'
|
app_button_id := 'com.system76.CosmicPanelAppButton'
|
||||||
workspaces_button_id := 'com.system76.CosmicPanelWorkspacesButton'
|
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 -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
|
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
|
# 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/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
|
install -Dm0644 applets/cosmic-panel-app-button/data/{{app_button_id}}.desktop {{sharedir}}/applications/{{app_button_id}}.desktop
|
||||||
|
|
|
||||||
|
|
@ -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"]
|
|
||||||
|
|
@ -1,3 +0,0 @@
|
||||||
# cosmic-panel
|
|
||||||
|
|
||||||
An **experimental** and incomplete panel, currently for X11 systems.
|
|
||||||
|
|
@ -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<bool>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[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::<gdk::Monitor>()
|
|
||||||
.unwrap());
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl GtkApplicationImpl for PanelAppInner {}
|
|
||||||
|
|
||||||
glib::wrapper! {
|
|
||||||
pub struct PanelApp(ObjectSubclass<PanelAppInner>)
|
|
||||||
@extends gtk4::Application, gio::Application,
|
|
||||||
@implements gio::ActionGroup, gio::ActionMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PanelApp {
|
|
||||||
pub fn new() -> Self {
|
|
||||||
glib::Object::new::<Self>(&[]).unwrap()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn inner(&self) -> &PanelAppInner {
|
|
||||||
PanelAppInner::from_instance(self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn add_window_for_monitor(&self, monitor: gdk::Monitor) {
|
|
||||||
window::create(self, monitor);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -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();
|
|
||||||
}
|
|
||||||
|
|
@ -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<gtk4::Widget>,
|
|
||||||
popover: DerefCell<gtk4::Popover>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[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<PopoverContainerInner>)
|
|
||||||
@extends gtk4::Widget;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PopoverContainer {
|
|
||||||
pub fn new<T: IsA<gtk4::Widget>>(child: &T) -> Self {
|
|
||||||
let obj = glib::Object::new::<Self>(&[]).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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -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<Option<(i32, i32)>>,
|
|
||||||
monitor: DerefCell<gdk::Monitor>,
|
|
||||||
box_: DerefCell<gtk4::CenterBox>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[glib::object_subclass]
|
|
||||||
impl ObjectSubclass for PanelWindowInner {
|
|
||||||
const NAME: &'static str = "S76PanelWindow";
|
|
||||||
type ParentType = gtk4::ApplicationWindow;
|
|
||||||
type Type = PanelWindow;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ObjectImpl for PanelWindowInner {
|
|
||||||
fn constructed(&self, obj: &PanelWindow) {
|
|
||||||
let box_ = cascade! {
|
|
||||||
gtk4::CenterBox::new();
|
|
||||||
..set_start_widget(Some(&cascade! {
|
|
||||||
gtk4::Box::new(gtk4::Orientation::Horizontal, 0);
|
|
||||||
..append(&button("Workspaces"));
|
|
||||||
..append(&button("Applications"));
|
|
||||||
}));
|
|
||||||
};
|
|
||||||
|
|
||||||
cascade! {
|
|
||||||
obj;
|
|
||||||
..set_decorated(false);
|
|
||||||
..set_child(Some(&box_));
|
|
||||||
};
|
|
||||||
|
|
||||||
self.box_.set(box_);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl WidgetImpl for PanelWindowInner {
|
|
||||||
fn realize(&self, obj: &PanelWindow) {
|
|
||||||
self.parent_realize(obj);
|
|
||||||
|
|
||||||
let surface = obj.surface();
|
|
||||||
surface.connect_layout(clone!(@weak obj => move |_surface, width, height| {
|
|
||||||
let size = Some((width, height));
|
|
||||||
if obj.inner().size.replace(size) != size {
|
|
||||||
obj.monitor_geometry_changed();
|
|
||||||
}
|
|
||||||
}));
|
|
||||||
}
|
|
||||||
|
|
||||||
fn show(&self, obj: &PanelWindow) {
|
|
||||||
self.parent_show(obj);
|
|
||||||
|
|
||||||
if let Some((display, surface)) = x::get_window_x11(obj) {
|
|
||||||
unsafe {
|
|
||||||
surface.set_skip_pager_hint(true);
|
|
||||||
surface.set_skip_taskbar_hint(true);
|
|
||||||
x::wm_state_add(&display, &surface, "_NET_WM_STATE_ABOVE");
|
|
||||||
x::wm_state_add(&display, &surface, "_NET_WM_STATE_STICKY");
|
|
||||||
x::change_property(
|
|
||||||
&display,
|
|
||||||
&surface,
|
|
||||||
"_NET_WM_ALLOWED_ACTIONS",
|
|
||||||
x::PropMode::Replace,
|
|
||||||
&[
|
|
||||||
x::Atom::new(&display, "_NET_WM_ACTION_CHANGE_DESKTOP").unwrap(),
|
|
||||||
x::Atom::new(&display, "_NET_WM_ACTION_ABOVE").unwrap(),
|
|
||||||
x::Atom::new(&display, "_NET_WM_ACTION_BELOW").unwrap(),
|
|
||||||
],
|
|
||||||
);
|
|
||||||
x::change_property(
|
|
||||||
&display,
|
|
||||||
&surface,
|
|
||||||
"_NET_WM_WINDOW_TYPE",
|
|
||||||
x::PropMode::Replace,
|
|
||||||
&[x::Atom::new(&display, "_NET_WM_WINDOW_TYPE_DOCK").unwrap()],
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
self.monitor
|
|
||||||
.connect_geometry_notify(clone!(@strong obj => move |_| {
|
|
||||||
obj.monitor_geometry_changed();
|
|
||||||
}));
|
|
||||||
obj.monitor_geometry_changed();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl WindowImpl for PanelWindowInner {}
|
|
||||||
impl ApplicationWindowImpl for PanelWindowInner {}
|
|
||||||
|
|
||||||
glib::wrapper! {
|
|
||||||
pub struct PanelWindow(ObjectSubclass<PanelWindowInner>)
|
|
||||||
@extends gtk4::ApplicationWindow, gtk4::Window, gtk4::Widget,
|
|
||||||
@implements gtk4::Accessible, gtk4::Buildable, gtk4::ConstraintTarget, gtk4::Native, gtk4::Root, gtk4::ShortcutManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PanelWindow {
|
|
||||||
pub fn new(app: &PanelApp, monitor: gdk::Monitor) -> Self {
|
|
||||||
let obj = glib::Object::new::<Self>(&[]).unwrap();
|
|
||||||
|
|
||||||
monitor.connect_invalidate(clone!(@weak obj => move |_| obj.close()));
|
|
||||||
|
|
||||||
obj.set_size_request(monitor.geometry().width(), 0);
|
|
||||||
obj.inner().monitor.set(monitor);
|
|
||||||
|
|
||||||
obj.inner()
|
|
||||||
.box_
|
|
||||||
.set_center_widget(Some(&TimeButton::new(app)));
|
|
||||||
|
|
||||||
app.add_window(&obj);
|
|
||||||
|
|
||||||
obj
|
|
||||||
}
|
|
||||||
|
|
||||||
fn inner(&self) -> &PanelWindowInner {
|
|
||||||
PanelWindowInner::from_instance(self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn monitor_geometry_changed(&self) {
|
|
||||||
let geometry = self.inner().monitor.geometry();
|
|
||||||
self.set_size_request(geometry.width(), 0);
|
|
||||||
|
|
||||||
let height = if let Some((_width, height)) = self.inner().size.get() {
|
|
||||||
height as x::c_ulong
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Some((display, surface)) = x::get_window_x11(self) {
|
|
||||||
let start_x = geometry.x() as x::c_ulong;
|
|
||||||
let end_x = start_x + geometry.width() as x::c_ulong - 1;
|
|
||||||
|
|
||||||
unsafe {
|
|
||||||
let y = if BOTTOM {
|
|
||||||
geometry.height() as x::c_int - height as x::c_int
|
|
||||||
} else {
|
|
||||||
0
|
|
||||||
};
|
|
||||||
|
|
||||||
x::set_position(&display, &surface, start_x as _, y);
|
|
||||||
|
|
||||||
let strut = if BOTTOM {
|
|
||||||
[0, 0, 0, height, 0, 0, 0, 0, 0, 0, start_x, end_x]
|
|
||||||
} else {
|
|
||||||
[0, 0, height, 0, 0, 0, 0, 0, start_x, end_x, 0, 0]
|
|
||||||
};
|
|
||||||
|
|
||||||
x::change_property(
|
|
||||||
&display,
|
|
||||||
&surface,
|
|
||||||
"_NET_WM_STRUT_PARTIAL",
|
|
||||||
x::PropMode::Replace,
|
|
||||||
&strut,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue