ui/gtk/menu.c

changeset 2
eeb50c534497
parent 0
1f419bd32da1
child 16
a499c8a72c15
equal deleted inserted replaced
1:eb5269000bc8 2:eeb50c534497
251 void add_checkitemnv_widget(GtkWidget *p, UiMenuItemI *item, UiObject *obj) { 251 void add_checkitemnv_widget(GtkWidget *p, UiMenuItemI *item, UiObject *obj) {
252 UiCheckItemNV *ci = (UiCheckItemNV*)item; 252 UiCheckItemNV *ci = (UiCheckItemNV*)item;
253 GtkWidget *widget = gtk_check_menu_item_new_with_mnemonic(ci->label); 253 GtkWidget *widget = gtk_check_menu_item_new_with_mnemonic(ci->label);
254 gtk_menu_shell_append(GTK_MENU_SHELL(p), widget); 254 gtk_menu_shell_append(GTK_MENU_SHELL(p), widget);
255 255
256 UiVar *var = uic_getvar(obj, ci->varname); 256 UiVar *var = uic_connect_var(obj->ctx, ci->varname, UI_VAR_INTEGER);
257 if(!var) { 257 if(var) {
258 ui_window_addint(obj, ci->varname);
259 var = uic_getvar(obj, ci->varname);
260 }
261 if(var->type == 1) {
262 UiInteger *value = var->value; 258 UiInteger *value = var->value;
263 value->obj = widget; 259 value->obj = widget;
264 value->get = ui_checkitem_get; 260 value->get = ui_checkitem_get;
265 value->set = ui_checkitem_set; 261 value->set = ui_checkitem_set;
266 value = 0; 262 value = 0;
267 } else { 263 } else {
268 // TODO: error message 264 // TODO: error
269 } 265 }
270 } 266 }
271 267
272 268
273 269
274 void ui_menu_event_wrapper(GtkMenuItem *item, UiEventData *event) { 270 void ui_menu_event_wrapper(GtkMenuItem *item, UiEventData *event) {
275 UiEvent evt; 271 UiEvent evt;
276 evt.obj = event->obj; 272 evt.obj = event->obj;
277 evt.window = event->obj->window; 273 evt.window = event->obj->window;
278 evt.document = NULL; 274 evt.document = event->obj->document;
279 evt.intval = 0; 275 evt.intval = 0;
280 event->callback(&evt, event->user_data); 276 event->callback(&evt, event->user_data);
281 } 277 }
282 278
283 void ui_menu_event_toggled(GtkCheckMenuItem *ci, UiEventData *event) { 279 void ui_menu_event_toggled(GtkCheckMenuItem *ci, UiEventData *event) {
284 UiEvent evt; 280 UiEvent evt;
285 evt.obj = event->obj; 281 evt.obj = event->obj;
286 evt.window = event->obj->window; 282 evt.window = event->obj->window;
287 evt.document = NULL; 283 evt.document = event->obj->document;
288 evt.intval = gtk_check_menu_item_get_active(ci); 284 evt.intval = gtk_check_menu_item_get_active(ci);
289 event->callback(&evt, event->user_data); 285 event->callback(&evt, event->user_data);
290 } 286 }
291 287
292 int ui_checkitem_get(UiInteger *i) { 288 int ui_checkitem_get(UiInteger *i) {

mercurial