mirror of
https://github.com/JakeStanger/ironbar.git
synced 2024-11-29 21:16:00 +03:00
feat: introduce logging in some areas
This commit is contained in:
parent
6dcae66570
commit
1e38719996
@ -5,6 +5,7 @@ use color_eyre::Result;
|
||||
use gtk::gdk::Monitor;
|
||||
use gtk::prelude::*;
|
||||
use gtk::{Application, ApplicationWindow, Orientation};
|
||||
use tracing::{debug, info};
|
||||
|
||||
pub fn create_bar(
|
||||
app: &Application,
|
||||
@ -41,10 +42,12 @@ pub fn create_bar(
|
||||
win.add(&content);
|
||||
|
||||
win.connect_destroy_event(|_, _| {
|
||||
info!("Shutting down");
|
||||
gtk::main_quit();
|
||||
Inhibit(false)
|
||||
});
|
||||
|
||||
debug!("Showing bar");
|
||||
win.show_all();
|
||||
|
||||
Ok(())
|
||||
@ -104,6 +107,7 @@ fn add_modules(content: >k::Box, modules: Vec<ModuleConfig>, info: &ModuleInfo
|
||||
let widget = $module.into_widget(&info)?;
|
||||
widget.set_widget_name($name);
|
||||
content.add(&widget);
|
||||
debug!("Added module of type {}", $name);
|
||||
}};
|
||||
}
|
||||
|
||||
|
@ -110,12 +110,16 @@ fn create_bars(app: &Application, display: &Display, config: &Config) -> Result<
|
||||
|
||||
let outputs = serde_json::from_slice::<Vec<SwayOutput>>(&outputs)?;
|
||||
|
||||
debug!("Received {} outputs from Sway IPC", outputs.len());
|
||||
|
||||
let num_monitors = display.n_monitors();
|
||||
|
||||
for i in 0..num_monitors {
|
||||
let monitor = display.monitor(i).ok_or_else(|| Report::msg("GTK and Sway are reporting a different number of outputs - this is a severe bug and should never happen"))?;
|
||||
let monitor_name = &outputs.get(i as usize).ok_or_else(|| Report::msg("GTK and Sway are reporting a different set of outputs - this is a severe bug and should never happen"))?.name;
|
||||
|
||||
info!("Creating bar on '{}'", monitor_name);
|
||||
|
||||
config.monitors.as_ref().map_or_else(
|
||||
|| create_bar(app, &monitor, monitor_name, config.clone()),
|
||||
|config| {
|
||||
|
@ -59,6 +59,7 @@ impl Module<gtk::Box> for WorkspacesModule {
|
||||
if self.all_monitors {
|
||||
workspaces
|
||||
} else {
|
||||
trace!("Filtering workspaces to current monitor only");
|
||||
workspaces
|
||||
.into_iter()
|
||||
.filter(|workspace| workspace.output == info.output_name)
|
||||
@ -72,6 +73,7 @@ impl Module<gtk::Box> for WorkspacesModule {
|
||||
|
||||
let (ui_tx, mut ui_rx) = mpsc::channel(32);
|
||||
|
||||
trace!("Creating workspace buttons");
|
||||
for workspace in workspaces {
|
||||
let item = workspace.as_button(&name_map, &ui_tx);
|
||||
container.add(&item);
|
||||
@ -95,9 +97,11 @@ impl Module<gtk::Box> for WorkspacesModule {
|
||||
});
|
||||
|
||||
{
|
||||
trace!("Setting up sway event handler");
|
||||
let menubar = container.clone();
|
||||
let output_name = info.output_name.to_string();
|
||||
rx.attach(None, move |event| {
|
||||
debug!("Received workspace event {:?}", event);
|
||||
match event.change.as_str() {
|
||||
"focus" => {
|
||||
let old = event.old.and_then(|old| button_map.get(&old.name));
|
||||
@ -109,6 +113,8 @@ impl Module<gtk::Box> for WorkspacesModule {
|
||||
if let Some(new) = new {
|
||||
new.style_context().add_class("focused");
|
||||
}
|
||||
|
||||
trace!("{:?} {:?}", old, new);
|
||||
}
|
||||
"init" => {
|
||||
if let Some(workspace) = event.current {
|
||||
|
@ -133,6 +133,7 @@ impl SwayClient {
|
||||
}
|
||||
|
||||
pub fn ipc(&mut self, command: IpcCommand) -> Result<Vec<u8>> {
|
||||
debug!("Sending command: {:?}", command);
|
||||
match self.client.ipc(command) {
|
||||
Ok(res) => Ok(res),
|
||||
Err(err) => Err(get_client_error(err)),
|
||||
|
Loading…
Reference in New Issue
Block a user