#include <stdio.h>
#include <math.h>
-#include "ev-document.h"
#include "ps-document.h"
-#include "ps.h"
#include "gsdefaults.h"
#ifdef HAVE_LOCALE_H
enum { INTERPRETER_MESSAGE, INTERPRETER_ERROR, LAST_SIGNAL };
+enum {
+ PROP_0,
+ PROP_TITLE
+};
+
/* structure to describe section of file to send to ghostscript */
struct record_list {
FILE *fp;
gs->right_margin = 0;
gs->bottom_margin = 0;
+ gs->page_x_offset = 0;
+ gs->page_y_offset = 0;
+
/* Set user defined defaults */
gs->override_orientation = gtk_gs_defaults_get_override_orientation();
gs->fallback_orientation = gtk_gs_defaults_get_orientation();
gs->gs_status = _("No document loaded.");
}
+static void
+ps_document_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ switch (prop_id)
+
+ {
+ case PROP_TITLE:
+ /* read only */
+ break;
+ }
+}
+
+static void
+ps_document_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ PSDocument *ps = PS_DOCUMENT (object);
+
+ switch (prop_id)
+ {
+ case PROP_TITLE:
+ if (ps->doc) {
+ g_value_set_string (value, ps->doc->title);
+ } else {
+ g_value_set_string (value, NULL);
+ }
+ break;
+ }
+}
+
static void
ps_document_class_init(PSDocumentClass * klass)
{
gs_class = klass;
object_class->finalize = ps_document_finalize;
+ object_class->get_property = ps_document_get_property;
+ object_class->set_property = ps_document_set_property;
/* Create atoms */
klass->gs_atom = gdk_atom_intern("GHOSTVIEW", FALSE);
klass->string_atom = gdk_atom_intern("STRING", FALSE);
gtk_gs_defaults_load();
+
+ g_object_class_override_property (object_class, PROP_TITLE, "title");
}
/* Clean all memory and temporal files */
/* we grab the vital statistics!!! */
gs->doc = psscan(gs->gs_psfile, gs->respect_eof, filename);
+ g_object_notify (G_OBJECT (gs), "title");
+
if(gs->doc == NULL) {
/* File does not seem to be a Postscript one */
gchar buf[1024];
if(page == gs->current_page && !gs->changed)
return TRUE;
+ ps_document_set_page_size(gs, -1, page);
+
if(!is_interpreter_ready(gs))
ps_document_enable_interpreter(gs);
return result;
}
+static gboolean
+ps_document_save (EvDocument *document,
+ const char *uri,
+ GError **error)
+{
+ g_warning ("ps_document_save not implemented"); /* FIXME */
+ return TRUE;
+}
+
static int
ps_document_get_n_pages (EvDocument *document)
{
int x,
int y)
{
+ PSDocument *gs = PS_DOCUMENT (document);
+
+ gs->page_x_offset = x;
+ gs->page_y_offset = y;
}
static void
ps_document_get_page_size (EvDocument *document,
- int *width,
- int *height)
+ int page,
+ int *width,
+ int *height)
{
+ /* Post script documents never vary in size */
+
PSDocument *gs = PS_DOCUMENT (document);
if (width) {
int clip_height)
{
PSDocument *gs = PS_DOCUMENT (document);
+ GdkRectangle page;
+ GdkRectangle draw;
GdkGC *gc;
if (gs->pstarget == NULL ||
return;
}
+ page.x = gs->page_x_offset;
+ page.y = gs->page_y_offset;
+ page.width = gs->width;
+ page.height = gs->height;
+
+ draw.x = clip_x;
+ draw.y = clip_y;
+ draw.width = clip_width;
+ draw.height = clip_height;
+
gc = gdk_gc_new (gs->pstarget);
gdk_draw_drawable (gs->pstarget, gc,
gs->bpixmap,
- clip_x, clip_y,
- clip_x, clip_y,
- clip_width, clip_height);
+ draw.x - page.x, draw.y - page.y,
+ draw.x, draw.y,
+ draw.width, draw.height);
g_object_unref (gc);
}
+static char *
+ps_document_get_text (EvDocument *document, GdkRectangle *rect)
+{
+ g_warning ("ps_document_get_text not implemented"); /* FIXME ? */
+ return NULL;
+}
+
+static EvLink *
+ps_document_get_link (EvDocument *document,
+ int x,
+ int y)
+{
+ return NULL;
+}
+
static void
ps_document_document_iface_init (EvDocumentIface *iface)
{
iface->load = ps_document_load;
+ iface->save = ps_document_save;
+ iface->get_text = ps_document_get_text;
+ iface->get_link = ps_document_get_link;
iface->get_n_pages = ps_document_get_n_pages;
iface->set_page = ps_document_set_page;
iface->get_page = ps_document_get_page;