ui/gtk/toolkit.c

changeset 45
ab71409644b0
parent 44
473954dc6b74
child 48
ae61523bce20
equal deleted inserted replaced
44:473954dc6b74 45:ab71409644b0
382 } 382 }
383 383
384 384
385 385
386 #endif 386 #endif
387
388 void ui_set_name_and_style(GtkWidget *widget, const char *name, const char *style_classes) {
389 if(name) {
390 gtk_widget_set_name(widget, name);
391 }
392 if(style_classes) {
393 cxstring *cls = NULL;
394 size_t numClasses = cx_strsplit_a(cxDefaultAllocator, cx_str(style_classes), CX_STR(" "), 128, &cls);
395 for(int i=0;i<numClasses;i++) {
396 cxmutstr m = cx_strdup(cls[i]);
397 #if GTK_MAJOR_VERSION >= 4
398 gtk_widget_add_css_class(widget, m.ptr);
399 #elif GTK_MAJOR_VERSION >= 3
400 GtkStyleContext *ctx = gtk_widget_get_style_context(widget);
401 gtk_style_context_add_class(ctx, m.ptr);
402 #endif
403 free(m.ptr);
404 }
405 free(cls);
406
407 }
408 }

mercurial