X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=util%2Fbsetroot.cc;h=e578cfa0580d5d02948170481a608cc930706e65;hb=bf49e7642027f576716e5742544c282f4396f9ef;hp=cd047c2a63cc146d74cd2aba24e98ac005eb92e5;hpb=99555fea0847edda1e4aa6acac054868324f621f;p=chaz%2Fopenbox diff --git a/util/bsetroot.cc b/util/bsetroot.cc index cd047c2a..e578cfa0 100644 --- a/util/bsetroot.cc +++ b/util/bsetroot.cc @@ -1,4 +1,4 @@ -// -*- mode++; indent-tabs-mode: nil; c-basic-offset: 2; -*- +// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*- // bsetroot.cc for Blackbox - an X11 Window manager // Copyright (c) 2001 - 2002 Sean 'Shaleh' Perry // Copyright (c) 1997 - 2000, 2002 Brad Hughes @@ -37,21 +37,19 @@ extern "C" { #ifdef HAVE_STDIO_H # include #endif // HAVE_STDIO_H + +#ifdef HAVE_CTYPE_H +# include +#endif // HAVE_CTYPE_H } -#include "../src/i18n.hh" -#include "../src/GCCache.hh" -#include "../src/Texture.hh" -#include "../src/Util.hh" +#include "gccache.hh" +#include "texture.hh" +#include "util.hh" #include "bsetroot.hh" - -I18n i18n; - bsetroot::bsetroot(int argc, char **argv, char *dpy_name) - : BaseDisplay(argv[0], dpy_name) -{ - grad = fore = back = (char *) 0; + : BaseDisplay(argv[0], dpy_name) { bool mod = False, sol = False, grd = False; int mod_x = 0, mod_y = 0; @@ -97,14 +95,14 @@ bsetroot::bsetroot(int argc, char **argv, char *dpy_name) } else if (! strcmp("-display", argv[i])) { // -display passed through tests ealier... we just skip it now i++; - } else + } else { usage(); + } } if ((mod + sol + grd) != True) { fprintf(stderr, - i18n(bsetrootSet, bsetrootMustSpecify, - "%s: error: must specify one of: -solid, -mod, -gradient\n"), + "%s: error: must specify one of: -solid, -mod, -gradient\n", getApplicationName()); usage(2); @@ -114,9 +112,12 @@ bsetroot::bsetroot(int argc, char **argv, char *dpy_name) for (unsigned int s = 0; s < getNumberOfScreens(); ++s) img_ctrl[s] = new BImageControl(this, getScreenInfo(s), True); - if (sol && fore) solid(); - else if (mod && mod_x && mod_y && fore && back) modula(mod_x, mod_y); - else if (grd && grad && fore && back) gradient(); + if (sol && ! fore.empty()) + solid(); + else if (mod && mod_x && mod_y && ! (fore.empty() || back.empty())) + modula(mod_x, mod_y); + else if (grd && ! (grad.empty() || fore.empty() || back.empty())) + gradient(); else usage(); } @@ -288,8 +289,31 @@ void bsetroot::modula(int x, int y) { void bsetroot::gradient(void) { + /* + we have to be sure that neither raised nor sunken is specified otherwise + odd looking borders appear. So we convert to lowercase then look for + 'raised' or 'sunken' in the description and erase them. To be paranoid + the search is done in a loop. + */ + std::string descr; + descr.reserve(grad.size()); + + std::string::const_iterator it = grad.begin(), end = grad.end(); + for (; it != end; ++it) + descr += tolower(*it); + + std::string::size_type pos; + while ((pos = descr.find("raised")) != std::string::npos) + descr.erase(pos, 6); // 6 is strlen raised + + while ((pos = descr.find("sunken")) != std::string::npos) + descr.erase(pos, 6); + + // now add on 'flat' to prevent the bevels from being added + descr += "flat"; + for (unsigned int screen = 0; screen < getNumberOfScreens(); screen++) { - BTexture texture(grad, this, screen, img_ctrl[screen]); + BTexture texture(descr, this, screen, img_ctrl[screen]); const ScreenInfo *screen_info = getScreenInfo(screen); texture.setColor(BColor(fore, this, screen)); @@ -319,19 +343,18 @@ void bsetroot::gradient(void) { void bsetroot::usage(int exit_code) { fprintf(stderr, - i18n(bsetrootSet, bsetrootUsage, - "%s 2.0\n\n" - "Copyright (c) 1997-2000, 2002 Bradley T Hughes\n" - "Copyright (c) 2001-2002 Sean 'Shaleh' Perry\n\n" - " -display display connection\n" - " -mod modula pattern\n" - " -foreground, -fg modula foreground color\n" - " -background, -bg modula background color\n\n" - " -gradient gradient texture\n" - " -from gradient start color\n" - " -to gradient end color\n\n" - " -solid solid color\n\n" - " -help print this help text and exit\n"), + "%s 2.0\n\n" + "Copyright (c) 1997-2000, 2002 Bradley T Hughes\n" + "Copyright (c) 2001-2002 Sean 'Shaleh' Perry\n\n" + " -display use display connection\n" + " -mod modula pattern\n" + " -foreground, -fg modula foreground color\n" + " -background, -bg modula background color\n\n" + " -gradient gradient texture\n" + " -from gradient start color\n" + " -to gradient end color\n\n" + " -solid solid color\n\n" + " -help print this help text and exit\n", getApplicationName()); exit(exit_code); @@ -340,15 +363,12 @@ void bsetroot::usage(int exit_code) { int main(int argc, char **argv) { char *display_name = (char *) 0; - i18n.openCatalog("blackbox.cat"); - for (int i = 1; i < argc; i++) { if (! strcmp(argv[i], "-display")) { // check for -display option if ((++i) >= argc) { - fprintf(stderr, i18n(mainSet, mainDISPLAYRequiresArg, - "error: '-display' requires an argument\n")); + fprintf(stderr, "error: '-display' requires an argument\n"); ::exit(1); }