aboutsummaryrefslogtreecommitdiff
path: root/src/Slit.cc
diff options
context:
space:
mode:
authorrathnor <rathnor>2004-01-30 11:06:25 (GMT)
committerrathnor <rathnor>2004-01-30 11:06:25 (GMT)
commit8b5f039f10e51f972dbed0a4d75fc569bde4b9a8 (patch)
tree6807bde3faf8c4508c8050d5eab4a6c9665cc253 /src/Slit.cc
parentbfcf8c42056dbdb5f0e38cf97c653ea6c62e8cda (diff)
downloadfluxbox_pavel-8b5f039f10e51f972dbed0a4d75fc569bde4b9a8.zip
fluxbox_pavel-8b5f039f10e51f972dbed0a4d75fc569bde4b9a8.tar.bz2
slitlist fixing up
Diffstat (limited to 'src/Slit.cc')
-rw-r--r--src/Slit.cc31
1 files changed, 22 insertions, 9 deletions
diff --git a/src/Slit.cc b/src/Slit.cc
index 5d596ef..2c2574e 100644
--- a/src/Slit.cc
+++ b/src/Slit.cc
@@ -22,7 +22,7 @@
22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23// DEALINGS IN THE SOFTWARE. 23// DEALINGS IN THE SOFTWARE.
24 24
25// $Id: Slit.cc,v 1.87 2004/01/10 02:58:21 fluxgen Exp $ 25// $Id: Slit.cc,v 1.88 2004/01/30 11:06:25 rathnor Exp $
26 26
27#include "Slit.hh" 27#include "Slit.hh"
28 28
@@ -57,6 +57,7 @@
57#include "SlitClient.hh" 57#include "SlitClient.hh"
58#include "Xutil.hh" 58#include "Xutil.hh"
59#include "FbAtoms.hh" 59#include "FbAtoms.hh"
60#include "FbTk/StringUtil.hh"
60 61
61#include <algorithm> 62#include <algorithm>
62#include <iostream> 63#include <iostream>
@@ -415,7 +416,7 @@ void Slit::addClient(Window w) {
415 // Look for slot in client list by name 416 // Look for slot in client list by name
416 SlitClient *client = 0; 417 SlitClient *client = 0;
417 std::string match_name; 418 std::string match_name;
418 match_name = Xutil::getWMName(w); 419 match_name = Xutil::getWMClassName(w);
419 SlitClients::iterator it = m_client_list.begin(); 420 SlitClients::iterator it = m_client_list.begin();
420 SlitClients::iterator it_end = m_client_list.end(); 421 SlitClients::iterator it_end = m_client_list.end();
421 bool found_match = false; 422 bool found_match = false;
@@ -1123,22 +1124,34 @@ void Slit::toggleHidden() {
1123} 1124}
1124 1125
1125void Slit::loadClientList(const char *filename) { 1126void Slit::loadClientList(const char *filename) {
1126 if (filename == 0) 1127 if (filename == 0 || filename[0] == '\0')
1127 return; 1128 return;
1128 1129
1129 m_filename = filename; // save filename so we can save client list later 1130 // save filename so we can save client list later
1131 m_filename = FbTk::StringUtil::expandFilename(filename);
1130 1132
1131 struct stat buf; 1133 struct stat buf;
1132 if (!stat(filename, &buf)) { 1134 if (stat(filename, &buf) != 0) {
1133 std::ifstream file(filename); 1135 std::ifstream file(filename);
1134 std::string name; 1136 std::string name;
1135 while (! file.eof()) { 1137 while (! file.eof()) {
1136 name = ""; 1138 name = "";
1137 std::getline(file, name); // get the entire line 1139 std::getline(file, name); // get the entire line
1138 if (name.size() > 0) { // don't add client unless we have a valid line 1140 if (name.size() <= 0)
1139 SlitClient *client = new SlitClient(name.c_str()); 1141 continue;
1140 m_client_list.push_back(client); 1142
1141 } 1143 // remove whitespaces from start and end
1144 FbTk::StringUtil::removeFirstWhitespace(name);
1145
1146 // the cleaned string could still be a comment, or blank
1147 if ( name.size() <= 0 || name[0] == '#' || name[0] == '!' )
1148 continue;
1149
1150 // trailing whitespace won't affect the above test
1151 FbTk::StringUtil::removeTrailingWhitespace(name);
1152
1153 SlitClient *client = new SlitClient(name.c_str());
1154 m_client_list.push_back(client);
1142 } 1155 }
1143 } 1156 }
1144} 1157}