Re: gtk3 layout background image



I verify that i can't use css provider, don't works.

My css file is :

GtkLayout#layout_Home.background{
     background-image: url('background.png');
}

GtkLabel#Home_Cooling_Tunnel1_Cooler_label1{
     color: white;
}

GtkLabel#Home_Sensors_MoistAvg_value{
     font-family: Segoe UI;
     font-weight: lighter;
     font-size: 25px;
}

And this code:

static void apply_css(GtkWidget *widget, GtkStyleProvider *provider)
{
gtk_style_context_add_provider(gtk_widget_get_style_context(widget), 
GTK_STYLE_PROVIDER(provider),G_MAXUINT);
     if(GTK_IS_CONTAINER(widget))
         gtk_container_forall(GTK_CONTAINER(widget),(GtkCallback) 
apply_css,provider);

}

GFile *file= g_file_new_for_path("custom.css");
         GtkStyleProvider *css_provider = 
GTK_STYLE_PROVIDER(gtk_css_provider_new());
gtk_css_provider_load_from_file(GTK_CSS_PROVIDER(css_provider), file, 
&error);
apply_css(gtk_builder_get_object(builder,"window_Main"),css_provider);

This is the code used in gtk3-demo and don't works for me.. Why????

THanks

On 14-03-2017 10:00, Rúben Rodrigues wrote:
Hi guys,

Finnaly i migrate my application to gtk+3. So, now i neet to change some
things like image background. I used css provider like in this :

custom.css file:

GtkLayout:layout_Home{
      background-color: black;
}


C Program:

GFile *file= g_file_new_for_path("custom.css");
          GtkCssProvider *css_provider = gtk_css_provider_get_default();
          gtk_css_provider_load_from_file(css_provider, file, &error);
          GtkStyleContext *context = gtk_style_context_new();
          gtk_style_context_add_provider(context,
GTK_STYLE_PROVIDER(css_provider),GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);

But nothing happens. I tried this too:

http://stackoverflow.com/questions/7375624/gtk3-window-background-image


Someone can help me?


THanks

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]