Answer the question
In order to leave comments, you need to log in
Why does only one css style property work in a gtk application?
I decided to try my hand at building a window application using GTK3. I create a window and attach styles to it like this:
GtkCssProvider *cssProvider = gtk_css_provider_new();
if(gtk_css_provider_load_from_path(cssProvider, "cpp/test/style.css", NULL)){
gtk_style_context_add_provider_for_screen(gdk_screen_get_default(), GTK_STYLE_PROVIDER(cssProvider), GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
}
else
g_printerr ("Ошибка открытия файла стилей");
builder = gtk_builder_new ();
if (gtk_builder_add_from_file (builder, "cpp/test/window.ui", &error) == 0){
g_printerr ("Error loading file: %s\n", error->message);
g_clear_error (&error);
return 1;
}
window{
background-color: Peru;
}
GtkButton {
background-color: red;
}
#OneLvl{
background-color: red;
color: white;
font-weight: bold;
font-size: 50px;
}
Answer the question
In order to leave comments, you need to log in
1. The global theme of your Desktop environment can take precedence and only display what it doesn't ruin the "look and feel of the application". That is it is banal to disconnect X properties. Checked by changing the topic.
2. The last property is applied, as in the web world, overwriting the previous (similar) one.
3. CSS under Gtk is different from CSS Web, you need to study the API deeper.
4. Maybe you should have used a dot before the name, not a pound sign.
5. See examples on github or https://gitlab.com/gavr123456789/vala-css-examples...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question