new property argument to widget _tell functions

actually the _tell function won't handle the new argument.
Coming patches will handle them.

it will need now something like this:

echo '0 widget_tell widget property value'

where property can be anything used in the awesomerc file,
that means what will be supported. Like: fg, fg_end, width, font...

(actually it ignores the property value and changes what have been changed in
the past as well.)
This commit is contained in:
marco candrian 2008-02-17 08:16:40 +01:00 committed by Julien Danjou
parent ce7f77c8c5
commit 3569ab617d
6 changed files with 27 additions and 11 deletions

View File

@ -101,7 +101,7 @@ struct Widget
/** Draw function */
int (*draw)(Widget *, DrawCtx *, int, int);
/** Update function */
void (*tell)(Widget *, char *);
void (*tell)(Widget *, char *, char *);
/** ButtonPressedEvent handler */
void (*button_press)(Widget *, XButtonPressedEvent *);
/** Statusbar */

View File

@ -130,7 +130,8 @@ widget_common_button_press(Widget *widget, XButtonPressedEvent *ev)
* \param command unused argument
*/
static void
widget_common_tell(Widget *widget, char *command __attribute__ ((unused)))
widget_common_tell(Widget *widget, char *property __attribute__ ((unused)),
char *command __attribute__ ((unused)))
{
warn("%s widget does not accept commands.\n", widget->name);
}
@ -182,7 +183,7 @@ void
uicb_widget_tell(int screen, char *arg)
{
Widget *widget;
char *p, *command;
char *p, *property = NULL, *command;
ssize_t len;
if (!arg)
@ -206,17 +207,26 @@ uicb_widget_tell(int screen, char *arg)
return;
}
p = strtok(NULL, " ");
if(!p)
{
warn("Ignoring malformed widget command.\n");
return;
}
property = p;
if(p + a_strlen(p) < arg + len)
{
p = p + a_strlen(p) + 1;
len = a_strlen(p);
command = p_new(char, len + 1);
a_strncpy(command, len + 1, p, len);
widget->tell(widget, command);
widget->tell(widget, property, command);
p_delete(&command);
}
else
widget->tell(widget, NULL);
widget->tell(widget, property, NULL);
widget->cache.needs_update = True;

View File

@ -170,14 +170,14 @@ graph_draw(Widget *widget, DrawCtx *ctx, int offset,
}
static void
graph_tell(Widget *widget, char *command)
graph_tell(Widget *widget, char *property, char *command)
{
Data *d = widget->data;
int i, z;
float *value;
char *tok;
if(!command || d->width < 1 || !(d->data_items > 0))
if(!property || !command || d->width < 1 || !(d->data_items > 0))
return;
value = p_new(float, d->data_items);

View File

@ -64,10 +64,13 @@ iconbox_draw(Widget *widget, DrawCtx *ctx, int offset,
}
static void
iconbox_tell(Widget *widget, char *command)
iconbox_tell(Widget *widget, char *property, char *command)
{
Data *d = widget->data;
if(!property || !command)
return;
if(d->image)
p_delete(&d->image);
d->image = a_strdup(command);

View File

@ -118,13 +118,13 @@ progressbar_draw(Widget *widget, DrawCtx *ctx, int offset,
}
static void
progressbar_tell(Widget *widget, char *command)
progressbar_tell(Widget *widget, char *property, char *command)
{
Data *d = widget->data;
int i = 0, percent;
char * tok;
if(!command || !d->bars)
if(!property || !command || !d->bars)
return;
for (tok = strtok(command, ","); tok && i < d->bars; tok = strtok(NULL, ","), i++)

View File

@ -65,12 +65,15 @@ textbox_draw(Widget *widget, DrawCtx *ctx, int offset, int used)
}
static void
textbox_tell(Widget *widget, char *command)
textbox_tell(Widget *widget, char *property, char *command)
{
char *ntok, *tok;
ssize_t command_len = a_strlen(command);
int i = 0, phys_screen = get_phys_screen(widget->statusbar->screen);
if(!property || !command)
return;
Data *d = widget->data;
if (d->text)
p_delete(&d->text);