From e5d43edb8ebd472b680a5b4a96dfa1fcf1ef2260 Mon Sep 17 00:00:00 2001 From: Mark Tiefenbruck Date: Tue, 19 Aug 2008 05:48:16 -0700 Subject: update keys file for changes to NextWindow syntax --- data/init.in | 2 +- src/fluxbox.cc | 2 +- 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 session.doubleClickInterval: 250 session.cacheMax: 200 session.imageDither: True -session.configVersion: 9 +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() { if (create_windowmenu) FbTk::FileUtil::copyFile(DEFAULT_WINDOWMENU, windowmenu_file.c_str()); -#define CONFIG_VERSION 9 +#define CONFIG_VERSION 10 FbTk::Resource config_version(m_resourcemanager, 0, "session.configVersion", "Session.ConfigVersion"); 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) { new_version = 9; } + if (old_version < 10) { // update keys file for NextWindow syntax changes + string whole_keyfile = read_file(keyfilename); + + size_t pos = 0; + while (true) { + const char *keyfile = whole_keyfile.c_str(); + const char *loc = 0; + size_t old_pos = pos; + // find the first position that matches any of next/prevwindow/group + if ((loc = FbTk::StringUtil::strcasestr(keyfile + old_pos, + "nextwindow"))) + pos = (loc - keyfile) + 10; + if ((loc = FbTk::StringUtil::strcasestr(keyfile + old_pos, + "prevwindow"))) + pos = (pos > old_pos && keyfile + pos < loc) ? + pos : (loc - keyfile) + 10; + if ((loc = FbTk::StringUtil::strcasestr(keyfile + old_pos, + "nextgroup"))) + pos = (pos > old_pos && keyfile + pos < loc) ? + pos : (loc - keyfile) + 9; + if ((loc = FbTk::StringUtil::strcasestr(keyfile + old_pos, + "prevgroup"))) + pos = (pos > old_pos && keyfile + pos < loc) ? + pos : (loc - keyfile) + 9; + if (pos == old_pos) + break; + + pos = whole_keyfile.find_first_not_of(" \t", pos); + if (pos != std::string::npos && isdigit(whole_keyfile[pos])) { + char *endptr = 0; + unsigned int mask = strtoul(keyfile + pos, &endptr, 0); + string insert = ""; + if ((mask & 9) == 9) + insert = "{static groups}"; + else if (mask & 1) + insert = "{groups}"; + else if (mask & 8) + insert = "{static}"; + if (mask & 2) + insert += " (stuck=no)"; + if (mask & 4) + insert += " (shaded=no)"; + if (mask & 16) + insert += " (minimized=no)"; + if (mask) + whole_keyfile.replace(pos, endptr - keyfile - pos, insert); + } + } + + write_file(keyfilename, whole_keyfile); + new_version = 10; + } + return new_version; } -- cgit v0.11.2