Timed menu updates. Still needs work.
This commit is contained in:
parent
d03c1afac6
commit
b52b5a6fc0
1 changed files with 45 additions and 19 deletions
|
@ -96,23 +96,21 @@ void timed_menu_read_pipe(int fd, void *d)
|
||||||
TIMED_MENU_DATA(menu)->buf + TIMED_MENU_DATA(menu)->buflen,
|
TIMED_MENU_DATA(menu)->buf + TIMED_MENU_DATA(menu)->buflen,
|
||||||
num_realloc);
|
num_realloc);
|
||||||
if (num_read == 0) {
|
if (num_read == 0) {
|
||||||
unsigned long count = 0;
|
|
||||||
char *found = NULL;
|
|
||||||
menu->invalid = TRUE;
|
menu->invalid = TRUE;
|
||||||
menu_clear(menu);
|
menu_clear(menu);
|
||||||
|
|
||||||
/* TEMP: list them */
|
TIMED_MENU_DATA(menu)->buf[TIMED_MENU_DATA(menu)->buflen] = '\0';
|
||||||
while (NULL !=
|
|
||||||
(found = strchr(&TIMED_MENU_DATA(menu)->buf[count], '\n'))) {
|
xmlDocPtr doc = xmlParseMemory(TIMED_MENU_DATA(menu)->buf,
|
||||||
TIMED_MENU_DATA(menu)->buf
|
TIMED_MENU_DATA(menu)->buflen);
|
||||||
[found - TIMED_MENU_DATA(menu)->buf] = '\0';
|
|
||||||
menu_add_entry(menu,
|
xmlNodePtr node = xmlDocGetRootElement(doc);
|
||||||
menu_entry_new_separator
|
|
||||||
(&TIMED_MENU_DATA(menu)->buf[count]));
|
if (!xmlStrcasecmp(node->name, (const xmlChar*) "timed_menu")) {
|
||||||
count = found - TIMED_MENU_DATA(menu)->buf + 1;
|
if ((node = parse_find_node("item", node->xmlChildrenNode)))
|
||||||
|
parse_menu_full(doc, node, menu, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
TIMED_MENU_DATA(menu)->buf[TIMED_MENU_DATA(menu)->buflen] = '\0';
|
|
||||||
timed_menu_clean_up(menu);
|
timed_menu_clean_up(menu);
|
||||||
} else if (num_read > 0) {
|
} else if (num_read > 0) {
|
||||||
TIMED_MENU_DATA(menu)->buflen += num_read;
|
TIMED_MENU_DATA(menu)->buflen += num_read;
|
||||||
|
@ -184,16 +182,44 @@ void timed_menu_timeout_handler(void *d)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void *plugin_create()
|
void *plugin_create(PluginMenuCreateData *data)
|
||||||
{
|
{
|
||||||
Timed_Menu_Data *d = g_new(Timed_Menu_Data, 1);
|
char *id;
|
||||||
ObMenu *m = menu_new("", PLUGIN_NAME, NULL);
|
char *label;
|
||||||
|
char *timeout;
|
||||||
|
Timed_Menu_Data *d;
|
||||||
|
ObMenu *m;
|
||||||
|
|
||||||
|
parse_attr_string("id", data->node, &id);
|
||||||
|
parse_attr_string("label", data->node, &label);
|
||||||
|
|
||||||
|
d = g_new(Timed_Menu_Data, 1);
|
||||||
|
|
||||||
|
m = menu_new( (label != NULL ? label : ""),
|
||||||
|
(id != NULL ? id : PLUGIN_NAME),
|
||||||
|
data->parent);
|
||||||
|
|
||||||
m->plugin = PLUGIN_NAME;
|
m->plugin = PLUGIN_NAME;
|
||||||
|
|
||||||
d->type = TIMED_MENU_STAT;
|
if (data->parent)
|
||||||
d->timer = timer_start(6000000, &timed_menu_timeout_handler, m);
|
menu_add_entry(data->parent, menu_entry_new_submenu(
|
||||||
d->command = "/home/woodblock/timed_menu_stat";
|
(label != NULL ? label : ""),
|
||||||
|
m));
|
||||||
|
|
||||||
|
if (!parse_attr_string("command", data->node, &d->command)) {
|
||||||
|
d->command = g_strdup("");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parse_attr_string("timeout", data->node, &timeout)) {
|
||||||
|
char *endptr;
|
||||||
|
gdouble timeout_val = g_strtod(timeout, &endptr);
|
||||||
|
g_free(timeout);
|
||||||
|
d->timer = timer_start(timeout_val * 1000000,
|
||||||
|
&timed_menu_timeout_handler, m);
|
||||||
|
} else
|
||||||
|
d->timer = timer_start(600 * 1000000, &timed_menu_timeout_handler, m);
|
||||||
|
|
||||||
|
d->type = TIMED_MENU_PIPE;
|
||||||
d->buf = NULL;
|
d->buf = NULL;
|
||||||
d->buflen = 0;
|
d->buflen = 0;
|
||||||
d->fd = -1;
|
d->fd = -1;
|
||||||
|
|
Loading…
Reference in a new issue