Re: How to change GTK+3 label color dynamically
- From: Emmanuele Bassi <ebassi gmail com>
- To: Rúben Rodrigues <ruben_gr live com pt>
- Cc: Tilo Villwock <codemusings gmail com>, "gtk-app-devel-list gnome org" <gtk-app-devel-list gnome org>
- Subject: Re: How to change GTK+3 label color dynamically
- Date: Thu, 16 Mar 2017 13:19:44 +0000
You keep using an id in the selector, but you never show how you set
the id on the widget. I suspect you think the buildable ID you use
with GtkBuilder is also the ID used when theming — which is definitely
not the case. You will need gtk_widget_set_name(), instead. Of course,
that comes with its own set of caveats, most importantly: there's no
uniqueness of widget name enforced by GTK+ itself.
If you want to avoid all of this, use a CSS class; you can add a class
programmatically using gtk_style_context_add_class() or you can
specify the class in the GtkBuilder XML file.
Ciao,
Emmanuele.
On 16 March 2017 at 12:49, Rúben Rodrigues <ruben_gr live com pt> wrote:
I provide my code in previous emails.
This is my code now:
if(css_provider == NULL){
css_provider = gtk_css_provider_new();
gtk_style_context_add_provider
(gtk_widget_get_style_context(GTK_WIDGET(gtk_builder_get_object(builder,"window_Main"))),
GTK_STYLE_PROVIDER (css_provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_object_unref(css_provider);
}
gtk_css_provider_load_from_data (css_provider,"#label_Sensors {
color: red; }",-1,NULL);
On 16-03-2017 12:41, Tilo Villwock wrote:
Am Donnerstag, den 16.03.2017, 11:58 +0000 schrieb Rúben Rodrigues:
Hi,
This is what i have, and don't works...
The code I provided works. What GTK3 version are you using? Also nobody
will be able to help you if you don't show us your code.
--Tilo
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
--
https://www.bassi.io
[@] ebassi [@gmail.com]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]