This is the relevant part of the code:
btn1 = gtk_button_new_with_label("one");
gtk_grid_attach (GTK_GRID (grid_ptr), btn1, 0, 1, 1, 1);
gtk_widget_set_name ( btn1, "btn1");
GtkCssProvider *prvdr = gtk_css_provider_new ();
GtkStyleContext *cntxt = gtk_widget_get_style_context ( btn1 );
gtk_css_provider_load_from_data (prvdr, "button#btn1 { text-decoration: underline white;}", -1);
gtk_style_context_add_provider (cntxt, GTK_STYLE_PROVIDER (prvdr), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
It compiles without any issues, and runs without errors or warnings, but nothing gets underlined.
I have also tried these with the same result: "button#btn1 { text-decoration: underline;}" "button#btn1 { text-decoration-line: underline;}"
I have changed the text colour using "button#btn1 { color: #00ff00;}".
Can anyone explain why it does not work, or how to fix it?
For this to work, you shall have to use CSS selector for the label inside the button. Say something like
button#btn1 > label {...}A minimal example for the same: