diff --git a/libbackground/ChangeLog b/libbackground/ChangeLog index c0fbe0a69..f3800cef4 100644 --- a/libbackground/ChangeLog +++ b/libbackground/ChangeLog @@ -1,3 +1,10 @@ +2002-02-07 Richard Hestilow + + * applier.c (BGApplierPrivate): Add "timeout" field. + (bg_apply_cleanup_cb): Added. + (bg_applier_apply_prefs): Add/reset timeout for cleanup function + if we load a pixbuf. + 2002-02-04 Lauris Kaplinski * preferences.c (read_wptype_from_string): Do not crash on NULL diff --git a/libbackground/applier.c b/libbackground/applier.c index e2bf03335..794d33bb3 100644 --- a/libbackground/applier.c +++ b/libbackground/applier.c @@ -107,6 +107,9 @@ struct _BGApplierPrivate gboolean pixmap_is_set; /* TRUE iff the pixmap above * has been set as the root * pixmap */ + guint timeout; /* "Cleanup" timeout handler; + * reset to 30 seconds every + * time apply is called. */ }; static GObjectClass *parent_class; @@ -177,6 +180,8 @@ static void set_root_pixmap (GdkPixmap *pixmap); static gboolean is_nautilus_running (void); +static gboolean cleanup_cb (BGApplier *bg_applier); + guint bg_applier_get_type (void) { @@ -213,6 +218,7 @@ bg_applier_init (BGApplier *bg_applier, BGApplierClass *class) bg_applier->p->pixbuf = NULL; bg_applier->p->wallpaper_pixbuf = NULL; bg_applier->p->nautilus_running = is_nautilus_running (); + bg_applier->p->timeout = 0; } static void @@ -396,6 +402,14 @@ bg_applier_apply_prefs (BGApplier *bg_applier, g_warning (_("Could not load pixbuf \"%s\"; disabling wallpaper."), new_prefs->wallpaper_filename); new_prefs->wallpaper_enabled = FALSE; + + } + else + { + if (bg_applier->p->timeout) + g_source_remove (bg_applier->p->timeout); + bg_applier->p->timeout = g_timeout_add (30000, (GSourceFunc) cleanup_cb, bg_applier); + } } } @@ -1394,3 +1408,16 @@ is_nautilus_running (void) return running; } + +static gboolean +cleanup_cb (BGApplier *bg_applier) +{ + if (bg_applier->p->wallpaper_pixbuf != NULL) + { + g_object_unref (G_OBJECT (bg_applier->p->wallpaper_pixbuf)); + bg_applier->p->wallpaper_pixbuf = NULL; + } + bg_applier->p->timeout = 0; + + return FALSE; +}