mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-18 11:05:18 +00:00
text object list: allow appending a list of objects
This commit is contained in:
parent
02d104cc6a
commit
2e83ff05c5
@ -50,15 +50,16 @@ void gen_free_opaque(struct text_object *obj)
|
|||||||
* (this works in BOTH directions)
|
* (this works in BOTH directions)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* append an object to the given root object's list */
|
/* append an object or list of objects to the given root object's list */
|
||||||
int append_object(struct text_object *root, struct text_object *obj)
|
int append_object(struct text_object *root, struct text_object *obj)
|
||||||
{
|
{
|
||||||
struct text_object *end;
|
struct text_object *end;
|
||||||
|
|
||||||
|
/* hook in start of list to append */
|
||||||
end = root->prev;
|
end = root->prev;
|
||||||
obj->prev = end;
|
obj->prev = end;
|
||||||
obj->next = NULL;
|
|
||||||
|
|
||||||
|
/* update pointers of the list to append to */
|
||||||
if (end) {
|
if (end) {
|
||||||
if (end->next)
|
if (end->next)
|
||||||
CRIT_ERR(NULL, NULL, "huston, we have a lift-off");
|
CRIT_ERR(NULL, NULL, "huston, we have a lift-off");
|
||||||
@ -66,7 +67,12 @@ int append_object(struct text_object *root, struct text_object *obj)
|
|||||||
} else {
|
} else {
|
||||||
root->next = obj;
|
root->next = obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* find end of appended list to point root->prev there */
|
||||||
|
while (obj->next)
|
||||||
|
obj = obj->next;
|
||||||
root->prev = obj;
|
root->prev = obj;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user