From a356cfda9e09c5f6677d4bc8039fc1b29240363d Mon Sep 17 00:00:00 2001 From: sandmann Date: Mar 23 2007 21:56:44 +0000 Subject: Various gnome-bg fixes --- diff --git a/gnome-desktop-2.18.0-gnome-bg.patch b/gnome-desktop-2.18.0-gnome-bg.patch index 99a1f7d..a631b76 100644 --- a/gnome-desktop-2.18.0-gnome-bg.patch +++ b/gnome-desktop-2.18.0-gnome-bg.patch @@ -1,5 +1,5 @@ ---- gnome-desktop-2.18.0/configure.in.gnome-bg 2007-03-19 19:43:15.000000000 -0400 -+++ gnome-desktop-2.18.0/configure.in 2007-03-19 19:43:24.000000000 -0400 +--- gnome-desktop-2.18.0/configure.in.gnome-bg 2007-03-12 18:38:32.000000000 -0400 ++++ gnome-desktop-2.18.0/configure.in 2007-03-23 16:58:40.000000000 -0400 @@ -51,10 +51,10 @@ AC_SUBST(GNOME_DISTRIBUTOR) AC_SUBST(GNOME_DATE) @@ -16,8 +16,8 @@ # As a special favour for vuntz, support --disable-deprecations --- /dev/null 2007-03-05 16:01:59.843465905 -0500 -+++ gnome-desktop-2.18.0/libgnome-desktop/gnome-bg.c 2007-03-19 18:46:22.000000000 -0400 -@@ -0,0 +1,1679 @@ ++++ gnome-desktop-2.18.0/libgnome-desktop/gnome-bg.c 2007-03-23 17:46:47.000000000 -0400 +@@ -0,0 +1,1704 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- + +gnomebg.c: Object for the desktop background. @@ -85,6 +85,7 @@ + time_t uri_mtime; + GdkPixbuf * pixbuf_cache; + int timeout_id; ++ GList * file_cache; +}; + +struct _GnomeBGClass @@ -199,21 +200,6 @@ + c1->blue == c2->blue; +} + -+static gboolean -+image_totally_obscures (GnomeBG *bg) -+{ -+ if (!get_pixbuf (bg) || gdk_pixbuf_get_has_alpha (get_pixbuf (bg))) -+ return FALSE; -+ -+ if (bg->placement == GNOME_BG_PLACEMENT_TILED || -+ bg->placement == GNOME_BG_PLACEMENT_FILL_SCREEN || -+ bg->placement == GNOME_BG_PLACEMENT_ZOOMED) { -+ return TRUE; -+ } -+ -+ return FALSE; -+} -+ +void +gnome_bg_set_color (GnomeBG *bg, + GnomeBGColorType type, @@ -232,9 +218,7 @@ + bg->c2 = *c2; + } + -+ if (!image_totally_obscures (bg)) { -+ emit_changed (bg); -+ } ++ emit_changed (bg); + } +} + @@ -344,8 +328,6 @@ + *x = (width - *w) / 2; + *y = (height - *h) / 2; + -+ g_print ("position: %d %d %d %d\n", *x, *y, *w, *h); -+ + return new; +} + @@ -389,9 +371,7 @@ + if (!bg) + return; + -+ if (!image_totally_obscures (bg)) { -+ draw_color (bg, dest); -+ } ++ draw_color (bg, dest); + + draw_image (bg->placement, get_pixbuf (bg), dest); +} @@ -842,10 +822,7 @@ + Slide *slide = list->data; + + if (elapsed + slide->duration > delta) { -+ g_print ("delta: %f\n", delta); + *alpha = (delta - elapsed) / (double)slide->duration; -+ g_print ("alpha: %f\n", *alpha); -+ g_print ("slide %d\n", i); + return slide; + } + @@ -868,62 +845,136 @@ + return result; +} + -+/* FIXME: we should have caching for these operations */ -+/* FIXME: make sure memory management is understood */ ++typedef enum { ++ PIXBUF, ++ SLIDESHOW, ++ THUMBNAIL ++} FileType; + -+static gboolean -+do_unref (gpointer p) ++typedef struct FileCacheEntry FileCacheEntry; ++struct FileCacheEntry +{ -+ g_print ("free\n"); -+ -+ if (p) -+ g_object_unref (p); ++ FileType type; ++ char *uri; ++ union { ++ GdkPixbuf *pixbuf; ++ SlideShow *slideshow; ++ GdkPixbuf *thumbnail; ++ } u; ++}; + -+ return FALSE; ++static const FileCacheEntry * ++file_cache_lookup (GnomeBG *bg, FileType type, const char *uri) ++{ ++ GList *list; ++ ++ for (list = bg->file_cache; list != NULL; list = list->next) { ++ FileCacheEntry *ent = list->data; ++ ++ if (ent->type == type && strcmp (ent->uri, uri) == 0) ++ return ent; ++ } ++ ++ return NULL; +} + -+static gpointer -+idle_unref (gpointer p) ++static void ++file_cache_add_pixbuf (GnomeBG *bg, ++ const char *uri, ++ GdkPixbuf *pixbuf) +{ -+ g_idle_add (do_unref, p); -+ return p; ++ FileCacheEntry *ent = g_new0 (FileCacheEntry, 1); ++ ++ g_assert (!file_cache_lookup (bg, PIXBUF, uri)); ++ ++ ent->type = PIXBUF; ++ ent->uri = g_strdup (uri); ++ ent->u.pixbuf = pixbuf; ++ ++ bg->file_cache = g_list_prepend (bg->file_cache, ent); +} + -+static gboolean -+do_slideshow_free (gpointer s) ++static void ++file_cache_add_thumbnail (GnomeBG *bg, ++ const char *uri, ++ GdkPixbuf *pixbuf) +{ -+ SlideShow *show = s; ++ FileCacheEntry *ent = g_new0 (FileCacheEntry, 1); ++ ++ g_assert (!file_cache_lookup (bg, THUMBNAIL, uri)); + -+ if (show) -+ slideshow_free (show); ++ ent->type = THUMBNAIL; ++ ent->uri = g_strdup (uri); ++ ent->u.thumbnail = pixbuf; + -+ return FALSE; ++ bg->file_cache = g_list_prepend (bg->file_cache, ent); +} + -+static gpointer -+idle_delete (gpointer p) ++static void ++file_cache_add_slide_show (GnomeBG *bg, ++ const char *uri, ++ SlideShow *show) +{ -+ g_idle_add (do_slideshow_free, p); ++ FileCacheEntry *ent = g_new0 (FileCacheEntry, 1); ++ ++ g_assert (!file_cache_lookup (bg, SLIDESHOW, uri)); + -+ return p; ++ ent->type = SLIDESHOW; ++ ent->uri = g_strdup (uri); ++ ent->u.slideshow = show; ++ ++ bg->file_cache = g_list_prepend (bg->file_cache, ent); +} + +static GdkPixbuf * +get_as_pixbuf (GnomeBG *bg, const char *uri) +{ -+ return idle_unref (gnome_gdk_pixbuf_new_from_uri (uri)); ++ const FileCacheEntry *ent; ++ if ((ent = file_cache_lookup (bg, PIXBUF, uri))) { ++ return ent->u.pixbuf; ++ } ++ else { ++ GdkPixbuf *pixbuf = gnome_gdk_pixbuf_new_from_uri (uri); ++ ++ if (pixbuf) ++ file_cache_add_pixbuf (bg, uri, pixbuf); ++ ++ return pixbuf; ++ } +} + +static SlideShow * +get_as_slideshow (GnomeBG *bg, const char *uri) +{ -+ return idle_delete (read_slideshow_file (uri, NULL)); ++ const FileCacheEntry *ent; ++ if ((ent = file_cache_lookup (bg, SLIDESHOW, uri))) { ++ return ent->u.slideshow; ++ } ++ else { ++ SlideShow *show = read_slideshow_file (uri, NULL); ++ ++ if (show) ++ file_cache_add_slide_show (bg, uri, show); ++ ++ return show; ++ } +} + +static GdkPixbuf * +get_as_thumbnail (GnomeBG *bg, GnomeThumbnailFactory *factory, const char *uri) +{ -+ return idle_unref (get_thumbnail_for_uri (factory, uri)); ++ const FileCacheEntry *ent; ++ if ((ent = file_cache_lookup (bg, THUMBNAIL, uri))) { ++ return ent->u.thumbnail; ++ } ++ else { ++ GdkPixbuf *thumb = get_thumbnail_for_uri (factory, uri); ++ ++ if (thumb) ++ file_cache_add_thumbnail (bg, uri, thumb); ++ ++ return thumb; ++ } +} + +static gboolean @@ -931,8 +982,6 @@ +{ + GnomeBG *bg = data; + -+ g_print ("timeout fired\n"); -+ + if (bg->pixbuf_cache) { + g_object_unref (bg->pixbuf_cache); + bg->pixbuf_cache = NULL; @@ -955,15 +1004,11 @@ + if (slide->fixed) { + timeout = slide->duration; + } -+ else { -+ /* FIXME: maybe 60000 should be configurable? -+ */ -+ g_print ("not fixed\n"); -+ timeout = slide->duration / 255; ++ else { ++ /* Maybe the number of steps should be configurable? */ ++ timeout = slide->duration / 255.0; + } + -+ g_print ("installing timeout of %f ms\n", timeout * 1000); -+ + bg->timeout_id = g_timeout_add_full ( + G_PRIORITY_LOW, + timeout * 1000, on_timeout, bg, NULL); @@ -1393,8 +1438,6 @@ + height = dest_height - dest_y; + } + -+ g_print ("effective alpha: %d\n", (int)(alpha * 0xFF + 0.5)); -+ + gdk_pixbuf_composite (src, dest, + dest_x, dest_y, + width, height, @@ -1466,7 +1509,6 @@ + const char *s; + GList *l1, *l2; + va_list args; -+ gboolean result; + + stack = g_list_prepend (stack, (gpointer)s1); + @@ -1490,24 +1532,8 @@ + } + + g_list_free (stack); -+ -+ if (l1 || l2) -+ return FALSE; -+ else -+ return TRUE; -+} + -+static void -+print_stack (SlideShow *parser) -+{ -+ GList *l; -+ -+ g_print ("stack is: "); -+ -+ for (l = parser->stack->head; l != NULL; l = l->next) -+ g_print ("%s ", (char *)l->data); -+ -+ g_print ("\n"); ++ return (!l1 && !l2); +} + +static void @@ -1566,7 +1592,6 @@ +static void +dump_bg (SlideShow *show) +{ -+ g_print ("read a background\n"); +#if 0 + GList *list; + @@ -1698,7 +1723,7 @@ + return FALSE; +} --- gnome-desktop-2.18.0/libgnome-desktop/Makefile.am.gnome-bg 2007-03-12 18:18:57.000000000 -0400 -+++ gnome-desktop-2.18.0/libgnome-desktop/Makefile.am 2007-03-19 18:46:22.000000000 -0400 ++++ gnome-desktop-2.18.0/libgnome-desktop/Makefile.am 2007-03-23 16:58:40.000000000 -0400 @@ -18,7 +18,8 @@ libgnome_desktop_2_la_SOURCES = \ gnome-desktop-item.c \ @@ -1710,7 +1735,7 @@ libgnome_desktop_2_la_LIBADD = \ $(GNOME_DESKTOP_LIBS) --- gnome-desktop-2.18.0/libgnome-desktop/libgnomeui/Makefile.am.gnome-bg 2007-03-12 18:18:57.000000000 -0400 -+++ gnome-desktop-2.18.0/libgnome-desktop/libgnomeui/Makefile.am 2007-03-19 18:46:22.000000000 -0400 ++++ gnome-desktop-2.18.0/libgnome-desktop/libgnomeui/Makefile.am 2007-03-23 16:58:40.000000000 -0400 @@ -1,4 +1,5 @@ libgnomeui_desktopdir = $(includedir)/gnome-desktop-2.0/libgnomeui libgnomeui_desktop_HEADERS = \ @@ -1719,7 +1744,7 @@ + gnome-hint.h \ + gnome-bg.h --- /dev/null 2007-03-05 16:01:59.843465905 -0500 -+++ gnome-desktop-2.18.0/libgnome-desktop/libgnomeui/gnome-bg.h 2007-03-19 18:46:22.000000000 -0400 ++++ gnome-desktop-2.18.0/libgnome-desktop/libgnomeui/gnome-bg.h 2007-03-23 16:58:40.000000000 -0400 @@ -0,0 +1,99 @@ +/* gnome-bg.h - + diff --git a/gnome-desktop.spec b/gnome-desktop.spec index 0a0b15b..5519259 100644 --- a/gnome-desktop.spec +++ b/gnome-desktop.spec @@ -12,7 +12,7 @@ Summary: Package containing code shared among gnome-panel, gnome-session, nautilus, etc Name: gnome-desktop Version: 2.18.0 -Release: 3%{?dist} +Release: 4%{?dist} URL: http://www.gnome.org Source0: ftp://ftp.gnome.org/pub/GNOME/sources/gnome-desktop/2.18/%{name}-%{version}.tar.bz2 @@ -129,6 +129,9 @@ rm -rf $RPM_BUILD_ROOT %{_datadir}/gtk-doc/html/gnome-desktop/ %changelog +* Fri Mar 23 2007 Soren Sandmann - 2.18.0-4 +- Remove debug spew - add file caching - delete totally_obscures function. + * Tue Mar 20 2007 Soren Sandmann - 2.18.0-3 - Fix a bug where only parts of the background pixmap would be drawn.