Commits

Ilya Skriblovsky committed 83309b9 Draft

Background color setting: background.color = #202020

Comments (0)

Files changed (6)

 
 all: telescope
 
-#DEFINES = -DKDE -DDBUS
+#DEFINES = -DDESKTOP -DDBUS
 DEFINES = -DMAEMO4 -DDBUS
 
 LAUNCHER = 1
     XRenderParseColor(_dpy, Settings::instance()->borderColor(), &_borderColor);
     XRenderParseColor(_dpy, Settings::instance()->borderActiveColor(), &_borderActiveColor);
 
+    XRenderParseColor(_dpy, Settings::instance()->backgroundColor(), &_backgroundColor);
+
     reloadWallpaper();
 }
 
     {
         printf("Cannot load background\n");
         printf("rgb = (%d, %d, %d)\n",
-            Settings::instance()->backgroundR(),
-            Settings::instance()->backgroundG(),
-            Settings::instance()->backgroundB());
+            _backgroundColor.red   / 256,
+            _backgroundColor.green / 256,
+            _backgroundColor.blue  / 256
+        );
         background = imlib_create_image(width, height);
         imlib_context_set_image(background);
         imlib_context_set_color(
-            Settings::instance()->backgroundR(),
-            Settings::instance()->backgroundG(),
-            Settings::instance()->backgroundB(),
-            255);
+            _backgroundColor.red   / 256,
+            _backgroundColor.green / 256,
+            _backgroundColor.blue  / 256,
+            255
+        );
         imlib_image_fill_rectangle(0, 0, width, height);
     }
     else
         Image* _textBackground;
 
 
+        XRenderColor _backgroundColor;
+
         Image* _wallpaper;
 
     public:
 
     _backgroundFilename = 0; // Will be set later if not in config file
     _backgroundMode = Stretched;
-    _backgroundR = _backgroundG = _backgroundB = 0;
+    _backgroundColor = strdup("#202020");
 
     _headerLeftFilename = strdup("/usr/share/telescope/header-left.png");
     _headerRightFilename = strdup("/usr/share/telescope/header-right.png");
             char line[1024];
             static const char *prefix1 = "BackgroundImage=";
             static const char *prefix3 = "CachedAs=";
+            int r = 0, g = 0, b = 0;
             while (fgets(line, sizeof(line), homeBgFile) != 0)
             {
                 if (strstr(line, prefix1) == line)
                         _backgroundMode = Cropped;
                 }
                 else if (strncmp(line, "Red=", 4) == 0)
-                    _backgroundR = atoi(&line[4]) / 256;
+                    r = atoi(&line[4]) / 256;
                 else if (strncmp(line, "Green=", 6) == 0)
-                    _backgroundG = atoi(&line[6]) / 256;
+                    g = atoi(&line[6]) / 256;
                 else if (strncmp(line, "Blue=", 5) == 0)
-                    _backgroundB = atoi(&line[5]) / 256;
+                    b = atoi(&line[5]) / 256;
             }
 
+            free(_backgroundColor);
+            _backgroundColor = (char*)malloc(8);
+            snprintf(_backgroundColor, 8, "#%x%x%x", r, g, b);
+printf("BACKGROUND COLOR: %s\n", _backgroundColor);
+
             fclose(homeBgFile);
         }
 
 Settings::~Settings()
 {
     free(_backgroundFilename);
+    free(_backgroundColor);
     free(_headerLeftFilename);
     free(_headerRightFilename);
     free(_headerMiddleFilename);
         else if (strcmp(value, "cropped") == 0)
             _backgroundMode = Cropped;
     }
+    else if (strcmp(key, "background.color") == 0)
+    {
+        free(_backgroundColor);
+        _backgroundColor = strdup(value);
+
+        printf("Background color: %s\n", _backgroundColor);
+    }
     else if (strcmp(key, "header.left.filename") == 0)
     {
         free(_headerLeftFilename);
         bool _scrollingEnabled;
         char *_backgroundFilename;
         BackgroundMode _backgroundMode;
-        int _backgroundR, _backgroundG, _backgroundB;
+        char *_backgroundColor;
 
         char *_headerLeftFilename;
         char *_headerRightFilename;
 
         const char* backgroundFilename() { return _backgroundFilename; }
         BackgroundMode backgroundMode() { return _backgroundMode; }
-        int backgroundR() { return _backgroundR; }
-        int backgroundG() { return _backgroundG; }
-        int backgroundB() { return _backgroundB; }
+        char* backgroundColor() { return _backgroundColor; }
 
         const char* headerLeftFilename() { return _headerLeftFilename; }
         const char* headerRightFilename() { return _headerRightFilename; }
     XWindowAttributes attrs;
     XGetWindowAttributes(_dpy, _clientWindow, &attrs);
 
-#ifdef KDE
+#ifdef DESKTOP
     Window root;
     Window parent;
     Window *children;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.