ui/gtk/container.c

branch
newapi
changeset 330
d615aa36c98e
parent 328
059cba080ab4
child 331
cdad8b7e83db
equal deleted inserted replaced
329:08ce6680d1cf 330:d615aa36c98e
350 child, 350 child,
351 gtk_label_new(name), 351 gtk_label_new(name),
352 index); 352 index);
353 } 353 }
354 354
355 int64_t ui_notebook_get(UiInteger *i) {
356 GtkNotebook *nb = i->obj;
357 i->value = gtk_notebook_get_current_page(nb);
358 return i->value;
359 }
360
361 void ui_notebook_set(UiInteger *i, int64_t value) {
362 GtkNotebook *nb = i->obj;
363 gtk_notebook_set_current_page(nb, value);
364 i->value = gtk_notebook_get_current_page(nb);
365 }
366
355 UiGtkTabView* ui_widget_get_tabview_data(UIWIDGET tabview) { 367 UiGtkTabView* ui_widget_get_tabview_data(UIWIDGET tabview) {
356 return g_object_get_data(G_OBJECT(tabview), "ui_tabview"); 368 return g_object_get_data(G_OBJECT(tabview), "ui_tabview");
357 } 369 }
370
371 typedef int64_t(*ui_tabview_get_func)(UiInteger*);
372 typedef void (*ui_tabview_set_func)(UiInteger*, int64_t);
358 373
359 UIWIDGET ui_tabview_create(UiObject* obj, UiTabViewArgs args) { 374 UIWIDGET ui_tabview_create(UiObject* obj, UiTabViewArgs args) {
360 UiGtkTabView *data = malloc(sizeof(UiGtkTabView)); 375 UiGtkTabView *data = malloc(sizeof(UiGtkTabView));
361 data->margin = args.margin; 376 data->margin = args.margin;
362 data->spacing = args.spacing; 377 data->spacing = args.spacing;
363 data->columnspacing = args.columnspacing; 378 data->columnspacing = args.columnspacing;
364 data->rowspacing = args.rowspacing; 379 data->rowspacing = args.rowspacing;
365 380
381 ui_tabview_get_func getfunc = NULL;
382 ui_tabview_set_func setfunc = NULL;
383
366 GtkWidget *widget = NULL; 384 GtkWidget *widget = NULL;
367 switch(args.tabview) { 385 switch(args.tabview) {
368 case UI_TABVIEW_DOC: { 386 case UI_TABVIEW_DOC: {
369 // TODO 387 // TODO
370 break; 388 break;
371 } 389 }
372 case UI_TABVIEW_NAVIGATION_SIDE: { 390 case UI_TABVIEW_NAVIGATION_SIDE: {
373 // TODO 391 // TODO
374 break; 392 break;
375 } 393 }
376 case UI_TABVIEW_DEFAULT: 394 case UI_TABVIEW_DEFAULT: /* fall through */
377 case UI_TABVIEW_NAVIGATION_TOP: 395 case UI_TABVIEW_NAVIGATION_TOP: /* fall through */
378 case UI_TABVIEW_NAVIGATION_TOP2: { 396 case UI_TABVIEW_NAVIGATION_TOP2: {
379 widget = gtk_notebook_new(); 397 widget = gtk_notebook_new();
380 data->select_tab = ui_notebook_tab_select; 398 data->select_tab = ui_notebook_tab_select;
381 data->remove_tab = ui_notebook_tab_remove; 399 data->remove_tab = ui_notebook_tab_remove;
382 data->add_tab = ui_notebook_tab_add; 400 data->add_tab = ui_notebook_tab_add;
383 break; 401 getfunc = ui_notebook_get;
402 setfunc = ui_notebook_set;
403 /* fall through */
384 } 404 }
385 case UI_TABVIEW_INVISIBLE: { 405 case UI_TABVIEW_INVISIBLE: {
386 widget = gtk_notebook_new();
387 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(widget), FALSE); 406 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(widget), FALSE);
388 gtk_notebook_set_show_border(GTK_NOTEBOOK(widget), FALSE); 407 gtk_notebook_set_show_border(GTK_NOTEBOOK(widget), FALSE);
389 data->select_tab = ui_notebook_tab_select;
390 data->remove_tab = ui_notebook_tab_remove;
391 data->add_tab = ui_notebook_tab_add;
392 break; 408 break;
393 } 409 }
410 }
411
412 UiObject* current = uic_current_obj(obj);
413 if(args.value || args.varname) {
414 UiVar *var = uic_widget_var(obj->ctx, current->ctx, args.value, args.varname, UI_VAR_INTEGER);
415 UiInteger *i = var->value;
416 i->get = getfunc;
417 i->set = setfunc;
418 i->obj = widget;
394 } 419 }
395 420
396 g_object_set_data(G_OBJECT(widget), "ui_tabview", data); 421 g_object_set_data(G_OBJECT(widget), "ui_tabview", data);
397 data->widget = widget; 422 data->widget = widget;
398 data->subcontainer = args.subcontainer; 423 data->subcontainer = args.subcontainer;
399 424
400 UiObject* current = uic_current_obj(obj);
401 UI_APPLY_LAYOUT1(current, args); 425 UI_APPLY_LAYOUT1(current, args);
402 current->container->add(current->container, widget, TRUE); 426 current->container->add(current->container, widget, TRUE);
403 427
404 UiObject *newobj = uic_object_new(obj, widget); 428 UiObject *newobj = uic_object_new(obj, widget);
405 newobj->container = ui_tabview_container(obj, widget); 429 newobj->container = ui_tabview_container(obj, widget);

mercurial