@@ -55,6 +55,11 @@ namespace Gala
5555 */
5656 public Meta . BackgroundGroup background_group { get ; protected set ; }
5757
58+ /**
59+ * {@inheritDoc }
60+ */
61+ public bool enable_animations { get ; protected set ; }
62+
5863 Meta . PluginInfo info;
5964
6065 WindowSwitcher ? winswitcher = null ;
@@ -81,6 +86,8 @@ namespace Gala
8186 Gee . HashSet<Meta . WindowActor > unminimizing = new Gee .HashSet<Meta . WindowActor > ();
8287 GLib . HashTable<Meta . Window , int > ws_assoc = new GLib .HashTable<Meta . Window , int> (direct_hash, direct_equal);
8388
89+ GLib . Settings animations_settings;
90+
8491 public WindowManagerGala ()
8592 {
8693 info = Meta . PluginInfo () {name = " Gala" , version = Config . VERSION , author = " Gala Developers" ,
@@ -94,6 +101,12 @@ namespace Gala
94101 Prefs . override_preference_schema (" enable-animations" , Config . SCHEMA + " .animations" );
95102 }
96103
104+ construct {
105+ animations_settings = new GLib .Settings (Config . SCHEMA + " .animations" );
106+ animations_settings. bind (" enable-animations" , this , " enable-animations" , GLib . SettingsBindFlags . GET );
107+ enable_animations = animations_settings. get_boolean (" enable-animations" );
108+ }
109+
97110 public override void start ()
98111 {
99112 Util . later_add (LaterType . BEFORE_REDRAW , show_stage);
@@ -482,8 +495,6 @@ namespace Gala
482495 return ;
483496 }
484497
485- bool enable_animations = AnimationSettings . get_default (). enable_animations;
486-
487498 var bottom_actor = bottom_window. get_compositor_private () as Meta . WindowActor ;
488499 if (enable_animations) {
489500 animate_bottom_window_scale (bottom_actor);
@@ -877,15 +888,14 @@ namespace Gala
877888 unowned Meta . WindowActor window_actor = window. get_compositor_private () as Meta . WindowActor ;
878889 window_group. set_child_below_sibling (tile_preview, window_actor);
879890
880- unowned AnimationSettings animation_settings = AnimationSettings . get_default ();
881- var duration = animation_settings. snap_duration / 2U ;
891+ var duration = AnimationDuration . SNAP / 2U ;
882892
883893 var rect = window. get_frame_rect ();
884894 tile_preview. set_position (rect. x, rect. y);
885895 tile_preview. set_size (rect. width, rect. height);
886896 tile_preview. show ();
887897
888- if (animation_settings . enable_animations) {
898+ if (enable_animations) {
889899 tile_preview. save_easing_state ();
890900 tile_preview. set_easing_mode (Clutter . AnimationMode . EASE_IN_OUT_QUAD );
891901 tile_preview. set_easing_duration (duration);
@@ -999,10 +1009,9 @@ namespace Gala
9991009
10001010 public override void minimize (WindowActor actor )
10011011 {
1002- unowned AnimationSettings animation_settings = AnimationSettings . get_default ();
1003- var duration = animation_settings. minimize_duration;
1012+ const int duration = AnimationDuration . MINIMIZE ;
10041013
1005- if (! animation_settings . enable_animations
1014+ if (! enable_animations
10061015 || duration == 0
10071016 || actor. get_meta_window (). window_type != WindowType . NORMAL ) {
10081017 minimize_completed (actor);
@@ -1071,10 +1080,9 @@ namespace Gala
10711080
10721081 void maximize (WindowActor actor , int ex , int ey , int ew , int eh )
10731082 {
1074- unowned AnimationSettings animation_settings = AnimationSettings . get_default ();
1075- var duration = animation_settings. snap_duration;
1083+ const int duration = AnimationDuration . SNAP ;
10761084
1077- if (! animation_settings . enable_animations
1085+ if (! enable_animations
10781086 || duration == 0 ) {
10791087 return ;
10801088 }
@@ -1164,9 +1172,7 @@ namespace Gala
11641172
11651173 public override void unminimize (WindowActor actor )
11661174 {
1167- unowned AnimationSettings animation_settings = AnimationSettings . get_default ();
1168-
1169- if (! animation_settings. enable_animations) {
1175+ if (! enable_animations) {
11701176 actor. show ();
11711177 unminimize_completed (actor);
11721178 return ;
@@ -1179,7 +1185,7 @@ namespace Gala
11791185
11801186 switch (window. window_type) {
11811187 case WindowType . NORMAL:
1182- var duration = animation_settings . minimize_duration ;
1188+ var duration = AnimationDuration . MINIMIZE ;
11831189 if (duration == 0 ) {
11841190 unminimize_completed (actor);
11851191 return ;
@@ -1214,10 +1220,8 @@ namespace Gala
12141220
12151221 public override void map (WindowActor actor )
12161222 {
1217- unowned AnimationSettings animation_settings = AnimationSettings . get_default ();
1218-
12191223 var window = actor. get_meta_window ();
1220- if (! animation_settings . enable_animations) {
1224+ if (! enable_animations) {
12211225 actor. show ();
12221226 map_completed (actor);
12231227
@@ -1233,7 +1237,7 @@ namespace Gala
12331237
12341238 switch (window. window_type) {
12351239 case WindowType . NORMAL:
1236- var duration = animation_settings . open_duration ;
1240+ var duration = AnimationDuration . MINIMIZE ;
12371241 if (duration == 0 ) {
12381242 map_completed (actor);
12391243 return ;
@@ -1271,7 +1275,7 @@ namespace Gala
12711275 case WindowType . MENU:
12721276 case WindowType . DROPDOWN_MENU:
12731277 case WindowType . POPUP_MENU:
1274- var duration = animation_settings . menu_duration ;
1278+ var duration = AnimationDuration . MENU_MAP ;
12751279 if (duration == 0 ) {
12761280 map_completed (actor);
12771281 return ;
@@ -1339,12 +1343,11 @@ namespace Gala
13391343
13401344 public override void destroy (WindowActor actor )
13411345 {
1342- unowned AnimationSettings animation_settings = AnimationSettings . get_default ();
13431346 var window = actor. get_meta_window ();
13441347
13451348 ws_assoc. remove (window);
13461349
1347- if (! animation_settings . enable_animations) {
1350+ if (! enable_animations) {
13481351 destroy_completed (actor);
13491352
13501353 // only NORMAL windows have icons
@@ -1358,7 +1361,7 @@ namespace Gala
13581361
13591362 switch (window. window_type) {
13601363 case WindowType . NORMAL:
1361- var duration = animation_settings . close_duration ;
1364+ const int duration = AnimationDuration . CLOSE ;
13621365 if (duration == 0 ) {
13631366 destroy_completed (actor);
13641367 return ;
@@ -1409,7 +1412,7 @@ namespace Gala
14091412 case WindowType . MENU:
14101413 case WindowType . DROPDOWN_MENU:
14111414 case WindowType . POPUP_MENU:
1412- var duration = animation_settings . menu_duration ;
1415+ var duration = AnimationDuration . MENU_MAP ;
14131416 if (duration == 0 ) {
14141417 destroy_completed (actor);
14151418 return ;
@@ -1438,10 +1441,8 @@ namespace Gala
14381441
14391442 void unmaximize (Meta .WindowActor actor , int ex , int ey , int ew , int eh )
14401443 {
1441- unowned AnimationSettings animation_settings = AnimationSettings . get_default ();
1442- var duration = animation_settings. snap_duration;
1443-
1444- if (! animation_settings. enable_animations
1444+ const int duration = AnimationDuration . SNAP ;
1445+ if (! enable_animations
14451446 || duration == 0 ) {
14461447 return ;
14471448 }
@@ -1560,10 +1561,9 @@ namespace Gala
15601561
15611562 public override void switch_workspace (int from , int to , MotionDirection direction )
15621563 {
1563- unowned AnimationSettings animation_settings = AnimationSettings . get_default ();
1564- var animation_duration = animation_settings. workspace_switch_duration;
1564+ const int animation_duration = AnimationDuration . WORKSPACE_SWITCH ;
15651565
1566- if (! animation_settings . enable_animations
1566+ if (! enable_animations
15671567 || animation_duration == 0
15681568 || (direction != MotionDirection . LEFT && direction != MotionDirection . RIGHT )) {
15691569 switch_workspace_completed ();
0 commit comments