]> www.fi.muni.cz Git - evince.git/commitdiff
Default page is 0. Calculate size even when we have no target yet.
authorMarco Pesenti Gritti <marco@gnome.org>
Mon, 28 Feb 2005 21:07:44 +0000 (21:07 +0000)
committerMarco Pesenti Gritti <marco@src.gnome.org>
Mon, 28 Feb 2005 21:07:44 +0000 (21:07 +0000)
2005-02-28  Marco Pesenti Gritti  <marco@gnome.org>

        * ps/ps-document.c: (ps_document_init), (ps_document_cleanup),
        (set_up_page), (document_load), (ps_document_set_zoom):

        Default page is 0. Calculate size even when we have no
        target yet.

ChangeLog
ps/ps-document.c

index a61cfefe45de4b1bd59d081e51ac4fa8767c9869..fd78fbc8c812a1faa1a2f029e8a3dba44e5f0d1d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2005-02-28  Marco Pesenti Gritti  <marco@gnome.org>
+
+       * ps/ps-document.c: (ps_document_init), (ps_document_cleanup),
+       (set_up_page), (document_load), (ps_document_set_zoom):
+
+       Default page is 0. Calculate size even when we have no
+       target yet.
+
 2005-02-28  Carlos Garcia Campos <carlosgc@gnome.org>
 
        * shell/ev-sidebar.c: expand the selection widget to be always as
index dea5ddf5ac63743d73ed851efc64bd26fdb1a05c..d78ad744a8b5e5b51718f7820c819c3a7fe36551 100644 (file)
@@ -226,7 +226,7 @@ ps_document_init(PSDocument * gs)
 {
   gs->bpixmap = NULL;
 
-  gs->current_page = -2;
+  gs->current_page = 0;
   gs->disable_start = FALSE;
   gs->interpreter_pid = -1;
 
@@ -379,7 +379,7 @@ ps_document_cleanup(PSDocument * gs)
     g_free(gs->gs_filename_unc);
     gs->gs_filename_unc = NULL;
   }
-  gs->current_page = -1;
+  gs->current_page = 0;
   gs->loaded = FALSE;
   gs->llx = 0;
   gs->lly = 0;
@@ -486,6 +486,7 @@ set_up_page(PSDocument * gs)
   GdkGC *fill;
   GdkColor white = { 0, 0xFFFF, 0xFFFF, 0xFFFF };   /* pixel, r, g, b */
   GdkColormap *colormap;
+  gboolean size_changed;
 
   LOG ("Setup the page");
 
@@ -493,6 +494,8 @@ set_up_page(PSDocument * gs)
   char *savelocale;
 #endif
 
+  size_changed = compute_size (gs);
+
   if (gs->pstarget == NULL)
     return;
 
@@ -502,7 +505,7 @@ set_up_page(PSDocument * gs)
 
   orientation = ps_document_get_orientation(gs);
 
-  if(compute_size(gs)) {
+  if(size_changed) {
     gdk_flush();
 
     /* clear new pixmap (set to white) */
@@ -1315,7 +1318,7 @@ document_load(PSDocument * gs, const gchar * fname)
   /* default values: no dsc information available  */
   gs->structured_doc = FALSE;
   gs->send_filename_to_gs = TRUE;
-  gs->current_page = -2;
+  gs->current_page = 0;
   gs->loaded = FALSE;
   if(*fname == '/') {
     /* an absolute path */
@@ -1632,55 +1635,19 @@ ps_document_set_page_size(PSDocument * gs, gint new_pagesize, gint pageid)
   return FALSE;
 }
 
-static gfloat
-ps_document_zoom_to_fit(PSDocument * gs, gboolean fit_width)
-{
-  gint new_y;
-  gfloat new_zoom;
-  guint avail_w, avail_h;
-
-  g_return_val_if_fail(gs != NULL, 0.0);
-  g_return_val_if_fail(GTK_IS_GS(gs), 0.0);
-
-  avail_w = (gs->avail_w > 0) ? gs->avail_w : gs->width;
-  avail_h = (gs->avail_h > 0) ? gs->avail_h : gs->height;
-
-  new_zoom = ((gfloat) avail_w) / ((gfloat) gs->width) * gs->zoom_factor;
-  if(!fit_width) {
-    new_y = new_zoom * ((gfloat) gs->height) / gs->zoom_factor;
-    if(new_y > avail_h)
-      new_zoom = ((gfloat) avail_h) / ((gfloat) gs->height) * gs->zoom_factor;
-  }
-
-  return new_zoom;
-}
-
 static void
-ps_document_set_zoom(PSDocument * gs, gfloat zoom)
+ps_document_set_zoom (PSDocument * gs, gfloat zoom)
 {
-  g_return_if_fail(gs != NULL);
-  g_return_if_fail(GTK_IS_GS(gs));
+       g_return_if_fail (gs != NULL);
 
-  switch (gs->zoom_mode) {
-  case GTK_GS_ZOOM_FIT_WIDTH:
-    zoom = ps_document_zoom_to_fit(gs, TRUE);
-    break;
-  case GTK_GS_ZOOM_FIT_PAGE:
-    zoom = ps_document_zoom_to_fit(gs, FALSE);
-    break;
-  case GTK_GS_ZOOM_ABSOLUTE:
-  default:
-    break;
-  }
+       gs->zoom_factor = zoom;
 
-  if(fabs(gs->zoom_factor - zoom) > 0.001) {
-    gs->zoom_factor = zoom;
-    set_up_page(gs);
-    gs->changed = TRUE;
-  }
-  
-  gs->scaling = TRUE;
-  ps_document_goto_page(gs, gs->current_page);
+       if (gs->pstarget != NULL) {
+               set_up_page(gs);
+               gs->changed = TRUE;
+               gs->scaling = TRUE;
+               ps_document_goto_page (gs, gs->current_page);
+       }
 }
 
 static gboolean