From 3058861f8977374dff1ed6401bbdac9cce92bc99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Sat, 13 Aug 2016 16:37:57 +0200 Subject: indicate iconified windows in iconbar --- src/IconButton.cc | 10 +++++++++- src/IconbarTool.cc | 19 +++++++++++++++++++ src/IconbarTool.hh | 5 +++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/IconButton.cc b/src/IconButton.cc index 4b0b423..d8205fb 100644 --- a/src/IconButton.cc +++ b/src/IconButton.cc @@ -25,6 +25,7 @@ #include "IconbarTheme.hh" #include "Screen.hh" +#include "Window.hh" #include "FbTk/App.hh" #include "FbTk/Command.hh" @@ -58,6 +59,10 @@ IconButton::IconButton(const FbTk::FbWindow &parent, m_signals.join(m_win.titleSig(), MemFunIgnoreArgs(m_title_update_timer, &FbTk::Timer::start)); + if (m_win.fbwindow()) + m_signals.join(m_win.fbwindow()->stateSig(), + MemFunIgnoreArgs(*this, &IconButton::clientTitleChanged)); + m_signals.join(m_win.focusSig(), MemFunIgnoreArgs(*this, &IconButton::reconfigAndClear)); @@ -250,7 +255,10 @@ void IconButton::clientTitleChanged() { void IconButton::setupWindow() { m_icon_window.clear(); - setText(m_win.title()); + FbTk::FbString title = m_win.title().logical(); + if (m_win.fbwindow() && m_win.fbwindow()->isIconic()) + title = IconbarTool::iconifiedPrefix() + title + IconbarTool::iconifiedSuffix(); + setText(title); FbTk::TextButton::clear(); } diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc index d940b1d..128b71e 100644 --- a/src/IconbarTool.cc +++ b/src/IconbarTool.cc @@ -225,6 +225,8 @@ private: } // end anonymous namespace +std::string IconbarTool::s_iconifiedDecoration[2]; + IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, FbTk::ThemeProxy &focused_theme, FbTk::ThemeProxy &unfocused_theme, @@ -252,6 +254,8 @@ IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, *screen.layerManager().getLayer(ResourceLayer::MENU)), m_alpha(255) { + updateIconifiedPattern(); + // setup mode menu setupModeMenu(m_menu, *this); _FB_USES_NLS; @@ -279,6 +283,8 @@ IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, FbTk::MemFun(*this, &IconbarTool::themeReconfigured)); m_tracker.join(unfocused_theme.reconfigSig(), FbTk::MemFun(*this, &IconbarTool::themeReconfigured)); + m_tracker.join(screen.reconfigureSig(), + FbTk::MemFunIgnoreArgs(*this, &IconbarTool::updateIconifiedPattern)); themeReconfigured(); } @@ -439,6 +445,19 @@ void IconbarTool::update(UpdateReason reason, Focusable *win) { renderTheme(); } +void IconbarTool::updateIconifiedPattern() { + FbTk::Resource p(m_screen.resourceManager(), "( %t )", + m_screen.name() + ".iconbar.iconifiedPattern", + m_screen.altName() + ".Iconbar.IconifiedPattern"); + size_t tidx = p->find("%t"); + s_iconifiedDecoration[0].clear(); + s_iconifiedDecoration[1].clear(); + if (tidx != std::string::npos) { + s_iconifiedDecoration[0] = p->substr(0, tidx); + s_iconifiedDecoration[1] = p->substr(tidx+2); + } +} + void IconbarTool::insertWindow(Focusable &win, int pos) { IconButton *button = 0; diff --git a/src/IconbarTool.hh b/src/IconbarTool.hh index 21c8078..6044005 100644 --- a/src/IconbarTool.hh +++ b/src/IconbarTool.hh @@ -68,6 +68,8 @@ public: void setOrientation(FbTk::Orientation orient); FbTk::Container::Alignment alignment() const { return m_icon_container.alignment(); } + static std::string &iconifiedPrefix() { return s_iconifiedDecoration[0]; } + static std::string &iconifiedSuffix() { return s_iconifiedDecoration[1]; } const BScreen &screen() const { return m_screen; } private: @@ -98,6 +100,8 @@ private: /// called when the list emits a signal void update(UpdateReason reason, Focusable *win); + void updateIconifiedPattern(); + void themeReconfigured(); BScreen &m_screen; @@ -118,6 +122,7 @@ private: FbTk::Resource m_rc_use_pixmap; ///< if iconbar should use win pixmap or not FbMenu m_menu; int m_alpha; + static std::string s_iconifiedDecoration[2]; }; #endif // ICONBARTOOL_HH -- cgit v0.11.2