[gnome-shell/wip/clutter-deprecation-fixes: 12/21] st-container: Remove custom ClutterContainer implementation
- From: Jasper St. Pierre <jstpierre src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/clutter-deprecation-fixes: 12/21] st-container: Remove custom ClutterContainer implementation
- Date: Tue, 14 Feb 2012 22:02:27 +0000 (UTC)
commit 2546e83a745e4ba4e00e3c337fe870db33dee868
Author: Jasper St. Pierre <jstpierre mecheye net>
Date: Tue Feb 14 11:23:51 2012 -0500
st-container: Remove custom ClutterContainer implementation
This is a quick prerequisite to getting rid of StContainer for real.
We simply port StContainer to be a quick wrapper on top of the concrete
ClutterContainer implementation in ClutterActor to make the transition
hopefully seamless and easier to understand.
https://bugzilla.gnome.org/show_bug.cgi?id=670034
js/gdm/loginDialog.js | 2 +-
js/ui/appDisplay.js | 2 +-
js/ui/autorunManager.js | 2 +-
js/ui/calendar.js | 6 +-
js/ui/dash.js | 2 +-
js/ui/endSessionDialog.js | 2 +-
js/ui/modalDialog.js | 2 +-
js/ui/shellMountOperation.js | 2 +-
js/ui/workspaceSwitcherPopup.js | 2 +-
src/st/st-container.c | 383 ++-------------------------------------
src/st/st-container.h | 1 -
11 files changed, 26 insertions(+), 380 deletions(-)
---
diff --git a/js/gdm/loginDialog.js b/js/gdm/loginDialog.js
index 46f3fa4..6d4ae2b 100644
--- a/js/gdm/loginDialog.js
+++ b/js/gdm/loginDialog.js
@@ -694,7 +694,7 @@ const SessionList = new Lang.Class({
},
_populate: function() {
- this._itemList.destroy_children();
+ this._itemList.destroy_all_children();
this._activeSessionId = null;
this._items = {};
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 5d845e6..5490562 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -236,7 +236,7 @@ const ViewByCategories = new Lang.Class({
_removeAll: function() {
this._categories = [];
- this._categoryBox.destroy_children();
+ this._categoryBox.destroy_all_children();
},
refresh: function() {
diff --git a/js/ui/autorunManager.js b/js/ui/autorunManager.js
index 2dec5fb..175eecf 100644
--- a/js/ui/autorunManager.js
+++ b/js/ui/autorunManager.js
@@ -339,7 +339,7 @@ const AutorunResidentNotification = new Lang.Class({
updateForMounts: function(mounts) {
// remove all the layout content
- this._layout.destroy_children();
+ this._layout.destroy_all_children();
for (let idx = 0; idx < mounts.length; idx++) {
let element = mounts[idx];
diff --git a/js/ui/calendar.js b/js/ui/calendar.js
index 0c33ed0..9a7258a 100644
--- a/js/ui/calendar.js
+++ b/js/ui/calendar.js
@@ -406,7 +406,7 @@ const Calendar = new Lang.Class({
_buildHeader: function() {
let offsetCols = this._useWeekdate ? 1 : 0;
- this.actor.destroy_children();
+ this.actor.destroy_all_children();
// Top line of the calendar '<| September 2009 |>'
this._topBox = new St.BoxLayout();
@@ -685,7 +685,7 @@ const EventsList = new Lang.Class({
},
_showOtherDay: function(day) {
- this.actor.destroy_children();
+ this.actor.destroy_all_children();
let dayBegin = _getBeginningOfDay(day);
let dayEnd = _getEndOfDay(day);
@@ -702,7 +702,7 @@ const EventsList = new Lang.Class({
},
_showToday: function() {
- this.actor.destroy_children();
+ this.actor.destroy_all_children();
let now = new Date();
let dayBegin = _getBeginningOfDay(now);
diff --git a/js/ui/dash.js b/js/ui/dash.js
index 5835bc4..15e0ced 100644
--- a/js/ui/dash.js
+++ b/js/ui/dash.js
@@ -148,7 +148,7 @@ const DashItemContainer = new Lang.Class({
if (this.child == actor)
return;
- this.actor.destroy_children();
+ this.actor.destroy_all_children();
this.child = actor;
this.actor.add_actor(this.child);
diff --git a/js/ui/endSessionDialog.js b/js/ui/endSessionDialog.js
index 39cbcf8..2a6e6c8 100644
--- a/js/ui/endSessionDialog.js
+++ b/js/ui/endSessionDialog.js
@@ -501,7 +501,7 @@ const EndSessionDialog = new Lang.Class({
let [type, timestamp, totalSecondsToStayOpen, inhibitorObjectPaths] = parameters;
this._totalSecondsToStayOpen = totalSecondsToStayOpen;
this._inhibitors = [];
- this._applicationList.destroy_children();
+ this._applicationList.destroy_all_children();
this._type = type;
if (!(this._type in DialogContent)) {
diff --git a/js/ui/modalDialog.js b/js/ui/modalDialog.js
index a647959..66c17d4 100644
--- a/js/ui/modalDialog.js
+++ b/js/ui/modalDialog.js
@@ -105,7 +105,7 @@ const ModalDialog = new Lang.Class({
setButtons: function(buttons) {
let hadChildren = this._buttonLayout.get_children() > 0;
- this._buttonLayout.destroy_children();
+ this._buttonLayout.destroy_all_children();
this._actionKeys = {};
for (let i = 0; i < buttons.length; i++) {
diff --git a/js/ui/shellMountOperation.js b/js/ui/shellMountOperation.js
index 8a91d98..93f9d9c 100644
--- a/js/ui/shellMountOperation.js
+++ b/js/ui/shellMountOperation.js
@@ -359,7 +359,7 @@ const ShellProcessesDialog = new Lang.Class({
_setAppsForPids: function(pids) {
// remove all the items
- this._applicationList.destroy_children();
+ this._applicationList.destroy_all_children();
pids.forEach(Lang.bind(this, function(pid) {
let tracker = Shell.WindowTracker.get_default();
diff --git a/js/ui/workspaceSwitcherPopup.js b/js/ui/workspaceSwitcherPopup.js
index 58dd657..15383db 100644
--- a/js/ui/workspaceSwitcherPopup.js
+++ b/js/ui/workspaceSwitcherPopup.js
@@ -105,7 +105,7 @@ const WorkspaceSwitcherPopup = new Lang.Class({
},
_redraw : function(direction, activeWorkspaceIndex) {
- this._list.destroy_children();
+ this._list.destroy_all_children();
for (let i = 0; i < global.screen.n_workspaces; i++) {
let indicator = null;
diff --git a/src/st/st-container.c b/src/st/st-container.c
index 1e8380f..2f58505 100644
--- a/src/st/st-container.c
+++ b/src/st/st-container.c
@@ -28,142 +28,7 @@
#include "st-container.h"
-#define ST_CONTAINER_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj),ST_TYPE_CONTAINER, StContainerPrivate))
-
-struct _StContainerPrivate
-{
- GList *children;
- ClutterActor *first_child;
- ClutterActor *last_child;
- gboolean block_update_pseudo_classes;
-};
-
-static void clutter_container_iface_init (ClutterContainerIface *iface);
-
-G_DEFINE_ABSTRACT_TYPE_WITH_CODE (StContainer, st_container, ST_TYPE_WIDGET,
- G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_CONTAINER,
- clutter_container_iface_init));
-
-static void
-st_container_update_pseudo_classes (StContainer *container)
-{
- GList *first_item, *last_item;
- ClutterActor *first_child, *last_child;
- StContainerPrivate *priv = container->priv;
-
- if (priv->block_update_pseudo_classes)
- return;
-
- first_item = priv->children;
- first_child = first_item ? first_item->data : NULL;
- if (first_child != priv->first_child)
- {
- if (priv->first_child && ST_IS_WIDGET (priv->first_child))
- st_widget_remove_style_pseudo_class (ST_WIDGET (priv->first_child),
- "first-child");
- if (priv->first_child)
- {
- g_object_unref (priv->first_child);
- priv->first_child = NULL;
- }
-
- if (first_child && ST_IS_WIDGET (first_child))
- st_widget_add_style_pseudo_class (ST_WIDGET (first_child),
- "first-child");
- if (first_child)
- priv->first_child = g_object_ref (first_child);
- }
-
- last_item = g_list_last (priv->children);
- last_child = last_item ? last_item->data : NULL;
- if (last_child != priv->last_child)
- {
- if (priv->last_child && ST_IS_WIDGET (priv->last_child))
- st_widget_remove_style_pseudo_class (ST_WIDGET (priv->last_child),
- "last-child");
- if (priv->last_child)
- {
- g_object_unref (priv->last_child);
- priv->last_child = NULL;
- }
-
- if (last_child && ST_IS_WIDGET (last_child))
- st_widget_add_style_pseudo_class (ST_WIDGET (last_child),
- "last-child");
- if (last_child)
- priv->last_child = g_object_ref (last_child);
- }
-}
-
-/**
- * st_container_destroy_children:
- * @container: An #StContainer
- *
- * Destroys all child actors from @container.
- */
-void
-st_container_destroy_children (StContainer *container)
-{
- StContainerPrivate *priv = container->priv;
-
- priv->block_update_pseudo_classes = TRUE;
-
- while (priv->children)
- clutter_actor_destroy (priv->children->data);
-
- priv->block_update_pseudo_classes = FALSE;
-
- st_container_update_pseudo_classes (container);
-}
-
-void
-st_container_move_child (StContainer *container,
- ClutterActor *actor,
- int pos)
-{
- StContainerPrivate *priv = container->priv;
- GList *item = NULL;
-
- item = g_list_find (priv->children, actor);
-
- if (item == NULL)
- {
- g_warning ("Actor of type '%s' is not a child of the %s container",
- g_type_name (G_OBJECT_TYPE (actor)),
- g_type_name (G_OBJECT_TYPE (container)));
- return;
- }
-
- priv->children = g_list_delete_link (priv->children, item);
- priv->children = g_list_insert (priv->children, actor, pos);
-
- st_container_update_pseudo_classes (container);
-
- clutter_actor_queue_relayout ((ClutterActor*) container);
-}
-
-void
-st_container_move_before (StContainer *container,
- ClutterActor *actor,
- ClutterActor *sibling)
-{
- StContainerPrivate *priv = container->priv;
- GList *actor_item = NULL;
- GList *sibling_item = NULL;
-
- actor_item = g_list_find (priv->children, actor);
- sibling_item = g_list_find (priv->children, sibling);
-
- g_return_if_fail (actor_item != NULL);
- g_return_if_fail (sibling_item != NULL);
-
- priv->children = g_list_delete_link (priv->children, actor_item);
- priv->children = g_list_insert_before (priv->children, sibling_item, actor);
-
- st_container_update_pseudo_classes (container);
-
- clutter_actor_queue_relayout (CLUTTER_ACTOR (container));
-}
+G_DEFINE_ABSTRACT_TYPE (StContainer, st_container, ST_TYPE_WIDGET);
/**
* st_container_get_children_list:
@@ -177,79 +42,7 @@ st_container_move_before (StContainer *container,
GList *
st_container_get_children_list (StContainer *container)
{
- g_return_val_if_fail (ST_IS_CONTAINER (container), NULL);
-
- return container->priv->children;
-}
-
-static gint
-sort_z_order (gconstpointer a,
- gconstpointer b)
-{
- float depth_a, depth_b;
-
- depth_a = clutter_actor_get_depth (CLUTTER_ACTOR (a));
- depth_b = clutter_actor_get_depth (CLUTTER_ACTOR (b));
-
- if (depth_a < depth_b)
- return -1;
- if (depth_a > depth_b)
- return 1;
- return 0;
-}
-
-static void
-st_container_add (ClutterContainer *container,
- ClutterActor *actor)
-{
- StContainerPrivate *priv = ST_CONTAINER (container)->priv;
-
- g_object_ref (actor);
-
- priv->children = g_list_append (priv->children, actor);
- clutter_actor_set_parent (actor, CLUTTER_ACTOR (container));
-
- /* queue a relayout, to get the correct positioning inside
- * the ::actor-added signal handlers
- */
- clutter_actor_queue_relayout (CLUTTER_ACTOR (container));
-
- g_signal_emit_by_name (container, "actor-added", actor);
-
- clutter_container_sort_depth_order (container);
- st_container_update_pseudo_classes (ST_CONTAINER (container));
-
- g_object_unref (actor);
-}
-
-static void
-st_container_remove (ClutterContainer *container,
- ClutterActor *actor)
-{
- StContainerPrivate *priv = ST_CONTAINER (container)->priv;
-
- g_object_ref (actor);
-
- priv->children = g_list_remove (priv->children, actor);
- clutter_actor_unparent (actor);
-
- /* queue a relayout, to get the correct positioning inside
- * the ::actor-removed signal handlers
- */
- clutter_actor_queue_relayout (CLUTTER_ACTOR (container));
-
- /* at this point, the actor passed to the "actor-removed" signal
- * handlers is not parented anymore to the container but since we
- * are holding a reference on it, it's still valid
- */
- g_signal_emit_by_name (container, "actor-removed", actor);
-
- st_container_update_pseudo_classes (ST_CONTAINER (container));
-
- if (CLUTTER_ACTOR_IS_VISIBLE (container))
- clutter_actor_queue_redraw (CLUTTER_ACTOR (container));
-
- g_object_unref (actor);
+ return clutter_actor_get_children (CLUTTER_ACTOR (container));
}
static void
@@ -257,171 +50,25 @@ st_container_foreach (ClutterContainer *container,
ClutterCallback callback,
gpointer user_data)
{
- StContainerPrivate *priv = ST_CONTAINER (container)->priv;
-
- /* Using g_list_foreach instead of iterating the list manually
- * because it has better protection against the current node being
- * removed. This will happen for example if someone calls
- * clutter_container_foreach(container, clutter_actor_destroy)
- */
- g_list_foreach (priv->children, (GFunc) callback, user_data);
-}
-
-static void
-st_container_raise (ClutterContainer *container,
- ClutterActor *actor,
- ClutterActor *sibling)
-{
- StContainerPrivate *priv = ST_CONTAINER (container)->priv;
-
- priv->children = g_list_remove (priv->children, actor);
-
- /* Raise at the top */
- if (!sibling)
- {
- GList *last_item;
-
- last_item = g_list_last (priv->children);
-
- if (last_item)
- sibling = last_item->data;
-
- priv->children = g_list_append (priv->children, actor);
- }
- else
- {
- gint pos;
-
- pos = g_list_index (priv->children, sibling) + 1;
-
- priv->children = g_list_insert (priv->children, actor, pos);
- }
-
- /* set Z ordering a value below, this will then call sort
- * as values are equal ordering shouldn't change but Z
- * values will be correct.
- *
- * FIXME: optimise
- */
- if (sibling &&
- clutter_actor_get_depth (sibling) != clutter_actor_get_depth (actor))
- {
- clutter_actor_set_depth (actor, clutter_actor_get_depth (sibling));
- }
-
- st_container_update_pseudo_classes (ST_CONTAINER (container));
-
- if (CLUTTER_ACTOR_IS_VISIBLE (container))
- clutter_actor_queue_redraw (CLUTTER_ACTOR (container));
+ g_list_foreach (clutter_actor_get_children (CLUTTER_ACTOR (container)), (GFunc) callback, user_data);
}
-static void
-st_container_lower (ClutterContainer *container,
- ClutterActor *actor,
- ClutterActor *sibling)
-{
- StContainerPrivate *priv = ST_CONTAINER (container)->priv;
-
- priv->children = g_list_remove (priv->children, actor);
-
- /* Push to bottom */
- if (!sibling)
- {
- GList *last_item;
-
- last_item = g_list_first (priv->children);
-
- if (last_item)
- sibling = last_item->data;
-
- priv->children = g_list_prepend (priv->children, actor);
- }
- else
- {
- gint pos;
-
- pos = g_list_index (priv->children, sibling);
-
- priv->children = g_list_insert (priv->children, actor, pos);
- }
-
- /* See comment in st_container_raise() for this */
- if (sibling &&
- clutter_actor_get_depth (sibling) != clutter_actor_get_depth (actor))
- {
- clutter_actor_set_depth (actor, clutter_actor_get_depth (sibling));
- }
-
- st_container_update_pseudo_classes (ST_CONTAINER (container));
-
- if (CLUTTER_ACTOR_IS_VISIBLE (container))
- clutter_actor_queue_redraw (CLUTTER_ACTOR (container));
-}
-
-static void
-st_container_sort_depth_order (ClutterContainer *container)
+void
+st_container_move_child (StContainer *container,
+ ClutterActor *actor,
+ int pos)
{
- StContainerPrivate *priv = ST_CONTAINER (container)->priv;
-
- priv->children = g_list_sort (priv->children, sort_z_order);
-
- if (CLUTTER_ACTOR_IS_VISIBLE (container))
- clutter_actor_queue_redraw (CLUTTER_ACTOR (container));
+ clutter_actor_set_child_at_index (CLUTTER_ACTOR (container),
+ actor, pos);
}
-static void
-st_container_dispose (GObject *object)
-{
- StContainerPrivate *priv = ST_CONTAINER (object)->priv;
-
- if (priv->children)
- {
- g_list_foreach (priv->children, (GFunc) clutter_actor_destroy, NULL);
- g_list_free (priv->children);
-
- priv->children = NULL;
- }
-
- if (priv->first_child)
- g_object_unref (priv->first_child);
- priv->first_child = NULL;
-
- if (priv->last_child)
- g_object_unref (priv->last_child);
- priv->last_child = NULL;
-
- G_OBJECT_CLASS (st_container_parent_class)->dispose (object);
-}
-
-static gboolean
-st_container_get_paint_volume (ClutterActor *actor,
- ClutterPaintVolume *volume)
+void
+st_container_move_before (StContainer *container,
+ ClutterActor *actor,
+ ClutterActor *sibling)
{
- StContainerPrivate *priv = ST_CONTAINER (actor)->priv;
- GList *l;
-
- if (!CLUTTER_ACTOR_CLASS (st_container_parent_class)->get_paint_volume (actor, volume))
- return FALSE;
-
- if (!clutter_actor_get_clip_to_allocation (actor))
- {
- /* Based on ClutterGroup/ClutterBox; include the children's
- * paint volumes, since they may paint outside our allocation.
- */
- for (l = priv->children; l != NULL; l = l->next)
- {
- ClutterActor *child = l->data;
- const ClutterPaintVolume *child_volume;
-
- child_volume = clutter_actor_get_transformed_paint_volume (child, actor);
- if (!child_volume)
- return FALSE;
-
- clutter_paint_volume_union (volume, child_volume);
- }
- }
-
- return TRUE;
+ clutter_actor_set_child_below_sibling (CLUTTER_ACTOR (container),
+ actor, sibling);
}
/* filter @children to contain only only actors that overlap @rbox
diff --git a/src/st/st-container.h b/src/st/st-container.h
index 418ca43..434df1b 100644
--- a/src/st/st-container.h
+++ b/src/st/st-container.h
@@ -42,7 +42,6 @@ typedef struct _StContainerPrivate StContainerPrivate;
struct _StContainer {
StWidget parent;
- StContainerPrivate *priv;
};
struct _StContainerClass {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]