[gnome-shell/wip/clutter-deprecation-fixes: 19/25] st: Remove st-group



commit b092077650a22331920960e363c1616b9354efe7
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Tue Jan 17 17:58:46 2012 -0500

    st: Remove st-group
    
    Now that ClutterActor/StWidget are concrete, we won't need it.

 js/ui/messageTray.js            |    6 +-
 js/ui/modalDialog.js            |    6 +-
 js/ui/overview.js               |    4 +-
 js/ui/panel.js                  |   51 +++++---
 js/ui/workspaceSwitcherPopup.js |   12 +-
 js/ui/workspaceThumbnail.js     |    6 +-
 js/ui/workspacesView.js         |    2 +-
 src/Makefile-st.am              |    2 -
 src/st/st-group.c               |  265 ---------------------------------------
 src/st/st-group.h               |   70 ----------
 src/st/st-texture-cache.c       |   18 ++--
 src/st/st-texture-cache.h       |    2 +-
 12 files changed, 58 insertions(+), 386 deletions(-)
---
diff --git a/js/ui/messageTray.js b/js/ui/messageTray.js
index b811a49..d0c62a5 100644
--- a/js/ui/messageTray.js
+++ b/js/ui/messageTray.js
@@ -1347,9 +1347,9 @@ const MessageTray = new Lang.Class({
             this._onStatusChanged(status);
         }));
 
-        this.actor = new St.Group({ name: 'message-tray',
-                                    reactive: true,
-                                    track_hover: true });
+        this.actor = new St.Widget({ name: 'message-tray',
+                                     reactive: true,
+                                     track_hover: true });
         this.actor.connect('notify::hover', Lang.bind(this, this._onTrayHoverChanged));
 
         this._notificationBin = new St.Bin();
diff --git a/js/ui/modalDialog.js b/js/ui/modalDialog.js
index 66c17d4..372a6b9 100644
--- a/js/ui/modalDialog.js
+++ b/js/ui/modalDialog.js
@@ -40,9 +40,9 @@ const ModalDialog = new Lang.Class({
         this._hasModal = false;
         this._shellReactive = params.shellReactive;
 
-        this._group = new St.Group({ visible: false,
-                                     x: 0,
-                                     y: 0 });
+        this._group = new St.Widget({ visible: false,
+                                      x: 0,
+                                      y: 0 });
         Main.uiGroup.add_actor(this._group);
 
         let constraint = new Clutter.BindConstraint({ source: global.stage,
diff --git a/js/ui/overview.js b/js/ui/overview.js
index 566d3f1..830cd48 100644
--- a/js/ui/overview.js
+++ b/js/ui/overview.js
@@ -126,8 +126,8 @@ const Overview = new Lang.Class({
 
         this._spacing = 0;
 
-        this._group = new St.Group({ name: 'overview',
-                                     reactive: true });
+        this._group = new St.Widget({ name: 'overview',
+                                      reactive: true });
         this._group._delegate = this;
         this._group.connect('style-changed',
             Lang.bind(this, function() {
diff --git a/js/ui/panel.js b/js/ui/panel.js
index 2f9a439..d8a9a93 100644
--- a/js/ui/panel.js
+++ b/js/ui/panel.js
@@ -106,38 +106,47 @@ const AnimatedIcon = new Lang.Class({
     _init: function(name, size) {
         this.actor = new St.Bin({ visible: false });
         this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
-        this.actor.connect('notify::visible', Lang.bind(this, function() {
-            if (this.actor.visible) {
-                this._timeoutId = Mainloop.timeout_add(ANIMATED_ICON_UPDATE_TIMEOUT, Lang.bind(this, this._update));
-            } else {
-                if (this._timeoutId)
-                    Mainloop.source_remove(this._timeoutId);
-                this._timeoutId = 0;
-            }
-        }));
+        this.actor.connect('notify::visible', Lang.bind(this, this._onVisibleNotify));
 
         this._timeoutId = 0;
-        this._i = 0;
+        this._frame = 0;
         this._animations = St.TextureCache.get_default().load_sliced_image (global.datadir + '/theme/' + name, size, size);
         this.actor.set_child(this._animations);
     },
 
-    _update: function() {
-        this._animations.hide_all();
-        this._animations.show();
-        if (this._i && this._i < this._animations.get_n_children())
-            this._animations.get_nth_child(this._i++).show();
-        else {
-            this._i = 1;
-            if (this._animations.get_n_children())
-                this._animations.get_nth_child(0).show();
+    _disconnectTimeout: function() {
+        if (this._timeoutId > 0) {
+            Mainloop.source_remove(this._timeoutId);
+            this._timeoutId = 0;
         }
+    },
+
+    _onVisibleNotify: function() {
+        if (this.actor.visible)
+            this._timeoutId = Mainloop.timeout_add(ANIMATED_ICON_UPDATE_TIMEOUT, Lang.bind(this, this._update));
+        else
+            this._disconnectTimeout();
+    },
+
+    _showFrame: function(frame) {
+        let oldFrameActor = this._animations.get_child_at_index(this._frame);
+        if (oldFrameActor)
+            oldFrameActor.hide();
+
+        this._frame = (frame % this._animations.get_n_children());
+
+        let newFrameActor = this._animations.get_child_at_index(this._frame);
+        if (newFrameActor)
+            newFrameActor.show();
+    },
+
+    _update: function() {
+        this._showFrame(this._frame + 1);
         return true;
     },
 
     _onDestroy: function() {
-        if (this._timeoutId)
-            Mainloop.source_remove(this._timeoutId);
+        this._disconnectTimeout();
     }
 });
 
diff --git a/js/ui/workspaceSwitcherPopup.js b/js/ui/workspaceSwitcherPopup.js
index 15383db..51d2c28 100644
--- a/js/ui/workspaceSwitcherPopup.js
+++ b/js/ui/workspaceSwitcherPopup.js
@@ -19,12 +19,12 @@ const WorkspaceSwitcherPopup = new Lang.Class({
     Name: 'WorkspaceSwitcherPopup',
 
     _init : function() {
-        this.actor = new St.Group({ reactive: true,
-                                         x: 0,
-                                         y: 0,
-                                         width: global.screen_width,
-                                         height: global.screen_height,
-                                         style_class: 'workspace-switcher-group' });
+        this.actor = new St.Widget({ reactive: true,
+                                     x: 0,
+                                     y: 0,
+                                     width: global.screen_width,
+                                     height: global.screen_height,
+                                     style_class: 'workspace-switcher-group' });
         Main.uiGroup.add_actor(this.actor);
 
         this._container = new St.BoxLayout({ style_class: 'workspace-switcher-container' });
diff --git a/js/ui/workspaceThumbnail.js b/js/ui/workspaceThumbnail.js
index 52b2a74..0e68abc 100644
--- a/js/ui/workspaceThumbnail.js
+++ b/js/ui/workspaceThumbnail.js
@@ -156,9 +156,9 @@ const WorkspaceThumbnail = new Lang.Class({
 
         this._removed = false;
 
-        this.actor = new St.Group({ reactive: true,
-                                    clip_to_allocation: true,
-                                    style_class: 'workspace-thumbnail' });
+        this.actor = new St.Widget({ reactive: true,
+                                     clip_to_allocation: true,
+                                     style_class: 'workspace-thumbnail' });
         this.actor._delegate = this;
 
         this._contents = new Clutter.Group();
diff --git a/js/ui/workspacesView.js b/js/ui/workspacesView.js
index 0e1bee8..925f791 100644
--- a/js/ui/workspacesView.js
+++ b/js/ui/workspacesView.js
@@ -29,7 +29,7 @@ const WorkspacesView = new Lang.Class({
     Name: 'WorkspacesView',
 
     _init: function(workspaces) {
-        this.actor = new St.Group({ style_class: 'workspaces-view' });
+        this.actor = new St.Widget({ style_class: 'workspaces-view' });
 
         // The actor itself isn't a drop target, so we don't want to pick on its area
         this.actor.set_size(0, 0);
diff --git a/src/Makefile-st.am b/src/Makefile-st.am
index b6ba99c..2243b03 100644
--- a/src/Makefile-st.am
+++ b/src/Makefile-st.am
@@ -54,7 +54,6 @@ st_source_h =					\
 	st/st-drawing-area.h			\
 	st/st-entry.h				\
 	st/st-focus-manager.h			\
-	st/st-group.h				\
 	st/st-icon.h				\
 	st/st-icon-colors.h			\
 	st/st-im-text.h				\
@@ -110,7 +109,6 @@ st_source_c =					\
 	st/st-drawing-area.c			\
 	st/st-entry.c				\
 	st/st-focus-manager.c			\
-	st/st-group.c				\
 	st/st-icon.c				\
 	st/st-icon-colors.c			\
 	st/st-im-text.c				\
diff --git a/src/st/st-texture-cache.c b/src/st/st-texture-cache.c
index 813c0fe..0b5a920 100644
--- a/src/st/st-texture-cache.c
+++ b/src/st/st-texture-cache.c
@@ -1162,7 +1162,7 @@ load_from_pixbuf (GdkPixbuf *pixbuf)
 typedef struct {
   gchar *path;
   gint   grid_width, grid_height;
-  ClutterGroup *group;
+  ClutterActor *actor;
 } AsyncImageData;
 
 static void
@@ -1170,7 +1170,7 @@ on_data_destroy (gpointer data)
 {
   AsyncImageData *d = (AsyncImageData *)data;
   g_free (d->path);
-  g_object_unref (d->group);
+  g_object_unref (d->actor);
   g_free (d);
 }
 
@@ -1190,7 +1190,7 @@ on_sliced_image_loaded (GObject *source_object,
     {
       ClutterActor *actor = load_from_pixbuf (GDK_PIXBUF (list->data));
       clutter_actor_hide (actor);
-      clutter_container_add_actor (CLUTTER_CONTAINER (data->group), actor);
+      clutter_actor_add_child (data->actor, actor);
     }
 }
 
@@ -1252,9 +1252,9 @@ load_sliced_image (GSimpleAsyncResult *result,
  * note that the dimensions of the image loaded from @path 
  * should be a multiple of the specified grid dimensions.
  *
- * Returns: (transfer none): A new #ClutterGroup
+ * Returns: (transfer none): A new #ClutterActor
  */
-ClutterGroup *
+ClutterActor *
 st_texture_cache_load_sliced_image (StTextureCache    *cache,
                                     const gchar       *path,
                                     gint               grid_width,
@@ -1262,14 +1262,14 @@ st_texture_cache_load_sliced_image (StTextureCache    *cache,
 {
   AsyncImageData *data;
   GSimpleAsyncResult *result;
-  ClutterGroup *group = CLUTTER_GROUP (clutter_group_new ());
+  ClutterActor *actor = clutter_actor_new ();
 
   data = g_new0 (AsyncImageData, 1);
   data->grid_width = grid_width;
   data->grid_height = grid_height;
   data->path = g_strdup (path);
-  data->group = group;
-  g_object_ref (G_OBJECT (group));
+  data->actor = actor;
+  g_object_ref (G_OBJECT (actor));
 
   result = g_simple_async_result_new (G_OBJECT (cache), on_sliced_image_loaded, data, st_texture_cache_load_sliced_image);
 
@@ -1278,7 +1278,7 @@ st_texture_cache_load_sliced_image (StTextureCache    *cache,
 
   g_object_unref (result);
 
-  return group;
+  return actor;
 }
 
 /**
diff --git a/src/st/st-texture-cache.h b/src/st/st-texture-cache.h
index 5f1e701..7275703 100644
--- a/src/st/st-texture-cache.h
+++ b/src/st/st-texture-cache.h
@@ -68,7 +68,7 @@ GType st_texture_cache_get_type (void) G_GNUC_CONST;
 
 StTextureCache* st_texture_cache_get_default (void);
 
-ClutterGroup *
+ClutterActor *
 st_texture_cache_load_sliced_image (StTextureCache    *cache,
                                     const gchar       *path,
                                     gint               grid_width,



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