diff options
author | Mark Tiefenbruck <mark@fluxbox.org> | 2008-08-19 12:48:16 (GMT) |
---|---|---|
committer | Mark Tiefenbruck <mark@fluxbox.org> | 2008-08-19 12:48:16 (GMT) |
commit | e5d43edb8ebd472b680a5b4a96dfa1fcf1ef2260 (patch) | |
tree | 422fe8cbb5ff5b48ee7d2dd1e3da6061277d62ac | |
parent | 18ae02875fbe67b375bbc5a8d3ac84771d0767c1 (diff) | |
download | fluxbox-e5d43edb8ebd472b680a5b4a96dfa1fcf1ef2260.zip fluxbox-e5d43edb8ebd472b680a5b4a96dfa1fcf1ef2260.tar.bz2 |
update keys file for changes to NextWindow syntax
-rw-r--r-- | data/init.in | 2 | ||||
-rw-r--r-- | src/fluxbox.cc | 2 | ||||
-rw-r--r-- | util/fluxbox-update_configs.cc | 53 |
3 files changed, 55 insertions, 2 deletions
diff --git a/data/init.in b/data/init.in index aea9dac..a8fdccd 100644 --- a/data/init.in +++ b/data/init.in | |||
@@ -29,4 +29,4 @@ session.colorsPerChannel: 4 | |||
29 | session.doubleClickInterval: 250 | 29 | session.doubleClickInterval: 250 |
30 | session.cacheMax: 200 | 30 | session.cacheMax: 200 |
31 | session.imageDither: True | 31 | session.imageDither: True |
32 | session.configVersion: 9 | 32 | session.configVersion: 10 |
diff --git a/src/fluxbox.cc b/src/fluxbox.cc index 1c3b783..d9deea7 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc | |||
@@ -595,7 +595,7 @@ void Fluxbox::setupConfigFiles() { | |||
595 | if (create_windowmenu) | 595 | if (create_windowmenu) |
596 | FbTk::FileUtil::copyFile(DEFAULT_WINDOWMENU, windowmenu_file.c_str()); | 596 | FbTk::FileUtil::copyFile(DEFAULT_WINDOWMENU, windowmenu_file.c_str()); |
597 | 597 | ||
598 | #define CONFIG_VERSION 9 | 598 | #define CONFIG_VERSION 10 |
599 | FbTk::Resource<int> config_version(m_resourcemanager, 0, | 599 | FbTk::Resource<int> config_version(m_resourcemanager, 0, |
600 | "session.configVersion", "Session.ConfigVersion"); | 600 | "session.configVersion", "Session.ConfigVersion"); |
601 | if (*config_version < CONFIG_VERSION) { | 601 | if (*config_version < CONFIG_VERSION) { |
diff --git a/util/fluxbox-update_configs.cc b/util/fluxbox-update_configs.cc index 0105c18..0528119 100644 --- a/util/fluxbox-update_configs.cc +++ b/util/fluxbox-update_configs.cc | |||
@@ -323,6 +323,59 @@ int run_updates(int old_version, FbTk::ResourceManager &rm) { | |||
323 | new_version = 9; | 323 | new_version = 9; |
324 | } | 324 | } |
325 | 325 | ||
326 | if (old_version < 10) { // update keys file for NextWindow syntax changes | ||
327 | string whole_keyfile = read_file(keyfilename); | ||
328 | |||
329 | size_t pos = 0; | ||
330 | while (true) { | ||
331 | const char *keyfile = whole_keyfile.c_str(); | ||
332 | const char *loc = 0; | ||
333 | size_t old_pos = pos; | ||
334 | // find the first position that matches any of next/prevwindow/group | ||
335 | if ((loc = FbTk::StringUtil::strcasestr(keyfile + old_pos, | ||
336 | "nextwindow"))) | ||
337 | pos = (loc - keyfile) + 10; | ||
338 | if ((loc = FbTk::StringUtil::strcasestr(keyfile + old_pos, | ||
339 | "prevwindow"))) | ||
340 | pos = (pos > old_pos && keyfile + pos < loc) ? | ||
341 | pos : (loc - keyfile) + 10; | ||
342 | if ((loc = FbTk::StringUtil::strcasestr(keyfile + old_pos, | ||
343 | "nextgroup"))) | ||
344 | pos = (pos > old_pos && keyfile + pos < loc) ? | ||
345 | pos : (loc - keyfile) + 9; | ||
346 | if ((loc = FbTk::StringUtil::strcasestr(keyfile + old_pos, | ||
347 | "prevgroup"))) | ||
348 | pos = (pos > old_pos && keyfile + pos < loc) ? | ||
349 | pos : (loc - keyfile) + 9; | ||
350 | if (pos == old_pos) | ||
351 | break; | ||
352 | |||
353 | pos = whole_keyfile.find_first_not_of(" \t", pos); | ||
354 | if (pos != std::string::npos && isdigit(whole_keyfile[pos])) { | ||
355 | char *endptr = 0; | ||
356 | unsigned int mask = strtoul(keyfile + pos, &endptr, 0); | ||
357 | string insert = ""; | ||
358 | if ((mask & 9) == 9) | ||
359 | insert = "{static groups}"; | ||
360 | else if (mask & 1) | ||
361 | insert = "{groups}"; | ||
362 | else if (mask & 8) | ||
363 | insert = "{static}"; | ||
364 | if (mask & 2) | ||
365 | insert += " (stuck=no)"; | ||
366 | if (mask & 4) | ||
367 | insert += " (shaded=no)"; | ||
368 | if (mask & 16) | ||
369 | insert += " (minimized=no)"; | ||
370 | if (mask) | ||
371 | whole_keyfile.replace(pos, endptr - keyfile - pos, insert); | ||
372 | } | ||
373 | } | ||
374 | |||
375 | write_file(keyfilename, whole_keyfile); | ||
376 | new_version = 10; | ||
377 | } | ||
378 | |||
326 | return new_version; | 379 | return new_version; |
327 | } | 380 | } |
328 | 381 | ||