]> www.fi.muni.cz Git - evince.git/commitdiff
*** empty log message ***
authorMarco Pesenti Gritti <marco@src.gnome.org>
Wed, 22 Dec 2004 14:22:25 +0000 (14:22 +0000)
committerMarco Pesenti Gritti <marco@src.gnome.org>
Wed, 22 Dec 2004 14:22:25 +0000 (14:22 +0000)
ChangeLog
ps/Makefile.am
ps/gtkgs.c
ps/gtkgs.h
shell/Makefile.am
shell/ev-view.c
shell/ev-window.c

index ad9ddb626d3ad674cd96dfda8739627c598c276f..432ad41bfa4f4d5780f441bf61e9b8e1c78f4bc4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,26 @@
+2004-12-22  Marco Pesenti Gritti  <marco@gnome.org>
+
+       * ps/Makefile.am:
+       * ps/gtkgs.c: (gtk_gs_class_init), (gtk_gs_finalize),
+       (gtk_gs_value_adjustment_changed), (compute_size),
+       (gtk_gs_get_type), (gtk_gs_new), (gtk_gs_new_from_file),
+       (gtk_gs_center_page), (gtk_gs_load), (gtk_gs_set_page_size),
+       (gtk_gs_set_override_orientation), (gtk_gs_set_override_size),
+       (gtk_gs_set_zoom), (gtk_gs_set_default_orientation),
+       (gtk_gs_start_scroll), (gtk_gs_get_postscript),
+       (gtk_gs_set_adjustments), (gtk_gs_set_available_size),
+       (ps_document_load), (ps_document_get_n_pages),
+       (ps_document_set_page), (ps_document_get_page),
+       (ps_document_set_target), (ps_document_set_scale),
+       (ps_document_set_page_offset), (ps_document_get_page_size),
+       (ps_document_render), (ps_document_begin_find),
+       (ps_document_end_find), (ps_document_document_iface_init):
+       * ps/gtkgs.h:
+       * shell/Makefile.am:
+       * shell/ev-window.c: (ev_window_open):
+
+       Some work to integrate gtkgs with EvDocument
+
 2004-12-22  Anders Carlsson  <andersca@gnome.org>
 
        * shell/ev-window.c: (update_fullscreen_popup),
index 3c6fcf378b4523406e622d9667d96d99d0455fb1..a9b298d1662592ef6a5137e3bf8268ba1e5010fc 100644 (file)
@@ -1,6 +1,7 @@
-INCLUDES =                     \
-       -I$(top_srcdir)         \
-       -DGNOMEICONDIR=\""${prefix}/${DATADIRNAME}/pixmaps"\" \
+INCLUDES = \
+       -I$(top_srcdir)                                         \
+       -I$(top_srcdir)/backend                                 \
+       -DGNOMEICONDIR=\""${prefix}/${DATADIRNAME}/pixmaps"\"   \
        $(PS_CFLAGS)
 
 noinst_LTLIBRARIES = libgtkgs.la
index 3890c68e97e0e0fff354a7bd1d691cf64095a33a..a548942c5bde7142c8c2c71c4a0e1273934c5a6c 100644 (file)
@@ -148,6 +148,7 @@ The DONE message indicates that ghostscript has finished processing.
 #include <stdio.h>
 #include <math.h>
 
+#include "ev-document.h"
 #include "gtkgs.h"
 #include "ggvutils.h"
 #include "ps.h"
@@ -180,14 +181,6 @@ catchPipe(int i)
 /* Forward declarations */
 static void gtk_gs_init(GtkGS * gs);
 static void gtk_gs_class_init(GtkGSClass * klass);
-static void gtk_gs_destroy(GtkObject * object);
-static void gtk_gs_realize(GtkWidget * widget);
-static void gtk_gs_size_request(GtkWidget * widget,
-                                GtkRequisition * requisition);
-static void gtk_gs_size_allocate(GtkWidget * widget,
-                                 GtkAllocation * allocation);
-static gint gtk_gs_widget_event(GtkWidget * widget, GdkEvent * event,
-                                gpointer data);
 static void gtk_gs_value_adjustment_changed(GtkAdjustment * adjustment,
                                             gpointer data);
 static void gtk_gs_interpreter_message(GtkGS * gs, gchar * msg,
@@ -195,6 +188,7 @@ static void gtk_gs_interpreter_message(GtkGS * gs, gchar * msg,
 static void gtk_gs_emit_error_msg(GtkGS * gs, const gchar * msg);
 static void gtk_gs_set_adjustments(GtkGS * gs, GtkAdjustment * hadj,
                                    GtkAdjustment * vadj);
+static void gtk_gs_finalize(GObject * object);
 static void send_ps(GtkGS * gs, long begin, unsigned int len, gboolean close);
 static void set_up_page(GtkGS * gs);
 static void close_pipe(int p[2]);
@@ -207,8 +201,9 @@ static void input(gpointer data, gint source, GdkInputCondition condition);
 static void stop_interpreter(GtkGS * gs);
 static gint start_interpreter(GtkGS * gs);
 gboolean computeSize(void);
+static void ps_document_document_iface_init (EvDocumentIface *iface);
 
-static GtkWidgetClass *parent_class = NULL;
+static GObjectClass *parent_class = NULL;
 
 static GtkGSClass *gs_class = NULL;
 
@@ -274,41 +269,6 @@ ggv_marshaller_VOID__INT(GClosure * closure,
   callback(data1, g_value_get_int(param_values + 1), data2);
 }
 
-static void
-ggv_marshaller_VOID__POINTER_POINTER(GClosure * closure,
-                                     GValue * return_value,
-                                     guint n_param_values,
-                                     const GValue * param_values,
-                                     gpointer invocation_hint,
-                                     gpointer marshal_data)
-{
-  typedef void (*GMarshalFunc_VOID__POINTER_POINTER) (gpointer data1,
-                                                      gpointer arg_1,
-                                                      gpointer arg_2,
-                                                      gpointer data2);
-  register GMarshalFunc_VOID__POINTER_POINTER callback;
-  register GCClosure *cc = (GCClosure *) closure;
-  register gpointer data1, data2;
-
-  g_return_if_fail(n_param_values == 3);
-
-  if(G_CCLOSURE_SWAP_DATA(closure)) {
-    data1 = closure->data;
-    data2 = g_value_peek_pointer(param_values + 0);
-  }
-  else {
-    data1 = g_value_peek_pointer(param_values + 0);
-    data2 = closure->data;
-  }
-  callback =
-    (GMarshalFunc_VOID__POINTER_POINTER) (marshal_data ? marshal_data : cc->
-                                          callback);
-
-  callback(data1,
-           g_value_get_pointer(param_values + 1),
-           g_value_get_pointer(param_values + 2), data2);
-}
-
 static void
 gtk_gs_init(GtkGS * gs)
 {
@@ -382,13 +342,9 @@ gtk_gs_init(GtkGS * gs)
 static void
 gtk_gs_class_init(GtkGSClass * klass)
 {
-  GtkObjectClass *object_class;
-  GObjectClass *gobject_class;
-  GtkWidgetClass *widget_class;
+  GObjectClass *object_class;
 
-  object_class = (GtkObjectClass *) klass;
-  gobject_class = (GObjectClass *) klass;
-  widget_class = (GtkWidgetClass *) klass;
+  object_class = (GObjectClass *) klass;
   parent_class = gtk_type_class(gtk_widget_get_type());
   gs_class = klass;
 
@@ -410,20 +366,7 @@ gtk_gs_class_init(GtkGSClass * klass)
                  NULL, NULL, ggv_marshaller_VOID__INT, G_TYPE_NONE, 1,
                  G_TYPE_INT);
 
-  object_class->destroy = gtk_gs_destroy;
-
-  widget_class->realize = gtk_gs_realize;
-  widget_class->size_request = gtk_gs_size_request;
-  widget_class->size_allocate = gtk_gs_size_allocate;
-  widget_class->set_scroll_adjustments_signal =
-    g_signal_new("set_scroll_adjustments",
-                 G_TYPE_FROM_CLASS(object_class),
-                 G_SIGNAL_RUN_LAST,
-                 G_STRUCT_OFFSET(GtkGSClass, set_scroll_adjustments),
-                 NULL,
-                 NULL,
-                 ggv_marshaller_VOID__POINTER_POINTER,
-                 G_TYPE_NONE, 2, G_TYPE_POINTER, G_TYPE_POINTER);
+  object_class->finalize = gtk_gs_finalize;
 
   /* Create atoms */
   klass->gs_atom = gdk_atom_intern("GHOSTVIEW", FALSE);
@@ -497,7 +440,7 @@ gtk_gs_interpreter_message(GtkGS * gs, gchar * msg, gpointer user_data)
 }
 
 static void
-gtk_gs_destroy(GtkObject * object)
+gtk_gs_finalize(GObject * object)
 {
   GtkGS *gs;
 
@@ -527,195 +470,13 @@ gtk_gs_destroy(GtkObject * object)
     gs->vadj = NULL;
   }
 
-  if(GTK_OBJECT_CLASS(parent_class)->destroy)
-    (*GTK_OBJECT_CLASS(parent_class)->destroy) (object);
+  (*G_OBJECT_CLASS(parent_class)->finalize) (object);
 }
 
-/* FIXME: I'm not sure if all this is supposed to be here 
- * this is just a quick hack so that this can be called whenever
- * something changes.
- */
-static void
-gtk_gs_munge_adjustments(GtkGS * gs)
-{
-  gint x, y;
-
-  gdk_window_get_position(gs->pstarget, &x, &y);
-
-  /* 
-   * This is a bit messy:
-   * we want to make sure that we do the right thing if dragged.
-   */
-  if(gs->widget.allocation.width >= gs->width ||
-     gs->zoom_mode != GTK_GS_ZOOM_ABSOLUTE) {
-    x = (gs->widget.allocation.width - gs->width) / 2;
-    gs->hadj->value = 0.0;
-    gs->hadj->page_size = 1.0;
-    gs->hadj->step_increment = 1.0;
-  }
-  else {
-    if(x > 0)
-      x = 0;
-    else if(gs->widget.allocation.width > x + gs->width)
-      x = gs->widget.allocation.width - gs->width;
-    gs->hadj->page_size = ((gfloat) gs->widget.allocation.width) / gs->width;
-    gs->hadj->page_increment = gs->hadj->page_size * 0.9;
-    gs->hadj->step_increment = gs->scroll_step * gs->hadj->page_size;
-    gs->hadj->value = -((gfloat) x) / gs->width;
-  }
-  if(gs->widget.allocation.height >= gs->height ||
-     gs->zoom_mode == GTK_GS_ZOOM_FIT_PAGE) {
-    y = (gs->widget.allocation.height - gs->height) / 2;
-    gs->vadj->value = 0.0;
-    gs->vadj->page_size = 1.0;
-    gs->vadj->step_increment = 1.0;
-  }
-  else {
-    if(y > 0)
-      y = 0;
-    else if(gs->widget.allocation.height > y + gs->height)
-      y = gs->widget.allocation.height - gs->height;
-    gs->vadj->page_size = ((gfloat) gs->widget.allocation.height) / gs->height;
-    gs->vadj->page_increment = gs->vadj->page_size * 0.9;
-    gs->vadj->step_increment = gs->scroll_step * gs->vadj->page_size;
-    gs->vadj->value = -((gfloat) y) / gs->height;
-  }
-
-  gdk_window_move(gs->pstarget, x, y);
-
-  gtk_adjustment_changed(gs->hadj);
-  gtk_adjustment_changed(gs->vadj);
-}
-
-static void
-gtk_gs_realize(GtkWidget * widget)
-{
-  GtkGS *gs;
-  GdkWindowAttr attributes;
-  gint attributes_mask;
-
-  g_return_if_fail(widget != NULL);
-  g_return_if_fail(GTK_IS_GS(widget));
-
-  gs = GTK_GS(widget);
-
-  /* we set up the main widget! */
-  GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED);
-  attributes.window_type = GDK_WINDOW_CHILD;
-  attributes.x = widget->allocation.x;
-  attributes.y = widget->allocation.y;
-  attributes.width = widget->allocation.width;
-  attributes.height = widget->allocation.height;
-  attributes.wclass = GDK_INPUT_OUTPUT;
-  attributes.visual = gtk_widget_get_visual(widget);
-  attributes.colormap = gtk_widget_get_colormap(widget);
-  attributes.event_mask = gtk_widget_get_events(widget) | GDK_EXPOSURE_MASK;
-  attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
-
-  widget->window =
-    gdk_window_new(widget->parent->window, &attributes, attributes_mask);
-  gdk_window_set_user_data(widget->window, gs);
-  widget->style = gtk_style_attach(widget->style, widget->window);
-  gtk_style_set_background(widget->style, widget->window, GTK_STATE_NORMAL);
-
-  /* now we set up the child window.  This is the one that ps actually draws too. */
-  attributes.x = 0;
-  attributes.y = 0;
-
-  gs->pstarget = gdk_window_new(widget->window, &attributes, attributes_mask);
-  gdk_window_set_user_data(gs->pstarget, widget);
-  gdk_window_clear(gs->pstarget);
-  gtk_style_set_background(widget->style, gs->pstarget, GTK_STATE_ACTIVE);
-  gs->psgc = gdk_gc_new(gs->pstarget);
-  gdk_gc_set_function(gs->psgc, GDK_INVERT);
-
-  gs->width = 0;
-  gs->height = 0;
-
-  gtk_gs_set_page_size(gs, -1, 0);
-
-  if((gs->width > 0) && (gs->height > 0) && GTK_WIDGET_REALIZED(gs)) {
-    gtk_gs_munge_adjustments(gs);
-  }
-
-  g_signal_connect(G_OBJECT(widget), "event",
-                   G_CALLBACK(gtk_gs_widget_event), gs);
-
-  gtk_gs_goto_page(gs, gs->current_page);
-}
-
-static void
-gtk_gs_size_request(GtkWidget * widget, GtkRequisition * requisition)
-{
-  GtkGS *gs = GTK_GS(widget);
-
-  compute_size(gs);
-  requisition->width = gs->width;
-  requisition->height = gs->height;
-}
-
-static void
-gtk_gs_size_allocate(GtkWidget * widget, GtkAllocation * allocation)
-{
-  GtkGS *gs = GTK_GS(widget);
-  GdkEventConfigure event;
-
-  g_return_if_fail(widget != NULL);
-  g_return_if_fail(GTK_IS_GS(widget));
-  g_return_if_fail(allocation != NULL);
-
-  widget->allocation = *allocation;
-  if(GTK_WIDGET_REALIZED(widget)) {
-    gdk_window_move_resize(widget->window,
-                           allocation->x, allocation->y,
-                           allocation->width, allocation->height);
-
-    event.type = GDK_CONFIGURE;
-    event.window = widget->window;
-    event.x = allocation->x;
-    event.y = allocation->y;
-    event.width = allocation->width;
-    event.height = allocation->height;
-    gtk_widget_event(widget, (GdkEvent *) & event);
-  }
-
-  /* 
-   * update the adjustment if necessary (ie. a resize);
-   */
-#if 0
-  if(gs->zoom_mode != GTK_GS_ZOOM_ABSOLUTE) {
-    gtk_gs_set_zoom(gs, 0.0);
-  }
-#endif
-
-  if(GTK_WIDGET_REALIZED(gs)) {
-    gtk_gs_munge_adjustments(gs);
-  }
-
-  gtk_gs_goto_page(gs, gs->current_page);
-}
-
-static gboolean
-gtk_gs_widget_event(GtkWidget * widget, GdkEvent * event, gpointer data)
-{
-  GtkGS *gs = (GtkGS *) data;
-  if(event->type != GDK_CLIENT_EVENT)
-    return FALSE;
-
-  /* the first long is the window to communicate with gs,
-     only if event if client_event */
-  gs->message_window = event->client.data.l[0];
-
-  if(event->client.message_type == gs_class->page_atom) {
-    gs->busy = FALSE;
-  }
-  return TRUE;
-}
-
-
 static void
 gtk_gs_value_adjustment_changed(GtkAdjustment * adjustment, gpointer data)
 {
+#if 0
   GtkGS *gs;
   gint x, y, width, height, depth;
   gint newx, newy;
@@ -744,6 +505,7 @@ gtk_gs_value_adjustment_changed(GtkAdjustment * adjustment, gpointer data)
     newy = -gs->vadj->value * gs->height;
 
   gdk_window_move(gs->pstarget, newx, newy);
+#endif
 }
 
 void
@@ -1540,7 +1302,7 @@ compute_size(GtkGS * gs)
          && gs->height > 0)
         gdk_window_show(gs->pstarget);
     }
-    gtk_gs_munge_adjustments(gs);
+    //gtk_gs_munge_adjustments(gs);
   }
 
   return (change);
@@ -1583,36 +1345,47 @@ gtk_gs_get_type(void)
       (GInstanceInitFunc) gtk_gs_init
     };
 
+    static const GInterfaceInfo document_info =
+    {
+        (GInterfaceInitFunc) ps_document_document_iface_init,
+        NULL,
+        NULL
+    };
+
     gs_type = g_type_register_static(gtk_widget_get_type(),
                                      "GtkGS", &gs_info, 0);
+
+    g_type_add_interface_static (gs_type,
+                                 EV_TYPE_DOCUMENT,
+                                 &document_info);
   }
   return gs_type;
 
 
 }
 
-GtkWidget *
+GObject *
 gtk_gs_new(GtkAdjustment * hadj, GtkAdjustment * vadj)
 {
-  GtkGS *gs;
+  GObject *gs;
 
   if(NULL == hadj)
     hadj = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 1.0, 0.01, 0.1, 0.09));
   if(NULL == vadj)
     vadj = GTK_ADJUSTMENT(gtk_adjustment_new(0.0, 0.0, 1.0, 0.01, 0.1, 0.09));
 
-  gs = (GtkGS *) gtk_type_new(gtk_gs_get_type());
+  gs = g_object_new(GTK_GS_TYPE, NULL);
 
-  gtk_gs_set_adjustments(gs, hadj, vadj);
+  //gtk_gs_set_adjustments(gs, hadj, vadj);
 
-  return GTK_WIDGET(gs);
+  return gs;
 }
 
 
-GtkWidget *
+GObject *
 gtk_gs_new_from_file(GtkAdjustment * hadj, GtkAdjustment * vadj, char *fname)
 {
-  GtkWidget *gs = gtk_gs_new(hadj, vadj);
+  GObject *gs = gtk_gs_new(hadj, vadj);
   gtk_gs_load(GTK_GS(gs), fname);
   return gs;
 }
@@ -1652,6 +1425,7 @@ gtk_gs_emit_error_msg(GtkGS * gs, const gchar * msg)
 void
 gtk_gs_center_page(GtkGS * gs)
 {
+#if 0
   g_return_if_fail(gs != NULL);
   g_return_if_fail(GTK_IS_GS(gs));
 
@@ -1666,6 +1440,7 @@ gtk_gs_center_page(GtkGS * gs)
   gs->vadj->value = 0.5 - gs->vadj->page_size / 2;
   gtk_adjustment_changed(gs->hadj);
   gtk_adjustment_changed(gs->vadj);
+#endif
 }
 
 void
@@ -1794,7 +1569,6 @@ gtk_gs_load(GtkGS * gs, const gchar * fname)
     }
   }
   gtk_gs_set_page_size(gs, -1, gs->current_page);
-  gtk_widget_queue_resize(&(gs->widget));
   gs->loaded = TRUE;
 
   gs->gs_status = _("Document loaded.");
@@ -2044,7 +1818,7 @@ gtk_gs_set_page_size(GtkGS * gs, gint new_pagesize, gint pageid)
   if(gs->changed) {
     if(GTK_WIDGET_REALIZED(gs)) {
       set_up_page(gs);
-      gtk_widget_queue_resize(&(gs->widget));
+      //gtk_widget_queue_resize(&(gs->widget));
     }
     return TRUE;
   }
@@ -2071,7 +1845,7 @@ gtk_gs_set_override_orientation(GtkGS * gs, gboolean bNewOverride)
     if(GTK_WIDGET_REALIZED(gs))
       set_up_page(gs);
   }
-  gtk_widget_queue_resize(&(gs->widget));
+  //gtk_widget_queue_resize(&(gs->widget));
 }
 
 gboolean
@@ -2096,7 +1870,7 @@ gtk_gs_set_override_size(GtkGS * gs, gboolean f)
     if(GTK_WIDGET_REALIZED(gs))
       set_up_page(gs);
   }
-  gtk_widget_queue_resize(&(gs->widget));
+  //gtk_widget_queue_resize(&(gs->widget));
 }
 
 gboolean
@@ -2134,7 +1908,7 @@ gtk_gs_set_zoom(GtkGS * gs, gfloat zoom)
     if(GTK_WIDGET_REALIZED(gs))
       set_up_page(gs);
     gs->changed = TRUE;
-    gtk_widget_queue_resize(&(gs->widget));
+    //gtk_widget_queue_resize(&(gs->widget));
   }
 }
 
@@ -2190,7 +1964,7 @@ gtk_gs_set_default_orientation(GtkGS * gs, gint orientation)
     gs->changed = TRUE;
     if(GTK_WIDGET_REALIZED(gs))
       set_up_page(gs);
-    gtk_widget_queue_resize(&(gs->widget));
+    //gtk_widget_queue_resize(&(gs->widget));
     return TRUE;
   }
 
@@ -2360,8 +2134,8 @@ gtk_gs_start_scroll(GtkGS * gs)
   gdk_window_get_geometry(gs->pstarget, &x, &y, &w, &h, NULL);
   gs->scroll_start_x = MAX(-x, 0);
   gs->scroll_start_y = MAX(-y, 0);
-  gs->scroll_width = MIN(gs->widget.allocation.width - 1, w - 1);
-  gs->scroll_height = MIN(gs->widget.allocation.height - 1, h - 1);
+  //gs->scroll_width = MIN(gs->widget.allocation.width - 1, w - 1);
+  //gs->scroll_height = MIN(gs->widget.allocation.height - 1, h - 1);
 
   if(gs->bpixmap) {
     GdkRectangle rect;
@@ -2621,12 +2395,12 @@ gtk_gs_get_postscript(GtkGS * gs, gint * pages)
     cmd = g_strdup_printf(gtk_gs_defaults_get_convert_pdf_cmd(), tmpn, fname);
     g_free(fname);
     if((system(cmd) == 0) && ggv_file_readable(tmpn)) {
-      GtkWidget *tmp_gs;
+      GObject *tmp_gs;
       tmp_gs = gtk_gs_new_from_file(NULL, NULL, tmpn);
       if(NULL != tmp_gs) {
         if(GTK_GS(tmp_gs)->loaded)
           pscopydoc(sink, tmpn, GTK_GS(tmp_gs)->doc, pages);
-        gtk_widget_destroy(tmp_gs);
+        g_object_unref(tmp_gs);
       }
     }
     g_free(cmd);
@@ -2697,8 +2471,8 @@ gtk_gs_set_adjustments(GtkGS * gs, GtkAdjustment * hadj, GtkAdjustment * vadj)
                      G_CALLBACK(gtk_gs_value_adjustment_changed),
                      (gpointer) gs);
   }
-  if(GTK_WIDGET_REALIZED(gs))
-    gtk_gs_munge_adjustments(gs);
+  //if(GTK_WIDGET_REALIZED(gs))
+    //gtk_gs_munge_adjustments(gs);
 }
 
 
@@ -2738,3 +2512,99 @@ gtk_gs_set_available_size(GtkGS * gs, guint avail_w, guint avail_h)
     gtk_gs_set_zoom(gs, 0.0);
   }
 }
+
+static gboolean
+ps_document_load (EvDocument  *document,
+                  const char  *uri,
+                  GError     **error)
+{
+       return gtk_gs_load (GTK_GS (document), uri);
+}
+
+static int
+ps_document_get_n_pages (EvDocument  *document)
+{
+       return gtk_gs_get_page_count (GTK_GS (document));
+}
+
+static void
+ps_document_set_page (EvDocument  *document,
+                      int          page)
+{
+       gtk_gs_goto_page (GTK_GS (document), page);
+}
+
+static int
+ps_document_get_page (EvDocument  *document)
+{
+       return gtk_gs_get_current_page (GTK_GS (document));
+}
+
+static void
+ps_document_set_target (EvDocument  *document,
+                        GdkDrawable *target)
+{
+       GTK_GS (document)->pstarget = target;
+}
+
+static void
+ps_document_set_scale (EvDocument  *document,
+                       double       scale)
+{
+       gtk_gs_set_zoom (GTK_GS (document), scale);
+}
+
+static void
+ps_document_set_page_offset (EvDocument  *document,
+                             int          x,
+                             int          y)
+{
+}
+
+static void
+ps_document_get_page_size (EvDocument   *document,
+                           int          *width,
+                           int          *height)
+{
+}
+
+static void
+ps_document_render (EvDocument  *document,
+                    int          clip_x,
+                    int          clip_y,
+                    int          clip_width,
+                    int          clip_height)
+{
+       GtkGS *gs = GTK_GS (document);
+
+       start_interpreter(gs);
+       gtk_gs_goto_page(gs, gs->current_page);
+}
+
+static void
+ps_document_begin_find (EvDocument   *document,
+                         const char   *search_string,
+                         gboolean      case_sensitive)
+{
+}
+
+static void
+ps_document_end_find (EvDocument   *document)
+{
+}
+
+static void
+ps_document_document_iface_init (EvDocumentIface *iface)
+{
+       iface->load = ps_document_load;
+       iface->get_n_pages = ps_document_get_n_pages;
+       iface->set_page = ps_document_set_page;
+       iface->get_page = ps_document_get_page;
+       iface->set_scale = ps_document_set_scale;
+       iface->set_target = ps_document_set_target;
+       iface->set_page_offset = ps_document_set_page_offset;
+       iface->get_page_size = ps_document_get_page_size;
+       iface->render = ps_document_render;
+        iface->begin_find = ps_document_begin_find;
+        iface->end_find = ps_document_end_find;
+}
index 35f9bfd59f73f317ae9208ea55550aeffd98fd61..7c0f048e3e42b6d1e2e3726cf059e7bd33de0678 100644 (file)
@@ -37,6 +37,7 @@
 
 G_BEGIN_DECLS
 
+#define GTK_GS_TYPE         (gtk_gs_get_type())
 #define GTK_GS(obj)         GTK_CHECK_CAST (obj, gtk_gs_get_type (), GtkGS)
 #define GTK_GS_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_gs_get_type (), GtkGSClass)
 #define GTK_IS_GS(obj)      GTK_CHECK_TYPE (obj, gtk_gs_get_type())
@@ -60,7 +61,7 @@ typedef enum {
 } GtkGSZoomMode;
 
 struct _GtkGS {
-  GtkWidget widget;             /* the main widget */
+  GtkObject object;             /* the main widget */
   GdkWindow *pstarget;          /* the window passed to gv
                                  * it is a child of widget...
                                  */
@@ -136,7 +137,7 @@ struct _GtkGS {
 };
 
 struct _GtkGSClass {
-  GtkWidgetClass parent_class;
+  GObjectClass parent_class;
   GdkAtom gs_atom;
   GdkAtom gs_colors_atom;
   GdkAtom next_atom;
@@ -169,9 +170,9 @@ struct _GtkGSPaperSize {
 
 GType gtk_gs_get_type(void);
 
-GtkWidget *gtk_gs_new_from_file(GtkAdjustment * hadj, GtkAdjustment * vadj,
+GObject *gtk_gs_new_from_file(GtkAdjustment * hadj, GtkAdjustment * vadj,
                                 gchar * fname);
-GtkWidget *gtk_gs_new(GtkAdjustment * hadj, GtkAdjustment * vadj);
+GObject *gtk_gs_new(GtkAdjustment * hadj, GtkAdjustment * vadj);
 gboolean gtk_gs_load(GtkGS * gs, const gchar * fname);
 void gtk_gs_reload(GtkGS * gs);
 
index a360a946bf746a1fd5c5ac3aac9e37ad093aca81..d51abd14d2a88d5749b5d114db244f7300df7b18 100644 (file)
@@ -5,6 +5,7 @@ INCLUDES=                                       \
        -I$(top_srcdir)/lib                     \
        -I$(top_srcdir)/backend                 \
        -I$(top_srcdir)/pdf/xpdf                \
+       -I$(top_srcdir)/ps                      \
        -DGNOMELOCALEDIR=\"$(datadir)/locale\"  \
        -DGNOMEICONDIR=\""$(datadir)/pixmaps"\" \
        $(SHELL_CFLAGS)                         \
@@ -40,6 +41,7 @@ evince_LDADD=                                         \
        $(SHELL_LIBS)                                   \
        $(top_builddir)/backend/libevbackend.la         \
        $(top_builddir)/pdf/xpdf/libpdfdocument.la      \
+       $(top_builddir)/ps/libgtkgs.la                  \
        $(NULL)
 
 BUILT_SOURCES = ev-marshal.h ev-marshal.c
index dd8723dc8e9fcbb3f99865ad0a67dc423cc1a96c..45535253d2ad349dfc62655d008ca594b6333f3c 100644 (file)
@@ -295,7 +295,7 @@ expose_bin_window (GtkWidget      *widget,
        EvView *view = EV_VIEW (widget);
         int i;
         const EvFindResult *results;
-       
+
        if (view->document)
                ev_document_render (view->document,
                                    event->area.x, event->area.y,
index fb3570a65dd5e18835e5a46a100b1a306f88536d..b23a1a6e8bb714d3fdd7f35139c76f4e308aa9d1 100644 (file)
@@ -36,6 +36,7 @@
 #include "eggfindbar.h"
 
 #include "pdf-document.h"
+#include "gtkgs.h"
 
 #include <glib/gi18n.h>
 #include <gtk/gtk.h>
@@ -214,6 +215,8 @@ ev_window_open (EvWindow *ev_window, const char *uri)
 
        if (!strcmp (mime_type, "application/pdf"))
                document = g_object_new (PDF_TYPE_DOCUMENT, NULL);
+       else if (!strcmp (mime_type, "application/postscript"))
+               document = g_object_new (GTK_GS_TYPE, NULL);
 
        if (document) {
                GError *error = NULL;