aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-08-12 12:16:28 (GMT)
committerfluxgen <fluxgen>2003-08-12 12:16:28 (GMT)
commitcb0621a6b6a9470abb507a9fe87bd3d90491d695 (patch)
tree2a6ac20a3f842fec3ac3003d62f9426d7be0640e /src
parentee0ff9d6e3aaac0d39b39860e409863cfa2a439f (diff)
downloadfluxbox-cb0621a6b6a9470abb507a9fe87bd3d90491d695.zip
fluxbox-cb0621a6b6a9470abb507a9fe87bd3d90491d695.tar.bz2
code cleaning and optimization
Diffstat (limited to 'src')
-rw-r--r--src/IconbarTool.cc120
1 files changed, 54 insertions, 66 deletions
diff --git a/src/IconbarTool.cc b/src/IconbarTool.cc
index 526817a..17faf7c 100644
--- a/src/IconbarTool.cc
+++ b/src/IconbarTool.cc
@@ -20,7 +20,7 @@
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE. 21// DEALINGS IN THE SOFTWARE.
22 22
23// $Id: IconbarTool.cc,v 1.4 2003/08/12 11:09:46 fluxgen Exp $ 23// $Id: IconbarTool.cc,v 1.5 2003/08/12 12:16:28 fluxgen Exp $
24 24
25#include "IconbarTool.hh" 25#include "IconbarTool.hh"
26 26
@@ -31,14 +31,6 @@
31#include "IconButton.hh" 31#include "IconButton.hh"
32#include "Workspace.hh" 32#include "Workspace.hh"
33 33
34#include <iostream>
35using namespace std;
36class ShowTextCmd: public FbTk::Command {
37 void execute() {
38 cerr<<"ShowTextCmd"<<endl;
39 }
40};
41
42IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, BScreen &screen): 34IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, BScreen &screen):
43 ToolbarItem(ToolbarItem::RELATIVE), 35 ToolbarItem(ToolbarItem::RELATIVE),
44 m_screen(screen), 36 m_screen(screen),
@@ -58,10 +50,7 @@ IconbarTool::IconbarTool(const FbTk::FbWindow &parent, IconbarTheme &theme, BScr
58} 50}
59 51
60IconbarTool::~IconbarTool() { 52IconbarTool::~IconbarTool() {
61 while (!m_icon_list.empty()) { 53 deleteIcons();
62 delete m_icon_list.back();
63 m_icon_list.pop_back();
64 }
65 54
66 // remove cached images 55 // remove cached images
67 if (m_focused_pm) 56 if (m_focused_pm)
@@ -106,26 +95,41 @@ unsigned int IconbarTool::height() const {
106} 95}
107 96
108void IconbarTool::update(FbTk::Subject *subj) { 97void IconbarTool::update(FbTk::Subject *subj) {
98 // ignore updates if we're shutting down
99 if (m_screen.isShuttingdown())
100 return;
109 101
110 // just focus signal? 102 // just focus signal?
111 if (subj != 0 && typeid(*subj) == typeid(FluxboxWindow::WinSubject)) { 103 if (subj != 0 && typeid(*subj) == typeid(FluxboxWindow::WinSubject)) {
112 // we handle everything except die signal here 104 // we handle everything except die signal here
113 FluxboxWindow::WinSubject *winsubj = static_cast<FluxboxWindow::WinSubject *>(subj); 105 FluxboxWindow::WinSubject *winsubj = static_cast<FluxboxWindow::WinSubject *>(subj);
114 if (subj != &(winsubj->win().dieSig())) { 106 if (subj != &(winsubj->win().dieSig())) {
115 renderButton(winsubj->win()); 107 renderWindow(winsubj->win());
116 return; 108 return;
109 } else {
110 // got window die signal, lets find and remove the window
111 IconList::iterator it = m_icon_list.begin();
112 IconList::iterator it_end = m_icon_list.end();
113 for (; it != it_end; ++it) {
114 if (&(*it)->win() == &winsubj->win())
115 break;
116 }
117 // did we find it?
118 if (it == m_icon_list.end())
119 return;
120 // remove from list and render theme again
121 delete *it;
122 m_icon_list.erase(it);
123 m_icon_container.removeItem(m_icon_container.find(*it));
124 renderTheme();
125 return; // we don't need to update the entire list
117 } 126 }
118 } 127 }
119 128
120 // ok, we got some signal that we need to update our iconbar container 129 // ok, we got some signal that we need to update our iconbar container
121 130
122 // remove all clients and add them again...the only way to do it now 131 // remove all clients and add them again...the only way to do it now
123 m_icon_container.removeAll(); 132 deleteIcons();
124
125 while (!m_icon_list.empty()) {
126 delete m_icon_list.back();
127 m_icon_list.pop_back();
128 }
129 133
130 // get current workspace and all it's clients 134 // get current workspace and all it's clients
131 Workspace &space = *m_screen.currentWorkspace(); 135 Workspace &space = *m_screen.currentWorkspace();
@@ -152,7 +156,7 @@ void IconbarTool::update(FbTk::Subject *subj) {
152 renderTheme(); 156 renderTheme();
153} 157}
154 158
155void IconbarTool::renderButton(FluxboxWindow &win) { 159void IconbarTool::renderWindow(FluxboxWindow &win) {
156 160
157 IconList::iterator icon_it = m_icon_list.begin(); 161 IconList::iterator icon_it = m_icon_list.begin();
158 IconList::iterator icon_it_end = m_icon_list.end(); 162 IconList::iterator icon_it_end = m_icon_list.end();
@@ -160,33 +164,11 @@ void IconbarTool::renderButton(FluxboxWindow &win) {
160 if (&(*icon_it)->win() == &win) 164 if (&(*icon_it)->win() == &win)
161 break; 165 break;
162 } 166 }
167
163 if (icon_it == m_icon_list.end()) 168 if (icon_it == m_icon_list.end())
164 return; 169 return;
165 170
166 IconButton &button = *(*icon_it); 171 renderButton(*(*icon_it));
167
168 if (button.win().isFocused()) { // focused texture
169 button.setGC(m_theme.focusedText().textGC());
170 button.setFont(m_theme.focusedText().font());
171 button.setJustify(m_theme.focusedText().justify());
172
173 if (m_focused_pm != 0)
174 button.setBackgroundPixmap(m_focused_pm);
175 else
176 button.setBackgroundColor(m_theme.focusedTexture().color());
177
178
179 } else { // unfocused
180 button.setGC(m_theme.unfocusedText().textGC());
181 button.setFont(m_theme.unfocusedText().font());
182 button.setJustify(m_theme.unfocusedText().justify());
183
184 if (m_unfocused_pm != 0)
185 button.setBackgroundPixmap(m_unfocused_pm);
186 else
187 button.setBackgroundColor(m_theme.unfocusedTexture().color());
188 }
189
190} 172}
191 173
192void IconbarTool::renderTheme() { 174void IconbarTool::renderTheme() {
@@ -230,32 +212,38 @@ void IconbarTool::renderTheme() {
230 // update buttons 212 // update buttons
231 IconList::iterator icon_it = m_icon_list.begin(); 213 IconList::iterator icon_it = m_icon_list.begin();
232 IconList::iterator icon_it_end = m_icon_list.end(); 214 IconList::iterator icon_it_end = m_icon_list.end();
233 for (; icon_it != icon_it_end; ++icon_it) { 215 for (; icon_it != icon_it_end; ++icon_it)
234 216 renderButton(*(*icon_it));
235 IconButton &button = *(*icon_it); 217}
236 218
237 if (button.win().isFocused()) { // focused texture 219void IconbarTool::renderButton(IconButton &button) {
238 button.setGC(m_theme.focusedText().textGC());
239 button.setFont(m_theme.focusedText().font());
240 button.setJustify(m_theme.focusedText().justify());
241 220
242 if (m_focused_pm != 0) 221 if (button.win().isFocused()) { // focused texture
243 button.setBackgroundPixmap(m_focused_pm); 222 button.setGC(m_theme.focusedText().textGC());
244 else 223 button.setFont(m_theme.focusedText().font());
245 button.setBackgroundColor(m_theme.focusedTexture().color()); 224 button.setJustify(m_theme.focusedText().justify());
246 225
226 if (m_focused_pm != 0)
227 button.setBackgroundPixmap(m_focused_pm);
228 else
229 button.setBackgroundColor(m_theme.focusedTexture().color());
247 230
248 } else { // unfocused 231 } else { // unfocused
249 button.setGC(m_theme.unfocusedText().textGC()); 232 button.setGC(m_theme.unfocusedText().textGC());
250 button.setFont(m_theme.unfocusedText().font()); 233 button.setFont(m_theme.unfocusedText().font());
251 button.setJustify(m_theme.unfocusedText().justify()); 234 button.setJustify(m_theme.unfocusedText().justify());
252 235
253 if (m_unfocused_pm != 0) 236 if (m_unfocused_pm != 0)
254 button.setBackgroundPixmap(m_unfocused_pm); 237 button.setBackgroundPixmap(m_unfocused_pm);
255 else 238 else
256 button.setBackgroundColor(m_theme.unfocusedTexture().color()); 239 button.setBackgroundColor(m_theme.unfocusedTexture().color());
257 } 240 }
241}
258 242
259 button.clear(); 243void IconbarTool::deleteIcons() {
244 m_icon_container.removeAll();
245 while (!m_icon_list.empty()) {
246 delete m_icon_list.back();
247 m_icon_list.pop_back();
260 } 248 }
261} 249}