]> www.fi.muni.cz Git - evince.git/commitdiff
[libdocument] Add specific method to get a loading thumbnail
authorCarlos Garcia Campos <carlosgc@gnome.org>
Tue, 4 May 2010 09:29:47 +0000 (11:29 +0200)
committerCarlos Garcia Campos <carlosgc@gnome.org>
Tue, 4 May 2010 09:29:47 +0000 (11:29 +0200)
It allows getting a loading thumbnail with inverted colors. See
bug #616111.

libdocument/ev-document-misc.c
libdocument/ev-document-misc.h

index 4d8bc28153fa36085a5dd2ca97b9e12883861034..605cbb0a87c0074a67a7c03762db37af0ddd0e41 100644 (file)
  * NULL, then it will fill the return pixbuf with the contents of
  * source_pixbuf.
  */
-GdkPixbuf *
-ev_document_misc_get_thumbnail_frame (int        width,
-                                     int        height,
-                                     GdkPixbuf *source_pixbuf)
+static GdkPixbuf *
+create_thumbnail_frame (int        width,
+                       int        height,
+                       GdkPixbuf *source_pixbuf,
+                       gboolean   fill_bg)
 {
        GdkPixbuf *retval;
        guchar *data;
@@ -67,8 +68,10 @@ ev_document_misc_get_thumbnail_frame (int        width,
        rowstride = gdk_pixbuf_get_rowstride (retval);
 
        gdk_pixbuf_fill (retval, 0x000000ff);
-       for (i = 1; i < height_r + 1; i++)
-               memset (data + (rowstride * i) + 4, 0xffffffff, width_r * 4);
+       if (fill_bg) {
+               for (i = 1; i < height_r + 1; i++)
+                       memset (data + (rowstride * i) + 4, 0xffffffff, width_r * 4);
+       }
 
        /* copy the source pixbuf */
        if (source_pixbuf)
@@ -91,6 +94,22 @@ ev_document_misc_get_thumbnail_frame (int        width,
        return retval;
 }
 
+GdkPixbuf *
+ev_document_misc_get_thumbnail_frame (int        width,
+                                     int        height,
+                                     GdkPixbuf *source_pixbuf)
+{
+       return create_thumbnail_frame (width, height, source_pixbuf, TRUE);
+}
+
+GdkPixbuf *
+ev_document_misc_get_loading_thumbnail (int      width,
+                                       int      height,
+                                       gboolean inverted_colors)
+{
+       return create_thumbnail_frame (width, height, NULL, !inverted_colors);
+}
+
 void
 ev_document_misc_get_page_border_size (gint       page_width,
                                       gint       page_height,
index 2503aa78821c84686b348c2db429935d54d4b685..b09c19421ba841a73f84a37cc10c608b68be6c4d 100644 (file)
@@ -36,6 +36,9 @@ G_BEGIN_DECLS
 GdkPixbuf *ev_document_misc_get_thumbnail_frame  (int           width,
                                                  int           height,
                                                  GdkPixbuf    *source_pixbuf);
+GdkPixbuf *ev_document_misc_get_loading_thumbnail (int      width,
+                                                  int      height,
+                                                  gboolean inverted_colors);
 void       ev_document_misc_get_page_border_size (gint          page_width,
                                                  gint          page_height,
                                                  GtkBorder    *border);