+
+#define ZOOM_IN_FACTOR 1.2
+#define ZOOM_OUT_FACTOR (1.0/ZOOM_IN_FACTOR)
+
+#define MIN_SCALE 0.05409
+#define MAX_SCALE 18.4884
+
+static void
+ev_view_zoom (EvView *view,
+ double factor,
+ gboolean relative)
+{
+ double scale;
+
+ if (relative)
+ scale = view->scale * factor;
+ else
+ scale = factor;
+
+ view->scale = CLAMP (scale, MIN_SCALE, MAX_SCALE);
+
+ ev_document_set_scale (view->document, view->scale);
+
+ gtk_widget_queue_resize (GTK_WIDGET (view));
+}
+
+void
+ev_view_zoom_in (EvView *view)
+{
+ ev_view_zoom (view, ZOOM_IN_FACTOR, TRUE);
+}
+
+void
+ev_view_zoom_out (EvView *view)
+{
+ ev_view_zoom (view, ZOOM_OUT_FACTOR, TRUE);
+}
+
+void
+ev_view_normal_size (EvView *view)
+{
+ ev_view_zoom (view, 1.0, FALSE);
+}
+
+void
+ev_view_best_fit (EvView *view)
+{
+ double scale;
+ int width, height;
+
+ width = height = 0;
+ ev_document_get_page_size (view->document, &width, &height);
+
+ scale = 1.0;
+ if (width != 0 && height != 0) {
+ double scale_w, scale_h;
+
+ scale_w = (double)GTK_WIDGET (view)->allocation.width * view->scale / width;
+ scale_h = (double)GTK_WIDGET (view)->allocation.height * view->scale / height;
+
+ scale = (scale_w < scale_h) ? scale_w : scale_h;
+ }
+
+ ev_view_zoom (view, scale, FALSE);
+}
+
+void
+ev_view_fit_width (EvView *view)
+{
+ double scale = 1.0;
+ int width;
+
+ width = 0;
+ ev_document_get_page_size (view->document, &width, NULL);
+
+ scale = 1.0;
+ if (width != 0)
+ scale = (double)GTK_WIDGET (view)->allocation.width * view->scale / width;
+
+ ev_view_zoom (view, scale, FALSE);
+}
+
+char*
+ev_view_get_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"));
+ } else {
+ return g_strdup_printf (_("%3d%% remaining to search"),
+ (int) ((1.0 - view->find_percent_complete) * 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);
+ }
+}