*/
#include <gtk/gtk.h>
+#include <glib/gi18n.h>
#include <string.h>
+
#include "imposter.h"
#include "impress-document.h"
#include "ev-document-thumbnails.h"
filename = g_filename_from_uri (uri, NULL, error);
if (!filename)
{
- //FIXME
- //g_error_set ();
+ g_set_error (error,
+ EV_DOCUMENT_ERROR,
+ EV_DOCUMENT_ERROR_INVALID,
+ _("Remote files aren't supported"));
return FALSE;
}
if (!imp)
{
- //FIXME translate the err, set error
+ g_set_error (error,
+ EV_DOCUMENT_ERROR,
+ EV_DOCUMENT_ERROR_INVALID,
+ _("Invalid document"));
g_free (filename);
return FALSE;
}
{
ImpressDocument *impress_document = IMPRESS_DOCUMENT (object);
- g_mutex_free (impress_document->mutex);
+ if (impress_document->mutex)
+ g_mutex_free (impress_document->mutex);
+
+ if (impress_document->imp)
+ imp_close (impress_document->imp);
+
+ if (impress_document->ctx)
+ imp_delete_context (impress_document->ctx);
- imp_close (impress_document->imp);
- imp_delete_context (impress_document->ctx);
- g_free (impress_document->pango_ctx);
- g_object_unref (G_OBJECT (impress_document->pixmap));
- g_object_unref (impress_document->gc);
+ if (impress_document->pango_ctx)
+ g_object_unref (impress_document->pango_ctx);
+
+ if (impress_document->pixmap)
+ g_object_unref (G_OBJECT (impress_document->pixmap));
+
+ if (impress_document->gc)
+ g_object_unref (impress_document->gc);
G_OBJECT_CLASS (impress_document_parent_class)->finalize (object);
}
static GdkPixbuf *
impress_document_thumbnails_get_thumbnail (EvDocumentThumbnails *document,
- gint page,
- gint rotation,
- gint size,
- gboolean border)
+ EvRenderContext *rc,
+ gboolean border)
{
GdkPixbuf *pixbuf = NULL;
gdouble w, h;
- EvRenderContext *rc;
-
- impress_document_get_page_size (EV_DOCUMENT (document),
- page,
- &w, &h);
- rc = ev_render_context_new (rotation, page, size/w);
pixbuf = impress_document_render_pixbuf (EV_DOCUMENT (document), rc);
- g_object_unref (G_OBJECT (rc));
if (border)
{
GdkPixbuf *tmp_pixbuf = pixbuf;
- pixbuf = ev_document_misc_get_thumbnail_frame (-1, -1, 0, tmp_pixbuf);
+
+ pixbuf = ev_document_misc_get_thumbnail_frame (-1, -1, tmp_pixbuf);
g_object_unref (tmp_pixbuf);
}
static void
impress_document_thumbnails_get_dimensions (EvDocumentThumbnails *document,
- gint page,
- gint suggested_width,
- gint *width,
- gint *height)
+ EvRenderContext *rc,
+ gint *width,
+ gint *height)
{
- gdouble page_ratio;
- gdouble w, h;
+ gdouble page_width, page_height;
impress_document_get_page_size (EV_DOCUMENT (document),
- page,
- &w, &h);
- g_return_if_fail (w > 0);
- page_ratio = h/w;
- *width = suggested_width;
- *height = (gint) (suggested_width * page_ratio);
+ rc->page,
+ &page_width, &page_height);
+
+ if (rc->rotation == 90 || rc->rotation == 270)
+ {
+ *width = (gint) (page_height * rc->scale);
+ *height = (gint) (page_width * rc->scale);
+ }
+ else
+ {
+ *width = (gint) (page_width * rc->scale);
+ *height = (gint) (page_height * rc->scale);
+ }
}
static void
impress_document->pixmap = gdk_pixmap_new (window,
PAGE_WIDTH, PAGE_HEIGHT, -1);
impress_document->gc = gdk_gc_new (impress_document->pixmap);
- impress_document->pango_ctx = gdk_pango_context_get ();
+ impress_document->pango_ctx = gdk_pango_context_get_for_screen (gdk_screen_get_default ());
}
/*