Re: set custom entry background?
- From: Emmanuele Bassi <ebassi gmail com>
- To: Allin Cottrell <cottrell wfu edu>
- Cc: "gtk-app-devel-list gnome org" <gtk-app-devel-list gnome org>
- Subject: Re: set custom entry background?
- Date: Mon, 16 Nov 2015 17:53:59 +0000
Hi;
On 15 November 2015 at 19:32, Allin Cottrell <cottrell wfu edu> wrote:
I'm trying to set a custom background for a GtkEntry (as a temporary thing,
by way of an alert for invalid input). I can do that fine for gtk 2 using
gtk_widget_modify_base(), but am struggling with gtk 3.
Use:
gtk_style_context_add_class (gtk_widget_get_style_context (entry),
GTK_STYLE_CLASS_ERROR);
Themes will usually honour this style class for entries, and will set
a red "glow" around it.
Alternatively, use a custom CSS snippet by using a GtkCssProvider
associated with the default screen, and define your own error class,
e.g.
.error-entry { background-color: red; }
provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (provider, css_definitions, -1, NULL);
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
provider, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
Then add and remove the "error-entry" style class on the GtkEntry as
appropriate.
My strong suggestion is not not hijack the style machinery for this
case, and use the system already in place.
Ciao,
Emmanuele.
--
https://www.bassi.io
[ ] ebassi [ gmail com]
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]