[lightsoff] Fixed several deprecation warnings



commit fbd915e02536cf6190f5b01a4401e007ef710ab0
Author: Robert Roth <robert roth off gmail com>
Date:   Wed May 7 03:48:42 2014 +0300

    Fixed several deprecation warnings

 src/board-view.vala |   12 +++++-----
 src/game-view.vala  |   56 ++++++++++++++++++++++++++++++---------------------
 src/led-array.vala  |    4 +-
 src/lightsoff.vala  |    6 ++--
 4 files changed, 44 insertions(+), 34 deletions(-)
---
diff --git a/src/board-view.vala b/src/board-view.vala
index 7fe0b99..263967d 100644
--- a/src/board-view.vala
+++ b/src/board-view.vala
@@ -31,12 +31,12 @@ private class Light : Clutter.Group
 
         off = new Clutter.Clone (off_actor);
         off.anchor_gravity = Clutter.Gravity.CENTER;
-        add_actor (off);
+        add_child (off);
 
         on = new Clutter.Clone (on_actor);
         on.anchor_gravity = Clutter.Gravity.CENTER;
         on.opacity = 0;
-        add_actor (on);
+        add_child (on);
 
         // Add a 2 px margin around the tile image, center tiles within it.
         width += 4;
@@ -72,7 +72,7 @@ private class Light : Clutter.Group
 
 public class BoardView : Clutter.Group
 {
-    private const int size = 5;
+    private new const int size = 5;
     private PuzzleGenerator puzzle_generator;
     private Clutter.Texture off_texture;
     private Clutter.Texture on_texture;
@@ -105,7 +105,7 @@ public class BoardView : Clutter.Group
                 l.set_position (xx, yy);
 
                 lights[x, y] = l;
-                add_actor (l);
+                add_child (l);
             }
         }
     }
@@ -151,14 +151,14 @@ public class BoardView : Clutter.Group
         /* Bring into foreground and make visible */
         animate_with_timeline (Clutter.AnimationMode.EASE_IN_SINE, timeline,
                                "opacity", 255,
-                               "depth", 0.0);
+                               "z_position", 0.0);
     }
 
     public void swap_out (float direction, Clutter.Timeline timeline)
     {
         /* Fade into background or drop down */
         animate_with_timeline (Clutter.AnimationMode.EASE_IN_SINE, timeline,
-                               "depth", 250.0 * direction,
+                               "z_position", 250.0 * direction,
                                "opacity", 0);
     }
 
diff --git a/src/game-view.vala b/src/game-view.vala
index 98b3896..6407e8b 100644
--- a/src/game-view.vala
+++ b/src/game-view.vala
@@ -8,6 +8,11 @@
  * license.
  */
 
+public void setup_animation (Clutter.Actor actor, Clutter.AnimationMode mode, uint duration) {
+    actor.set_easing_duration (duration);
+    actor.set_easing_mode (mode);
+}
+
 public class GameView : Clutter.Group
 {
     private Clutter.Texture backing_texture;
@@ -22,7 +27,7 @@ public class GameView : Clutter.Group
     private List<Clutter.Actor> actor_remove_queue = null;
 
     private LEDArray score_view;
-    private Clutter.Group board_group;
+    private Clutter.Actor board_group;
     private BoardView board_view;
     private BoardView? new_board_view = null;
     private Clutter.Actor backing_view;
@@ -59,38 +64,38 @@ public class GameView : Clutter.Group
 
         /* Add textures onto the scene so they can be cloned */
         backing_texture.hide ();
-        add_actor (backing_texture);
+        add_child (backing_texture);
         highlight_texture.hide ();
-        add_actor (highlight_texture);
+        add_child (highlight_texture);
         off_texture.hide ();
-        add_actor (off_texture);
+        add_child (off_texture);
         on_texture.hide ();
-        add_actor (on_texture);
+        add_child (on_texture);
         led_back_texture.hide ();
-        add_actor (led_back_texture);
+        add_child (led_back_texture);
         arrow_texture.hide ();
-        add_actor (arrow_texture);
+        add_child (arrow_texture);
 
         var real_board_width = 5 * off_texture.width + 4;
         var real_board_height = 5 * off_texture.height + 4;
 
-        board_group = new Clutter.Group ();
-        add_actor (board_group);
+        board_group = new Clutter.Actor ();
+        add_child (board_group);
 
         current_level = level;
         board_view = create_board_view (current_level);
         board_view.playable = true;
-        board_group.add_actor (board_view);
+        board_group.add_child (board_view);
 
         backing_view = new Clutter.Clone (backing_texture);
         backing_view.set_position (0, real_board_height);
-        add_actor (backing_view);
+        add_child (backing_view);
 
         score_view = new LEDArray (5, led_back_texture);
         score_view.value = current_level;
         score_view.set_anchor_point (score_view.width / 2, 0);
         score_view.set_position (real_board_width / 2, real_board_height + 18);
-        add_actor (score_view);
+        add_child (score_view);
 
         set_size (real_board_width, score_view.y + score_view.height);
 
@@ -99,7 +104,7 @@ public class GameView : Clutter.Group
         left_arrow.reactive = true;
         left_arrow.button_release_event.connect (left_arrow_button_release_cb);
         left_arrow.set_position ((score_view.x - score_view.anchor_x) / 2, score_view.y + (score_view.height 
/ 2) - 10);
-        add_actor (left_arrow);
+        add_child (left_arrow);
 
         right_arrow = new Clutter.Clone (arrow_texture);
         right_arrow.anchor_gravity = Clutter.Gravity.CENTER;
@@ -107,12 +112,12 @@ public class GameView : Clutter.Group
         right_arrow.button_release_event.connect (right_arrow_button_release_cb);
         right_arrow.rotation_angle_y = 180;
         right_arrow.set_position (real_board_width - left_arrow.x, score_view.y + (score_view.height / 2) - 
10);
-        add_actor (right_arrow);
+        add_child (right_arrow);
 
         key_cursor_view = new Clutter.Clone (highlight_texture);
         key_cursor_view.set_position (-100, -100);
         key_cursor_view.anchor_gravity = Clutter.Gravity.CENTER;
-        add_actor (key_cursor_view);
+        add_child (key_cursor_view);
     }
 
     private BoardView create_board_view (int level)
@@ -163,7 +168,7 @@ public class GameView : Clutter.Group
         last_sign = sign;
 
         new_board_view = create_board_view (current_level);
-        board_group.add_actor (new_board_view);
+        board_group.add_child (new_board_view);
 
         timeline = new Clutter.Timeline (1500);
         new_board_view.slide_in (direction, sign, timeline);
@@ -206,8 +211,8 @@ public class GameView : Clutter.Group
         timeline = new Clutter.Timeline (500);
 
         new_board_view = create_board_view (current_level);
-        board_group.add_actor (new_board_view);
-        new_board_view.depth = -250 * direction;
+        board_group.add_child (new_board_view);
+        new_board_view.z_position = -250 * direction;
         new_board_view.opacity = 0;
 
         new_board_view.swap_in (direction, timeline);
@@ -219,7 +224,8 @@ public class GameView : Clutter.Group
 
     public void hide_cursor ()
     {
-        key_cursor_view.animate (Clutter.AnimationMode.EASE_OUT_SINE, 250, "opacity", 0);
+        setup_animation (key_cursor_view, Clutter.AnimationMode.EASE_OUT_SINE, 250);
+        key_cursor_view.set_opacity (0);
         key_cursor_ready = false;
     }
 
@@ -239,12 +245,16 @@ public class GameView : Clutter.Group
         board_view.get_light_position (key_cursor_x, key_cursor_y, out x, out y);
 
         if (key_cursor_ready)
-            key_cursor_view.animate (Clutter.AnimationMode.EASE_OUT_SINE, 250, "x", x, "y", y);
+        {
+            setup_animation (key_cursor_view, Clutter.AnimationMode.EASE_OUT_SINE, 250);
+            key_cursor_view.set_position (x, y);
+        }
         else
         {
             key_cursor_view.opacity = 0;
             key_cursor_view.set_position (x, y);
-            key_cursor_view.animate (Clutter.AnimationMode.EASE_OUT_SINE, 250, "opacity", 255);
+            setup_animation (key_cursor_view, Clutter.AnimationMode.EASE_OUT_SINE, 250);
+            key_cursor_view.set_opacity (255);
         }
 
         key_cursor_ready = true;
@@ -267,8 +277,8 @@ public class GameView : Clutter.Group
         timeline = new Clutter.Timeline (500);
 
         new_board_view = create_board_view (current_level);
-        board_group.add_actor (new_board_view);
-        new_board_view.depth = 250;
+        board_group.add_child (new_board_view);
+        new_board_view.z_position = 250;
         new_board_view.opacity = 0;
 
         new_board_view.swap_in (-1, timeline);
diff --git a/src/led-array.vala b/src/led-array.vala
index a0a1110..911ef87 100644
--- a/src/led-array.vala
+++ b/src/led-array.vala
@@ -126,7 +126,7 @@ public class LEDArray : Clutter.Group
         var inner_y_margin = -1;
 
         back = new Clutter.Clone (back_texture);
-        add_actor (back);
+        add_child (back);
 
         for (var i = 0; i < n_digits; i++)
         {
@@ -134,7 +134,7 @@ public class LEDArray : Clutter.Group
             d.set_anchor_point (0, d.height / 2);
             d.x = i * (d.width + margin) + inner_x_margin;
             d.y = back.height / 2 + inner_y_margin;
-            add_actor (d);
+            add_child (d);
             digits.prepend (d);
         }
     }
diff --git a/src/lightsoff.vala b/src/lightsoff.vala
index 0054b7f..349256b 100644
--- a/src/lightsoff.vala
+++ b/src/lightsoff.vala
@@ -53,7 +53,7 @@ public class LightsOff : Gtk.Application
 
         window = new Gtk.ApplicationWindow (this);
         window.icon_name = "lightsoff";
-       window.resizable = false;
+        window.resizable = false;
 
         var headerbar = new Gtk.HeaderBar ();
         headerbar.show_close_button = true;
@@ -67,12 +67,12 @@ public class LightsOff : Gtk.Application
 
         var stage = (Clutter.Stage) clutter_embed.get_stage ();
         stage.key_release_event.connect (key_release_event_cb);
-        stage.color = Clutter.Color.from_string ("#000000");
+        stage.background_color = Clutter.Color.from_string ("#000000");
 
         game_view = new GameView (settings.get_int ("level"));
         game_view.level_changed.connect (level_changed_cb);
         game_view.show ();
-        stage.add_actor (game_view);
+        stage.add_child (game_view);
 
         stage.set_size (game_view.width, game_view.height);
         clutter_embed.set_size_request ((int) stage.width, (int) stage.height);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]