@@ -111,6 +111,7 @@ public class Dock.Launcher : BaseItem {
111111
112112 var badge = new Gtk .Label (" !" );
113113 badge. add_css_class (Granite . STYLE_CLASS_BADGE );
114+ badge. set_data< Scalable > (" scalable" , new Scalable (badge));
114115
115116 animatable_badge = new AnimatableWidget () {
116117 child = badge
@@ -442,6 +443,7 @@ public class Dock.Launcher : BaseItem {
442443 valign = END
443444 };
444445 app. bind_property (" progress" , progress_bar, " fraction" , SYNC_CREATE );
446+ progress_bar. set_data< Scalable > (" scalable" , new Scalable (progress_bar));
445447
446448 progress_revealer. child = progress_bar;
447449 }
@@ -461,4 +463,46 @@ public class Dock.Launcher : BaseItem {
461463 to_value. set_string (src > 0 ? " %lld " . printf (src) : " !" );
462464 return true ;
463465 }
466+
467+ /**
468+ * Scalable is a class that handles scale style classes on Gtk.Widgets.
469+ * Can be used for scaling widgets based on icon-size with CSS only.
470+ * Possible CSS classes are "large" and "small".
471+ */
472+ private class Scalable : Object {
473+ private const string CSS_CLASS_LARGE = " large" ;
474+ private const string CSS_CLASS_SMALL = " small" ;
475+ private static Settings settings = new Settings (" io.elementary.dock" );
476+
477+ private weak Gtk . Widget widget;
478+
479+ public Scalable (Gtk .Widget widget ) {
480+ this . widget = widget;
481+ this . widget. weak_ref (on_widget_disposed);
482+
483+ settings. changed[" icon-size" ]. connect (update_icon_size);
484+ update_icon_size ();
485+ }
486+
487+ ~Scalable () {
488+ widget? . weak_unref (on_widget_disposed);
489+ }
490+
491+ private void on_widget_disposed () {
492+ widget = null ;
493+ }
494+
495+ private void update_icon_size () {
496+ var icon_size = settings. get_int (" icon-size" );
497+
498+ widget. remove_css_class (CSS_CLASS_LARGE );
499+ widget. remove_css_class (CSS_CLASS_SMALL );
500+
501+ if (icon_size >= 64 ) {
502+ widget. add_css_class (CSS_CLASS_LARGE );
503+ } else if (icon_size <= 32 ) {
504+ widget. add_css_class (CSS_CLASS_SMALL );
505+ }
506+ }
507+ }
464508}
0 commit comments