From f833ff71a579406f6e5d46770acb726ba040f9e1 Mon Sep 17 00:00:00 2001 From: Gregor Bollerhey Date: Sun, 12 Jan 2014 04:35:30 +0100 Subject: Use FbTk::StringUtils instead of own tokenizer. --- src/SystemTray.cc | 37 +++++++++---------------------------- 1 file changed, 9 insertions(+), 28 deletions(-) diff --git a/src/SystemTray.cc b/src/SystemTray.cc index dff10b5..b4f1e9b 100644 --- a/src/SystemTray.cc +++ b/src/SystemTray.cc @@ -23,6 +23,7 @@ #include "FbTk/EventManager.hh" #include "FbTk/ImageControl.hh" +#include "FbTk/StringUtil.hh" #include "FbTk/TextUtils.hh" #include "FbTk/MemFun.hh" @@ -83,31 +84,6 @@ void getScreenCoordinates(Window win, int x, int y, int &screen_x, int &screen_y static SystemTray *s_theoneandonly = 0; -static std::string trim(const std::string& str) -{ - // removes trailing and leading whitespace from a string - - const std::string whitespace(" \t"); - const auto strBegin = str.find_first_not_of(whitespace); - if (strBegin == std::string::npos) - return ""; // no content - - const auto strEnd = str.find_last_not_of(whitespace); - const auto strRange = strEnd - strBegin + 1; - - return str.substr(strBegin, strRange); -} - -static void parse_order(const std::string s, std::vector &out) { - // splits a comma seperated list and performs trimming - - std::stringstream ss(s); - std::string item; - - while (std::getline(ss, item, ',')) - out.push_back(trim(item)); -} - /// helper class for tray windows, so we dont call XDestroyWindow class SystemTray::TrayWindow : public FbTk::FbWindow { public: @@ -259,8 +235,8 @@ SystemTray::SystemTray(const FbTk::FbWindow& parent, "", screen.name() + ".systray.pinRight", screen.altName() + ".Systray.PinRight") { - parse_order(m_rc_systray_pinleft, m_pinleft); - parse_order(m_rc_systray_pinright, m_pinright); + FbTk::StringUtil::stringtok(m_pinleft, m_rc_systray_pinleft, " ,"); + FbTk::StringUtil::stringtok(m_pinright, m_rc_systray_pinright, " ,"); FbTk::EventManager::instance()->add(*this, m_window); FbTk::EventManager::instance()->add(*this, m_selection_owner); @@ -627,7 +603,12 @@ void SystemTray::showClient(TrayWindow *traywin) { } void SystemTray::sortClients() { - m_clients.sort([](TrayWindow *a, TrayWindow *b){return a->m_order < b->m_order;}); + m_clients.sort( + [](TrayWindow *a, TrayWindow *b) { + return a->m_order < b->m_order; + } + ); + rearrangeClients(); } -- cgit v0.11.2