+Sat May 28 07:38:03 2005 Jonathan Blandford <jrb@redhat.com>
+
+ * shell/ev-view.c (draw_one_page): modify the expose handling to
+ get the shadows.
+
+ * shell/ev-window.c (update_action_sensitivity): Respect
+ permissions field. Kowtow to the man.
+
+ * pdf/ev-poppler.cc: Get the permissions field.
+
+ * tiff/*c: Make a tiny bit more robust.
+
2005-05-26 Nickolay V. Shmyrev <nshmyrev@yandex.ru>
* djvu/djvu-document.c:
Display location of results in thumbnails?
Only display thumbnails of pages found?
-
Sidebar improvements for ps/pixbuf, or PDF files without a TOC. bug 164811
Improve Printing Support: (libgnomeprintui?)
Document Properties Dialog for document meta-data bug 164843
-Make an object that handles the page count.
-
-Move to having three sizing types:
-
- * Free zooming
- * constrain to width
- * constrain to height
- * also, maybe add a 1-1 button. Possibly dubious, though.
-
-
Add some code to sanity check documents, including:
* n_pages > 0
* Single page (prolly default for some backends)
* Continuous scrolling bug 164597
* Side-by-side continuous scrolling
+Make an object that handles the page count.
+Move to having three sizing types:
+ * Free zooming
+ * constrain to width
+ * constrain to height
EV_DOCUMENT_UI_HINT_DIRECTION_RTL = 1 << 6,
} EvDocumentUIHints;
+
+typedef enum
+{
+ EV_DOCUMENT_PERMISSIONS_OK_TO_PRINT = 1 << 0,
+ EV_DOCUMENT_PERMISSIONS_OK_TO_MODIFY = 1 << 1,
+ EV_DOCUMENT_PERMISSIONS_OK_TO_COPY = 1 << 2,
+ EV_DOCUMENT_PERMISSIONS_OK_TO_ADD_NOTES = 1 << 3,
+ EV_DOCUMENT_PERMISSIONS_FULL = (EV_DOCUMENT_PERMISSIONS_OK_TO_PRINT
+ | EV_DOCUMENT_PERMISSIONS_OK_TO_MODIFY
+ | EV_DOCUMENT_PERMISSIONS_OK_TO_COPY
+ | EV_DOCUMENT_PERMISSIONS_OK_TO_ADD_NOTES),
+} EvDocumentPermissions;
+
typedef enum
{
EV_DOCUMENT_INFO_TITLE = 1 << 0,
EV_DOCUMENT_INFO_START_MODE = 1 << 6,
EV_DOCUMENT_INFO_CREATION_DATE = 1 << 7,
EV_DOCUMENT_INFO_UI_HINTS = 1 << 8,
+ EV_DOCUMENT_INFO_PERMISSIONS = 1 << 9,
} EvDocumentInfoFields;
struct _EvDocumentInfo
EvDocumentMode mode;
GDate creation_date;
guint ui_hints;
+ guint permissions;
/* Mask of all the valid fields */
guint fields_mask;
GMutex *ev_document_get_doc_mutex (void);
void ev_document_doc_mutex_lock (void);
void ev_document_doc_mutex_unlock (void);
+
EvDocumentInfo *ev_document_get_info (EvDocument *document);
gboolean ev_document_load (EvDocument *document,
const char *uri,
double max_height_page_height;
EvPageCacheInfo *size_cache;
+ EvDocumentInfo *page_info;
};
struct _EvPageCacheClass
g_free (page_cache->title);
g_free (page_cache->size_cache);
+ ev_document_info_free (page_cache->page_info);
}
EvPageCache *
}
}
+ page_cache->page_info = ev_document_get_info (document);
+
/* make some sanity check assertions */
if (! page_cache->uniform)
g_assert (page_cache->size_cache != NULL);
return page_cache->has_labels;
}
+const EvDocumentInfo *
+ev_page_cache_get_info (EvPageCache *page_cache)
+{
+ g_return_val_if_fail (EV_IS_PAGE_CACHE (page_cache), NULL);
+
+ return page_cache->page_info;
+}
+
+
gboolean
ev_page_cache_next_page (EvPageCache *page_cache)
{
char *ev_page_cache_get_page_label (EvPageCache *page_cache,
gint page);
gboolean ev_page_cache_has_nonnumeric_page_labels (EvPageCache *page_cache);
+const EvDocumentInfo *ev_page_cache_get_info (EvPageCache *page_cache);
/* Navigation */
gint ev_page_cache_get_current_page (EvPageCache *page_cache);
PopplerPageLayout layout;
PopplerPageMode mode;
PopplerViewerPreferences view_prefs;
+ PopplerPermissions permissions;
info = g_new0 (EvDocumentInfo, 1);
EV_DOCUMENT_INFO_LAYOUT |
EV_DOCUMENT_INFO_START_MODE |
/* Missing EV_DOCUMENT_INFO_CREATION_DATE | */
+ EV_DOCUMENT_INFO_PERMISSIONS |
EV_DOCUMENT_INFO_UI_HINTS;
"page-mode", &mode,
"page-layout", &layout,
"viewer-preferences", &view_prefs,
+ "permissions", &permissions,
NULL);
switch (layout) {
info->ui_hints |= EV_DOCUMENT_UI_HINT_DIRECTION_RTL;
}
+ info->permissions = 0;
+ if (permissions & POPPLER_PERMISSIONS_OK_TO_PRINT) {
+ info->permissions |= EV_DOCUMENT_PERMISSIONS_OK_TO_PRINT;
+ }
+ if (permissions & POPPLER_PERMISSIONS_OK_TO_MODIFY) {
+ info->permissions |= EV_DOCUMENT_PERMISSIONS_OK_TO_MODIFY;
+ }
+ if (permissions & POPPLER_PERMISSIONS_OK_TO_COPY) {
+ info->permissions |= EV_DOCUMENT_PERMISSIONS_OK_TO_COPY;
+ }
+ if (permissions & POPPLER_PERMISSIONS_OK_TO_ADD_NOTES) {
+ info->permissions |= EV_DOCUMENT_PERMISSIONS_OK_TO_ADD_NOTES;
+ }
return info;
}
$(top_builddir)/cut-n-paste/zoom-control/libephywidgets.la \
$(top_builddir)/cut-n-paste/toolbar-editor/libtoolbareditor.la \
$(top_builddir)/lib/libev.la \
+ -ltiff -lz \
libevbackendfactory.la \
$(NULL)
pixbuf_cache->end_page = 0;
pixbuf_cache->job_list = g_new0 (CacheJobInfo, PAGE_CACHE_LEN (pixbuf_cache));
- pixbuf_cache->preload_cache_size = 1;
+ pixbuf_cache->preload_cache_size = 2;
pixbuf_cache->prev_job = g_new0 (CacheJobInfo, pixbuf_cache->preload_cache_size);
pixbuf_cache->next_job = g_new0 (CacheJobInfo, pixbuf_cache->preload_cache_size);
}
y = view->spacing;
/* Adjust for extra allocation */
- x = x + MAX (0, widget->allocation.width - (width + view->spacing * 2))/2;
- y = y + MAX (0, widget->allocation.height - (height + view->spacing * 2))/2;
+ x = x + MAX (0, widget->allocation.width - (width + border->left + border->right + view->spacing * 2))/2;
+ y = y + MAX (0, widget->allocation.height - (height + border->top + border->bottom + view->spacing * 2))/2;
}
page_area->x = x;
GdkRectangle real_page_area;
g_assert (view->document);
+ if (! gdk_rectangle_intersect (page_area, expose_area, &overlap))
+ return;
ev_page_cache_get_size (view->page_cache,
page, view->scale,
&width, &height);
-
/* Render the document itself */
real_page_area = *page_area;
real_page_area.width -= (border->left + border->right);
real_page_area.height -= (border->top + border->bottom);
- if (! gdk_rectangle_intersect (&real_page_area, expose_area, &overlap))
- return;
-
ev_document_misc_paint_one_page (GTK_WIDGET(view)->window,
GTK_WIDGET (view),
page_area, border);
- current_pixbuf = ev_pixbuf_cache_get_pixbuf (view->pixbuf_cache, page);
+ if (gdk_rectangle_intersect (&real_page_area, expose_area, &overlap)) {
+ current_pixbuf = ev_pixbuf_cache_get_pixbuf (view->pixbuf_cache, page);
- if (current_pixbuf == NULL)
- scaled_image = NULL;
- else if (width == gdk_pixbuf_get_width (current_pixbuf) &&
- height == gdk_pixbuf_get_height (current_pixbuf))
- scaled_image = g_object_ref (current_pixbuf);
- else
- /* FIXME: We don't want to scale the whole area, just the right
- * area of it */
- scaled_image = gdk_pixbuf_scale_simple (current_pixbuf,
- width, height,
- GDK_INTERP_NEAREST);
-
- if (scaled_image) {
- gdk_draw_pixbuf (GTK_WIDGET(view)->window,
- GTK_WIDGET (view)->style->fg_gc[GTK_STATE_NORMAL],
- scaled_image,
- overlap.x - real_page_area.x,
- overlap.y - real_page_area.y,
- overlap.x, overlap.y,
- overlap.width, overlap.height,
- GDK_RGB_DITHER_NORMAL,
- 0, 0);
- g_object_unref (scaled_image);
+ if (current_pixbuf == NULL)
+ scaled_image = NULL;
+ else if (width == gdk_pixbuf_get_width (current_pixbuf) &&
+ height == gdk_pixbuf_get_height (current_pixbuf))
+ scaled_image = g_object_ref (current_pixbuf);
+ else
+ /* FIXME: We don't want to scale the whole area, just the right
+ * area of it */
+ scaled_image = gdk_pixbuf_scale_simple (current_pixbuf,
+ width, height,
+ GDK_INTERP_NEAREST);
+
+ if (scaled_image) {
+ gdk_draw_pixbuf (GTK_WIDGET(view)->window,
+ GTK_WIDGET (view)->style->fg_gc[GTK_STATE_NORMAL],
+ scaled_image,
+ overlap.x - real_page_area.x,
+ overlap.y - real_page_area.y,
+ overlap.x, overlap.y,
+ overlap.width, overlap.height,
+ GDK_RGB_DITHER_NORMAL,
+ 0, 0);
+ g_object_unref (scaled_image);
+ }
}
}
{
GTK_WIDGET_SET_FLAGS (view, GTK_CAN_FOCUS);
- view->spacing = 10;
+ view->spacing = 5;
view->scale = 1.0;
view->current_page = 0;
view->pressed_button = -1;
{
EvView *view;
EvDocument *document;
+ const EvDocumentInfo *info = NULL;
EvWindowPageMode page_mode;
gboolean sensitive, has_pages = FALSE, has_document;
int n_pages = 0, page = -1;
+ gboolean ok_to_print = TRUE;
+ gboolean ok_to_copy = TRUE;
view = EV_VIEW (ev_window->priv->view);
document = ev_window->priv->document;
+ if (document)
+ info = ev_page_cache_get_info (ev_window->priv->page_cache);
page_mode = ev_window->priv->page_mode;
has_document = document != NULL;
if (has_document && ev_window->priv->page_cache) {
has_pages = has_document && n_pages > 0;
}
+ if (info && info->fields_mask & EV_DOCUMENT_INFO_PERMISSIONS) {
+ ok_to_print = (info->permissions & EV_DOCUMENT_PERMISSIONS_OK_TO_PRINT);
+ ok_to_copy = (info->permissions & EV_DOCUMENT_PERMISSIONS_OK_TO_COPY);
+ }
+
/* File menu */
/* "FileOpen": always sensitive */
- set_action_sensitive (ev_window, "FileSaveAs", has_document);
- set_action_sensitive (ev_window, "FilePrint", has_pages);
+ set_action_sensitive (ev_window, "FileSaveAs", has_document && ok_to_copy);
+ set_action_sensitive (ev_window, "FilePrint", has_pages && ok_to_print);
/* "FileCloseWindow": always sensitive */
/* Edit menu */
sensitive = has_pages && ev_document_can_get_text (document);
- set_action_sensitive (ev_window, "EditCopy", sensitive);
- set_action_sensitive (ev_window, "EditSelectAll", sensitive);
+ set_action_sensitive (ev_window, "EditCopy", sensitive && ok_to_copy);
+ set_action_sensitive (ev_window, "EditSelectAll", sensitive && ok_to_copy);
set_action_sensitive (ev_window, "EditFind",
has_pages && EV_IS_DOCUMENT_FIND (document));
set_action_sensitive (ev_window, "Slash",
static void
ev_window_setup_document (EvWindow *ev_window)
{
- EvDocumentInfo *info;
+ const EvDocumentInfo *info;
EvDocument *document;
EvView *view = EV_VIEW (ev_window->priv->view);
EvSidebar *sidebar = EV_SIDEBAR (ev_window->priv->sidebar);
ev_page_action_set_document (EV_PAGE_ACTION (action), document);
update_action_sensitivity (ev_window);
- info = ev_document_get_info (document);
+ info = ev_page_cache_get_info (ev_window->priv->page_cache);
update_document_mode (ev_window, info->mode);
- ev_document_info_free (info);
}
static void
$(LIBTIFF) \
$(top_builddir)/lib/libev.la \
$(top_builddir)/shell/libevbackendfactory.la \
+ -ltiff -lz \
$(NULL)
pixmapdir = $(pkgdatadir)
{
TiffDocument *tiff_document = TIFF_DOCUMENT (document);
int width, height;
+ gint rowstride, bytes;
+ guchar *pixels = NULL;
GdkPixbuf *pixbuf;
GdkPixbuf *scaled_pixbuf;
return NULL;
}
- TIFFGetField (tiff_document->tiff, TIFFTAG_IMAGEWIDTH, &width);
- TIFFGetField (tiff_document->tiff, TIFFTAG_IMAGELENGTH, &height);
+ if (!TIFFGetField (tiff_document->tiff, TIFFTAG_IMAGEWIDTH, &width))
+ {
+ pop_handlers ();
+ return NULL;
+ }
+
+ if (! TIFFGetField (tiff_document->tiff, TIFFTAG_IMAGELENGTH, &height))
+ {
+ pop_handlers ();
+ return NULL;
+ }
+
+ pop_handlers ();
+
+ /* Sanity check the doc */
+ if (width <= 0 || height <= 0)
+ return NULL;
+
+ rowstride = width * 4;
+ if (rowstride / 4 != width)
+ /* overflow */
+ return NULL;
+
+ bytes = height * rowstride;
+ if (bytes / rowstride != height)
+ /* overflow */
+ return NULL;
+
+ pixels = g_try_malloc (bytes);
+ if (!pixels)
+ return NULL;
+
+ pixbuf = gdk_pixbuf_new_from_data (pixels, GDK_COLORSPACE_RGB, TRUE, 8,
+ width, height, rowstride,
+ (GdkPixbufDestroyNotify) g_free, NULL);
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, width, height);
TIFFReadRGBAImageOriented (tiff_document->tiff, width, height, (uint32 *)gdk_pixbuf_get_pixels (pixbuf), ORIENTATION_TOPLEFT, 1);