[gnome-shell] Remove st_widget accessors for background and border actors



commit a4481b38d2c5a5db3e3ff36591e2afcbf4c63f14
Author: Colin Walters <walters verbum org>
Date:   Mon Feb 8 14:57:33 2010 -0500

    Remove st_widget accessors for background and border actors
    
    StButton animated the background for button transitions; since these aren't
    presently part of the shell design, simply remove them.  We can readd
    these in the future.
    
    StTooltip should probably have :vertical and :horizontal pseudo classes
    to make the arrow work but it should still function.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=607500

 src/st/st-button.c  |  125 +--------------------------------------------------
 src/st/st-button.h  |    3 +-
 src/st/st-tooltip.c |   98 ++--------------------------------------
 src/st/st-widget.c  |   62 +-------------------------
 src/st/st-widget.h  |    4 --
 5 files changed, 8 insertions(+), 284 deletions(-)
---
diff --git a/src/st/st-button.c b/src/st/st-button.c
index 1f6113e..69dc476 100644
--- a/src/st/st-button.c
+++ b/src/st/st-button.c
@@ -73,10 +73,6 @@ struct _StButtonPrivate
 {
   gchar            *text;
 
-  ClutterActor     *old_bg;
-  gboolean          old_bg_parented; /* TRUE if we have adopted old_bg */
-  gboolean          old_bg_animating; /* TRUE if the opacity animation is running and we hold a self-ref */
-
   guint8            old_opacity;
 
   guint             is_pressed : 1;
@@ -110,50 +106,14 @@ st_button_update_label_style (StButton *button)
 }
 
 static void
-st_button_dispose_old_bg (StButton *button)
-{
-  StButtonPrivate *priv = button->priv;
-
-  if (priv->old_bg)
-    {
-      if (priv->old_bg_parented)
-        {
-          clutter_actor_unparent (priv->old_bg);
-          priv->old_bg_parented = FALSE;
-        }
-      g_object_unref (priv->old_bg);
-      priv->old_bg = NULL;
-      if (priv->old_bg_animating)
-        {
-          g_object_unref (button);
-          priv->old_bg_animating = FALSE;
-        }
-    }
-}
-
-static void
-st_animation_completed (ClutterAnimation *animation,
-                        StButton         *button)
-{
-  st_button_dispose_old_bg (button);
-}
-
-static void
 st_button_style_changed (StWidget *widget)
 {
   StButton *button = ST_BUTTON (widget);
   StButtonPrivate *priv = button->priv;
   StButtonClass *button_class = ST_BUTTON_GET_CLASS (button);
   StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (button));
-  ClutterActor *bg_image;
   double spacing;
 
-  st_button_dispose_old_bg (button);
-
-  bg_image = st_widget_get_border_image ((StWidget*) button);
-  if (bg_image)
-    button->priv->old_bg = g_object_ref (bg_image);
-
   ST_WIDGET_CLASS (st_button_parent_class)->style_changed (widget);
 
   spacing = 6;
@@ -166,42 +126,7 @@ st_button_style_changed (StWidget *widget)
   /* run a transition if applicable */
   if (button_class->transition)
     {
-      button_class->transition (button, priv->old_bg);
-    }
-  else
-    {
-      if (priv->old_bg &&
-          (!st_widget_get_style_pseudo_class (widget)))
-        {
-          ClutterAnimation *animation;
-          if (!clutter_actor_get_parent (priv->old_bg))
-            {
-              clutter_actor_set_parent (priv->old_bg, (ClutterActor*) widget);
-              priv->old_bg_parented = TRUE;
-            }
-          if (priv->transition_duration > 0)
-            {
-              animation = clutter_actor_animate (priv->old_bg,
-                                                 CLUTTER_LINEAR,
-                                                 priv->transition_duration,
-                                                 "opacity", 0,
-                                                 NULL);
-              /* The reference counting here is looped; through the button, old_bg,
-               * and the animation.  However, that's not a problem because we will
-               * break the cycle when either the animation completes, or when
-               * we dispose.
-               */
-              priv->old_bg_animating = TRUE;
-              g_object_ref (button);
-              g_signal_connect (animation, "completed",
-                                G_CALLBACK (st_animation_completed), button);
-            }
-          else
-            {
-              st_button_dispose_old_bg (button);
-            }
-
-        }
+      button_class->transition (button);
     }
 }
 
@@ -395,49 +320,6 @@ st_button_finalize (GObject *gobject)
 }
 
 static void
-st_button_dispose (GObject *gobject)
-{
-  st_button_dispose_old_bg (ST_BUTTON (gobject));
-
-  G_OBJECT_CLASS (st_button_parent_class)->dispose (gobject);
-}
-
-static void
-st_button_map (ClutterActor *self)
-{
-  StButtonPrivate *priv = ST_BUTTON (self)->priv;
-
-  CLUTTER_ACTOR_CLASS (st_button_parent_class)->map (self);
-
-  if (priv->old_bg && priv->old_bg_parented)
-    clutter_actor_map (priv->old_bg);
-}
-
-static void
-st_button_unmap (ClutterActor *self)
-{
-  StButtonPrivate *priv = ST_BUTTON (self)->priv;
-
-  CLUTTER_ACTOR_CLASS (st_button_parent_class)->unmap (self);
-
-  if (priv->old_bg && priv->old_bg_parented)
-    clutter_actor_unmap (priv->old_bg);
-}
-
-static void
-st_button_draw_background (StWidget         *widget)
-{
-  StButtonPrivate *priv;
-
-  ST_WIDGET_CLASS (st_button_parent_class)->draw_background (widget);
-
-  priv = ST_BUTTON (widget)->priv;
-
-  if (priv->old_bg && priv->old_bg_parented)
-    clutter_actor_paint (priv->old_bg);
-}
-
-static void
 st_button_class_init (StButtonClass *klass)
 {
   GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
@@ -452,7 +334,6 @@ st_button_class_init (StButtonClass *klass)
 
   gobject_class->set_property = st_button_set_property;
   gobject_class->get_property = st_button_get_property;
-  gobject_class->dispose = st_button_dispose;
   gobject_class->finalize = st_button_finalize;
 
   actor_class->button_press_event = st_button_button_press;
@@ -460,10 +341,6 @@ st_button_class_init (StButtonClass *klass)
   actor_class->enter_event = st_button_enter;
   actor_class->leave_event = st_button_leave;
 
-  actor_class->map = st_button_map;
-  actor_class->unmap = st_button_unmap;
-
-  widget_class->draw_background = st_button_draw_background;
   widget_class->style_changed = st_button_style_changed;
 
   pspec = g_param_spec_string ("label",
diff --git a/src/st/st-button.h b/src/st/st-button.h
index 615a216..f17bc50 100644
--- a/src/st/st-button.h
+++ b/src/st/st-button.h
@@ -68,8 +68,7 @@ struct _StButtonClass
   /* vfuncs, not signals */
   void (* pressed)    (StButton     *button);
   void (* released)   (StButton     *button);
-  void (* transition) (StButton     *button,
-                       ClutterActor *old_bg);
+  void (* transition) (StButton     *button);
 
   /* signals */
   void (* clicked) (StButton *button);
diff --git a/src/st/st-tooltip.c b/src/st/st-tooltip.c
index 1fbec22..5195270 100644
--- a/src/st/st-tooltip.c
+++ b/src/st/st-tooltip.c
@@ -148,27 +148,13 @@ st_tooltip_get_preferred_width (ClutterActor *self,
 {
   StTooltipPrivate *priv = ST_TOOLTIP (self)->priv;
   StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (self));
-  gfloat label_height, arrow_height;
-  ClutterActor *arrow_image;
+  gfloat label_height;
 
   st_theme_node_adjust_for_height (theme_node, &for_height);
 
-  arrow_image = st_widget_get_background_image (ST_WIDGET (self));
-  if (arrow_image)
-    {
-      clutter_actor_get_preferred_height (arrow_image,
-                                          -1,
-                                          NULL,
-                                          &arrow_height);
-    }
-  else
-    {
-      arrow_height = 0;
-    }
-
   if (for_height > -1)
     {
-      label_height = for_height - arrow_height;
+      label_height = for_height;
     }
   else
     {
@@ -194,26 +180,10 @@ st_tooltip_get_preferred_height (ClutterActor *self,
 {
   StTooltipPrivate *priv = ST_TOOLTIP (self)->priv;
   StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (self));
-  gfloat arrow_height;
   gfloat min_label_h, natural_label_h;
-  ClutterActor *arrow_image;
 
   st_theme_node_adjust_for_width (theme_node, &for_width);
 
-  arrow_image = st_widget_get_background_image (ST_WIDGET (self));
-
-  if (arrow_image && !priv->actor_below)
-    {
-      clutter_actor_get_preferred_height (arrow_image,
-                                          -1,
-                                          NULL,
-                                          &arrow_height);
-    }
-  else
-    {
-      arrow_height = 0;
-    }
-
   if (priv->label)
     {
       clutter_actor_get_preferred_height (priv->label,
@@ -228,10 +198,10 @@ st_tooltip_get_preferred_height (ClutterActor *self,
     }
 
   if (min_height_p)
-    *min_height_p = arrow_height + min_label_h;
+    *min_height_p = min_label_h;
 
   if (natural_height_p)
-    *natural_height_p = arrow_height + natural_label_h;
+    *natural_height_p = natural_label_h;
 
   st_theme_node_adjust_preferred_height (theme_node, min_height_p, natural_height_p);
 }
@@ -243,9 +213,7 @@ st_tooltip_allocate (ClutterActor          *self,
 {
   StTooltipPrivate *priv = ST_TOOLTIP (self)->priv;
   StThemeNode *theme_node = st_widget_get_theme_node (ST_WIDGET (self));
-  ClutterActorBox content_box, child_box, arrow_box;
-  gfloat arrow_height, arrow_width;
-  ClutterActor *border_image, *arrow_image;
+  ClutterActorBox content_box, child_box;
 
   CLUTTER_ACTOR_CLASS (st_tooltip_parent_class)->allocate (self,
                                                            box,
@@ -253,61 +221,23 @@ st_tooltip_allocate (ClutterActor          *self,
 
   st_theme_node_get_content_box (theme_node, box, &content_box);
 
-  arrow_image = st_widget_get_background_image (ST_WIDGET (self));
-
-  if (arrow_image && !priv->actor_below)
-    {
-      clutter_actor_get_preferred_height (arrow_image, -1, NULL, &arrow_height);
-      clutter_actor_get_preferred_width (arrow_image, -1, NULL, &arrow_width);
-
-      arrow_box.x1 = (float)(priv->arrow_offset) - (int)(arrow_width / 2);
-      arrow_box.y1 = 0;
-      arrow_box.x2 = arrow_box.x1 + arrow_width;
-      arrow_box.y2 = arrow_box.y1 + arrow_height;
-
-      clutter_actor_allocate (arrow_image, &arrow_box, flags);
-    }
-  else
-    {
-      arrow_height = 0;
-      arrow_width = 0;
-    }
-
   child_box.x1 = child_box.y1 = 0;
   child_box.x2 = (box->x2 - box->x1);
   child_box.y2 = (box->y2 - box->y1);
 
-  /* remove the space that is used by the arrow */
-  child_box.y1 += arrow_height;
-
-  border_image = st_widget_get_border_image (ST_WIDGET (self));
-  if (border_image)
-    clutter_actor_allocate (border_image, &child_box, flags);
-
   if (priv->label)
     {
       child_box = content_box;
-      child_box.y1 += arrow_height;
 
       clutter_actor_allocate (priv->label, &child_box, flags);
     }
 }
 
-
 static void
 st_tooltip_paint (ClutterActor *self)
 {
-  ClutterActor *border_image, *arrow_image;
   StTooltipPrivate *priv = ST_TOOLTIP (self)->priv;
 
-  border_image = st_widget_get_border_image (ST_WIDGET (self));
-  if (border_image)
-    clutter_actor_paint (border_image);
-
-  arrow_image = st_widget_get_background_image (ST_WIDGET (self));
-  if (arrow_image && !priv->actor_below)
-    clutter_actor_paint (arrow_image);
-
   clutter_actor_paint (priv->label);
 }
 
@@ -315,18 +245,9 @@ static void
 st_tooltip_map (ClutterActor *self)
 {
   StTooltipPrivate *priv = ST_TOOLTIP (self)->priv;
-  ClutterActor *border_image, *arrow_image;
 
   CLUTTER_ACTOR_CLASS (st_tooltip_parent_class)->map (self);
 
-  border_image = st_widget_get_border_image (ST_WIDGET (self));
-  if (border_image)
-    clutter_actor_map (border_image);
-
-  arrow_image = st_widget_get_background_image (ST_WIDGET (self));
-  if (arrow_image)
-    clutter_actor_map (arrow_image);
-
   clutter_actor_map (priv->label);
 }
 
@@ -334,18 +255,9 @@ static void
 st_tooltip_unmap (ClutterActor *self)
 {
   StTooltipPrivate *priv = ST_TOOLTIP (self)->priv;
-  ClutterActor *border_image, *arrow_image;
 
   CLUTTER_ACTOR_CLASS (st_tooltip_parent_class)->unmap (self);
 
-  border_image = st_widget_get_border_image (ST_WIDGET (self));
-  if (border_image)
-    clutter_actor_unmap (border_image);
-
-  arrow_image = st_widget_get_background_image (ST_WIDGET (self));
-  if (arrow_image)
-    clutter_actor_unmap (arrow_image);
-
   clutter_actor_unmap (priv->label);
 }
 
diff --git a/src/st/st-widget.c b/src/st/st-widget.c
index e5d200c..4a674c5 100644
--- a/src/st/st-widget.c
+++ b/src/st/st-widget.c
@@ -537,9 +537,8 @@ static void
 st_widget_paint (ClutterActor *self)
 {
   StWidgetPrivate *priv = ST_WIDGET (self)->priv;
-  StWidgetClass *klass = ST_WIDGET_GET_CLASS (self);
 
-  klass->draw_background (ST_WIDGET (self));
+  st_widget_real_draw_background (ST_WIDGET (self));
 
   if (priv->background_image != NULL)
     {
@@ -1190,7 +1189,6 @@ st_widget_class_init (StWidgetClass *klass)
   actor_class->leave_event = st_widget_leave;
   actor_class->hide = st_widget_hide;
 
-  klass->draw_background = st_widget_real_draw_background;
   klass->style_changed = st_widget_real_style_changed;
 
   /**
@@ -1574,40 +1572,6 @@ st_widget_set_direction (StWidget *self, StTextDirection dir)
 }
 
 /**
- * st_widget_get_border_image:
- * @actor: A #StWidget
- *
- * Get the texture used as the border image. This is set using the
- * "border-image" CSS property. This function should normally only be used
- * by subclasses.
- *
- * Returns: (transfer none): #ClutterActor
- */
-ClutterActor *
-st_widget_get_border_image (StWidget *actor)
-{
-  StWidgetPrivate *priv = ST_WIDGET (actor)->priv;
-  return priv->border_image;
-}
-
-/**
- * st_widget_get_background_image:
- * @actor: A #StWidget
- *
- * Get the texture used as the background image. This is set using the
- * "background-image" CSS property. This function should normally only be used
- * by subclasses.
- *
- * Returns: (transfer none): a #ClutterActor
- */
-ClutterActor *
-st_widget_get_background_image (StWidget *actor)
-{
-  StWidgetPrivate *priv = ST_WIDGET (actor)->priv;
-  return priv->background_image;
-}
-
-/**
  * st_widget_set_has_tooltip:
  * @widget: A #StWidget
  * @has_tooltip: #TRUE if the widget should display a tooltip
@@ -1768,27 +1732,3 @@ st_widget_hide_tooltip (StWidget *widget)
   if (widget->priv->tooltip)
     st_tooltip_hide (widget->priv->tooltip);
 }
-
-/**
- * st_widget_draw_background:
- * @widget: a #StWidget
- *
- * Invokes #StWidget::draw_background() using the default background
- * image and/or color from the @widget style
- *
- * This function should be used by subclasses of #StWidget that override
- * the paint() virtual function and cannot chain up
- */
-void
-st_widget_draw_background (StWidget *self)
-{
-  StWidgetPrivate *priv;
-  StWidgetClass *klass;
-
-  g_return_if_fail (ST_IS_WIDGET (self));
-
-  priv = self->priv;
-
-  klass = ST_WIDGET_GET_CLASS (self);
-  klass->draw_background (ST_WIDGET (self));
-}
diff --git a/src/st/st-widget.h b/src/st/st-widget.h
index bebe286..2000e28 100644
--- a/src/st/st-widget.h
+++ b/src/st/st-widget.h
@@ -78,7 +78,6 @@ struct _StWidgetClass
   ClutterActorClass parent_class;
 
   /* vfuncs */
-  void (* draw_background) (StWidget *self);
   void (* style_changed)   (StWidget *self);
 };
 
@@ -119,9 +118,6 @@ void st_widget_set_direction (StWidget *self, StTextDirection dir);
 void          st_widget_style_changed        (StWidget  *widget);
 StThemeNode  *st_widget_get_theme_node       (StWidget  *widget);
 
-ClutterActor *st_widget_get_background_image (StWidget  *actor);
-ClutterActor *st_widget_get_border_image     (StWidget  *actor);
-void          st_widget_draw_background      (StWidget  *widget);
 
 G_END_DECLS
 



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