+2006-01-07 Nickolay V. Shmyrev <nshmyrev@yandex.ru>
+
+ * shell/ev-page-cache.c: (build_height_to_page),
+ (ev_page_cache_get_height_to_page):
+ * shell/ev-page-cache.h:
+ * shell/ev-view.c: (view_update_range_and_current_page),
+ (get_page_y_offset), (get_page_extents), (ev_view_next_page),
+ (ev_view_previous_page):
+
+ Dual mode places even pages to the left. Fix for the bug #309393.
+
+ * shell/ev-view.h:
+ * shell/ev-window.c: (update_action_sensitivity),
+ (setup_view_from_metadata), (view_menu_popup_cb):
+
+ Don't restore presentation in empty windows, more intelligent
+ next page behaviour in dual mode.
+
+ * shell/ev-pixbuf-cache.c: (check_job_size_and_unref),
+ (ev_pixbuf_cache_clear_job_sizes):
+
+ Cleanup job callback on removal. Fix for the bug #325886.
+
2006-01-07 Nickolay V. Shmyrev <nshmyrev@yandex.ru>
* ps/ps.c: (psscan):
g_free (page_cache->height_to_page);
g_free (page_cache->dual_height_to_page);
- page_cache->height_to_page = g_new0(double, page_cache->n_pages);
- page_cache->dual_height_to_page = g_new0(double, page_cache->n_pages / 2 + 1);
+ page_cache->height_to_page = g_new0(double, page_cache->n_pages + 1);
+ page_cache->dual_height_to_page = g_new0(double, page_cache->n_pages + 2);
saved_height = 0;
- for (i = 0; i < page_cache->n_pages; i++) {
+ for (i = 0; i <= page_cache->n_pages; i++) {
if (page_cache->uniform) {
if (!swap) {
uniform_height = page_cache->uniform_height;
} else {
uniform_height = page_cache->uniform_width;
}
- page_cache->height_to_page [i] = (i + 1) * uniform_height;
+ page_cache->height_to_page [i] = i * uniform_height;
} else {
if (!swap) {
page_height = page_cache->size_cache [i].height;
} else {
page_height = page_cache->size_cache [i].width;
}
- page_cache->height_to_page [i] = saved_height + page_height;
- saved_height = page_cache->height_to_page [i];
+ page_cache->height_to_page [i] = saved_height;
+ saved_height += page_height;
}
}
-
- saved_height = 0;
- for (i = 0; i < page_cache->n_pages; i += 2) {
+
+ if (DUAL_EVEN_LEFT && !page_cache->uniform) {
+ if (!swap) {
+ saved_height = page_cache->size_cache [0].height;
+ } else {
+ saved_height = page_cache->size_cache [0].width;
+ }
+ } else {
+ saved_height = 0;
+ }
+ for (i = DUAL_EVEN_LEFT; i < page_cache->n_pages + 2; i += 2) {
if (page_cache->uniform) {
if (!swap) {
uniform_height = page_cache->uniform_height;
} else {
uniform_height = page_cache->uniform_width;
}
- page_cache->dual_height_to_page [i / 2] = (i / 2 + 1) * uniform_height;
+ page_cache->dual_height_to_page [i] = ((i + DUAL_EVEN_LEFT) / 2) * uniform_height;
+ if (i + 1 < page_cache->n_pages + 2)
+ page_cache->dual_height_to_page [i + 1] = ((i + DUAL_EVEN_LEFT) / 2) * uniform_height;
} else {
- if (!swap) {
- page_height = page_cache->size_cache [i].height;
- next_page_height = page_cache->size_cache [i + 1].height;
+ if (i + 1 < page_cache->n_pages) {
+ if (!swap) {
+ next_page_height = page_cache->size_cache [i + 1].height;
+ } else {
+ next_page_height = page_cache->size_cache [i + 1].width;
+ }
} else {
- page_height = page_cache->size_cache [i].width;
- next_page_height = page_cache->size_cache [i + 1].width;
+ next_page_height = 0;
}
- if (i == page_cache->n_pages - 1) {
- page_cache->dual_height_to_page [i / 2] =
- saved_height + page_height;
+ if (i < page_cache->n_pages) {
+ if (!swap) {
+ page_height = page_cache->size_cache [i].height;
+ } else {
+ page_height = page_cache->size_cache [i].width;
+ }
+ } else {
+ page_height = 0;
}
- else {
- page_cache->dual_height_to_page [i / 2] = saved_height +
- MAX(page_height, next_page_height);
- saved_height = page_cache->dual_height_to_page [i / 2];
+ if (i + 1 < page_cache->n_pages + 2) {
+ page_cache->dual_height_to_page [i] = saved_height;
+ page_cache->dual_height_to_page [i + 1] = saved_height;
+ saved_height += MAX(page_height, next_page_height);
+ } else {
+ page_cache->dual_height_to_page [i] = saved_height;
}
}
}
gint *height,
gint *dual_height)
{
- double result = 0.0;
- double dual_result = 0.0;
-
g_return_if_fail (EV_IS_PAGE_CACHE (page_cache));
if (page_cache->rotation != rotation) {
page_cache->rotation = rotation;
build_height_to_page (page_cache);
}
-
- if (page > 0)
- result = page_cache->height_to_page [page - 1];
if (height)
- *height = result * scale;
+ *height = page_cache->height_to_page [page] * scale;
- if (page > 1)
- dual_result = page_cache->dual_height_to_page [page / 2 - 1];
-
if (dual_height)
- *dual_height = dual_result * scale;
+ *dual_height = page_cache->dual_height_to_page [page] * scale;
}
gint
#include <gtk/gtkwidget.h>
#include "ev-document.h"
+#define DUAL_EVEN_LEFT 1
+
G_BEGIN_DECLS
#define EV_TYPE_PAGE_CACHE (ev_page_cache_get_type ())
#define EV_PAGE_CACHE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EV_TYPE_PAGE_CACHE, EvPageCache))
* given a scale. If it won't, it removes the job and clears it to NULL.
*/
static void
-check_job_size_and_unref (CacheJobInfo *job_info,
+check_job_size_and_unref (EvPixbufCache *pixbuf_cache,
+ CacheJobInfo *job_info,
EvPageCache *page_cache,
gfloat scale)
{
height == EV_JOB_RENDER (job_info->job)->target_height)
return;
- /* Try to remove the job. If we can't, then the thread has already
- * picked it up and we are going get a signal when it's done. If we
- * can, then the job is fully dead and will never rnu.. */
- if (ev_job_queue_remove_job (job_info->job))
- g_object_unref (job_info->job);
-
+ g_signal_handlers_disconnect_by_func (job_info->job,
+ G_CALLBACK (job_finished_cb),
+ pixbuf_cache);
+ ev_job_queue_remove_job (job_info->job);
+ g_object_unref (job_info->job);
job_info->job = NULL;
}
page_cache = ev_page_cache_get (pixbuf_cache->document);
for (i = 0; i < PAGE_CACHE_LEN (pixbuf_cache); i++) {
- check_job_size_and_unref (pixbuf_cache->job_list + i, page_cache, scale);
+ check_job_size_and_unref (pixbuf_cache, pixbuf_cache->job_list + i, page_cache, scale);
}
for (i = 0; i < pixbuf_cache->preload_cache_size; i++) {
- check_job_size_and_unref (pixbuf_cache->prev_job + i, page_cache, scale);
- check_job_size_and_unref (pixbuf_cache->next_job + i, page_cache, scale);
+ check_job_size_and_unref (pixbuf_cache, pixbuf_cache->prev_job + i, page_cache, scale);
+ check_job_size_and_unref (pixbuf_cache, pixbuf_cache->next_job + i, page_cache, scale);
}
}
static void
view_update_range_and_current_page (EvView *view)
{
+ gint current_page;
+
if (view->pending_scroll != SCROLL_TO_KEEP_POSITION)
return;
} else if (view->continuous) {
GdkRectangle current_area, unused, page_area;
GtkBorder border;
- gint current_page;
gboolean found = FALSE;
int i;
}
}
- current_page = ev_page_cache_get_current_page (view->page_cache);
-
- if (current_page < view->start_page || current_page > view->end_page) {
- view->current_page = view->start_page;
- ev_page_cache_set_current_page (view->page_cache, view->start_page);
- }
} else {
if (view->dual_page) {
- if (view->current_page % 2 == 0) {
+ if (view->current_page % 2 == DUAL_EVEN_LEFT) {
view->start_page = view->current_page;
if (view->current_page + 1 < ev_page_cache_get_n_pages (view->page_cache))
view->end_page = view->start_page + 1;
else
view->end_page = view->start_page;
} else {
- view->start_page = view->current_page - 1;
+ if (view->current_page - 1 < 0)
+ view->start_page = view->current_page;
+ else
+ view->start_page = view->current_page - 1;
view->end_page = view->current_page;
}
} else {
view->start_page = view->current_page;
view->end_page = view->current_page;
}
+
+ }
+
+ current_page = ev_page_cache_get_current_page (view->page_cache);
+
+ if (current_page < view->start_page || current_page > view->end_page) {
+ view->current_page = view->start_page;
+ ev_page_cache_set_current_page (view->page_cache, view->start_page);
}
ev_pixbuf_cache_set_page_range (view->pixbuf_cache,
if (view->dual_page) {
ev_page_cache_get_height_to_page (view->page_cache, page,
view->rotation, zoom, NULL, &offset);
- offset += (page / 2 + 1) * view->spacing + (page / 2) * (border.top + border.bottom);
+ offset += ((page + DUAL_EVEN_LEFT) / 2 + 1) * view->spacing + ((page + DUAL_EVEN_LEFT) / 2 ) * (border.top + border.bottom);
} else {
ev_page_cache_get_height_to_page (view->page_cache, page,
view->rotation, zoom, &offset, NULL);
max_width = max_width + border->left + border->right;
/* Get the location of the bounding box */
if (view->dual_page) {
- x = view->spacing + (page % 2) * (max_width + view->spacing);
+ x = view->spacing + ((page % 2 == DUAL_EVEN_LEFT) ? 0 : 1) * (max_width + view->spacing);
x = x + MAX (0, widget->allocation.width - (max_width * 2 + view->spacing * 3)) / 2;
- if (page % 2 == 0)
+ if (page % 2 == DUAL_EVEN_LEFT)
x = x + (max_width - width - border->left - border->right);
} else {
x = view->spacing;
GtkBorder overall_border;
gint other_page;
- other_page = page ^ 1;
+ other_page = (page % 2 == DUAL_EVEN_LEFT) ? page + 1: page - 1;
/* First, we get the bounding box of the two pages */
- if (other_page < ev_page_cache_get_n_pages (view->page_cache)) {
+ if (other_page < ev_page_cache_get_n_pages (view->page_cache)
+ && (0 <= other_page)) {
ev_page_cache_get_size (view->page_cache,
other_page,
view->rotation,
y = view->spacing;
/* Adjust for being the left or right page */
- if (page % 2 == 0)
+ if (page % 2 == DUAL_EVEN_LEFT)
x = x + max_width - width;
else
x = x + (max_width + overall_border.left + overall_border.right) + view->spacing;
if (page < ev_page_cache_get_n_pages (view->page_cache)) {
ev_page_cache_set_current_page (view->page_cache, page);
return TRUE;
+ } else if (ev_view_get_dual_page (view) && page == ev_page_cache_get_n_pages (view->page_cache)) {
+ ev_page_cache_set_current_page (view->page_cache, page - 1);
+ return TRUE;
} else {
return FALSE;
}
if (page >= 0) {
ev_page_cache_set_current_page (view->page_cache, page);
return TRUE;
- } else {
+ } else if (ev_view_get_dual_page (view) && page == -1) {
+ ev_page_cache_set_current_page (view->page_cache, 0);
+ return TRUE;
+ } else {
return FALSE;
}
}
-gboolean
-ev_view_can_previous_page (EvView *view)
-{
- int page;
-
- g_return_val_if_fail (EV_IS_VIEW (view), FALSE);
-
- page = ev_page_cache_get_current_page (view->page_cache);
- page = ev_view_get_dual_page (view) ? page - 2 : page - 1;
-
- return (page >=0);
-}
-
-gboolean ev_view_can_next_page (EvView *view)
-{
- int page;
-
- g_return_val_if_fail (EV_IS_VIEW (view), FALSE);
-
- page = ev_page_cache_get_current_page (view->page_cache);
- page = ev_view_get_dual_page (view) ? page + 2 : page + 1;
-
- return (page < ev_page_cache_get_n_pages (view->page_cache));
-}
-
/*** Enum description for usage in signal ***/
GType
EvLink *link);
gboolean ev_view_next_page (EvView *view);
gboolean ev_view_previous_page (EvView *view);
-gboolean ev_view_can_next_page (EvView *view);
-gboolean ev_view_can_previous_page (EvView *view);
G_END_DECLS
/* Go menu */
if (document) {
- set_action_sensitive (ev_window, "GoPreviousPage", ev_view_can_previous_page (view));
- set_action_sensitive (ev_window, "GoNextPage", ev_view_can_next_page (view));
+ set_action_sensitive (ev_window, "GoPreviousPage", page > 0);
+ set_action_sensitive (ev_window, "GoNextPage", page < n_pages - 1);
set_action_sensitive (ev_window, "GoFirstPage", page > 0);
set_action_sensitive (ev_window, "GoLastPage", page < n_pages - 1);
} else {
/* Presentation */
if (ev_metadata_manager_get (uri, "presentation", &presentation, FALSE)) {
- if (g_value_get_boolean (&presentation)) {
+ if (g_value_get_boolean (&presentation) && uri) {
ev_window_run_presentation (window);
}
}
/* Fullscreen */
if (ev_metadata_manager_get (uri, "fullscreen", &fullscreen, FALSE)) {
- if (g_value_get_boolean (&fullscreen)) {
+ if (g_value_get_boolean (&fullscreen) && uri) {
ev_window_run_fullscreen (window);
}
}
gboolean show_external = FALSE;
gboolean show_internal = FALSE;
GtkAction *action;
+
+ if (ev_view_get_presentation (EV_VIEW (ev_window->priv->view)))
+ return FALSE;
if (ev_window->priv->link)
g_object_unref (ev_window->priv->link);
gtk_menu_popup (GTK_MENU (popup), NULL, NULL,
NULL, NULL,
3, gtk_get_current_event_time ());
- return TRUE;
+ return FALSE;
}
static void