--- gnome-bg.c.old 2008-10-26 22:28:55.000000000 +0000 +++ gnome-bg.c 2008-10-26 22:40:40.000000000 +0000 @@ -72,6 +72,8 @@ { gint width; gint height; + gint offset_x; + gint offset_y; char *file; }; @@ -1747,16 +1749,15 @@ static GdkPixbuf * get_pixbuf (GnomeBG *bg) { - /* FIXME: this ref=TRUE/FALSE stuff is crazy */ - - gboolean ref = FALSE; if (!bg->pixbuf_cache && bg->filename) { - ref = TRUE; bg->file_mtime = get_mtime (bg->filename); bg->pixbuf_cache = get_as_pixbuf (bg, bg->filename); - if (!bg->pixbuf_cache) { + if (bg->pixbuf_cache) { + g_object_ref (bg->pixbuf_cache); + } + else { SlideShow *show = get_as_slideshow (bg, bg->filename); if (show) { @@ -1769,21 +1770,32 @@ if (slide->fixed) { FileSize *size; + GdkPixbuf *pixbuf; size = find_best_size (slide->file1, bg->last_pixmap_width, bg->last_pixmap_height); - bg->pixbuf_cache = get_as_pixbuf (bg, size->file); + pixbuf = get_as_pixbuf (bg, size->file); + if (pixbuf){ + bg->pixbuf_cache = gdk_pixbuf_new_subpixbuf(pixbuf, size->offset_x , size->offset_y, size->width, size->height); + } + + } else { - FileSize *size; + FileSize *size1, *size2; GdkPixbuf *p1, *p2; - size = find_best_size (slide->file1, bg->last_pixmap_width, bg->last_pixmap_height); - p1 = get_as_pixbuf (bg, size->file); - size = find_best_size (slide->file2, bg->last_pixmap_width, bg->last_pixmap_height); - p2 = get_as_pixbuf (bg, size->file); + size1 = find_best_size (slide->file1, bg->last_pixmap_width, bg->last_pixmap_height); + p1 = get_as_pixbuf (bg, size1->file); + size2 = find_best_size (slide->file2, bg->last_pixmap_width, bg->last_pixmap_height); + p2 = get_as_pixbuf (bg, size2->file); if (p1 && p2) { - bg->pixbuf_cache = blend (p1, p2, alpha); - ref = FALSE; + p1 = gdk_pixbuf_new_subpixbuf(p1, size1->offset_x , size1->offset_y, size1->width, size1->height); + p2 = gdk_pixbuf_new_subpixbuf(p2, size2->offset_x , size2->offset_y, size2->width, size2->height); + if (p1 && p2) { + bg->pixbuf_cache = blend (p1, p2, alpha); + } + if (p1) g_object_unref (p1); + if (p2) g_object_unref (p2); } } @@ -1794,9 +1806,6 @@ } } - if (bg->pixbuf_cache && ref) - g_object_ref (bg->pixbuf_cache); - return bg->pixbuf_cache; } @@ -2107,6 +2116,10 @@ size->width = atoi (attr_values[i]); else if (strcmp (attr_names[i], "height") == 0) size->height = atoi (attr_values[i]); + else if (strcmp (attr_names[i], "x") == 0) + size->offset_x = atoi (attr_values[i]); + else if (strcmp (attr_names[i], "y") == 0) + size->offset_y = atoi (attr_values[i]); } if (parser->stack->tail && (strcmp (parser->stack->tail->data, "file") == 0 || @@ -2222,6 +2235,8 @@ fs = g_new (FileSize, 1); fs->width = -1; fs->height = -1; + fs->offset_x = 0; + fs->offset_y = 0; fs->file = g_strdup (text); slide->file1 = g_slist_prepend (slide->file1, fs); if (slide->file1->next != NULL) @@ -2244,6 +2259,8 @@ fs = g_new (FileSize, 1); fs->width = -1; fs->height = -1; + fs->offset_x = 0; + fs->offset_y = 0; fs->file = g_strdup (text); slide->file2 = g_slist_prepend (slide->file2, fs); if (slide->file2->next != NULL) @@ -2318,14 +2335,14 @@ g_print ("File1:\n"); for (slist = slide->file1; slist != NULL; slist = slist->next) { FileSize *size = slist->data; - g_print ("\t%s (%dx%d)\n", - size->file, size->width, size->height); + g_print ("\t%s (%dx%d+%d+%d)\n", + size->file, size->width, size->height, size->offset_x, size->offset_y); } g_print ("File2:\n"); for (slist = slide->file2; slist != NULL; slist = slist->next) { FileSize *size = slist->data; - g_print ("\t%s (%dx%d)\n", - size->file, size->width, size->height); + g_print ("\t%s (%dx%d+%d+%d)\n", + size->file, size->width, size->height, size->offset_x, size->offset_y); } } #endif