wip: use toplevel protocols
This commit is contained in:
parent
647a402206
commit
560ebc0bf5
20 changed files with 1073 additions and 623 deletions
|
|
@ -13,7 +13,7 @@ use once_cell::sync::OnceCell;
|
|||
use tokio::sync::mpsc::Sender;
|
||||
|
||||
use crate::dock_object::DockObject;
|
||||
use crate::utils::Event;
|
||||
use crate::utils::AppListEvent;
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct DockPopover {
|
||||
|
|
@ -26,7 +26,7 @@ pub struct DockPopover {
|
|||
pub quit_all_item: Rc<RefCell<Button>>,
|
||||
//TODO figure out how to use lifetimes with glib::wrapper! macro
|
||||
pub dock_object: Rc<RefCell<Option<DockObject>>>,
|
||||
pub tx: OnceCell<Sender<Event>>,
|
||||
pub tx: OnceCell<Sender<AppListEvent>>,
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
|
|
|
|||
|
|
@ -9,9 +9,11 @@ use gtk4::{prelude::*, Label};
|
|||
use gtk4::{Box, Button, Image, ListBox, Orientation};
|
||||
use tokio::sync::mpsc::Sender;
|
||||
|
||||
use crate::wayland::ToplevelEvent;
|
||||
use crate::{TX, WAYLAND_TX};
|
||||
use crate::dock_object::DockObject;
|
||||
use crate::utils::BoxedWindowList;
|
||||
use crate::utils::Event;
|
||||
use crate::utils::AppListEvent;
|
||||
|
||||
mod imp;
|
||||
|
||||
|
|
@ -22,10 +24,9 @@ glib::wrapper! {
|
|||
}
|
||||
|
||||
impl DockPopover {
|
||||
pub fn new(tx: Sender<Event>) -> Self {
|
||||
pub fn new() -> Self {
|
||||
let self_: DockPopover = glib::Object::new(&[]).expect("Failed to create DockList");
|
||||
let imp = imp::DockPopover::from_instance(&self_);
|
||||
imp.tx.set(tx).unwrap();
|
||||
self_.layout();
|
||||
//dnd behavior is different for each type, as well as the data in the model
|
||||
self_
|
||||
|
|
@ -192,30 +193,24 @@ impl DockPopover {
|
|||
self_.emit_hide();
|
||||
}));
|
||||
|
||||
let tx = imp.tx.get().unwrap().clone();
|
||||
let self_ = self.clone();
|
||||
quit_all_item.connect_clicked(glib::clone!(@weak dock_object => move |_| {
|
||||
let active = dock_object.property::<BoxedWindowList>("active").0;
|
||||
for w in active {
|
||||
let entity = w.entity;
|
||||
let tx = tx.clone();
|
||||
glib::MainContext::default().spawn_local(async move {
|
||||
let _ = tx.clone().send(Event::Close(entity)).await;
|
||||
});
|
||||
let t = w.toplevel_handle.clone();
|
||||
let tx = WAYLAND_TX.get().unwrap().clone();
|
||||
let _ = tx.clone().send(ToplevelEvent::Close(t));
|
||||
}
|
||||
self_.emit_hide();
|
||||
}));
|
||||
|
||||
let tx = imp.tx.get().unwrap().clone();
|
||||
let self_ = self.clone();
|
||||
favorite_item.connect_clicked(glib::clone!(@weak dock_object => move |_| {
|
||||
let saved = dock_object.property::<bool>("saved");
|
||||
let tx = tx.clone();
|
||||
glib::MainContext::default().spawn_local(async move {
|
||||
if let Some(name) = dock_object.get_name() {
|
||||
let _ = tx.clone().send(Event::Favorite((name, !saved))).await;
|
||||
}
|
||||
});
|
||||
if let Some(name) = dock_object.get_name() {
|
||||
let tx = TX.get().unwrap().clone();
|
||||
let _ = tx.clone().send(AppListEvent::Favorite((name, !saved)));
|
||||
}
|
||||
self_.emit_hide();
|
||||
}));
|
||||
|
||||
|
|
@ -227,16 +222,13 @@ impl DockPopover {
|
|||
// }),
|
||||
// );
|
||||
|
||||
let tx = imp.tx.get().unwrap().clone();
|
||||
let self_ = self.clone();
|
||||
window_listbox.connect_row_activated(
|
||||
glib::clone!(@weak dock_object => move |_, item| {
|
||||
let active = dock_object.property::<BoxedWindowList>("active").0;
|
||||
let entity = active[usize::try_from(item.index()).unwrap()].entity;
|
||||
let tx = tx.clone();
|
||||
glib::MainContext::default().spawn_local(async move {
|
||||
let _ = tx.send(Event::Activate(entity)).await;
|
||||
});
|
||||
let t = active[usize::try_from(item.index()).unwrap()].toplevel_handle.clone();
|
||||
let tx = WAYLAND_TX.get().unwrap().clone();
|
||||
let _ = tx.send(ToplevelEvent::Activate(t));
|
||||
self_.emit_hide();
|
||||
}),
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue