]> www.fi.muni.cz Git - evince.git/blobdiff - ps/ps-document.c
Copy-paste g_file_set_contents to keep compatibility with gtk 2.6
[evince.git] / ps / ps-document.c
index 31bb082d622e5b29485b7a2eba7e964f257f7688..cfd22d9d0f0f0eeb910a6916b6502937e51da37e 100644 (file)
@@ -137,6 +137,8 @@ ps_document_init (PSDocument *gs)
 
        gs->ps_export_pagelist = NULL;
        gs->ps_export_filename = NULL;
 
        gs->ps_export_pagelist = NULL;
        gs->ps_export_filename = NULL;
+
+       gs->orientation = GTK_GS_ORIENTATION_NONE;
 }
 
 static void
 }
 
 static void
@@ -176,6 +178,12 @@ ps_document_dispose (GObject *object)
                gs->input_buffer = NULL;
        }
 
                gs->input_buffer = NULL;
        }
 
+       if (gs->target_window) {
+               gtk_widget_destroy (gs->target_window);
+               gs->target_window = NULL;
+               gs->pstarget = NULL;
+       }
+
        stop_interpreter (gs);
 
        G_OBJECT_CLASS (parent_class)->dispose (object);
        stop_interpreter (gs);
 
        G_OBJECT_CLASS (parent_class)->dispose (object);
@@ -441,6 +449,9 @@ get_page_orientation (PSDocument *gs, int page)
        if (orientation == GTK_GS_ORIENTATION_NONE) {
                orientation = GTK_GS_ORIENTATION_PORTRAIT;
        }
        if (orientation == GTK_GS_ORIENTATION_NONE) {
                orientation = GTK_GS_ORIENTATION_PORTRAIT;
        }
+       if (gs->orientation != GTK_GS_ORIENTATION_NONE) {
+               orientation = gs->orientation;
+       }
 
        return orientation;
 }
 
        return orientation;
 }
@@ -450,32 +461,22 @@ setup_page (PSDocument *gs, int page, double scale)
 {
        char buf[1024];
        int urx, ury, llx, lly, orientation;
 {
        char buf[1024];
        int urx, ury, llx, lly, orientation;
-#ifdef HAVE_LOCALE_H
-       char *savelocale;
-#endif
+       char scaled_xdpi[G_ASCII_DTOSTR_BUF_SIZE];      
+       char scaled_ydpi[G_ASCII_DTOSTR_BUF_SIZE];
 
        LOG ("Setup the page");
 
 
        LOG ("Setup the page");
 
-#ifdef HAVE_LOCALE_H
-       /* gs needs floating point parameters with '.' as decimal point
-        * while some (european) locales use ',' instead, so we set the 
-        * locale for this snprintf to "C".
-        */
-       savelocale = setlocale (LC_NUMERIC, "C");
-#endif
        get_page_box (gs, page, &urx, &ury, &llx, &lly);
        orientation = get_page_orientation (gs, page);
        get_page_box (gs, page, &urx, &ury, &llx, &lly);
        orientation = get_page_orientation (gs, page);
+       g_ascii_dtostr (scaled_xdpi, G_ASCII_DTOSTR_BUF_SIZE, get_xdpi (gs) * scale);
+       g_ascii_dtostr (scaled_ydpi, G_ASCII_DTOSTR_BUF_SIZE, get_ydpi (gs) * scale);
 
 
-       g_snprintf (buf, 1024, "%ld %d %d %d %d %d %f %f %d %d %d %d",
+       g_snprintf (buf, 1024, "%ld %d %d %d %d %d %s %s %d %d %d %d",
                    0L, orientation * 90, llx, lly, urx, ury,
                    0L, orientation * 90, llx, lly, urx, ury,
-                   get_xdpi (gs) * scale,
-                   get_ydpi (gs) * scale,
+                   scaled_xdpi, scaled_ydpi,               
                    0, 0, 0, 0);
        LOG ("GS property %s", buf);
 
                    0, 0, 0, 0);
        LOG ("GS property %s", buf);
 
-#ifdef HAVE_LOCALE_H
-       setlocale(LC_NUMERIC, savelocale);
-#endif
        gdk_property_change (gs->pstarget, gs_class->gs_atom, gs_class->string_atom,
                             8, GDK_PROP_MODE_REPLACE, (guchar *)buf, strlen(buf));
        gdk_flush ();
        gdk_property_change (gs->pstarget, gs_class->gs_atom, gs_class->string_atom,
                             8, GDK_PROP_MODE_REPLACE, (guchar *)buf, strlen(buf));
        gdk_flush ();
@@ -1202,15 +1203,13 @@ ps_async_renderer_render_pixbuf (EvAsyncRenderer *renderer, int page, double sca
        PSDocument *gs = PS_DOCUMENT (renderer);
 
        if (gs->pstarget == NULL) {
        PSDocument *gs = PS_DOCUMENT (renderer);
 
        if (gs->pstarget == NULL) {
-               GtkWidget *widget;
-
-               widget = gtk_window_new (GTK_WINDOW_POPUP);
-               gtk_widget_realize (widget);
-               gs->pstarget = widget->window;
+               gs->target_window = gtk_window_new (GTK_WINDOW_POPUP);
+               gtk_widget_realize (gs->target_window);
+               gs->pstarget = gs->target_window->window;
 
                g_assert (gs->pstarget != NULL);
 
 
                g_assert (gs->pstarget != NULL);
 
-               g_signal_connect (widget, "event",
+               g_signal_connect (gs->target_window, "event",
                                  G_CALLBACK (ps_document_widget_event),
                                  gs);
        }
                                  G_CALLBACK (ps_document_widget_event),
                                  gs);
        }
@@ -1229,8 +1228,13 @@ ps_document_get_info (EvDocument *document)
 
        info = g_new0 (EvDocumentInfo, 1);
        info->fields_mask = EV_DOCUMENT_INFO_TITLE |
 
        info = g_new0 (EvDocumentInfo, 1);
        info->fields_mask = EV_DOCUMENT_INFO_TITLE |
+                           EV_DOCUMENT_INFO_FORMAT |
+                           EV_DOCUMENT_INFO_CREATOR |
                            EV_DOCUMENT_INFO_N_PAGES;
        info->title = g_strdup (ps->doc->title);
                            EV_DOCUMENT_INFO_N_PAGES;
        info->title = g_strdup (ps->doc->title);
+       info->format = ps->doc->epsf ? g_strdup (_("Encapsulated PostScript"))
+                                    : g_strdup (_("PostScript"));
+       info->creator = g_strdup (ps->doc->creator);
        info->n_pages = ev_document_get_n_pages (document);
 
        return info;
        info->n_pages = ev_document_get_n_pages (document);
 
        return info;
@@ -1255,7 +1259,8 @@ ps_async_renderer_iface_init (EvAsyncRendererIface *iface)
 
 static void
 ps_document_ps_export_begin (EvPSExporter *exporter, const char *filename,
 
 static void
 ps_document_ps_export_begin (EvPSExporter *exporter, const char *filename,
-                            int first_page, int last_page)
+                            int first_page, int last_page,
+                             double width, double height, gboolean duplex)
 {
        PSDocument *document = PS_DOCUMENT (exporter);
 
 {
        PSDocument *document = PS_DOCUMENT (exporter);
 
@@ -1266,11 +1271,11 @@ ps_document_ps_export_begin (EvPSExporter *exporter, const char *filename,
 }
 
 static void
 }
 
 static void
-ps_document_ps_export_do_page (EvPSExporter *exporter, int page)
+ps_document_ps_export_do_page (EvPSExporter *exporter, EvRenderContext *rc)
 {
        PSDocument *document = PS_DOCUMENT (exporter);
        
 {
        PSDocument *document = PS_DOCUMENT (exporter);
        
-       document->ps_export_pagelist[page] = 1;
+       document->ps_export_pagelist[rc->page] = 1;
 }
 
 static void
 }
 
 static void