aboutsummaryrefslogtreecommitdiff
path: root/src/Remember.cc
diff options
context:
space:
mode:
authormathias <mathias>2006-10-27 06:57:43 (GMT)
committermathias <mathias>2006-10-27 06:57:43 (GMT)
commit10082d821d6691f42a8d8ad6fa2e42e5b3f44edd (patch)
tree99c94a6105cf35612307e307be343eda2aea8baf /src/Remember.cc
parent34b7f7ddfc3e914238fd0d30ff50c4f37c2a6dd8 (diff)
downloadfluxbox-10082d821d6691f42a8d8ad6fa2e42e5b3f44edd.zip
fluxbox-10082d821d6691f42a8d8ad6fa2e42e5b3f44edd.tar.bz2
cosmetic patch from slava semushin, removes whitespaces and
uses only those things from "namespace std" what we really need.
Diffstat (limited to 'src/Remember.cc')
-rw-r--r--src/Remember.cc49
1 files changed, 30 insertions, 19 deletions
diff --git a/src/Remember.cc b/src/Remember.cc
index cf2c934..6106eb2 100644
--- a/src/Remember.cc
+++ b/src/Remember.cc
@@ -2,7 +2,7 @@
2// Copyright (c) 2003 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org) 2// Copyright (c) 2003 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org)
3// and Simon Bowden (rathnor at users.sourceforge.net) 3// and Simon Bowden (rathnor at users.sourceforge.net)
4// Copyright (c) 2002 Xavier Brouckaert 4// Copyright (c) 2002 Xavier Brouckaert
5// 5//
6// Permission is hereby granted, free of charge, to any person obtaining a 6// Permission is hereby granted, free of charge, to any person obtaining a
7// copy of this software and associated documentation files (the "Software"), 7// copy of this software and associated documentation files (the "Software"),
8// to deal in the Software without restriction, including without limitation 8// to deal in the Software without restriction, including without limitation
@@ -56,7 +56,17 @@
56#include <set> 56#include <set>
57 57
58 58
59using namespace std; 59using std::cerr;
60using std::endl;
61using std::string;
62using std::list;
63using std::set;
64using std::make_pair;
65using std::ifstream;
66using std::ofstream;
67using std::hex;
68using std::dec;
69
60 70
61namespace { 71namespace {
62 72
@@ -254,7 +264,7 @@ Remember::~Remember() {
254 // the patterns free the "Application"s 264 // the patterns free the "Application"s
255 // the client mapping shouldn't need cleaning 265 // the client mapping shouldn't need cleaning
256 Patterns::iterator it; 266 Patterns::iterator it;
257 std::set<Application *> all_apps; // no duplicates 267 set<Application *> all_apps; // no duplicates
258 while (!m_pats->empty()) { 268 while (!m_pats->empty()) {
259 it = m_pats->begin(); 269 it = m_pats->begin();
260 delete it->first; // ClientPattern 270 delete it->first; // ClientPattern
@@ -262,7 +272,7 @@ Remember::~Remember() {
262 m_pats->erase(it); 272 m_pats->erase(it);
263 } 273 }
264 274
265 std::set<Application *>::iterator ait = all_apps.begin(); // no duplicates 275 set<Application *>::iterator ait = all_apps.begin(); // no duplicates
266 for (; ait != all_apps.end(); ++ait) { 276 for (; ait != all_apps.end(); ++ait) {
267 delete (*ait); 277 delete (*ait);
268 } 278 }
@@ -300,7 +310,7 @@ Application * Remember::add(WinClient &winclient) {
300 return app; 310 return app;
301} 311}
302 312
303int Remember::parseApp(std::ifstream &file, Application &app, std::string *first_line) { 313int Remember::parseApp(ifstream &file, Application &app, string *first_line) {
304 string line; 314 string line;
305 _FB_USES_NLS; 315 _FB_USES_NLS;
306 int row = 0; 316 int row = 0;
@@ -346,13 +356,13 @@ int Remember::parseApp(std::ifstream &file, Application &app, std::string *first
346 continue; //read next line 356 continue; //read next line
347 if (strcasecmp(str_key.c_str(), "Workspace") == 0) { 357 if (strcasecmp(str_key.c_str(), "Workspace") == 0) {
348 unsigned int w; 358 unsigned int w;
349 if (getuint(str_label.c_str(), w)) 359 if (getuint(str_label.c_str(), w))
350 app.rememberWorkspace(w); 360 app.rememberWorkspace(w);
351 else 361 else
352 had_error = true; 362 had_error = true;
353 } else if (strcasecmp(str_key.c_str(), "Head") == 0) { 363 } else if (strcasecmp(str_key.c_str(), "Head") == 0) {
354 unsigned int h; 364 unsigned int h;
355 if (getuint(str_label.c_str(), h)) 365 if (getuint(str_label.c_str(), h))
356 app.rememberHead(h); 366 app.rememberHead(h);
357 else 367 else
358 had_error = true; 368 had_error = true;
@@ -403,7 +413,7 @@ int Remember::parseApp(std::ifstream &file, Application &app, std::string *first
403 } 413 }
404 } 414 }
405 415
406 if (!had_error && sscanf(str_label.c_str(), "%u %u", &x, &y) == 2) 416 if (!had_error && sscanf(str_label.c_str(), "%u %u", &x, &y) == 2)
407 app.rememberPosition(x, y, r); 417 app.rememberPosition(x, y, r);
408 else 418 else
409 had_error = true; 419 had_error = true;
@@ -476,8 +486,8 @@ int Remember::parseApp(std::ifstream &file, Application &app, std::string *first
476 This function is used to search for old instances of the same pattern 486 This function is used to search for old instances of the same pattern
477 (when reloading apps file). More than one pattern might match, but only 487 (when reloading apps file). More than one pattern might match, but only
478 if the application is the same (also note that they'll be adjacent). 488 if the application is the same (also note that they'll be adjacent).
479 We REMOVE and delete any matching patterns from the old list, as they're 489 We REMOVE and delete any matching patterns from the old list, as they're
480 effectively moved into the new 490 effectively moved into the new
481*/ 491*/
482 492
483Application *Remember::findMatchingPatterns(ClientPattern *pat, Patterns *patlist, bool is_group) { 493Application *Remember::findMatchingPatterns(ClientPattern *pat, Patterns *patlist, bool is_group) {
@@ -519,10 +529,11 @@ void Remember::reconfigure() {
519 time_t timestamp = FbTk::FileUtil::getLastStatusChangeTimestamp(apps_string.c_str()); 529 time_t timestamp = FbTk::FileUtil::getLastStatusChangeTimestamp(apps_string.c_str());
520 if (m_last_timestamp > 0 && m_last_timestamp == timestamp) 530 if (m_last_timestamp > 0 && m_last_timestamp == timestamp)
521 return; 531 return;
522 532
523#ifdef DEBUG 533#ifdef DEBUG
524 cerr<<__FILE__<<"("<<__FUNCTION__<<"): Loading apps file ["<<apps_string<<"]"<<endl; 534 cerr<<__FILE__<<"("<<__FUNCTION__<<"): Loading apps file ["<<apps_string<<"]"<<endl;
525#endif // DEBUG 535#endif // DEBUG
536
526 ifstream apps_file(apps_string.c_str()); 537 ifstream apps_file(apps_string.c_str());
527 538
528 // we merge the old patterns with new ones 539 // we merge the old patterns with new ones
@@ -536,7 +547,7 @@ void Remember::reconfigure() {
536 string line; 547 string line;
537 int row = 0; 548 int row = 0;
538 bool in_group = false; 549 bool in_group = false;
539 std::list<ClientPattern *> grouped_pats; 550 list<ClientPattern *> grouped_pats;
540 while (getline(apps_file, line) && ! apps_file.eof()) { 551 while (getline(apps_file, line) && ! apps_file.eof()) {
541 row++; 552 row++;
542 FbTk::StringUtil::removeFirstWhitespace(line); 553 FbTk::StringUtil::removeFirstWhitespace(line);
@@ -554,7 +565,7 @@ void Remember::reconfigure() {
554 if (!in_group) { 565 if (!in_group) {
555 if ((err = pat->error()) == 0) { 566 if ((err = pat->error()) == 0) {
556 Application *app = findMatchingPatterns(pat, old_pats, false); 567 Application *app = findMatchingPatterns(pat, old_pats, false);
557 if (!app) 568 if (!app)
558 app = new Application(false); 569 app = new Application(false);
559 570
560 m_pats->push_back(make_pair(pat, app)); 571 m_pats->push_back(make_pair(pat, app));
@@ -578,8 +589,8 @@ void Remember::reconfigure() {
578 // otherwise assume that it is the start of the attributes 589 // otherwise assume that it is the start of the attributes
579 Application *app = 0; 590 Application *app = 0;
580 // search for a matching app 591 // search for a matching app
581 std::list<ClientPattern *>::iterator it = grouped_pats.begin(); 592 list<ClientPattern *>::iterator it = grouped_pats.begin();
582 std::list<ClientPattern *>::iterator it_end = grouped_pats.end(); 593 list<ClientPattern *>::iterator it_end = grouped_pats.end();
583 while (!app && it != it_end) { 594 while (!app && it != it_end) {
584 app = findMatchingPatterns(*it, old_pats, true); 595 app = findMatchingPatterns(*it, old_pats, true);
585 ++it; 596 ++it;
@@ -617,9 +628,9 @@ void Remember::reconfigure() {
617 // Clean up old state 628 // Clean up old state
618 // can't just delete old patterns list. Need to delete the 629 // can't just delete old patterns list. Need to delete the
619 // patterns themselves, plus the applications! 630 // patterns themselves, plus the applications!
620 631
621 Patterns::iterator it; 632 Patterns::iterator it;
622 std::set<Application *> old_apps; // no duplicates 633 set<Application *> old_apps; // no duplicates
623 while (!old_pats->empty()) { 634 while (!old_pats->empty()) {
624 it = old_pats->begin(); 635 it = old_pats->begin();
625 delete it->first; // ClientPattern 636 delete it->first; // ClientPattern
@@ -640,7 +651,7 @@ void Remember::reconfigure() {
640 } 651 }
641 } 652 }
642 653
643 std::set<Application *>::iterator ait = old_apps.begin(); // no duplicates 654 set<Application *>::iterator ait = old_apps.begin(); // no duplicates
644 for (; ait != old_apps.end(); ++ait) { 655 for (; ait != old_apps.end(); ++ait) {
645 delete (*ait); 656 delete (*ait);
646 } 657 }
@@ -667,7 +678,7 @@ void Remember::save() {
667 Patterns::iterator it = m_pats->begin(); 678 Patterns::iterator it = m_pats->begin();
668 Patterns::iterator it_end = m_pats->end(); 679 Patterns::iterator it_end = m_pats->end();
669 680
670 std::set<Application *> grouped_apps; // no duplicates 681 set<Application *> grouped_apps; // no duplicates
671 682
672 for (; it != it_end; ++it) { 683 for (; it != it_end; ++it) {
673 Application &a = *it->second; 684 Application &a = *it->second;