And more gperf.
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
This commit is contained in:
parent
4d21d0fd98
commit
8d7f45d76a
|
@ -2,25 +2,32 @@ bg
|
|||
border_padding
|
||||
border_width
|
||||
bordercolor
|
||||
bottom
|
||||
bottomleft
|
||||
bottomright
|
||||
center
|
||||
data
|
||||
draw_style
|
||||
fg
|
||||
fg_center
|
||||
fg_end
|
||||
fg_off
|
||||
flex
|
||||
gap
|
||||
grow
|
||||
height
|
||||
left
|
||||
line
|
||||
max_value
|
||||
min_value
|
||||
reverse
|
||||
right
|
||||
scale
|
||||
ticks_count
|
||||
ticks_gap
|
||||
top
|
||||
topleft
|
||||
topright
|
||||
vertical
|
||||
vertical_gradient
|
||||
width
|
||||
|
|
167
widgets/graph.c
167
widgets/graph.c
|
@ -24,6 +24,7 @@
|
|||
|
||||
#include "widget.h"
|
||||
#include "screen.h"
|
||||
#include "common/tokenize.h"
|
||||
#include "common/draw.h"
|
||||
|
||||
extern awesome_t globalconf;
|
||||
|
@ -281,19 +282,64 @@ graph_tell(widget_t *widget, const char *property, const char *new_value)
|
|||
float value;
|
||||
char *title, *setting;
|
||||
char *new_val;
|
||||
awesome_token_t prop = a_tokenize(property, -1);
|
||||
|
||||
if(!new_value)
|
||||
return WIDGET_ERROR_NOVALUE;
|
||||
/* following properties need a datasection */
|
||||
else if(!a_strcmp(property, "data")
|
||||
|| !a_strcmp(property, "fg")
|
||||
|| !a_strcmp(property, "fg_center")
|
||||
|| !a_strcmp(property, "fg_end")
|
||||
|| !a_strcmp(property, "vertical_gradient")
|
||||
|| !a_strcmp(property, "scale")
|
||||
|| !a_strcmp(property, "max_value")
|
||||
|| !a_strcmp(property, "draw_style"))
|
||||
|
||||
switch (prop) {
|
||||
default:
|
||||
return WIDGET_ERROR;
|
||||
|
||||
case A_TK_HEIGHT:
|
||||
d->height = atof(new_value);
|
||||
return WIDGET_NOERROR;
|
||||
case A_TK_WIDTH:
|
||||
d->width = atoi(new_value);
|
||||
d->size = d->width - 2;
|
||||
/* re-allocate/initialise necessary values */
|
||||
for(graph = d->graphs; graph; graph = graph->next)
|
||||
{
|
||||
p_realloc(&graph->values, d->size);
|
||||
p_realloc(&graph->lines, d->size);
|
||||
p_clear(graph->values, d->size);
|
||||
p_clear(graph->lines, d->size);
|
||||
graph->index = 0;
|
||||
graph->current_max = 0;
|
||||
graph->max_index = 0;
|
||||
}
|
||||
return WIDGET_NOERROR;
|
||||
case A_TK_BG:
|
||||
if(!xcolor_new(globalconf.connection,
|
||||
globalconf.default_screen,
|
||||
new_value, &d->bg))
|
||||
return WIDGET_ERROR_FORMAT_COLOR;
|
||||
return WIDGET_NOERROR;
|
||||
case A_TK_BORDERCOLOR:
|
||||
if(!xcolor_new(globalconf.connection,
|
||||
globalconf.default_screen,
|
||||
new_value, &d->bordercolor))
|
||||
return WIDGET_ERROR_FORMAT_COLOR;
|
||||
return WIDGET_NOERROR;
|
||||
case A_TK_GROW:
|
||||
switch((d->grow = position_get_from_str(new_value)))
|
||||
{
|
||||
case Left:
|
||||
case Right:
|
||||
return WIDGET_NOERROR;
|
||||
default:
|
||||
warn("error changing property %s of widget %s, must be 'left' or 'right'",
|
||||
property, widget->name);
|
||||
return WIDGET_ERROR_CUSTOM;
|
||||
}
|
||||
case A_TK_DATA:
|
||||
case A_TK_FG:
|
||||
case A_TK_FG_CENTER:
|
||||
case A_TK_FG_END:
|
||||
case A_TK_VERTICAL_GRADIENT:
|
||||
case A_TK_SCALE:
|
||||
case A_TK_MAX_VALUE:
|
||||
case A_TK_DRAW_STYLE:
|
||||
/* check if this section is defined already */
|
||||
new_val = a_strdup(new_value);
|
||||
title = strtok(new_val, " ");
|
||||
|
@ -308,10 +354,11 @@ graph_tell(widget_t *widget, const char *property, const char *new_value)
|
|||
/* no section found -> create one */
|
||||
if(!graph)
|
||||
graph = graph_data_add(d, title);
|
||||
break;
|
||||
}
|
||||
|
||||
/* change values accordingly... */
|
||||
if(!a_strcmp(property, "data"))
|
||||
{
|
||||
switch (prop) {
|
||||
case A_TK_DATA:
|
||||
/* assign incoming value */
|
||||
value = MAX(atof(setting), 0);
|
||||
|
||||
|
@ -356,89 +403,47 @@ graph_tell(widget_t *widget, const char *property, const char *new_value)
|
|||
else
|
||||
graph->lines[graph->index] = d->box_height;
|
||||
}
|
||||
p_delete(&new_val);
|
||||
return WIDGET_NOERROR;
|
||||
}
|
||||
else if(!a_strcmp(property, "fg"))
|
||||
break;
|
||||
case A_TK_FG:
|
||||
xcolor_new(globalconf.connection, globalconf.default_screen, setting, &graph->color_start);
|
||||
else if(!a_strcmp(property, "fg_center"))
|
||||
break;
|
||||
case A_TK_FG_CENTER:
|
||||
graph_pcolor_set(&graph->pcolor_center, setting);
|
||||
else if(!a_strcmp(property, "fg_end"))
|
||||
break;
|
||||
case A_TK_FG_END:
|
||||
graph_pcolor_set(&graph->pcolor_end, setting);
|
||||
else if(!a_strcmp(property, "vertical_gradient"))
|
||||
break;
|
||||
case A_TK_VERTICAL_GRADIENT:
|
||||
graph->vertical_gradient = a_strtobool(setting);
|
||||
else if(!a_strcmp(property, "scale"))
|
||||
break;
|
||||
case A_TK_SCALE:
|
||||
graph->scale = a_strtobool(setting);
|
||||
else if(!a_strcmp(property, "max_value"))
|
||||
{
|
||||
break;
|
||||
case A_TK_MAX_VALUE:
|
||||
graph->max_value = atof(setting);
|
||||
graph->current_max = graph->max_value;
|
||||
}
|
||||
else if(!a_strcmp(property, "draw_style"))
|
||||
{
|
||||
if(!a_strcmp(setting, "bottom"))
|
||||
break;
|
||||
case A_TK_DRAW_STYLE:
|
||||
switch (a_tokenize(setting, -1)) {
|
||||
case A_TK_BOTTOM:
|
||||
graph->draw_style = Bottom_Style;
|
||||
else if(!a_strcmp(setting, "line"))
|
||||
break;
|
||||
case A_TK_LINE:
|
||||
graph->draw_style = Line_Style;
|
||||
else if(!a_strcmp(setting, "top"))
|
||||
break;
|
||||
case A_TK_TOP:
|
||||
graph->draw_style = Top_Style;
|
||||
else
|
||||
{
|
||||
warn("'error changing property %s of widget %s, must be 'bottom', 'top' or 'line'",
|
||||
property, widget->name);
|
||||
p_delete(&new_val);
|
||||
return WIDGET_ERROR_CUSTOM;
|
||||
}
|
||||
}
|
||||
p_delete(&new_val);
|
||||
return WIDGET_NOERROR;
|
||||
}
|
||||
else if(!a_strcmp(property, "height"))
|
||||
d->height = atof(new_value);
|
||||
else if(!a_strcmp(property, "width"))
|
||||
{
|
||||
d->width = atoi(new_value);
|
||||
d->size = d->width - 2;
|
||||
/* re-allocate/initialise necessary values */
|
||||
for(graph = d->graphs; graph; graph = graph->next)
|
||||
{
|
||||
p_realloc(&graph->values, d->size);
|
||||
p_realloc(&graph->lines, d->size);
|
||||
p_clear(graph->values, d->size);
|
||||
p_clear(graph->lines, d->size);
|
||||
graph->index = 0;
|
||||
graph->current_max = 0;
|
||||
graph->max_index = 0;
|
||||
}
|
||||
}
|
||||
else if(!a_strcmp(property, "bg"))
|
||||
{
|
||||
if(!xcolor_new(globalconf.connection,
|
||||
globalconf.default_screen,
|
||||
new_value, &d->bg))
|
||||
return WIDGET_ERROR_FORMAT_COLOR;
|
||||
}
|
||||
else if(!a_strcmp(property, "bordercolor"))
|
||||
{
|
||||
if(!xcolor_new(globalconf.connection,
|
||||
globalconf.default_screen,
|
||||
new_value, &d->bordercolor))
|
||||
return WIDGET_ERROR_FORMAT_COLOR;
|
||||
}
|
||||
else if(!a_strcmp(property, "grow"))
|
||||
switch((d->grow = position_get_from_str(new_value)))
|
||||
{
|
||||
case Left:
|
||||
case Right:
|
||||
break;
|
||||
default:
|
||||
warn("error changing property %s of widget %s, must be 'left' or 'right'",
|
||||
warn("'error changing property %s of widget %s, must be 'bottom', 'top' or 'line'",
|
||||
property, widget->name);
|
||||
return WIDGET_ERROR_CUSTOM;
|
||||
break;
|
||||
}
|
||||
else
|
||||
return WIDGET_ERROR;
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
p_delete(&new_val);
|
||||
return WIDGET_NOERROR;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue