Commit 8e94fdff authored by Jonathan Blandford's avatar Jonathan Blandford Committed by Jonathan Blandford

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.
parent 560a7e43
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:
......
......@@ -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
......@@ -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;
......
......@@ -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,
......
......@@ -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)
{
......
......@@ -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);
......
......@@ -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;
}
......
......@@ -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)
......
......@@ -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);
}
......
......@@ -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,13 +1621,11 @@ 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);
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)
......@@ -1653,6 +1652,7 @@ draw_one_page (EvView *view,
0, 0);
g_object_unref (scaled_image);
}
}
}
/*** GObject functions ***/
......@@ -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;
......
......@@ -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
......
......@@ -25,6 +25,7 @@ evince_thumbnailer_LDADD= \
$(LIBTIFF) \
$(top_builddir)/lib/libev.la \
$(top_builddir)/shell/libevbackendfactory.la \
-ltiff -lz \
$(NULL)
pixmapdir = $(pkgdatadir)
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment