Use GtkApplication
This commit is contained in:
parent
f3828f8239
commit
4e5479cdd8
3 changed files with 97 additions and 34 deletions
37
src/main.rs
37
src/main.rs
|
|
@ -1,5 +1,6 @@
|
|||
use gtk4::{gdk, glib, prelude::*};
|
||||
use gtk4::prelude::*;
|
||||
|
||||
mod application;
|
||||
mod deref_cell;
|
||||
mod mpris;
|
||||
mod mpris_player;
|
||||
|
|
@ -13,36 +14,8 @@ mod time_button;
|
|||
mod window;
|
||||
mod x;
|
||||
|
||||
use application::PanelApp;
|
||||
|
||||
fn main() {
|
||||
gtk4::init().unwrap();
|
||||
let main_context = glib::MainContext::default();
|
||||
let _acquire_guard = main_context.acquire().unwrap();
|
||||
|
||||
let display = gdk::Display::default().unwrap();
|
||||
let monitors = display.monitors().unwrap();
|
||||
|
||||
for i in 0..monitors.n_items() {
|
||||
let monitor = monitors
|
||||
.item(i)
|
||||
.unwrap()
|
||||
.downcast::<gdk::Monitor>()
|
||||
.unwrap();
|
||||
window::PanelWindow::new(monitor).show();
|
||||
}
|
||||
|
||||
monitors.connect_items_changed(|monitors, position, _removed, added| {
|
||||
for i in position..position + added {
|
||||
let monitor = monitors
|
||||
.item(i)
|
||||
.unwrap()
|
||||
.downcast::<gdk::Monitor>()
|
||||
.unwrap();
|
||||
window::PanelWindow::new(monitor).show();
|
||||
}
|
||||
});
|
||||
|
||||
status_notifier_watcher::start();
|
||||
let _notificiations = notifications::Notifications::new();
|
||||
|
||||
glib::MainLoop::new(None, false).run();
|
||||
PanelApp::new().run();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue