From b8d499808e78ae86395c051e81a654caad2cd1af Mon Sep 17 00:00:00 2001 From: Simon Steinbeiss Date: Tue, 30 May 2017 00:00:30 +0200 Subject: [PATCH] Use the flat class to make sure arrowbuttons blink (Bug #13599) --- libxfce4panel/xfce-arrow-button.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/libxfce4panel/xfce-arrow-button.c b/libxfce4panel/xfce-arrow-button.c index 7d17a575..2617d2f9 100644 --- a/libxfce4panel/xfce-arrow-button.c +++ b/libxfce4panel/xfce-arrow-button.c @@ -107,8 +107,10 @@ struct _XfceArrowButtonPrivate * MAX_BLINKING_COUNT is reached */ guint blinking_counter; +#if !GTK_CHECK_VERSION (3, 0, 0) /* button relief when the blinking starts */ GtkReliefStyle last_relief; +#endif }; @@ -195,7 +197,9 @@ xfce_arrow_button_init (XfceArrowButton *button) button->priv->arrow_type = GTK_ARROW_UP; button->priv->blinking_timeout_id = 0; button->priv->blinking_counter = 0; +#if !GTK_CHECK_VERSION (3, 0, 0) button->priv->last_relief = GTK_RELIEF_NORMAL; +#endif /* set some widget properties */ gtk_widget_set_has_window (GTK_WIDGET (button), FALSE); @@ -590,6 +594,16 @@ static gboolean xfce_arrow_button_blinking_timeout (gpointer user_data) { XfceArrowButton *button = XFCE_ARROW_BUTTON (user_data); + +#if GTK_CHECK_VERSION (3, 0, 0) + GtkStyleContext *context; + + context = gtk_widget_get_style_context (GTK_WIDGET (button)); + if (gtk_style_context_has_class (context, "flat")) + gtk_style_context_remove_class (context, "flat"); + else + gtk_style_context_add_class (context, "flat"); +#else GtkStyle *style; GtkRcStyle *rc; @@ -609,6 +623,7 @@ xfce_arrow_button_blinking_timeout (gpointer user_data) rc->bg[GTK_STATE_NORMAL] = style->bg[GTK_STATE_SELECTED]; gtk_widget_modify_style(GTK_WIDGET (button), rc); } +#endif return (button->priv->blinking_counter++ < MAX_BLINKING_COUNT); } @@ -619,12 +634,20 @@ static void xfce_arrow_button_blinking_timeout_destroyed (gpointer user_data) { XfceArrowButton *button = XFCE_ARROW_BUTTON (user_data); + +#if GTK_CHECK_VERSION (3, 0, 0) + GtkStyleContext *context; + + context = gtk_widget_get_style_context (GTK_WIDGET (button)); + gtk_style_context_remove_class (context, "flat"); +#else GtkRcStyle *rc; rc = gtk_widget_get_modifier_style (GTK_WIDGET (button)); gtk_button_set_relief (GTK_BUTTON (button), button->priv->last_relief); PANEL_UNSET_FLAG (rc->color_flags[GTK_STATE_NORMAL], GTK_RC_BG); gtk_widget_modify_style (GTK_WIDGET (button), rc); +#endif button->priv->blinking_timeout_id = 0; button->priv->blinking_counter = 0; @@ -738,8 +761,10 @@ xfce_arrow_button_set_blinking (XfceArrowButton *button, if (blinking) { +#if !GTK_CHECK_VERSION (3, 0, 0) /* store the relief of the button */ button->priv->last_relief = gtk_button_get_relief (GTK_BUTTON (button)); +#endif if (button->priv->blinking_timeout_id == 0) { -- 2.11.0