Use libcosmic-applet in time applet
Need to get button height right.
This commit is contained in:
parent
765e3af815
commit
ee142903bb
10 changed files with 24 additions and 75 deletions
|
|
@ -1,3 +1,4 @@
|
|||
use cascade::cascade;
|
||||
use gtk4::{glib, prelude::*};
|
||||
|
||||
mod deref_cell;
|
||||
|
|
@ -7,25 +8,11 @@ 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();
|
||||
cascade! {
|
||||
libcosmic_applet::AppletWindow::new();
|
||||
..set_child(Some(&TimeButton::new()));
|
||||
..show();
|
||||
};
|
||||
|
||||
let main_loop = glib::MainLoop::new(None, false);
|
||||
main_loop.run();
|
||||
|
|
|
|||
|
|
@ -1,33 +0,0 @@
|
|||
.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;
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@ use crate::deref_cell::DerefCell;
|
|||
#[derive(Default)]
|
||||
pub struct TimeButtonInner {
|
||||
calendar: DerefCell<gtk4::Calendar>,
|
||||
button: DerefCell<gtk4::MenuButton>,
|
||||
button: DerefCell<libcosmic_applet::AppletButton>,
|
||||
label: DerefCell<gtk4::Label>,
|
||||
}
|
||||
|
||||
|
|
@ -40,21 +40,15 @@ impl ObjectImpl for TimeButtonInner {
|
|||
}));
|
||||
};
|
||||
|
||||
let popover = cascade! {
|
||||
gtk4::Popover::new();
|
||||
..set_child(Some(&cascade! {
|
||||
let button = cascade! {
|
||||
libcosmic_applet::AppletButton::new();
|
||||
..set_parent(obj);
|
||||
..connect_activate(clone!(@strong obj => move |_| obj.opening()));
|
||||
..set_button_child(Some(&label));
|
||||
..set_popover_child(Some(&cascade! {
|
||||
gtk4::Box::new(gtk4::Orientation::Horizontal, 0);
|
||||
..append(&calendar);
|
||||
}));
|
||||
..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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue