19
19
20
20
typedef struct xml_loader_t {
21
21
/** 键,作为在视图加载完后传给事件处理器的额外参数 */
22
- char * key ;
23
- char * filepath ; /**< 视图文件路径 */
24
- char * target_id ; /**< 目标容器部件的标识 */
25
- ui_widget_t * pack ; /**< 已经加载的视图内容包 */
26
- ui_widget_t * widget ; /**< 触发视图加载器的部件 */
22
+ char * key ;
23
+ char * filepath ; /**< 视图文件路径 */
24
+ char * target_id ; /**< 目标容器部件的标识 */
25
+ ui_widget_t * pack ; /**< 已经加载的视图内容包 */
26
+ ui_widget_t * widget ; /**< 触发视图加载器的部件 */
27
27
} xml_loader_t ;
28
28
29
29
static struct ui_anchor_module_t {
30
- ui_widget_prototype_t * proto ;
31
- worker_t * worker ;
30
+ ui_widget_prototype_t * proto ;
31
+ worker_t * worker ;
32
32
} ui_anchor ;
33
33
34
- static void xml_loader_on_widget_destroy (ui_widget_t * w , ui_event_t * e ,
35
- void * arg )
34
+ static void xml_loader_on_widget_destroy (ui_widget_t * w , ui_event_t * e ,
35
+ void * arg )
36
36
{
37
- xml_loader_t * loader = e -> data ;
37
+ xml_loader_t * loader = e -> data ;
38
38
39
39
loader -> widget = NULL ;
40
40
}
41
41
42
- static void xml_loader_destroy (xml_loader_t * loader )
42
+ static void xml_loader_destroy (xml_loader_t * loader )
43
43
{
44
44
if (loader -> widget ) {
45
45
ui_widget_off (loader -> widget , "destroy" ,
@@ -56,10 +56,10 @@ static void xml_loader_destroy(xml_loader_t* loader)
56
56
free (loader );
57
57
}
58
58
59
- static xml_loader_t * xml_loader_create (ui_widget_t * w )
59
+ static xml_loader_t * xml_loader_create (ui_widget_t * w )
60
60
{
61
- xml_loader_t * loader ;
62
- const char * key = ui_widget_get_attr (w , "key" );
61
+ xml_loader_t * loader ;
62
+ const char * key = ui_widget_get_attr (w , "key" );
63
63
64
64
loader = malloc (sizeof (xml_loader_t ));
65
65
if (!loader ) {
@@ -77,9 +77,9 @@ static xml_loader_t* xml_loader_create(ui_widget_t* w)
77
77
return loader ;
78
78
}
79
79
80
- static void ui_anchor_on_load (ui_widget_t * w , ui_event_t * e , void * arg )
80
+ static void ui_anchor_on_load (ui_widget_t * w , ui_event_t * e , void * arg )
81
81
{
82
- xml_loader_t * loader = arg ;
82
+ xml_loader_t * loader = arg ;
83
83
ui_widget_t * target , * root ;
84
84
ui_event_t ev = { 0 };
85
85
@@ -96,9 +96,9 @@ static void ui_anchor_on_load(ui_widget_t* w, ui_event_t* e, void* arg)
96
96
ui_widget_emit_event (root , ev , loader -> key );
97
97
}
98
98
99
- static void xml_loader_load (xml_loader_t * loader )
99
+ static void xml_loader_load (xml_loader_t * loader )
100
100
{
101
- ui_widget_t * pack ;
101
+ ui_widget_t * pack ;
102
102
ui_event_t e ;
103
103
char * path , dirname [] = "assets/views/" ;
104
104
@@ -131,10 +131,10 @@ static void xml_loader_load(xml_loader_t* loader)
131
131
(ui_event_arg_destructor_t )xml_loader_destroy );
132
132
}
133
133
134
- static void ui_anchor_on_startload (ui_widget_t * w , ui_event_t * e , void * arg )
134
+ static void ui_anchor_on_startload (ui_widget_t * w , ui_event_t * e , void * arg )
135
135
{
136
- ui_widget_t * target ;
137
- xml_loader_t * loader = arg ;
136
+ ui_widget_t * target ;
137
+ xml_loader_t * loader = arg ;
138
138
139
139
target = ui_get_widget (loader -> target_id );
140
140
if (!target ) {
@@ -144,14 +144,15 @@ static void ui_anchor_on_startload(ui_widget_t* w, ui_event_t* e, void* arg)
144
144
return ;
145
145
}
146
146
ui_widget_empty (target );
147
- worker_post_task (ui_anchor .worker , loader , xml_loader_load , NULL );
147
+ worker_post_task (ui_anchor .worker , loader ,
148
+ (worker_task_cb )xml_loader_load , NULL );
148
149
}
149
150
150
- void ui_anchor_open (ui_widget_t * w )
151
+ void ui_anchor_open (ui_widget_t * w )
151
152
{
152
153
ui_event_t e ;
153
- xml_loader_t * loader ;
154
- const char * attr_href = ui_widget_get_attr (w , "href" );
154
+ xml_loader_t * loader ;
155
+ const char * attr_href = ui_widget_get_attr (w , "href" );
155
156
156
157
if (!attr_href ) {
157
158
logger_error ("[anchor] href are required\n" );
@@ -176,12 +177,13 @@ void ui_anchor_open(ui_widget_t* w)
176
177
ui_post_event (& e , loader , NULL );
177
178
}
178
179
179
- static void ui_anchor_on_click (ui_widget_t * w , ui_event_t * e , void * arg )
180
+ static void ui_anchor_on_click (ui_widget_t * w , ui_event_t * e , void * arg )
180
181
{
181
- worker_post_task (ui_anchor .worker , w , ui_anchor_open , NULL );
182
+ worker_post_task (ui_anchor .worker , w , (worker_task_cb )ui_anchor_open ,
183
+ NULL );
182
184
}
183
185
184
- static void ui_anchor_on_init (ui_widget_t * w )
186
+ static void ui_anchor_on_init (ui_widget_t * w )
185
187
{
186
188
ui_widget_on (w , "click" , ui_anchor_on_click , NULL );
187
189
ui_widget_on (w , "startload.anchor" , ui_anchor_on_startload , NULL );
0 commit comments