#include "ev-marshal.h"
#include "ev-view.h"
#include "ev-document-find.h"
+#include "ev-debug.h"
#define EV_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), EV_TYPE_VIEW, EvViewClass))
#define EV_IS_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), EV_TYPE_VIEW))
{
EvView *view = EV_VIEW (object);
+ LOG ("Finalize")
+
if (view->document)
g_object_unref (view->document);
if (GTK_WIDGET_REALIZED (widget)) {
if (view->document) {
ev_document_get_page_size (view->document,
+ -1,
&requisition->width,
&requisition->height);
} else {
static void
draw_rubberband (GtkWidget *widget, GdkWindow *window,
- const GdkRectangle *rect, gboolean dark)
+ const GdkRectangle *rect, guchar alpha)
{
GdkGC *gc;
GdkPixbuf *pixbuf;
guint fill_color;
fill_color_gdk = gdk_color_copy (>K_WIDGET (widget)->style->base[GTK_STATE_SELECTED]);
- fill_color = ev_gdk_color_to_rgb (fill_color_gdk) << 8 |
- (dark ? 0x90 : 0x40);
+ fill_color = ev_gdk_color_to_rgb (fill_color_gdk) << 8 | alpha;
pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8,
rect->width, rect->height);
for (i = 0; i < results; i++) {
GdkRectangle rectangle;
- gboolean current;
+ guchar alpha;
- current = (i == view->find_result);
+ alpha = (i == view->find_result) ? 0x90 : 0x20;
ev_document_find_get_result (find, i, &rectangle);
draw_rubberband (GTK_WIDGET (view), view->bin_window,
- &rectangle, current);
+ &rectangle, alpha);
}
}
x_offset + 1,
y_offset + 1);
+ LOG ("Render area %d %d %d %d", event->area.x, event->area.y,
+ event->area.width, event->area.height)
+
ev_document_render (view->document,
event->area.x, event->area.y,
event->area.width, event->area.height);
- highlight_find_results (view);
+ if (EV_IS_DOCUMENT_FIND (view->document)) {
+ highlight_find_results (view);
+ }
if (view->has_selection) {
draw_rubberband (widget, view->bin_window,
- &view->selection, FALSE);
+ &view->selection, 0x40);
}
}
view->selection.y = MIN (view->selection_start.y, event->y);
view->selection.width = ABS (view->selection_start.x - event->x) + 1;
view->selection.height = ABS (view->selection_start.y - event->y) + 1;
+
+ gtk_widget_queue_draw (widget);
} else if (view->document) {
EvLink *link;
}
}
- gtk_widget_queue_draw (widget);
-
return TRUE;
}
view->cursor = EV_VIEW_CURSOR_NORMAL;
}
-static char *
-ev_view_get_find_status_message (EvView *view)
+static void
+update_find_status_message (EvView *view)
{
-/*
- if (view->find_results->len == 0) {
- if (view->find_percent_complete >= (1.0 - 1e-10)) {
- return g_strdup (_("Not found"));
+ char *message;
+
+ if (ev_document_get_page (view->document) == view->find_page) {
+ int results;
+
+ results = ev_document_find_get_n_results
+ (EV_DOCUMENT_FIND (view->document));
+
+ message = g_strdup_printf (_("%d found on this page"),
+ results);
+ } else {
+ double percent;
+
+ percent = ev_document_find_get_progress
+ (EV_DOCUMENT_FIND (view->document));
+
+ if (percent >= (1.0 - 1e-10)) {
+ message = g_strdup (_("Not found"));
} else {
- return g_strdup_printf (_("%3d%% remaining to search"),
- (int) ((1.0 - view->find_percent_complete) * 100));
+ message = g_strdup_printf (_("%3d%% remaining to search"),
+ (int) ((1.0 - percent) * 100));
}
- } else if (view->results_on_this_page == 0) {
- g_assert (view->next_page_with_result != 0);
- return g_strdup_printf (_("Found on page %d"),
- view->next_page_with_result);
- } else {
- return g_strdup_printf (_("%d found on this page"),
- view->results_on_this_page);
+
}
-*/
+
+ ev_view_set_find_status (view, message);
+ g_free (message);
}
static void
-set_document_page (EvView *view, int page)
+set_document_page (EvView *view, int new_page)
{
+ int page;
+ int pages;
+
+ pages = ev_document_get_n_pages (view->document);
+ page = CLAMP (new_page, 1, pages);
+
if (view->document) {
int old_page = ev_document_get_page (view->document);
int old_width, old_height;
ev_document_get_page_size (view->document,
+ -1,
&old_width, &old_height);
if (old_page != page) {
view->has_selection = FALSE;
ev_document_get_page_size (view->document,
+ -1,
&width, &height);
if (width != old_width || height != old_height)
gtk_widget_queue_resize (GTK_WIDGET (view));
+
+ gtk_adjustment_set_value (view->vadjustment,
+ view->vadjustment->lower);
}
view->find_page = page;
view->find_result = 0;
+
+ if (EV_IS_DOCUMENT_FIND (view->document)) {
+ update_find_status_message (view);
+ }
}
}
static void
jump_to_find_result (EvView *view)
{
+ EvDocumentFind *find = EV_DOCUMENT_FIND (view->document);
GdkRectangle rect;
+ int n_results;
+
+ n_results = ev_document_find_get_n_results (find);
- ev_document_find_get_result (EV_DOCUMENT_FIND (view->document),
- view->find_result, &rect);
- ensure_rectangle_is_visible (view, &rect);
+ if (n_results > view->find_result) {
+ ev_document_find_get_result
+ (find, view->find_result, &rect);
+ ensure_rectangle_is_visible (view, &rect);
+ }
}
static void
{
jump_to_find_page (view);
jump_to_find_result (view);
-
- g_print ("Update for page %d\n", page);
+ update_find_status_message (view);
if (ev_document_get_page (document) == page) {
gtk_widget_queue_draw (GTK_WIDGET (view));
if (document != view->document) {
if (view->document) {
- g_signal_handlers_disconnect_by_func (view->document,
- find_changed_cb,
- view);
+ g_signal_handlers_disconnect_by_func
+ (view->document, find_changed_cb, view);
g_object_unref (view->document);
}
if (view->document) {
g_object_ref (view->document);
- if (EV_IS_DOCUMENT_FIND (view->document))
+ if (EV_IS_DOCUMENT_FIND (view->document)) {
g_signal_connect (view->document,
"find_changed",
G_CALLBACK (find_changed_cb),
view);
+ }
g_signal_connect (view->document,
"changed",
G_CALLBACK (document_changed_callback),
int width, height;
width = height = 0;
- ev_document_get_page_size (view->document, &width, &height);
+ ev_document_get_page_size (view->document, -1, &width, &height);
scale = 1.0;
if (width != 0 && height != 0) {
int width;
width = 0;
- ev_document_get_page_size (view->document, &width, NULL);
+ ev_document_get_page_size (view->document, -1, &width, NULL);
scale = 1.0;
if (width != 0)