1
/* gui_util.c - GUI utility functions. */
3
* GRUB -- GRand Unified Bootloader
4
* Copyright (C) 2008 Free Software Foundation, Inc.
6
* GRUB is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
11
* GRUB is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with GRUB. If not, see <http://www.gnu.org/licenses/>.
21
#include <grub/misc.h>
23
#include <grub/gui_string_util.h>
26
struct find_by_id_state
29
grub_gui_component_callback match_callback;
34
find_by_id_recursively (grub_gui_component_t component, void *userdata)
36
struct find_by_id_state *state;
39
state = (struct find_by_id_state *) userdata;
40
id = component->ops->get_id (component);
41
if (id && grub_strcmp (id, state->match_id) == 0)
42
state->match_callback (component, state->match_userdata);
44
if (component->ops->is_instance (component, "container"))
46
grub_gui_container_t container;
47
container = (grub_gui_container_t) component;
48
container->ops->iterate_children (container,
49
find_by_id_recursively,
55
grub_gui_find_by_id (grub_gui_component_t root,
57
grub_gui_component_callback cb,
60
struct find_by_id_state state;
62
state.match_callback = cb;
63
state.match_userdata = userdata;
64
find_by_id_recursively (root, &state);
68
struct iterate_recursively_state
70
grub_gui_component_callback callback;
75
void iterate_recursively_cb (grub_gui_component_t component, void *userdata)
77
struct iterate_recursively_state *state;
79
state = (struct iterate_recursively_state *) userdata;
80
state->callback (component, state->userdata);
82
if (component->ops->is_instance (component, "container"))
84
grub_gui_container_t container;
85
container = (grub_gui_container_t) component;
86
container->ops->iterate_children (container,
87
iterate_recursively_cb,
93
grub_gui_iterate_recursively (grub_gui_component_t root,
94
grub_gui_component_callback cb,
97
struct iterate_recursively_state state;
99
state.userdata = userdata;
100
iterate_recursively_cb (root, &state);