diff options
Diffstat (limited to 'src/WorkspaceNameTool.cc')
-rw-r--r-- | src/WorkspaceNameTool.cc | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/WorkspaceNameTool.cc b/src/WorkspaceNameTool.cc index dbbc571..fdc4ffe 100644 --- a/src/WorkspaceNameTool.cc +++ b/src/WorkspaceNameTool.cc | |||
@@ -30,6 +30,8 @@ | |||
30 | 30 | ||
31 | #include "FbTk/ImageControl.hh" | 31 | #include "FbTk/ImageControl.hh" |
32 | 32 | ||
33 | #include <algorithm> | ||
34 | |||
33 | WorkspaceNameTool::WorkspaceNameTool(const FbTk::FbWindow &parent, | 35 | WorkspaceNameTool::WorkspaceNameTool(const FbTk::FbWindow &parent, |
34 | ToolTheme &theme, BScreen &screen): | 36 | ToolTheme &theme, BScreen &screen): |
35 | ToolbarItem(ToolbarItem::FIXED), | 37 | ToolbarItem(ToolbarItem::FIXED), |
@@ -68,6 +70,7 @@ void WorkspaceNameTool::moveResize(int x, int y, | |||
68 | } | 70 | } |
69 | 71 | ||
70 | void WorkspaceNameTool::update(FbTk::Subject *subj) { | 72 | void WorkspaceNameTool::update(FbTk::Subject *subj) { |
73 | |||
71 | m_button.setText(m_screen.currentWorkspace()->name()); | 74 | m_button.setText(m_screen.currentWorkspace()->name()); |
72 | if (m_button.width() != width()) { | 75 | if (m_button.width() != width()) { |
73 | resize(width(), height()); | 76 | resize(width(), height()); |
@@ -79,13 +82,13 @@ void WorkspaceNameTool::update(FbTk::Subject *subj) { | |||
79 | 82 | ||
80 | unsigned int WorkspaceNameTool::width() const { | 83 | unsigned int WorkspaceNameTool::width() const { |
81 | // calculate largest size | 84 | // calculate largest size |
82 | int max_size = 0; | 85 | unsigned int max_size = 0; |
83 | const int num_workspaces = m_screen.getNumberOfWorkspaces(); | 86 | const BScreen::Workspaces& workspaces = m_screen.getWorkspacesList(); |
84 | for (int workspace = 0; workspace < num_workspaces; ++workspace) { | 87 | BScreen::Workspaces::const_iterator it; |
85 | const std::string &name = m_screen.getWorkspace(workspace)->name().c_str(); | 88 | for (it = workspaces.begin(); it != workspaces.end(); it++) { |
86 | int size = m_theme.font().textWidth(name.c_str(), name.size()); | 89 | const std::string &name = (*it)->name(); |
87 | if (size > max_size) | 90 | max_size = std::max(m_theme.font().textWidth(name.c_str(), name.size()), |
88 | max_size = size; | 91 | max_size); |
89 | } | 92 | } |
90 | // so align text dont cut the last character | 93 | // so align text dont cut the last character |
91 | max_size += 2; | 94 | max_size += 2; |