view: fix incremental search entry color when text isn't found (GTK+3)

color and bg color depend on theme, so it won't always be white-on-red
as in GTK+2 build
This commit is contained in:
Monsta 2015-12-25 13:34:05 +03:00
parent e40f250130
commit 371aa73707
1 changed files with 12 additions and 0 deletions

View File

@ -763,8 +763,15 @@ static void
set_entry_state (GtkWidget *entry, set_entry_state (GtkWidget *entry,
PlumaSearchEntryState state) PlumaSearchEntryState state)
{ {
#if GTK_CHECK_VERSION (3, 0 ,0)
GtkStyleContext *context = gtk_widget_get_style_context (GTK_WIDGET (entry));
#endif
if (state == PLUMA_SEARCH_ENTRY_NOT_FOUND) if (state == PLUMA_SEARCH_ENTRY_NOT_FOUND)
{ {
#if GTK_CHECK_VERSION (3, 0 ,0)
gtk_style_context_add_class (context, GTK_STYLE_CLASS_ERROR);
#else
GdkColor red; GdkColor red;
GdkColor white; GdkColor white;
@ -779,15 +786,20 @@ set_entry_state (GtkWidget *entry,
gtk_widget_modify_text (entry, gtk_widget_modify_text (entry,
GTK_STATE_NORMAL, GTK_STATE_NORMAL,
&white); &white);
#endif
} }
else /* reset */ else /* reset */
{ {
#if GTK_CHECK_VERSION (3, 0 ,0)
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_ERROR);
#else
gtk_widget_modify_base (entry, gtk_widget_modify_base (entry,
GTK_STATE_NORMAL, GTK_STATE_NORMAL,
NULL); NULL);
gtk_widget_modify_text (entry, gtk_widget_modify_text (entry,
GTK_STATE_NORMAL, GTK_STATE_NORMAL,
NULL); NULL);
#endif
} }
} }