Re: set custom entry background?
- From: Allin Cottrell <cottrell wfu edu>
- To: Stefan Salewski <mail ssalewski de>, gtk-app-devel-list gnome org
- Subject: Re: set custom entry background?
- Date: Sun, 15 Nov 2015 19:30:33 -0500 (EST)
On Sun, 15 Nov 2015, Allin Cottrell wrote:
On Mon, 16 Nov 2015, Stefan Salewski wrote:
On Sun, 2015-11-15 at 14:32 -0500, Allin Cottrell wrote:
I'm trying to set a custom background for a GtkEntry
I think you have to use CSS -- unfortunately that is some work and I can
not provide an example yet. See
https://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-overri
de-background-color
Thanks. I've tried the CSS approach: that is, create a custom
GtkCssProvider and feed it a suitable snippet of CSS inline. This
works to change the background color OK.
For reference, here's CSS-based code that works to change the
selected-state background:
void entry_alert (GtkWidget *entry)
{
GtkCssProvider *prov;
GtkStyleContext *context;
const gchar *snippet =
"GtkEntry:selected {\n"
"background-color: #ff0000;\n"
"}\n";
prov = gtk_css_provider_new();
gtk_css_provider_load_from_data(prov, snippet, -1, NULL);
context = gtk_widget_get_style_context(entry);
gtk_style_context_add_provider(context,
GTK_STYLE_PROVIDER(prov),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
gtk_widget_grab_focus(entry);
gtk_editable_select_region(GTK_EDITABLE(entry), 0, -1);
}
But how can I "undo" this? (I mean, make it so that the background
color for the selected state reverts to what it was before I messed
with it, for subsequent selections.) That's trivial with the old
APIs but I have no idea how it can be done now.
--
Allin Cottrell
Department of Economics
Wake Forest University
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]