@@ -442,6 +442,25 @@ static void color_entry(const struct color c, GVariantDict *dict, const char *fi
442
442
}
443
443
}
444
444
445
+ static void gradient_entry (const struct gradient * grad , GVariantDict * dict , const char * field_name ) {
446
+ if (GRADIENT_VALID (grad )) {
447
+ if (grad -> length == 1 ) {
448
+ color_entry (grad -> colors [0 ], dict , field_name );
449
+ return ;
450
+ }
451
+
452
+ char * * strv = g_malloc ((grad -> length + 1 ) * sizeof (char * ));
453
+ for (int i = 0 ; i < grad -> length ; i ++ ) {
454
+ char buf [10 ];
455
+ if (color_to_string (grad -> colors [i ], buf ))
456
+ strv [i ] = g_strdup (buf );
457
+ }
458
+ strv [grad -> length ] = NULL ;
459
+
460
+ g_variant_dict_insert (dict , field_name , "^as" , strv );
461
+ }
462
+ }
463
+
445
464
static void dbus_cb_dunst_RuleList (GDBusConnection * connection ,
446
465
const gchar * sender ,
447
466
GVariant * parameters ,
@@ -543,7 +562,7 @@ static void dbus_cb_dunst_RuleList(GDBusConnection *connection,
543
562
enum_to_string (icon_position_enum_data , r -> icon_position ));
544
563
color_entry (r -> fg , & dict , "fg" );
545
564
color_entry (r -> bg , & dict , "bg" );
546
- color_entry (r -> highlight , & dict , "highlight" );
565
+ gradient_entry (r -> highlight , & dict , "highlight" );
547
566
color_entry (r -> fc , & dict , "fc" );
548
567
if (r -> format )
549
568
g_variant_dict_insert (& dict , "format" , "s" , r -> format );
@@ -838,12 +857,37 @@ static struct notification *dbus_message_to_notification(const gchar *sender, GV
838
857
g_variant_unref (dict_value );
839
858
}
840
859
841
- if ((dict_value = g_variant_lookup_value (hints , "hlcolor" , G_VARIANT_TYPE_STRING ))) {
860
+ if ((dict_value = g_variant_lookup_value (hints , "hlcolor" , G_VARIANT_TYPE_STRING_ARRAY ))) {
861
+ char * * cols = (char * * )g_variant_get_strv (dict_value , NULL );
862
+ size_t length = g_strv_length (cols );
863
+ struct gradient * grad = gradient_alloc (length );
864
+
865
+ for (int i = 0 ; i < length ; i ++ ) {
866
+ if (!string_parse_color (cols [i ], & grad -> colors [i ])) {
867
+ g_free (grad );
868
+ goto end ;
869
+ }
870
+ }
871
+
872
+
873
+ gradient_pattern (grad );
874
+
875
+ notification_keep_original (n );
876
+ if (!GRADIENT_VALID (n -> original -> highlight )) n -> original -> highlight = n -> colors .highlight ;
877
+ n -> colors .highlight = grad ;
878
+
879
+ end :
880
+ g_variant_unref (dict_value );
881
+ } else if ((dict_value = g_variant_lookup_value (hints , "hlcolor" , G_VARIANT_TYPE_STRING ))) {
842
882
struct color c ;
843
883
if (string_parse_color (g_variant_get_string (dict_value , NULL ), & c )) {
884
+ struct gradient * grad = gradient_alloc (1 );
885
+ grad -> colors [0 ] = c ;
886
+ gradient_pattern (grad );
887
+
844
888
notification_keep_original (n );
845
- if (!COLOR_VALID (n -> original -> highlight )) n -> original -> highlight = n -> colors .highlight ;
846
- n -> colors .highlight = c ;
889
+ if (!GRADIENT_VALID (n -> original -> highlight )) n -> original -> highlight = n -> colors .highlight ;
890
+ n -> colors .highlight = grad ;
847
891
}
848
892
g_variant_unref (dict_value );
849
893
}
0 commit comments