Closed Miqueas closed 4 years ago
Well... do you happen to have a self-contained example I could play with?
However, I am not quite sure what you are doing. Let's assume that Gui.Window
is a GtkWindow
. Then :get_style_context()
is gtk_widget_get_style_context()
returning a GtkStyleContext
. Next, you call :add_provider_for_screen()
, which would be this function:
void
gtk_style_context_add_provider_for_screen
(GdkScreen *screen,
GtkStyleProvider *provider,
guint priority);
This function does not expect a GtkStyleProvider
as its first argument, but you are calling with one due to the :
in :add_provider_for_screen()
.
Thus, a random guess would be that the following works:
Gui = Builder.objects
Styles = Gtk.CssProvider()
Styles:load_from_path("data/styles.css")
Gui.Window
:get_style_context()
.add_provider_for_screen(
Gui.Window:get_screen(),
Styles,
Gtk.StyleProvider.PRIORITY_USER
)
Sorry for the delay.
Answering the question you asked at the beginning, basically what I want to do is apply CSS to all the widgets that need it. According to the documentation I have in DevHelp, that method works for that.
Everything you assumed is correct, however I hadn't thought about that solution you mentioned. I will try with that
EDIT: IT WORKS!!! Thanks @psychon for your help!
I think that I found a problem with this function. I have the following code:
Then...
add_provider_for_screen()
takes the following arguments:GdkScreen
GtkStyleProvider
guint
Right? Well... When I run the code, I have the following error:
But... Why? Technically,
Gui.Window:get_screen()
returns aGdk.Screen
(acording to the docs)... So... I think that is a problem of LGI, but I'm not sure. If isn't a problem of LGI, can anyone help me?