[PATCH 2/9] clock: binary: fix widget style

Felipe Contreras felipe.contreras at gmail.com
Fri Jun 14 02:40:37 CEST 2019


The true binary clock was using the style of the parent, and the normal
one was doing the same thing regardless of the insensitive state check.

Do the same in both and simplify.

Signed-off-by: Felipe Contreras <felipe.contreras at gmail.com>
---
 plugins/clock/clock-binary.c | 52 +++++++++---------------------------
 1 file changed, 13 insertions(+), 39 deletions(-)

diff --git a/plugins/clock/clock-binary.c b/plugins/clock/clock-binary.c
index e9b2882d..ff04f0ff 100644
--- a/plugins/clock/clock-binary.c
+++ b/plugins/clock/clock-binary.c
@@ -272,26 +272,13 @@ xfce_clock_binary_draw_true_binary (XfceClockBinary *binary,
   GtkStyleContext  *ctx;
   GdkRGBA           active_rgba, inactive_rgba;
 
-  ctx = gtk_widget_get_style_context (GTK_WIDGET (gtk_widget_get_parent (GTK_WIDGET (binary))));
-
-  if (G_UNLIKELY (gtk_widget_get_state_flags (GTK_WIDGET (binary)) & GTK_STATE_FLAG_INSENSITIVE))
-    {
-      gtk_style_context_get_color (ctx, GTK_STATE_FLAG_INSENSITIVE,
-                                   &inactive_rgba);
-      inactive_rgba.alpha = 0.2;
-      gtk_style_context_get_color (ctx, GTK_STATE_FLAG_INSENSITIVE,
-                                   &active_rgba);
-      active_rgba.alpha = 1.0;
-    }
-  else
-    {
-      gtk_style_context_get_color (ctx, GTK_STATE_FLAG_NORMAL,
-                                   &inactive_rgba);
-      inactive_rgba.alpha = 0.2;
-      gtk_style_context_get_color (ctx, GTK_STATE_FLAG_ACTIVE,
-                                   &active_rgba);
-      active_rgba.alpha = 1.0;
-    }
+  ctx = gtk_widget_get_style_context (GTK_WIDGET (binary));
+  gtk_style_context_get_color (ctx, gtk_widget_get_state_flags (GTK_WIDGET (binary)),
+                               &inactive_rgba);
+  inactive_rgba.alpha = 0.2;
+  gtk_style_context_get_color (ctx, gtk_widget_get_state_flags (GTK_WIDGET (binary)),
+                               &active_rgba);
+  active_rgba.alpha = 1.0;
 
   time = clock_time_get_time (binary->time);
 
@@ -370,25 +357,12 @@ xfce_clock_binary_draw_binary (XfceClockBinary *binary,
   GdkRGBA           active_rgba, inactive_rgba;
 
   ctx = gtk_widget_get_style_context (GTK_WIDGET (binary));
-
-  if (G_UNLIKELY (gtk_widget_get_state_flags (GTK_WIDGET (binary)) & GTK_STATE_INSENSITIVE))
-    {
-      gtk_style_context_get_color (ctx, gtk_widget_get_state_flags (GTK_WIDGET (binary)),
-                                   &inactive_rgba);
-      inactive_rgba.alpha = 0.2;
-      gtk_style_context_get_color (ctx, gtk_widget_get_state_flags (GTK_WIDGET (binary)),
-                                   &active_rgba);
-      active_rgba.alpha = 1.0;
-    }
-  else
-    {
-      gtk_style_context_get_color (ctx, gtk_widget_get_state_flags (GTK_WIDGET (binary)),
-                                   &inactive_rgba);
-      inactive_rgba.alpha = 0.2;
-      gtk_style_context_get_color (ctx, gtk_widget_get_state_flags (GTK_WIDGET (binary)),
-                                   &active_rgba);
-      active_rgba.alpha = 1.0;
-    }
+  gtk_style_context_get_color (ctx, gtk_widget_get_state_flags (GTK_WIDGET (binary)),
+                               &inactive_rgba);
+  inactive_rgba.alpha = 0.2;
+  gtk_style_context_get_color (ctx, gtk_widget_get_state_flags (GTK_WIDGET (binary)),
+                               &active_rgba);
+  active_rgba.alpha = 1.0;
 
   time = clock_time_get_time (binary->time);
 
-- 
2.22.0.rc2.dirty



More information about the Xfce4-dev mailing list