ui/common/context.c

changeset 111
40dbf1a7526a
parent 108
fcf6d5fac8f5
child 121
1cc365c34125
equal deleted inserted replaced
110:36f1581b43e2 111:40dbf1a7526a
36 #include "document.h" 36 #include "document.h"
37 37
38 38
39 UiContext* uic_context(UiObject *toplevel, UcxMempool *mp) { 39 UiContext* uic_context(UiObject *toplevel, UcxMempool *mp) {
40 UiContext *ctx = ucx_mempool_malloc(mp, sizeof(UiContext)); 40 UiContext *ctx = ucx_mempool_malloc(mp, sizeof(UiContext));
41 ctx->parent = NULL; 41 memset(ctx, 0, sizeof(UiContext));
42 ctx->mempool = mp; 42 ctx->mempool = mp;
43 ctx->document = NULL;
44 ctx->obj = toplevel; 43 ctx->obj = toplevel;
45 ctx->vars = ucx_map_new_a(mp->allocator, 16); 44 ctx->vars = ucx_map_new_a(mp->allocator, 16);
46 ctx->groups = NULL;
47 ctx->group_widgets = NULL;
48 45
49 ctx->set_document = uic_context_set_document; 46 ctx->set_document = uic_context_set_document;
50 ctx->detach_document = uic_context_detach_document; 47 ctx->detach_document = uic_context_detach_document;
51
52 ctx->title = NULL;
53 48
54 #ifdef UI_GTK 49 #ifdef UI_GTK
55 if(toplevel->widget) { 50 if(toplevel->widget) {
56 ctx->accel_group = gtk_accel_group_new(); 51 ctx->accel_group = gtk_accel_group_new();
57 gtk_window_add_accel_group(GTK_WINDOW(toplevel->widget), ctx->accel_group); 52 gtk_window_add_accel_group(GTK_WINDOW(toplevel->widget), ctx->accel_group);
332 return NULL; 327 return NULL;
333 } 328 }
334 329
335 // public API 330 // public API
336 331
332 void ui_context_closefunc(UiContext *ctx, ui_callback fnc, void *udata) {
333 ctx->close_callback = fnc;
334 ctx->close_data = udata;
335 }
336
337 int ui_getint(UiObject *obj, char *name) { 337 int ui_getint(UiObject *obj, char *name) {
338 UiVar *var = uic_get_var(obj->ctx, name); 338 UiVar *var = uic_get_var(obj->ctx, name);
339 if(var) { 339 if(var) {
340 if(var->type == UI_VAR_INTEGER) { 340 if(var->type == UI_VAR_INTEGER) {
341 UiInteger *i = var->value; 341 UiInteger *i = var->value;

mercurial