[gnome-shell] Add st_widget_peek_theme_node()



commit 8d6ab6fe844fd57316a68a79a0862f1a7ead2cb6
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Tue Nov 2 16:09:49 2010 -0400

    Add st_widget_peek_theme_node()
    
    Sometimes it's useful to get the theme node if there is one and do
    nothing and wait for the ::style-changed signal if there is no theme
    node. Add st_widget_peek_theme_node() that just gets the current
    theme node if available. The caller must handle a %NULL return.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=633865

 src/st/st-widget.c |   26 ++++++++++++++++++++++++++
 src/st/st-widget.h |    1 +
 2 files changed, 27 insertions(+), 0 deletions(-)
---
diff --git a/src/st/st-widget.c b/src/st/st-widget.c
index a03af9a..312661d 100644
--- a/src/st/st-widget.c
+++ b/src/st/st-widget.c
@@ -522,6 +522,9 @@ get_root_theme_node (ClutterStage *stage)
  * The theme node is used to access standard and custom CSS
  * properties of the widget.
  *
+ * Note: it is a fatal error to call this on a widget that is
+ *  not been added to a stage.
+ *
  * Return value: (transfer none): the theme node for the widget.
  *   This is owned by the widget. When attributes of the widget
  *   or the environment that affect the styling change (for example
@@ -570,6 +573,29 @@ st_widget_get_theme_node (StWidget *widget)
   return priv->theme_node;
 }
 
+/**
+ * st_widget_peek_theme_node:
+ * @widget: a #StWidget
+ *
+ * Returns the theme node for the widget if it has already been
+ * computed, %NULL if the widget hasn't been added to a  stage or the theme
+ * node hasn't been computed. If %NULL is returned, then ::style-changed
+ * will be reliably emitted before the widget is allocated or painted.
+ *
+ * Return value: (transfer none): the theme node for the widget.
+ *   This is owned by the widget. When attributes of the widget
+ *   or the environment that affect the styling change (for example
+ *   the style_class property of the widget), it will be recreated,
+ *   and the ::style-changed signal will be emitted on the widget.
+ */
+StThemeNode *
+st_widget_peek_theme_node (StWidget *widget)
+{
+  StWidgetPrivate *priv = widget->priv;
+
+  return priv->theme_node;
+}
+
 static gboolean
 st_widget_enter (ClutterActor         *actor,
                  ClutterCrossingEvent *event)
diff --git a/src/st/st-widget.h b/src/st/st-widget.h
index ba47420..cc3b47c 100644
--- a/src/st/st-widget.h
+++ b/src/st/st-widget.h
@@ -151,6 +151,7 @@ gboolean              st_widget_navigate_focus            (StWidget        *widg
 /* Only to be used by sub-classes of StWidget */
 void                  st_widget_style_changed             (StWidget        *widget);
 StThemeNode *         st_widget_get_theme_node            (StWidget        *widget);
+StThemeNode *         st_widget_peek_theme_node           (StWidget        *widget);
 
 /* debug methods */
 char  *st_describe_actor       (ClutterActor *actor);



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