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:
parent
ce7f77c8c5
commit
3569ab617d
|
@ -101,7 +101,7 @@ struct Widget
|
||||||
/** Draw function */
|
/** Draw function */
|
||||||
int (*draw)(Widget *, DrawCtx *, int, int);
|
int (*draw)(Widget *, DrawCtx *, int, int);
|
||||||
/** Update function */
|
/** Update function */
|
||||||
void (*tell)(Widget *, char *);
|
void (*tell)(Widget *, char *, char *);
|
||||||
/** ButtonPressedEvent handler */
|
/** ButtonPressedEvent handler */
|
||||||
void (*button_press)(Widget *, XButtonPressedEvent *);
|
void (*button_press)(Widget *, XButtonPressedEvent *);
|
||||||
/** Statusbar */
|
/** Statusbar */
|
||||||
|
|
18
widget.c
18
widget.c
|
@ -130,7 +130,8 @@ widget_common_button_press(Widget *widget, XButtonPressedEvent *ev)
|
||||||
* \param command unused argument
|
* \param command unused argument
|
||||||
*/
|
*/
|
||||||
static void
|
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);
|
warn("%s widget does not accept commands.\n", widget->name);
|
||||||
}
|
}
|
||||||
|
@ -182,7 +183,7 @@ void
|
||||||
uicb_widget_tell(int screen, char *arg)
|
uicb_widget_tell(int screen, char *arg)
|
||||||
{
|
{
|
||||||
Widget *widget;
|
Widget *widget;
|
||||||
char *p, *command;
|
char *p, *property = NULL, *command;
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
|
|
||||||
if (!arg)
|
if (!arg)
|
||||||
|
@ -206,17 +207,26 @@ uicb_widget_tell(int screen, char *arg)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p = strtok(NULL, " ");
|
||||||
|
if(!p)
|
||||||
|
{
|
||||||
|
warn("Ignoring malformed widget command.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
property = p;
|
||||||
|
|
||||||
if(p + a_strlen(p) < arg + len)
|
if(p + a_strlen(p) < arg + len)
|
||||||
{
|
{
|
||||||
p = p + a_strlen(p) + 1;
|
p = p + a_strlen(p) + 1;
|
||||||
len = a_strlen(p);
|
len = a_strlen(p);
|
||||||
command = p_new(char, len + 1);
|
command = p_new(char, len + 1);
|
||||||
a_strncpy(command, len + 1, p, len);
|
a_strncpy(command, len + 1, p, len);
|
||||||
widget->tell(widget, command);
|
widget->tell(widget, property, command);
|
||||||
p_delete(&command);
|
p_delete(&command);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
widget->tell(widget, NULL);
|
widget->tell(widget, property, NULL);
|
||||||
|
|
||||||
widget->cache.needs_update = True;
|
widget->cache.needs_update = True;
|
||||||
|
|
||||||
|
|
|
@ -170,14 +170,14 @@ graph_draw(Widget *widget, DrawCtx *ctx, int offset,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
graph_tell(Widget *widget, char *command)
|
graph_tell(Widget *widget, char *property, char *command)
|
||||||
{
|
{
|
||||||
Data *d = widget->data;
|
Data *d = widget->data;
|
||||||
int i, z;
|
int i, z;
|
||||||
float *value;
|
float *value;
|
||||||
char *tok;
|
char *tok;
|
||||||
|
|
||||||
if(!command || d->width < 1 || !(d->data_items > 0))
|
if(!property || !command || d->width < 1 || !(d->data_items > 0))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
value = p_new(float, d->data_items);
|
value = p_new(float, d->data_items);
|
||||||
|
|
|
@ -64,10 +64,13 @@ iconbox_draw(Widget *widget, DrawCtx *ctx, int offset,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
iconbox_tell(Widget *widget, char *command)
|
iconbox_tell(Widget *widget, char *property, char *command)
|
||||||
{
|
{
|
||||||
Data *d = widget->data;
|
Data *d = widget->data;
|
||||||
|
|
||||||
|
if(!property || !command)
|
||||||
|
return;
|
||||||
|
|
||||||
if(d->image)
|
if(d->image)
|
||||||
p_delete(&d->image);
|
p_delete(&d->image);
|
||||||
d->image = a_strdup(command);
|
d->image = a_strdup(command);
|
||||||
|
|
|
@ -118,13 +118,13 @@ progressbar_draw(Widget *widget, DrawCtx *ctx, int offset,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
progressbar_tell(Widget *widget, char *command)
|
progressbar_tell(Widget *widget, char *property, char *command)
|
||||||
{
|
{
|
||||||
Data *d = widget->data;
|
Data *d = widget->data;
|
||||||
int i = 0, percent;
|
int i = 0, percent;
|
||||||
char * tok;
|
char * tok;
|
||||||
|
|
||||||
if(!command || !d->bars)
|
if(!property || !command || !d->bars)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (tok = strtok(command, ","); tok && i < d->bars; tok = strtok(NULL, ","), i++)
|
for (tok = strtok(command, ","); tok && i < d->bars; tok = strtok(NULL, ","), i++)
|
||||||
|
|
|
@ -65,12 +65,15 @@ textbox_draw(Widget *widget, DrawCtx *ctx, int offset, int used)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
textbox_tell(Widget *widget, char *command)
|
textbox_tell(Widget *widget, char *property, char *command)
|
||||||
{
|
{
|
||||||
char *ntok, *tok;
|
char *ntok, *tok;
|
||||||
ssize_t command_len = a_strlen(command);
|
ssize_t command_len = a_strlen(command);
|
||||||
int i = 0, phys_screen = get_phys_screen(widget->statusbar->screen);
|
int i = 0, phys_screen = get_phys_screen(widget->statusbar->screen);
|
||||||
|
|
||||||
|
if(!property || !command)
|
||||||
|
return;
|
||||||
|
|
||||||
Data *d = widget->data;
|
Data *d = widget->data;
|
||||||
if (d->text)
|
if (d->text)
|
||||||
p_delete(&d->text);
|
p_delete(&d->text);
|
||||||
|
|
Loading…
Reference in New Issue