[gnome-shell] st-widget: Add method to clear background-image
- From: Florian MÃllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] st-widget: Add method to clear background-image
- Date: Mon, 24 Sep 2012 20:05:36 +0000 (UTC)
commit cd024e21f0db76db95a6b61436d0819ccdf9112b
Author: Florian MÃllner <fmuellner gnome org>
Date: Fri Sep 21 16:21:40 2012 +0200
st-widget: Add method to clear background-image
For performance reasons, resources required to paint a widget are
aggressively cached; we know of at least one case where our caching
prevents updating the used background-image correctly, so add explicit
API to clear all associated cache data.
https://bugzilla.gnome.org/show_bug.cgi?id=679268
src/st/st-widget.c | 35 +++++++++++++++++++++++++++++++++++
src/st/st-widget.h | 2 ++
2 files changed, 37 insertions(+), 0 deletions(-)
---
diff --git a/src/st/st-widget.c b/src/st/st-widget.c
index c867f7d..27cc2fb 100644
--- a/src/st/st-widget.c
+++ b/src/st/st-widget.c
@@ -2760,3 +2760,38 @@ st_widget_get_focus_chain (StWidget *widget)
{
return ST_WIDGET_GET_CLASS (widget)->get_focus_chain (widget);
}
+
+/**
+ * st_widget_clear_background_image:
+ * @widget: An #StWidget
+ *
+ * Force a reload of the background-image property. Usually properties
+ * are cached heavily to avoid unnecessary work on paint, this method
+ * will force the cache to be recreated.
+ */
+void
+st_widget_clear_background_image (StWidget *actor)
+{
+ GFile *file;
+ const char *path;
+ char *uri;
+
+ if (actor->priv->theme_node == NULL)
+ return;
+
+ path = st_theme_node_get_background_image (actor->priv->theme_node);
+ if (path == NULL)
+ return;
+
+ file = g_file_new_for_path (path);
+ uri = g_file_get_uri (file);
+
+ st_texture_cache_clear_uri (st_texture_cache_get_default (), uri);
+ st_theme_node_invalidate_paint_state (actor->priv->theme_node);
+
+ if (CLUTTER_ACTOR_IS_MAPPED (CLUTTER_ACTOR (actor)))
+ clutter_actor_queue_redraw (CLUTTER_ACTOR (actor));
+
+ g_object_unref (file);
+ g_free (uri);
+}
diff --git a/src/st/st-widget.h b/src/st/st-widget.h
index eb9e4ce..b04defa 100644
--- a/src/st/st-widget.h
+++ b/src/st/st-widget.h
@@ -142,6 +142,8 @@ ClutterActor * st_widget_get_label_actor (StWidget *widg
void st_widget_set_label_actor (StWidget *widget,
ClutterActor *label);
+void st_widget_clear_background_image (StWidget *widget);
+
/* 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]