graph stuff fixed, sf.net bug 1401338 and 1400854
authorBrenden Matthews <brenden1@rty.ca>
Thu, 26 Jan 2006 04:44:19 +0000 (04:44 +0000)
committerBrenden Matthews <brenden1@rty.ca>
Thu, 26 Jan 2006 04:44:19 +0000 (04:44 +0000)
git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@512 7f574dfc-610e-0410-a909-a81674777703

ChangeLog
README
doc/conky.1
src/conky.c

index a7a1e6d..3261621 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 # $Id$
 
+2006-01-25
+       * Fixed stupid graph code (it still sucks) sf.net bug 1372962
+       * Fixed $if_* stuff, sf.net bug 1401338 and 1400854
+
 2006-01-11
        * Added xmms version 1 support.
        * Added bmp through 0.9.7.1 support.
diff --git a/README b/README
index f90d4aa..e60d642 100644 (file)
--- a/README
+++ b/README
@@ -558,7 +558,7 @@ VARIABLES
              Horizontal line, height is the height in pixels
 
 
-       i2c (dev), type, n
+       i2c (dev) type n
              I2C  sensor  from  sysfs  (Linux 2.6). dev may be omitted if you
              have only one I2C device. type is either  in  (or  vol)  meaning
              voltage, fan meaning fan or temp/tempf (first in C, second in F)
index 2300faf..96d1206 100644 (file)
@@ -515,7 +515,7 @@ Displays first N lines of supplied text text file. If interval is not supplied,
 Horizontal line, height is the height in pixels
 
 .TP 
-\fBi2c\fR \fB(dev), type, n\fR 
+\fBi2c\fR \fB(dev) type n\fR 
 I2C sensor from sysfs (Linux 2.6). dev may be omitted if you have only one I2C device. type is either in (or vol) meaning voltage, fan meaning fan or temp/tempf (first in C, second in F) meaning temperature. n is number of the sensor. See /sys/bus/i2c/devices/ on your local computer.
 
 .TP 
index 75f03c8..decade3 100644 (file)
@@ -522,9 +522,9 @@ inline void graph_append(struct special_t *graph, double f)
        if (graph->scaled) {
                graph->graph_scale = 1;
        }
-       graph->graph[graph->graph_width - 1] = f; /* add new data */
-       for (i = 0; i < graph->graph_width - 1; i++) { /* shift all the data by 1 */
-               graph->graph[i] = graph->graph[i + 1];
+       graph->graph[0] = f; /* add new data */
+       for (i = graph->graph_width - 1; i > 0; i--) { /* shift all the data by 1 */
+               graph->graph[i] = graph->graph[i - 1];
                if (graph->scaled && graph->graph[i] > graph->graph_scale) {
                        graph->graph_scale = graph->graph[i]; /* check if we need to update the scale */
                }
@@ -2445,8 +2445,7 @@ static void generate_text_internal(char *p, int p_max_size, struct text_object *
                                if (barnum > 100 || barnum < 0) {
                                        ERR("your execgraph value is not between 0 and 100, therefore it will be ignored");
                                } else {
-                                       new_graph(p, 0,
-                                       25, obj->c, obj->d, (int) (barnum), obj->e, 1);
+                                       new_graph(p, 0, 25, obj->c, obj->d, (int) (barnum), obj->e, 1);
                                }
 
                        }
@@ -4011,23 +4010,23 @@ static void draw_line(char *s)
        float gradient_factor = 0;
        float gradient_update = 0;
        unsigned long tmpcolour = current_color;
-       if (specials[special_index].first_colour != specials[special_index].last_colour) {
-               tmpcolour = specials[special_index].first_colour;
-               gradient_size = gradient_max(specials[special_index].first_colour, specials[special_index].last_colour);
+       if (specials[special_index].last_colour != specials[special_index].first_colour) {
+               tmpcolour = specials[special_index].last_colour;
+               gradient_size = gradient_max(specials[special_index].last_colour, specials[special_index].first_colour);
                gradient_factor = (float)gradient_size / (w - 3);
        }
-       for (i = 0; i < w - 3; i++) {
-               if (specials[special_index].first_colour != specials[special_index].last_colour) {
+       for (i = w - 3; i > 0; i--) {
+               if (specials[special_index].last_colour != specials[special_index].first_colour) {
                        XSetForeground(display, window.gc, tmpcolour);
                        gradient_update += gradient_factor;
                        while (gradient_update > 0) {
-                               tmpcolour = do_gradient(tmpcolour, specials[special_index].last_colour);
+                               tmpcolour = do_gradient(tmpcolour, specials[special_index].first_colour);
                                gradient_update--;
                        }
                }
-               if (i / ((float) (w - 3) / (specials[special_index].graph_width)) > j) {
+               if ((w - 3 - i) / ((float) (w - 3) / (specials[special_index].graph_width)) > j) {
                        j++;
-                                               }
+               }
                                                XDrawLine(display,  window.drawable, window.gc, cur_x + i + 2, by + h, cur_x + i + 2, by + h - specials[special_index].graph[j] * (h - 1) / specials[special_index].graph_scale);       /* this is mugfugly, but it works */
                                        }
                                        if (specials[special_index].