Skip to content

Commit 8f73a54

Browse files
committed
st-theme-context.c: Hook up texture cache's texture-file-changed
signal and invalidate any theme nodes using the passed file. If the underlying file contents changed, this forces a reload of the background/border image.
1 parent 0521520 commit 8f73a54

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed

src/st/st-theme-context.c

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@
2121

2222
#include <config.h>
2323

24+
#include "st-border-image.h"
2425
#include "st-settings.h"
2526
#include "st-texture-cache.h"
2627
#include "st-theme.h"
2728
#include "st-theme-context.h"
29+
#include "st-theme-node-private.h"
2830

2931
struct _StThemeContext {
3032
GObject parent;
@@ -68,6 +70,9 @@ static void on_font_name_changed (StSettings *settings,
6870
StThemeContext *context);
6971
static void on_icon_theme_changed (StTextureCache *cache,
7072
StThemeContext *context);
73+
static void on_texture_file_changed (StTextureCache *cache,
74+
GFile *file,
75+
StThemeContext *context);
7176

7277
static void st_theme_context_changed (StThemeContext *context);
7378

@@ -91,6 +96,9 @@ st_theme_context_finalize (GObject *object)
9196
g_signal_handlers_disconnect_by_func (st_texture_cache_get_default (),
9297
(gpointer) on_icon_theme_changed,
9398
context);
99+
g_signal_handlers_disconnect_by_func (st_texture_cache_get_default (),
100+
(gpointer) on_texture_file_changed,
101+
context);
94102

95103
g_signal_handlers_disconnect_by_func (clutter_get_default_backend (),
96104
(gpointer) st_theme_context_changed,
@@ -152,6 +160,10 @@ st_theme_context_init (StThemeContext *context)
152160
"icon-theme-changed",
153161
G_CALLBACK (on_icon_theme_changed),
154162
context);
163+
g_signal_connect (st_texture_cache_get_default (),
164+
"texture-file-changed",
165+
G_CALLBACK (on_texture_file_changed),
166+
context);
155167

156168
g_signal_connect_swapped (clutter_get_default_backend (),
157169
"resolution-changed",
@@ -292,6 +304,50 @@ on_icon_theme_changed (StTextureCache *cache,
292304
g_idle_add ((GSourceFunc) changed_idle, context);
293305
}
294306

307+
static void
308+
on_texture_file_changed (StTextureCache *cache,
309+
GFile *file,
310+
StThemeContext *context)
311+
{
312+
GHashTableIter iter;
313+
StThemeNode *node;
314+
char *changed_path;
315+
316+
changed_path = g_file_get_path (file);
317+
if (changed_path == NULL)
318+
return;
319+
320+
g_hash_table_iter_init (&iter, context->nodes);
321+
while (g_hash_table_iter_next (&iter, (gpointer *) &node, NULL))
322+
{
323+
const char *node_file;
324+
StBorderImage *border_image;
325+
326+
node_file = st_theme_node_get_background_image (node);
327+
if (node_file != NULL && strcmp (node_file, changed_path) == 0)
328+
{
329+
_st_theme_node_free_drawing_state (node);
330+
node->alloc_width = 0;
331+
node->alloc_height = 0;
332+
continue;
333+
}
334+
335+
border_image = st_theme_node_get_border_image (node);
336+
if (border_image != NULL)
337+
{
338+
node_file = st_border_image_get_filename (border_image);
339+
if (node_file != NULL && strcmp (node_file, changed_path) == 0)
340+
{
341+
_st_theme_node_free_drawing_state (node);
342+
node->alloc_width = 0;
343+
node->alloc_height = 0;
344+
}
345+
}
346+
}
347+
348+
g_free (changed_path);
349+
}
350+
295351
/**
296352
* st_theme_context_get_for_stage:
297353
* @stage: a #ClutterStage

0 commit comments

Comments
 (0)