X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;ds=sidebyside;f=ps%2Fps-document.c;h=8dca8cf663c0e3a31cabe54dc37ecfaa86a439bb;hb=b2e7a9f7c44d07a2af27c8b7a52c9fc4e19f615c;hp=83fa3d9fe93573659b558fadd6d709b87006a6c1;hpb=34af9d3d79512725f33a28299f92f39997290181;p=evince.git diff --git a/ps/ps-document.c b/ps/ps-document.c index 83fa3d9f..8dca8cf6 100644 --- a/ps/ps-document.c +++ b/ps/ps-document.c @@ -178,6 +178,12 @@ ps_document_dispose (GObject *object) 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); @@ -455,32 +461,22 @@ setup_page (PSDocument *gs, int page, double scale) { 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"); -#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); + 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, - get_xdpi (gs) * scale, - get_ydpi (gs) * scale, + scaled_xdpi, scaled_ydpi, 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 (); @@ -1207,15 +1203,13 @@ ps_async_renderer_render_pixbuf (EvAsyncRenderer *renderer, int page, double sca 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_signal_connect (widget, "event", + g_signal_connect (gs->target_window, "event", G_CALLBACK (ps_document_widget_event), gs); } @@ -1234,13 +1228,47 @@ ps_document_get_info (EvDocument *document) 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); + 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; } +static EvOrientation +ps_document_get_orientation (EvDocument *document) +{ + EvOrientation orientation; + PSDocument *ps = PS_DOCUMENT (document); + + g_return_val_if_fail (ps != NULL, EV_ORIENTATION_PORTRAIT); + + switch (ps->orientation) { + case GTK_GS_ORIENTATION_PORTRAIT: + orientation = EV_ORIENTATION_PORTRAIT; + break; + case GTK_GS_ORIENTATION_LANDSCAPE: + orientation = EV_ORIENTATION_LANDSCAPE; + break; + case GTK_GS_ORIENTATION_UPSIDEDOWN: + orientation = EV_ORIENTATION_UPSIDEDOWN; + break; + case GTK_GS_ORIENTATION_SEASCAPE: + orientation = EV_ORIENTATION_SEASCAPE; + break; + default: + orientation = EV_ORIENTATION_PORTRAIT; + break; + } + + return orientation; +} + static void ps_document_set_orientation (EvDocument *document, EvOrientation orientation) { @@ -1249,9 +1277,6 @@ ps_document_set_orientation (EvDocument *document, EvOrientation orientation) g_return_if_fail (ps != NULL); switch (orientation) { - case EV_ORIENTATION_DOCUMENT: - ps->orientation = GTK_GS_ORIENTATION_NONE; - break; case EV_ORIENTATION_PORTRAIT: ps->orientation = GTK_GS_ORIENTATION_PORTRAIT; break; @@ -1277,6 +1302,7 @@ ps_document_document_iface_init (EvDocumentIface *iface) iface->get_page_size = ps_document_get_page_size; iface->get_info = ps_document_get_info; iface->set_orientation = ps_document_set_orientation; + iface->get_orientation = ps_document_get_orientation; } static void