*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
#include <config.h>
#include <string.h>
+#include <math.h>
#include <gtk/gtk.h>
* 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;
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)
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,
GtkWidget *widget,
GdkRectangle *area,
GtkBorder *border,
- gboolean highlight)
+ gboolean highlight,
+ gboolean inverted_colors)
{
+ GtkStyle *style = gtk_widget_get_style (widget);
+ GtkStateType state = gtk_widget_get_state (widget);
+
gdk_draw_rectangle (drawable,
- highlight ?
- widget->style->text_gc[widget->state] : widget->style->dark_gc[widget->state],
+ highlight ? style->text_gc[state] : style->dark_gc[state],
TRUE,
area->x,
area->y,
area->width,
area->height);
gdk_draw_rectangle (drawable,
- widget->style->white_gc,
+ inverted_colors ? style->black_gc : style->white_gc,
TRUE,
area->x + border->left,
area->y + border->top,
area->width - (border->left + border->right),
area->height - (border->top + border->bottom));
gdk_draw_rectangle (drawable,
- widget->style->mid_gc[widget->state],
+ style->mid_gc[state],
TRUE,
area->x,
area->y + area->height - (border->bottom - border->top),
border->bottom - border->top,
border->bottom - border->top);
gdk_draw_rectangle (drawable,
- widget->style->mid_gc[widget->state],
+ style->mid_gc[state],
TRUE,
area->x + area->width - (border->right - border->left),
area->y,
}
}
}
+
+gdouble
+ev_document_misc_get_screen_dpi (GdkScreen *screen)
+{
+ gdouble dp, di;
+
+ /*diagonal in pixels*/
+ dp = hypot (gdk_screen_get_width (screen), gdk_screen_get_height (screen));
+
+ /*diagonal in inches*/
+ di = hypot (gdk_screen_get_width_mm(screen), gdk_screen_get_height_mm (screen)) / 25.4;
+
+ return (dp / di);
+}