mirror of
https://github.com/Zedfrigg/ironbar.git
synced 2025-07-03 19:51:03 +02:00
feat: more positioning options (#23)
* feat: more positioning options Can now display the bar on the left/right, and avoid anchoring to edges to centre the bar. BREAKING CHANGE: The `left` and `right` config options have been renamed to `start` and `end`
This commit is contained in:
parent
1b853bcb71
commit
06cfad62e2
14 changed files with 254 additions and 83 deletions
|
@ -6,7 +6,7 @@ use crate::modules::ModuleUpdateEvent;
|
|||
use crate::popup::Popup;
|
||||
use crate::wayland::ToplevelInfo;
|
||||
use gtk::prelude::*;
|
||||
use gtk::{Button, IconTheme, Image};
|
||||
use gtk::{Button, IconTheme, Image, Orientation};
|
||||
use std::rc::Rc;
|
||||
use std::sync::RwLock;
|
||||
use tokio::sync::mpsc::Sender;
|
||||
|
@ -139,6 +139,7 @@ impl ItemButton {
|
|||
item: &Item,
|
||||
show_names: bool,
|
||||
show_icons: bool,
|
||||
orientation: Orientation,
|
||||
icon_theme: &IconTheme,
|
||||
tx: &Sender<ModuleUpdateEvent<LauncherUpdate>>,
|
||||
controller_tx: &Sender<ItemEvent>,
|
||||
|
@ -208,8 +209,11 @@ impl ItemButton {
|
|||
)))
|
||||
.expect("Failed to send item open popup event");
|
||||
|
||||
tx.try_send(ModuleUpdateEvent::OpenPopup(Popup::button_pos(button)))
|
||||
.expect("Failed to send item open popup event");
|
||||
tx.try_send(ModuleUpdateEvent::OpenPopup(Popup::button_pos(
|
||||
button,
|
||||
orientation,
|
||||
)))
|
||||
.expect("Failed to send item open popup event");
|
||||
} else {
|
||||
tx.try_send(ModuleUpdateEvent::ClosePopup)
|
||||
.expect("Failed to send item close popup event");
|
||||
|
|
|
@ -309,20 +309,21 @@ impl Module<gtk::Box> for LauncherModule {
|
|||
fn into_widget(
|
||||
self,
|
||||
context: WidgetContext<Self::SendMessage, Self::ReceiveMessage>,
|
||||
_info: &ModuleInfo,
|
||||
info: &ModuleInfo,
|
||||
) -> crate::Result<ModuleWidget<gtk::Box>> {
|
||||
let icon_theme = IconTheme::new();
|
||||
if let Some(ref theme) = self.icon_theme {
|
||||
icon_theme.set_custom_theme(Some(theme));
|
||||
}
|
||||
|
||||
let container = gtk::Box::new(Orientation::Horizontal, 0);
|
||||
let container = gtk::Box::new(info.bar_position.get_orientation(), 0);
|
||||
|
||||
{
|
||||
let container = container.clone();
|
||||
|
||||
let show_names = self.show_names;
|
||||
let show_icons = self.show_icons;
|
||||
let orientation = info.bar_position.get_orientation();
|
||||
|
||||
let mut buttons = Collection::<String, ItemButton>::new();
|
||||
|
||||
|
@ -339,6 +340,7 @@ impl Module<gtk::Box> for LauncherModule {
|
|||
&item,
|
||||
show_names,
|
||||
show_icons,
|
||||
orientation,
|
||||
&icon_theme,
|
||||
&context.tx,
|
||||
&controller_tx2,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue