Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonathan Blandford <jrb@redhat.com>2005-05-29 07:27:23 (GMT)
committer Jonathan Blandford <jrb@src.gnome.org>2005-05-29 07:27:23 (GMT)
commit8e94fdff19bd0fec3d8932ec750b7386fc1c151b (patch)
treeec87cd61f0403bd6ad4e3895d81c42e683f8cd1e
parent560a7e43fe1f899e72130cb4ab1175d325f8e43c (diff)
modify the expose handling to get the shadows.
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.
-rw-r--r--ChangeLog12
-rw-r--r--TODO16
-rw-r--r--backend/ev-document-info.h15
-rw-r--r--backend/ev-document.h1
-rw-r--r--backend/ev-page-cache.c13
-rw-r--r--backend/ev-page-cache.h1
-rw-r--r--pdf/ev-poppler.cc16
-rw-r--r--shell/Makefile.am1
-rw-r--r--shell/ev-pixbuf-cache.c2
-rw-r--r--shell/ev-view.c62
-rw-r--r--shell/ev-window.c23
-rw-r--r--thumbnailer/Makefile.am1
-rw-r--r--tiff/tiff-document.c39
13 files changed, 150 insertions, 52 deletions
diff --git a/ChangeLog b/ChangeLog
index d16b617..541ba77 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+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:
diff --git a/TODO b/TODO
index b8c83c4..576f2ab 100644
--- a/TODO
+++ b/TODO
@@ -4,7 +4,6 @@ Improve Find system
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?)
@@ -14,16 +13,6 @@ 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
@@ -43,3 +32,8 @@ Move to three page views:
* 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
diff --git a/backend/ev-document-info.h b/backend/ev-document-info.h
index 15d27d0..02ea5b1 100644
--- a/backend/ev-document-info.h
+++ b/backend/ev-document-info.h
@@ -60,6 +60,19 @@ typedef enum
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,
@@ -71,6 +84,7 @@ typedef enum
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
@@ -84,6 +98,7 @@ struct _EvDocumentInfo
EvDocumentMode mode;
GDate creation_date;
guint ui_hints;
+ guint permissions;
/* Mask of all the valid fields */
guint fields_mask;
diff --git a/backend/ev-document.h b/backend/ev-document.h
index da38283..6ff356f 100644
--- a/backend/ev-document.h
+++ b/backend/ev-document.h
@@ -99,6 +99,7 @@ EvPageCache *ev_document_get_page_cache (EvDocument *document);
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,
diff --git a/backend/ev-page-cache.c b/backend/ev-page-cache.c
index 6302c42..36adf93 100644
--- a/backend/ev-page-cache.c
+++ b/backend/ev-page-cache.c
@@ -32,6 +32,7 @@ struct _EvPageCache
double max_height_page_height;
EvPageCacheInfo *size_cache;
+ EvDocumentInfo *page_info;
};
struct _EvPageCacheClass
@@ -91,6 +92,7 @@ ev_page_cache_finalize (GObject *object)
g_free (page_cache->title);
g_free (page_cache->size_cache);
+ ev_document_info_free (page_cache->page_info);
}
EvPageCache *
@@ -180,6 +182,8 @@ _ev_page_cache_new (EvDocument *document)
}
}
+ 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);
@@ -366,6 +370,15 @@ ev_page_cache_has_nonnumeric_page_labels (EvPageCache *page_cache)
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)
{
diff --git a/backend/ev-page-cache.h b/backend/ev-page-cache.h
index 6b9db53..fc1111b 100644
--- a/backend/ev-page-cache.h
+++ b/backend/ev-page-cache.h
@@ -50,6 +50,7 @@ void ev_page_cache_get_max_height_size (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);
diff --git a/pdf/ev-poppler.cc b/pdf/ev-poppler.cc
index bd3151a..dbc81d2 100644
--- a/pdf/ev-poppler.cc
+++ b/pdf/ev-poppler.cc
@@ -305,6 +305,7 @@ pdf_document_get_info (EvDocument *document)
PopplerPageLayout layout;
PopplerPageMode mode;
PopplerViewerPreferences view_prefs;
+ PopplerPermissions permissions;
info = g_new0 (EvDocumentInfo, 1);
@@ -316,6 +317,7 @@ pdf_document_get_info (EvDocument *document)
EV_DOCUMENT_INFO_LAYOUT |
EV_DOCUMENT_INFO_START_MODE |
/* Missing EV_DOCUMENT_INFO_CREATION_DATE | */
+ EV_DOCUMENT_INFO_PERMISSIONS |
EV_DOCUMENT_INFO_UI_HINTS;
@@ -328,6 +330,7 @@ pdf_document_get_info (EvDocument *document)
"page-mode", &mode,
"page-layout", &layout,
"viewer-preferences", &view_prefs,
+ "permissions", &permissions,
NULL);
switch (layout) {
@@ -394,6 +397,19 @@ pdf_document_get_info (EvDocument *document)
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;
}
diff --git a/shell/Makefile.am b/shell/Makefile.am
index 3e1c2b7..bd104e8 100644
--- a/shell/Makefile.am
+++ b/shell/Makefile.am
@@ -96,6 +96,7 @@ evince_LDADD= \
$(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)
diff --git a/shell/ev-pixbuf-cache.c b/shell/ev-pixbuf-cache.c
index b5227ee..083825a 100644
--- a/shell/ev-pixbuf-cache.c
+++ b/shell/ev-pixbuf-cache.c
@@ -73,7 +73,7 @@ ev_pixbuf_cache_init (EvPixbufCache *pixbuf_cache)
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);
}
diff --git a/shell/ev-view.c b/shell/ev-view.c
index 9f66d8a..3eea568 100644
--- a/shell/ev-view.c
+++ b/shell/ev-view.c
@@ -900,8 +900,8 @@ get_page_extents (EvView *view,
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;
@@ -1607,11 +1607,12 @@ draw_one_page (EvView *view,
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;
@@ -1620,38 +1621,37 @@ draw_one_page (EvView *view,
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);
+ }
}
}
@@ -1895,7 +1895,7 @@ ev_view_init (EvView *view)
{
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;
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 4671e4e..c5cfac6 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -190,12 +190,17 @@ update_action_sensitivity (EvWindow *ev_window)
{
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) {
@@ -204,17 +209,22 @@ update_action_sensitivity (EvWindow *ev_window)
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",
@@ -581,7 +591,7 @@ update_document_mode (EvWindow *window, EvDocumentMode mode)
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);
@@ -615,9 +625,8 @@ ev_window_setup_document (EvWindow *ev_window)
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
diff --git a/thumbnailer/Makefile.am b/thumbnailer/Makefile.am
index ea9dc34..8a4e933 100644
--- a/thumbnailer/Makefile.am
+++ b/thumbnailer/Makefile.am
@@ -25,6 +25,7 @@ evince_thumbnailer_LDADD= \
$(LIBTIFF) \
$(top_builddir)/lib/libev.la \
$(top_builddir)/shell/libevbackendfactory.la \
+ -ltiff -lz \
$(NULL)
pixmapdir = $(pkgdatadir)
diff --git a/tiff/tiff-document.c b/tiff/tiff-document.c
index 5c8cc8d..9605c16 100644
--- a/tiff/tiff-document.c
+++ b/tiff/tiff-document.c
@@ -167,6 +167,8 @@ tiff_document_render_pixbuf (EvDocument *document, int page, double scale)
{
TiffDocument *tiff_document = TIFF_DOCUMENT (document);
int width, height;
+ gint rowstride, bytes;
+ guchar *pixels = NULL;
GdkPixbuf *pixbuf;
GdkPixbuf *scaled_pixbuf;
@@ -180,8 +182,41 @@ tiff_document_render_pixbuf (EvDocument *document, int page, double scale)
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);