diff --git a/Makefile.am b/Makefile.am index d897e2af0..6c2d2556d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -34,7 +34,6 @@ WIDGETS += widgets/iconbox.c WIDGETS += widgets/progressbar.c WIDGETS += widgets/tasklist.c WIDGETS += widgets/graph.c -WIDGETS += widgets/common.c widgets/common.h doc_DATA += README diff --git a/widgets/common.c b/widgets/common.c deleted file mode 100644 index e4679aa9b..000000000 --- a/widgets/common.c +++ /dev/null @@ -1,81 +0,0 @@ -/* - * widgets/common.c - some functions used by widgets - * - * Copyright © 2008 Julien Danjou - * Copyright © 2008 Marco Candrian - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - */ - -#include "widgets/common.h" - -extern AwesomeConf globalconf; - -widget_tell_status_t -widget_set_color_for_data(xcolor_t *color, char *new_value, int data_items, char ** data_title) -{ - char *title, *setting; - int i; - title = strtok(new_value, " "); - if(!(setting = strtok(NULL, " "))) - return WIDGET_ERROR_NOVALUE; - for(i = 0; i < data_items; i++) - if(!a_strcmp(title, data_title[i])) - { - if(draw_color_new(globalconf.connection, - globalconf.default_screen, - setting, &color[i])) - return WIDGET_NOERROR; - else - return WIDGET_ERROR_FORMAT_COLOR; - } - return WIDGET_ERROR_FORMAT_SECTION; -} -widget_tell_status_t -widget_set_color_pointer_for_data(xcolor_t **color, char *new_value, int data_items, char ** data_title) -{ - char *title, *setting; - int i; - bool flag; - title = strtok(new_value, " "); - if(!(setting = strtok(NULL, " "))) - return WIDGET_ERROR_NOVALUE; - for(i = 0; i < data_items; i++) - if(!a_strcmp(title, data_title[i])) - { - flag = false; - if(!color[i]) - { - flag = true; /* p_delete && restore to NULL, if draw_color_new unsuccessful */ - color[i] = p_new(xcolor_t, 1); - } - if(!(draw_color_new(globalconf.connection, - globalconf.default_screen, - setting, color[i]))) - { - if(flag) /* restore */ - { - p_delete(&color[i]); - color[i] = NULL; - } - return WIDGET_ERROR_FORMAT_COLOR; - } - return WIDGET_NOERROR; - } - return WIDGET_ERROR_FORMAT_SECTION; -} - -// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/widgets/common.h b/widgets/common.h deleted file mode 100644 index da4d7bee3..000000000 --- a/widgets/common.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - * widgets/common.h - some functions headers used by widgets - * - * Copyright © 2008 Julien Danjou - * Copyright © 2008 Marco Candrian - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - * - */ - -#ifndef AWESOME_WIDGETS_COMMON_H -#define AWESOME_WIDGETS_COMMON_H -#include "widget.h" - -widget_tell_status_t widget_set_color_for_data(xcolor_t *, char *, int, char **); -widget_tell_status_t widget_set_color_pointer_for_data(xcolor_t **, char *, int, char **); - -#endif -// vim: filetype=c:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=80 diff --git a/widgets/graph.c b/widgets/graph.c index 2e9d84743..1a07fe3ca 100644 --- a/widgets/graph.c +++ b/widgets/graph.c @@ -23,7 +23,6 @@ #include "widget.h" #include "screen.h" #include "common/draw.h" -#include "common/configopts.h" extern AwesomeConf globalconf; diff --git a/widgets/progressbar.c b/widgets/progressbar.c index f483bd429..8715d960c 100644 --- a/widgets/progressbar.c +++ b/widgets/progressbar.c @@ -21,8 +21,6 @@ */ #include "screen.h" -#include "widgets/common.h" -#include "common/configopts.h" extern AwesomeConf globalconf; @@ -66,6 +64,62 @@ typedef struct xcolor_t *bordercolor; } Data; +static widget_tell_status_t +widget_set_color_for_data(xcolor_t *color, char *new_value, int data_items, char ** data_title) +{ + char *title, *setting; + int i; + title = strtok(new_value, " "); + if(!(setting = strtok(NULL, " "))) + return WIDGET_ERROR_NOVALUE; + for(i = 0; i < data_items; i++) + if(!a_strcmp(title, data_title[i])) + { + if(draw_color_new(globalconf.connection, + globalconf.default_screen, + setting, &color[i])) + return WIDGET_NOERROR; + else + return WIDGET_ERROR_FORMAT_COLOR; + } + return WIDGET_ERROR_FORMAT_SECTION; +} + +static widget_tell_status_t +widget_set_color_pointer_for_data(xcolor_t **color, char *new_value, int data_items, char ** data_title) +{ + char *title, *setting; + int i; + bool flag; + title = strtok(new_value, " "); + if(!(setting = strtok(NULL, " "))) + return WIDGET_ERROR_NOVALUE; + for(i = 0; i < data_items; i++) + if(!a_strcmp(title, data_title[i])) + { + flag = false; + if(!color[i]) + { + flag = true; /* p_delete && restore to NULL, if draw_color_new unsuccessful */ + color[i] = p_new(xcolor_t, 1); + } + if(!(draw_color_new(globalconf.connection, + globalconf.default_screen, + setting, color[i]))) + { + if(flag) /* restore */ + { + p_delete(&color[i]); + color[i] = NULL; + } + return WIDGET_ERROR_FORMAT_COLOR; + } + return WIDGET_NOERROR; + } + return WIDGET_ERROR_FORMAT_SECTION; +} + + static bool check_settings(Data *d, int status_height) {