Glade styling won't apply to compiled GTK program in C

Viewed 150

I have managed to apply the following CSS code to my Glade UI (adding pink to an EventBox behind a label and changing the Start Game font on the Button), as shown:

@define-color deepblue #1d8a99;
@define-color black #0e1116;
@define-color lavender #b7c3f3;
@define-color purple #735290;
@define-color turquoise #3ba99c;

.backing {
    background-color : pink;
}
.interesting{
    font-family: serif;
}

Glade UI

My C code is as follows:

#include <gtk/gtk.h>
int main (int argc, char *argv[])
{
  gtk_init (&argc, &argv);
  GtkBuilder *builder = gtk_builder_new ();
  gtk_builder_add_from_file (builder, "attempt.glade", NULL);
  GtkCssProvider *cssProvider = gtk_css_provider_new();
  gtk_css_provider_load_from_path(cssProvider, "styles.css", NULL);
  GtkWidget *win = (GtkWidget *) gtk_builder_get_object (builder, 
      "window1");
  
  gtk_widget_show_all (win);
  gtk_main ();
}

The filenames are all correct, and I have loaded the CSS file into Glade using the load CSS provider feature. The logo fonts have been added using markup, whereas the "Start Game" font is something I am trying to add using CSS to experiment. However, when I compile my code using gcc -Wall -Wextra -o Elise\ In\ Wonderland begin.c $(pkg-config gtk+-3.0 --cflags --libs) -rdynamic, my code compiles and runs without the CSS applied, but with all the markup changes.

No styling applied.

What should I do in order to make my CSS changes apply? Is there also a way to use markup on the start game button, or a way to use markup on the GtkEventBox (I'm using an EventBox to make the label background pink).

Here is my element hierarchy to shed light on what exactly I'm doing:

Hierarchy in Glade

1 Answers
Related