diff options
Diffstat (limited to 'src/button.c')
| -rw-r--r-- | src/button.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/button.c b/src/button.c index aac4ec0..b11f5b1 100644 --- a/src/button.c +++ b/src/button.c @@ -86,6 +86,29 @@ void button_set_width(Button *btn, int max, int min) btn->min_width = min; } +Button *button_copy(Button *btn) +{ + if (btn->simple) { + ButtonSimple *copy = g_malloc0(sizeof(ButtonSimple)); + memcpy(copy, CAST(btn, ButtonSimple), sizeof(ButtonSimple)); + copy->text = g_strdup(CAST(btn, ButtonSimple)->text); + copy->btn.anim = NULL; + // NOTE: What to do with data? + return CAST(copy, Button); + } else { + ButtonGroup *copy = g_malloc0(sizeof(ButtonGroup)); + memcpy(copy, CAST(btn, ButtonGroup), sizeof(ButtonGroup)); + copy->btn.anim = NULL; + copy->children = NULL; + + for (GList *it = CAST(btn, ButtonGroup)->children; it != NULL; it = it->next) { + copy->children = g_list_prepend(copy->children, button_copy(it->data)); + } + copy->children = g_list_reverse(copy->children); + return CAST(copy, Button); + } +} + void button_destroy(Button *btn) { animation_destroy(btn->anim); |
