[gnome-shell] Add a new property StWidget:label-actor



commit 90d061edafbb712bc55aa2d091ff849f5536574e
Author: Alejandro Piñeiro <apinheiro igalia com>
Date:   Tue Mar 8 19:33:41 2011 +0100

    Add a new property StWidget:label-actor
    
    This property represents that the widget is being labelled by an
    actor. The name is label-actor to avoid problems with the current
    StButton:label and StTooltip:label

 src/st/st-widget.c |   79 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 src/st/st-widget.h |    4 ++
 2 files changed, 82 insertions(+), 1 deletions(-)
---
diff --git a/src/st/st-widget.c b/src/st/st-widget.c
index f8e6074..d59bd59 100644
--- a/src/st/st-widget.c
+++ b/src/st/st-widget.c
@@ -75,6 +75,8 @@ struct _StWidgetPrivate
   StTextDirection   direction;
 
   AtkObject *accessible;
+
+  ClutterActor *label_actor;
 };
 
 /**
@@ -101,7 +103,8 @@ enum
   PROP_TOOLTIP_TEXT,
   PROP_TRACK_HOVER,
   PROP_HOVER,
-  PROP_CAN_FOCUS
+  PROP_CAN_FOCUS,
+  PROP_LABEL_ACTOR
 };
 
 enum
@@ -186,6 +189,10 @@ st_widget_set_property (GObject      *gobject,
       st_widget_set_can_focus (actor, g_value_get_boolean (value));
       break;
 
+    case PROP_LABEL_ACTOR:
+      st_widget_set_label_actor (actor, g_value_get_object (value));
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
       break;
@@ -243,6 +250,10 @@ st_widget_get_property (GObject    *gobject,
       g_value_set_boolean (value, priv->can_focus);
       break;
 
+    case PROP_LABEL_ACTOR:
+      g_value_set_object (value, priv->label_actor);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
       break;
@@ -300,6 +311,12 @@ st_widget_dispose (GObject *gobject)
   if (priv->accessible)
     priv->accessible = NULL;
 
+  if (priv->label_actor)
+    {
+      g_object_unref (priv->label_actor);
+      priv->label_actor = NULL;
+    }
+
   G_OBJECT_CLASS (st_widget_parent_class)->dispose (gobject);
 }
 
@@ -954,6 +971,19 @@ st_widget_class_init (StWidgetClass *klass)
                                    pspec);
 
   /**
+   * ClutterActor:label-actor:
+   *
+   * An actor that labels this widget.
+   */
+  g_object_class_install_property (gobject_class,
+                                   PROP_LABEL_ACTOR,
+                                   g_param_spec_object ("label-actor",
+                                                        "Label",
+                                                        "Label that identifies this widget",
+                                                        CLUTTER_TYPE_ACTOR,
+                                                        ST_PARAM_READWRITE));
+
+  /**
    * StWidget::style-changed:
    * @widget: the #StWidget
    *
@@ -2125,6 +2155,53 @@ st_get_slow_down_factor ()
   return st_slow_down_factor;
 }
 
+
+/**
+ * st_widget_get_label_actor:
+ * @widget: a #StWidget
+ *
+ * Gets the label that identifies @widget if it is defined
+ *
+ * Return value: (transfer none): the label that identifies the widget
+ */
+ClutterActor *
+st_widget_get_label_actor (StWidget *widget)
+{
+  g_return_val_if_fail (ST_IS_WIDGET (widget), NULL);
+
+  return widget->priv->label_actor;
+}
+
+/**
+ * st_widget_set_label_actor:
+ * @widget: a #StWidget
+ * @label: a #ClutterActor
+ *
+ * Sets @label as the #ClutterActor that identifies (labels)
+ * @widget. @label can be %NULL to indicate that @widget is not
+ * labelled any more
+ */
+
+void
+st_widget_set_label_actor (StWidget     *widget,
+                           ClutterActor *label)
+{
+  g_return_if_fail (ST_IS_WIDGET (widget));
+
+  if (widget->priv->label_actor != label)
+    {
+      if (widget->priv->label_actor)
+        g_object_unref (widget->priv->label_actor);
+
+      if (label != NULL)
+        widget->priv->label_actor = g_object_ref (label);
+      else
+        widget->priv->label_actor = NULL;
+
+      g_object_notify (G_OBJECT (widget), "label-actor");
+    }
+}
+
 /******************************************************************************/
 /*************************** ACCESSIBILITY SUPPORT ****************************/
 /******************************************************************************/
diff --git a/src/st/st-widget.h b/src/st/st-widget.h
index d38eb68..2ed46b3 100644
--- a/src/st/st-widget.h
+++ b/src/st/st-widget.h
@@ -152,6 +152,10 @@ gboolean              st_widget_navigate_focus            (StWidget        *widg
                                                            GtkDirectionType direction,
                                                            gboolean         wrap_around);
 
+ClutterActor *        st_widget_get_label_actor           (StWidget        *widget);
+void                  st_widget_set_label_actor           (StWidget        *widget,
+                                                           ClutterActor    *label);
+
 /* Only to be used by sub-classes of StWidget */
 void                  st_widget_style_changed             (StWidget        *widget);
 StThemeNode *         st_widget_get_theme_node            (StWidget        *widget);



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