feat: popup positioning depending on panel anchor
This commit is contained in:
parent
ac0b555946
commit
59a112523d
7 changed files with 34 additions and 14 deletions
|
|
@ -2,7 +2,7 @@
|
|||
use crate::dock_list::DockList;
|
||||
use crate::dock_list::DockListType;
|
||||
use cascade::cascade;
|
||||
use cosmic_panel_config::{CosmicPanelConfig, PanelAnchor};
|
||||
use cosmic_panel_config::{PanelAnchor};
|
||||
use gtk4::prelude::*;
|
||||
use gtk4::subclass::prelude::*;
|
||||
use gtk4::Orientation;
|
||||
|
|
|
|||
|
|
@ -17,3 +17,4 @@ serde = "1"
|
|||
zbus = "2.0.1"
|
||||
zbus_names = "2"
|
||||
zvariant = "3"
|
||||
cosmic-panel-config = {git = "https://github.com/pop-os/cosmic-panel", features = ["gtk4"] }
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
use gtk4::{glib, prelude::*};
|
||||
use gtk4::{glib, prelude::*, PositionType};
|
||||
use relm4_macros::view;
|
||||
use cosmic_panel_config::PanelAnchor;
|
||||
|
||||
mod dbus_service;
|
||||
mod deref_cell;
|
||||
|
|
@ -31,7 +32,16 @@ fn main() {
|
|||
window.show();
|
||||
|
||||
// XXX show in correct place
|
||||
let notification_popover = NotificationPopover::new(¬ifications);
|
||||
let position = std::env::var("COSMIC_PANEL_ANCHOR")
|
||||
.ok()
|
||||
.and_then(|anchor| anchor.parse::<PanelAnchor>().ok())
|
||||
.map(|anchor| match anchor {
|
||||
PanelAnchor::Left => PositionType::Right,
|
||||
PanelAnchor::Right => PositionType::Left,
|
||||
PanelAnchor::Top => PositionType::Bottom,
|
||||
PanelAnchor::Bottom => PositionType::Top,
|
||||
});
|
||||
let notification_popover = NotificationPopover::new(¬ifications, position);
|
||||
notification_popover.set_parent(&applet_button);
|
||||
|
||||
let main_loop = glib::MainLoop::new(None, false);
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use cascade::cascade;
|
|||
use gtk4::{
|
||||
glib::{self, clone},
|
||||
prelude::*,
|
||||
subclass::prelude::*,
|
||||
subclass::prelude::*, PositionType,
|
||||
};
|
||||
use std::cell::RefCell;
|
||||
|
||||
|
|
@ -75,9 +75,11 @@ glib::wrapper! {
|
|||
}
|
||||
|
||||
impl NotificationPopover {
|
||||
pub fn new(notifications: &Notifications) -> Self {
|
||||
pub fn new(notifications: &Notifications, position: Option<PositionType>) -> Self {
|
||||
let obj = glib::Object::new::<Self>(&[]).unwrap();
|
||||
|
||||
if let Some(position) = position {
|
||||
obj.set_position(position);
|
||||
}
|
||||
let notification_widget = cascade! {
|
||||
NotificationWidget::new(notifications);
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue