From 710ec65f6202732a44a010339d0770a9c0e46ed2 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Tue, 8 Mar 2005 16:06:22 +0000 Subject: [PATCH] Some more sanitization of the ps backend. Remove a lot of unused code and 2005-03-08 Marco Pesenti Gritti * ps/Makefile.am: * ps/gsdefaults.c: (gtk_gs_defaults_get_interpreter_cmd), (gtk_gs_defaults_get_alpha_parameters), (gtk_gs_defaults_get_ungzip_cmd), (gtk_gs_defaults_get_unbzip2_cmd): * ps/gsdefaults.h: * ps/ps-document.c: (ps_document_init), (ps_document_class_init), (ps_document_get_orientation), (document_load), (ps_document_goto_page), (ps_document_set_page_size): * ps/ps-document.h: Some more sanitization of the ps backend. Remove a lot of unused code and do not base our defaults on ggv preferences (ugh!) --- ChangeLog | 17 ++ ps/Makefile.am | 6 +- ps/gsdefaults.c | 452 +---------------------------------------------- ps/gsdefaults.h | 34 +--- ps/ps-document.c | 151 ++-------------- ps/ps-document.h | 4 - 6 files changed, 39 insertions(+), 625 deletions(-) diff --git a/ChangeLog b/ChangeLog index d528cc4c..6515ec55 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2005-03-08 Marco Pesenti Gritti + + * ps/Makefile.am: + * ps/gsdefaults.c: (gtk_gs_defaults_get_interpreter_cmd), + (gtk_gs_defaults_get_alpha_parameters), + (gtk_gs_defaults_get_ungzip_cmd), + (gtk_gs_defaults_get_unbzip2_cmd): + * ps/gsdefaults.h: + * ps/ps-document.c: (ps_document_init), (ps_document_class_init), + (ps_document_get_orientation), (document_load), + (ps_document_goto_page), (ps_document_set_page_size): + * ps/ps-document.h: + + Some more sanitization of the ps backend. Remove a lot + of unused code and do not base our defaults on ggv + preferences (ugh!) + 2005-03-08 Fernando Herrera * thumbnailer/evince-thumbnailer.schemas: diff --git a/ps/Makefile.am b/ps/Makefile.am index ca949d43..6ebc8960 100644 --- a/ps/Makefile.am +++ b/ps/Makefile.am @@ -10,10 +10,10 @@ noinst_LTLIBRARIES = libgtkgs.la libgtkgs_la_SOURCES = \ gsio.c \ gsio.h \ - gsdefaults.c \ - gsdefaults.h \ gstypes.h \ ps.c \ ps.h \ ps-document.c \ - ps-document.h + ps-document.h \ + gsdefaults.c \ + gsdefaults.h diff --git a/ps/gsdefaults.c b/ps/gsdefaults.c index d20a6c2c..faa4d062 100644 --- a/ps/gsdefaults.c +++ b/ps/gsdefaults.c @@ -22,48 +22,10 @@ #include -#include -#include +#include #include "gsdefaults.h" -#include - -static void gtk_gs_defaults_changed (GConfClient * client, guint cnxn_id, - GConfEntry * entry, gpointer user_data); - -/** - * defaults for GtkGS widgets - **/ - -static GConfClient *gconf_client; - -/* Default values to pass to gtk_gs_init */ -typedef struct _GtkGSDefaults { - gboolean antialiased; - gboolean override_size; - gint default_size; - gboolean override_orientation; - gboolean respect_eof; - gboolean show_scroll_rect; - gint fallback_orientation; - gfloat zoom_factor; - gfloat scroll_step; - gchar *interpreter_cmd; - gchar *alpha_params; - gchar *dsc_cmd; - gchar *convert_pdf_cmd; - gchar *ungzip_cmd; - gchar *unbzip2_cmd; - GtkGSZoomMode zoom_mode; -} GtkGSDefaults; - -static GtkGSDefaults gtk_gs_defaults = { - TRUE, FALSE, 8, FALSE, TRUE, TRUE, - 0, 1.0, 0.25, NULL, NULL, NULL, NULL, NULL, NULL, - GTK_GS_ZOOM_ABSOLUTE -}; - GtkGSPaperSize gtk_gs_paper_sizes[] = { {N_("BBox"), 0, 0}, {N_("Letter"), 612, 792,}, @@ -86,432 +48,32 @@ GtkGSPaperSize gtk_gs_paper_sizes[] = { {NULL, 0, 0} }; -void -gtk_gs_defaults_set_scroll_step(gfloat step) -{ - if(fabs(gtk_gs_defaults.scroll_step - step) > 0.001) { - gtk_gs_defaults.scroll_step = step; - gconf_client_set_float(gconf_client, - "/apps/ggv/gtkgs/scrollstep", - gtk_gs_defaults_get_scroll_step(), NULL); - } -} - -gfloat -gtk_gs_defaults_get_scroll_step() -{ - return gtk_gs_defaults.scroll_step; -} - -void -gtk_gs_defaults_set_size(gint iNewPageSize) -{ - if(gtk_gs_defaults.default_size != iNewPageSize) { - gtk_gs_defaults.default_size = iNewPageSize; - gconf_client_set_int(gconf_client, "/apps/ggv/gtkgs/size", - gtk_gs_defaults_get_size(), NULL); - } -} - -gint -gtk_gs_defaults_get_size() -{ - return gtk_gs_defaults.default_size; -} - -void -gtk_gs_defaults_set_override_size(gboolean bOverrSize) -{ - if(gtk_gs_defaults.override_size != bOverrSize) { - gtk_gs_defaults.override_size = bOverrSize; - gconf_client_set_bool(gconf_client, - "/apps/ggv/gtkgs/override_size", - gtk_gs_defaults_get_override_size(), NULL); - } -} - -gboolean -gtk_gs_defaults_get_override_size() -{ - return gtk_gs_defaults.override_size; -} - -void -gtk_gs_defaults_set_override_orientation(gboolean bOverOrien) -{ - if(gtk_gs_defaults.override_orientation != bOverOrien) { - gtk_gs_defaults.override_orientation = bOverOrien; - gconf_client_set_bool(gconf_client, - "/apps/ggv/gtkgs/override_orientation", - gtk_gs_defaults_get_override_orientation(), NULL); - } -} - -gboolean -gtk_gs_defaults_get_override_orientation() -{ - return gtk_gs_defaults.override_orientation; -} - -void -gtk_gs_defaults_set_antialiased(gint iNewAntialiased) -{ - if(gtk_gs_defaults.antialiased != iNewAntialiased) { - gtk_gs_defaults.antialiased = iNewAntialiased; - gconf_client_set_bool(gconf_client, - "/apps/ggv/gtkgs/antialiasing", - gtk_gs_defaults_get_antialiased(), NULL); - } -} - -gboolean -gtk_gs_defaults_get_antialiased() -{ - return gtk_gs_defaults.antialiased; -} - -void -gtk_gs_defaults_set_zoom_factor(gfloat fZoom) -{ - fZoom = MIN(fZoom, 30.0); - fZoom = MAX(0.05, fZoom); - if(fabs(gtk_gs_defaults.zoom_factor - fZoom) > 0.001) { - gtk_gs_defaults.zoom_factor = fZoom; - gconf_client_set_float(gconf_client, "/apps/ggv/gtkgs/zoom", - gtk_gs_defaults_get_zoom_factor(), NULL); - } -} - -gfloat -gtk_gs_defaults_get_zoom_factor() -{ - return gtk_gs_defaults.zoom_factor; -} - -void -gtk_gs_defaults_set_orientation(gint iNewOrientation) -{ - g_assert((iNewOrientation == GTK_GS_ORIENTATION_PORTRAIT) || - (iNewOrientation == GTK_GS_ORIENTATION_LANDSCAPE) || - (iNewOrientation == GTK_GS_ORIENTATION_UPSIDEDOWN) || - (iNewOrientation == GTK_GS_ORIENTATION_SEASCAPE)); - if(gtk_gs_defaults.fallback_orientation != iNewOrientation) { - gtk_gs_defaults.fallback_orientation = iNewOrientation; - gconf_client_set_int(gconf_client, - "/apps/ggv/gtkgs/orientation", - gtk_gs_defaults_get_orientation(), NULL); - } -} - -gint -gtk_gs_defaults_get_orientation() -{ - return gtk_gs_defaults.fallback_orientation; -} - -void -gtk_gs_defaults_set_respect_eof(gboolean resp) -{ - if(gtk_gs_defaults.respect_eof != resp) { - gtk_gs_defaults.respect_eof = resp; - gconf_client_set_bool(gconf_client, - "/apps/ggv/gtkgs/respect_eof", - gtk_gs_defaults_get_respect_eof(), NULL); - } -} - -gboolean -gtk_gs_defaults_get_respect_eof() -{ - return gtk_gs_defaults.respect_eof; -} - GtkGSPaperSize * gtk_gs_defaults_get_paper_sizes() { return gtk_gs_paper_sizes; } -gboolean -gtk_gs_defaults_get_show_scroll_rect() -{ - return gtk_gs_defaults.show_scroll_rect; -} - -void -gtk_gs_defaults_set_show_scroll_rect(gboolean f) -{ - if(gtk_gs_defaults.show_scroll_rect != f) { - gtk_gs_defaults.show_scroll_rect = f; - gconf_client_set_bool(gconf_client, - "/apps/ggv/gtkgs/show_scroll_rect", - gtk_gs_defaults_get_show_scroll_rect(), NULL); - } -} - const gchar * gtk_gs_defaults_get_interpreter_cmd() { - if(!gtk_gs_defaults.interpreter_cmd) return GS_PATH; - return gtk_gs_defaults.interpreter_cmd; -} - -const gchar * -gtk_gs_defaults_get_alpha_parameters() -{ - if(!gtk_gs_defaults.alpha_params) - return ALPHA_PARAMS; - return gtk_gs_defaults.alpha_params; } const gchar * -gtk_gs_defaults_get_convert_pdf_cmd() +gtk_gs_defaults_get_alpha_parameters (void) { - if(!gtk_gs_defaults.convert_pdf_cmd) - return GS_PATH - " -q -dNOPAUSE -dBATCH -dSAFER" - " -dQUIET -sDEVICE=pswrite" " -sOutputFile=%s -c save pop -f %s"; - return gtk_gs_defaults.convert_pdf_cmd; + return ALPHA_PARAMS; } const gchar * -gtk_gs_defaults_get_dsc_cmd() +gtk_gs_defaults_get_ungzip_cmd (void) { - if(!gtk_gs_defaults.dsc_cmd) - return GS_PATH - " -q -dNODISPLAY -dSAFER -dDELAYSAFER" - " -sDSCname=%s -sPDFname=%s pdf2dsc.ps" " -c quit"; - return gtk_gs_defaults.dsc_cmd; + return "gzip -cd"; } const gchar * -gtk_gs_defaults_get_ungzip_cmd() -{ - if(!gtk_gs_defaults.ungzip_cmd) - return "gzip -cd"; - return gtk_gs_defaults.ungzip_cmd; -} - -const gchar * -gtk_gs_defaults_get_unbzip2_cmd() -{ - if(!gtk_gs_defaults.unbzip2_cmd) - return "bzip2 -cd"; - return gtk_gs_defaults.unbzip2_cmd; -} - -void -gtk_gs_defaults_set_interpreter_cmd(gchar * cmd) -{ - if((NULL == gtk_gs_defaults.interpreter_cmd) || - strcmp(gtk_gs_defaults.interpreter_cmd, cmd)) { - if(gtk_gs_defaults.interpreter_cmd) - g_free(gtk_gs_defaults.interpreter_cmd); - gtk_gs_defaults.interpreter_cmd = cmd; - gconf_client_set_string(gconf_client, - "/apps/ggv/gtkgs/interpreter", - gtk_gs_defaults_get_interpreter_cmd(), NULL); - } -} - -void -gtk_gs_defaults_set_alpha_parameters(gchar * par) -{ - if((NULL == gtk_gs_defaults.alpha_params) || - strcmp(gtk_gs_defaults.alpha_params, par)) { - if(gtk_gs_defaults.alpha_params) - g_free(gtk_gs_defaults.alpha_params); - gtk_gs_defaults.alpha_params = par; - gconf_client_set_string(gconf_client, - "/apps/ggv/gtkgs/alphaparams", - gtk_gs_defaults_get_alpha_parameters(), NULL); - } -} - -void -gtk_gs_defaults_set_convert_pdf_cmd(gchar * cmd) -{ - if((NULL == gtk_gs_defaults.convert_pdf_cmd) || - strcmp(gtk_gs_defaults.convert_pdf_cmd, cmd)) { - if(gtk_gs_defaults.convert_pdf_cmd) - g_free(gtk_gs_defaults.convert_pdf_cmd); - gtk_gs_defaults.convert_pdf_cmd = cmd; - gconf_client_set_string(gconf_client, - "/apps/ggv/gtkgs/convertpdf", - gtk_gs_defaults_get_convert_pdf_cmd(), NULL); - } -} - -void -gtk_gs_defaults_set_dsc_cmd(gchar * cmd) -{ - if((NULL == gtk_gs_defaults.dsc_cmd) || strcmp(gtk_gs_defaults.dsc_cmd, cmd)) { - if(gtk_gs_defaults.dsc_cmd) - g_free(gtk_gs_defaults.dsc_cmd); - gtk_gs_defaults.dsc_cmd = cmd; - gconf_client_set_string(gconf_client, - "/apps/ggv/gtkgs/pdf2dsc", - gtk_gs_defaults_get_dsc_cmd(), NULL); - } -} - -void -gtk_gs_defaults_set_ungzip_cmd(gchar * cmd) -{ - if((NULL == gtk_gs_defaults.ungzip_cmd) || - strcmp(gtk_gs_defaults.ungzip_cmd, cmd)) { - if(gtk_gs_defaults.ungzip_cmd) - g_free(gtk_gs_defaults.ungzip_cmd); - gtk_gs_defaults.ungzip_cmd = cmd; - gconf_client_set_string(gconf_client, - "/apps/ggv/gtkgs/ungzip", - gtk_gs_defaults_get_ungzip_cmd(), NULL); - } -} - -void -gtk_gs_defaults_set_unbzip2_cmd(gchar * cmd) -{ - if((NULL == gtk_gs_defaults.unbzip2_cmd) || - strcmp(gtk_gs_defaults.unbzip2_cmd, cmd)) { - if(gtk_gs_defaults.unbzip2_cmd) - g_free(gtk_gs_defaults.unbzip2_cmd); - gtk_gs_defaults.unbzip2_cmd = cmd; - gconf_client_set_string(gconf_client, - "/apps/ggv/gtkgs/unbzip2", - gtk_gs_defaults_get_unbzip2_cmd(), NULL); - } -} - -GtkGSZoomMode -gtk_gs_defaults_get_zoom_mode() -{ - return gtk_gs_defaults.zoom_mode; -} - -void -gtk_gs_defaults_set_zoom_mode(GtkGSZoomMode zoom_mode) -{ - if(gtk_gs_defaults.zoom_mode != zoom_mode) { - gtk_gs_defaults.zoom_mode = zoom_mode; - gconf_client_set_int(gconf_client, "/apps/ggv/gtkgs/zoommode", - gtk_gs_defaults_get_zoom_mode(), NULL); - } -} - -static GConfClient * -gtk_gs_defaults_gconf_client() -{ - if(!gconf_client) { - g_assert(gconf_is_initialized()); - gconf_client = gconf_client_get_default(); - g_assert(gconf_client != NULL); - gconf_client_add_dir(gconf_client, "/apps/ggv/gtkgs", - GCONF_CLIENT_PRELOAD_RECURSIVE, NULL); - gconf_client_notify_add(gconf_client, - "/apps/ggv/gtkgs", (GConfClientNotifyFunc) - gtk_gs_defaults_changed, NULL, NULL, NULL); - } - - return gconf_client; -} - -void -gtk_gs_defaults_load() -{ - gtk_gs_defaults_gconf_client(); - - gtk_gs_defaults.respect_eof = - (gconf_client_get_bool(gconf_client, "/apps/ggv/gtkgs/respect_eof", NULL)); - gtk_gs_defaults.override_size = - (gconf_client_get_bool(gconf_client, "/apps/ggv/gtkgs/override_size", - NULL)); - gtk_gs_defaults.override_orientation = - (gconf_client_get_bool - (gconf_client, "/apps/ggv/gtkgs/override_orientation", NULL)); - gtk_gs_defaults.antialiased = - (gconf_client_get_bool(gconf_client, "/apps/ggv/gtkgs/antialiasing", NULL)); - gtk_gs_defaults.default_size = - (gconf_client_get_int(gconf_client, "/apps/ggv/gtkgs/size", NULL)); - gtk_gs_defaults.zoom_factor = - (gconf_client_get_float(gconf_client, "/apps/ggv/gtkgs/zoom", NULL)); - gtk_gs_defaults.fallback_orientation = - (gconf_client_get_int(gconf_client, "/apps/ggv/gtkgs/orientation", NULL)); - gtk_gs_defaults.interpreter_cmd = - (gconf_client_get_string - (gconf_client, "/apps/ggv/gtkgs/interpreter", NULL)); - gtk_gs_defaults.alpha_params = - (gconf_client_get_string - (gconf_client, "/apps/ggv/gtkgs/alphaparams", NULL)); - gtk_gs_defaults.convert_pdf_cmd = - (gconf_client_get_string(gconf_client, "/apps/ggv/gtkgs/convertpdf", NULL)); - gtk_gs_defaults.dsc_cmd = - (gconf_client_get_string(gconf_client, "/apps/ggv/gtkgs/pdf2dsc", NULL)); - gtk_gs_defaults.ungzip_cmd = - (gconf_client_get_string(gconf_client, "/apps/ggv/gtkgs/ungzip", NULL)); - gtk_gs_defaults.unbzip2_cmd = - (gconf_client_get_string(gconf_client, "/apps/ggv/gtkgs/unbzip2", NULL)); - gtk_gs_defaults.show_scroll_rect = - (gconf_client_get_bool - (gconf_client, "/apps/ggv/gtkgs/show_scroll_rect", NULL)); - gtk_gs_defaults.scroll_step = - (gconf_client_get_float(gconf_client, "/apps/ggv/gtkgs/scrollstep", NULL)); - gtk_gs_defaults.zoom_mode = - (gconf_client_get_int(gconf_client, "/apps/ggv/gtkgs/zoommode", NULL)); -} - -static void -gtk_gs_defaults_changed(GConfClient * client, guint cnxn_id, - GConfEntry * entry, gpointer user_data) +gtk_gs_defaults_get_unbzip2_cmd (void) { - if(!strcmp(entry->key, "/apps/ggv/gtkgs/respect_eof")) - gtk_gs_defaults_set_respect_eof - (gconf_client_get_bool(client, "/apps/ggv/gtkgs/respect_eof", NULL)); - else if(!strcmp(entry->key, "/apps/ggv/gtkgs/override_orientation")) - gtk_gs_defaults_set_override_orientation - (gconf_client_get_bool(client, "/apps/ggv/gtkgs/override_orientation", - NULL)); - else if(!strcmp(entry->key, "/apps/ggv/gtkgs/orientation")) - gtk_gs_defaults_set_orientation - (gconf_client_get_int(client, "/apps/ggv/gtkgs/orientation", NULL)); - else if(!strcmp(entry->key, "/apps/ggv/gtkgs/zoom")) - gtk_gs_defaults_set_zoom_factor - (gconf_client_get_float(client, "/apps/ggv/gtkgs/zoom", NULL)); - else if(!strcmp(entry->key, "/apps/ggv/gtkgs/size")) - gtk_gs_defaults_set_size - (gconf_client_get_int(client, "/apps/ggv/gtkgs/size", NULL)); - else if(!strcmp(entry->key, "/apps/ggv/gtkgs/antialiasing")) - gtk_gs_defaults_set_antialiased - (gconf_client_get_bool(client, "/apps/ggv/gtkgs/antialiasing", NULL)); - else if(!strcmp(entry->key, "/apps/ggv/gtkgs/override_size")) - gtk_gs_defaults_set_override_size - (gconf_client_get_bool(client, "/apps/ggv/gtkgs/override_size", NULL)); - else if(!strcmp(entry->key, "/apps/ggv/gtkgs/show_scroll_rect")) - gtk_gs_defaults_set_show_scroll_rect - (gconf_client_get_bool(client, "/apps/ggv/gtkgs/show_scroll_rect", NULL)); - else if(!strcmp(entry->key, "/apps/ggv/gtkgs/interpreter")) - gtk_gs_defaults_set_interpreter_cmd - (gconf_client_get_string(client, "/apps/ggv/gtkgs/interpreter", NULL)); - else if(!strcmp(entry->key, "/apps/ggv/gtkgs/alphaparams")) - gtk_gs_defaults_set_alpha_parameters - (gconf_client_get_string(client, "/apps/ggv/gtkgs/alphaparams", NULL)); - else if(!strcmp(entry->key, "/apps/ggv/gtkgs/convertpdf")) - gtk_gs_defaults_set_convert_pdf_cmd - (gconf_client_get_string(client, "/apps/ggv/gtkgs/convertpdf", NULL)); - else if(!strcmp(entry->key, "/apps/ggv/gtkgs/pdf2dsc")) - gtk_gs_defaults_set_dsc_cmd - (gconf_client_get_string(client, "/apps/ggv/gtkgs/pdf2dsc", NULL)); - else if(!strcmp(entry->key, "/apps/ggv/gtkgs/ungzip")) - gtk_gs_defaults_set_ungzip_cmd - (gconf_client_get_string(client, "/apps/ggv/gtkgs/ungzip", NULL)); - else if(!strcmp(entry->key, "/apps/ggv/gtkgs/unbzip2")) - gtk_gs_defaults_set_unbzip2_cmd - (gconf_client_get_string(client, "/apps/ggv/gtkgs/unbzip2", NULL)); - else if(!strcmp(entry->key, "/apps/ggv/gtkgs/zoommode")) - gtk_gs_defaults_set_zoom_mode - (gconf_client_get_int(client, "/apps/ggv/gtkgs/zoommode", NULL)); - else if(!strcmp(entry->key, "/apps/ggv/gtkgs/scrollstep")) - gtk_gs_defaults_set_scroll_step - (gconf_client_get_float(client, "/apps/ggv/gtkgs/scrollstep", NULL)); + return "bzip2 -cd"; } diff --git a/ps/gsdefaults.h b/ps/gsdefaults.h index 0b211c36..e8f47798 100644 --- a/ps/gsdefaults.h +++ b/ps/gsdefaults.h @@ -29,42 +29,12 @@ G_BEGIN_DECLS /* defaults accessors */ -void gtk_gs_defaults_set_size(gint iNewPageSize); -void gtk_gs_defaults_set_override_size(gboolean bOverrSize); -void gtk_gs_defaults_set_antialiased(gint iNewAntialiased); -void gtk_gs_defaults_set_orientation(gint); -void gtk_gs_defaults_set_override_orientation(gboolean bOverOrien); -void gtk_gs_defaults_set_zoom_factor(gfloat fZoom); -void gtk_gs_defaults_set_respect_eof(gboolean resp); -void gtk_gs_defaults_set_scroll_step(gfloat step); -void gtk_gs_defaults_set_show_scroll_rect(gboolean f); -gint gtk_gs_defaults_get_size(void); -gboolean gtk_gs_defaults_get_override_size(void); -gboolean gtk_gs_defaults_get_antialiased(void); -gint gtk_gs_defaults_get_orientation(void); -gboolean gtk_gs_defaults_get_override_orientation(void); -gfloat gtk_gs_defaults_get_zoom_factor(void); -gboolean gtk_gs_defaults_get_respect_eof(void); -gfloat gtk_gs_defaults_get_scroll_step(void); -gboolean gtk_gs_defaults_get_show_scroll_rect(void); + GtkGSPaperSize *gtk_gs_defaults_get_paper_sizes(void); const gchar *gtk_gs_defaults_get_interpreter_cmd(void); -const gchar *gtk_gs_defaults_get_convert_pdf_cmd(void); -const gchar *gtk_gs_defaults_get_dsc_cmd(void); +const gchar *gtk_gs_defaults_get_alpha_parameters(void); const gchar *gtk_gs_defaults_get_ungzip_cmd(void); const gchar *gtk_gs_defaults_get_unbzip2_cmd(void); -const gchar *gtk_gs_defaults_get_alpha_parameters(void); -void gtk_gs_defaults_set_interpreter_cmd(gchar *); -void gtk_gs_defaults_set_convert_pdf_cmd(gchar *); -void gtk_gs_defaults_set_dsc_cmd(gchar *); -void gtk_gs_defaults_set_ungzip_cmd(gchar *); -void gtk_gs_defaults_set_unbzip2_cmd(gchar *); -void gtk_gs_defaults_set_alpha_parameters(gchar *); -GtkGSZoomMode gtk_gs_defaults_get_zoom_mode(void); -void gtk_gs_defaults_set_zoom_mode(GtkGSZoomMode zoom_mode); - -/* prefs IO */ -void gtk_gs_defaults_load(void); G_END_DECLS diff --git a/ps/ps-document.c b/ps/ps-document.c index 4d56721b..958d7687 100644 --- a/ps/ps-document.c +++ b/ps/ps-document.c @@ -278,14 +278,11 @@ ps_document_init(PSDocument * gs) 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->zoom_factor = gtk_gs_defaults_get_zoom_factor(); - gs->default_size = gtk_gs_defaults_get_size(); - gs->antialiased = gtk_gs_defaults_get_antialiased(); - gs->override_size = gtk_gs_defaults_get_override_size(); - gs->respect_eof = gtk_gs_defaults_get_respect_eof(); - gs->zoom_mode = gtk_gs_defaults_get_zoom_mode(); + gs->fallback_orientation = GTK_GS_ORIENTATION_PORTRAIT; + gs->zoom_factor = 1.0; + gs->default_size = 1; + gs->antialiased = TRUE; + gs->respect_eof = TRUE; gs->gs_status = _("No document loaded."); } @@ -344,8 +341,6 @@ ps_document_class_init(PSDocumentClass *klass) klass->page_atom = gdk_atom_intern("PAGE", FALSE); klass->string_atom = gdk_atom_intern("STRING", FALSE); - gtk_gs_defaults_load(); - g_object_class_override_property (object_class, PROP_TITLE, "title"); } @@ -530,8 +525,7 @@ ps_document_get_orientation(PSDocument * gs) gs->real_orientation = gs->doc->orientation; } - if(gs->override_orientation || - gs->real_orientation == GTK_GS_ORIENTATION_NONE) + if(gs->real_orientation == GTK_GS_ORIENTATION_NONE) return gs->fallback_orientation; else return gs->real_orientation; @@ -1090,113 +1084,6 @@ check_filecompressed(PSDocument * gs) return filename_unc; } -/* - * Check if gs->gs_filename or gs->gs_filename_unc is a pdf file and scan - * pdf file if necessary. - * Set gs->filename_dsc to the name of the dsc file or NULL. - * Error reporting via signal 'interpreter_message'. - */ -static gchar * -check_pdf(PSDocument * gs) -{ - FILE *file; - gchar buf[1024], *filename; - int fd; - - /* use uncompressed file as input if necessary */ - filename = (gs->gs_filename_unc ? gs->gs_filename_unc : gs->gs_filename); - - if((file = fopen(filename, "r")) - && (fread(buf, sizeof(char), 5, file) == 5) - && (strncmp(buf, "%PDF-", 5) == 0)) { - /* we found a PDF file */ - gchar *fname, *filename_dsc, *filename_err, *cmd, *cmdline; - filename_dsc = g_strconcat(g_get_tmp_dir(), "/ggvXXXXXX", NULL); - if((fd = mkstemp(filename_dsc)) < 0) { - return NULL; - } - close(fd); - filename_err = g_strconcat(g_get_tmp_dir(), "/ggvXXXXXX", NULL); - if((fd = mkstemp(filename_err)) < 0) { - g_free(filename_dsc); - return NULL; - } - close(fd); - fname = g_shell_quote(filename); - cmd = g_strdup_printf(gtk_gs_defaults_get_dsc_cmd(), filename_dsc, fname); - g_free(fname); - /* this command (sometimes?) prints error messages to stdout! */ - cmdline = g_strdup_printf("%s >%s 2>&1", cmd, filename_err); - g_free(cmd); - - if((system(cmdline) == 0) && file_readable(filename_dsc)) { - - /* success */ - filename = gs->gs_filename_dsc = filename_dsc; - - if(file_length(filename_err) > 0) { - gchar *err_msg = " "; - GtkWidget *dialog; - FILE *err; - GdkColor color; - - if((err = fopen(filename_err, "r"))) { - - /* print the content of the file to a message box */ - while(fgets(buf, 1024, err)) - err_msg = g_strconcat(err_msg, buf, NULL); - - /* FIXME The dialog is not yet set to modal, difficult to - * get the parent of the dialog box here - */ - - dialog = gtk_message_dialog_new(NULL, - GTK_DIALOG_MODAL, - GTK_MESSAGE_WARNING, - GTK_BUTTONS_OK, - ("There was an error while scaning the file: %s \n%s"), - gs->gs_filename, err_msg); - - gdk_color_parse("white", &color); - gtk_widget_modify_bg(GTK_WIDGET(dialog), GTK_STATE_NORMAL, &color); - - g_signal_connect(G_OBJECT(dialog), "response", - G_CALLBACK(gtk_widget_destroy), NULL); - - gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE); - gtk_widget_show(dialog); - g_free(err_msg); - } - } - - } - else { - /* report error */ - g_snprintf(buf, 1024, - _("Error while converting pdf file %s:\n"), filename); - ps_document_emit_error_msg(gs, buf); - - if(file_length(filename_err) > 0) { - FILE *err; - if((err = fopen(filename_err, "r"))) { - /* print file to message window */ - while(fgets(buf, 1024, err)) - ps_document_emit_error_msg(gs, buf); - } - } - unlink(filename_dsc); - g_free(filename_dsc); - filename = NULL; - } - unlink(filename_err); - g_free(filename_err); - g_free(cmdline); - } - if(NULL != file) - fclose(file); - return filename; -} - #ifdef BROKEN_XINERAMA_PATCH_THAT_SHOULD_NOT_BE_USED /* never mind this patch: a properly working X server should take care of calculating the proper values. */ @@ -1409,8 +1296,6 @@ document_load(PSDocument * gs, const gchar * fname) } else { filename = check_filecompressed(gs); - if(filename) - filename = check_pdf(gs); } if(!filename || (gs->gs_psfile = fopen(filename, "r")) == NULL) { @@ -1440,22 +1325,7 @@ document_load(PSDocument * gs, const gchar * fname) } /* We have to set up the orientation of the document */ - - - /* orientation can only be portrait, and landscape or none. - This is the document default. A document can have - pages in landscape and some in portrait */ - if(gs->override_orientation) { - /* If the orientation should be override... - then gs->orientation has already the correct - value (it was set when the widget was created */ - /* So do nothing */ - - } - else { - /* Otherwise, set the proper orientation for the doc */ - gs->real_orientation = gs->doc->orientation; - } + gs->real_orientation = gs->doc->orientation; } ps_document_set_page_size(gs, -1, gs->current_page); gs->loaded = TRUE; @@ -1529,7 +1399,6 @@ ps_document_goto_page(PSDocument * gs, gint page) gs->current_page = page; if(gs->doc->pages[page].orientation != NONE && - !gs->override_orientation && gs->doc->pages[page].orientation != gs->real_orientation) { gs->real_orientation = gs->doc->pages[page].orientation; gs->changed = TRUE; @@ -1603,7 +1472,7 @@ ps_document_set_page_size(PSDocument * gs, gint new_pagesize, gint pageid) if(new_pagesize == -1) { if(gs->default_size > 0) new_pagesize = gs->default_size; - if(!gs->override_size && gs->doc) { + if(gs->doc) { /* If we have a document: We use -- the page size (if specified) or the doc. size (if specified) @@ -1634,7 +1503,7 @@ ps_document_set_page_size(PSDocument * gs, gint new_pagesize, gint pageid) } /* Compute bounding box */ - if(gs->doc && ((gs->doc->epsf && !gs->override_size) || new_pagesize == -1)) { /* epsf or bbox */ + if(gs->doc && (gs->doc->epsf || new_pagesize == -1)) { /* epsf or bbox */ if((pageid >= 0) && (gs->doc->pages) && (gs->doc->pages[pageid].boundingbox[URX] > @@ -1660,7 +1529,7 @@ ps_document_set_page_size(PSDocument * gs, gint new_pagesize, gint pageid) if(new_pagesize < 0) new_pagesize = gs->default_size; new_llx = new_lly = 0; - if(gs->doc && !gs->override_size && gs->doc->size && + if(gs->doc && gs->doc->size && (new_pagesize < gs->doc->numsizes)) { new_urx = gs->doc->size[new_pagesize].width; new_ury = gs->doc->size[new_pagesize].height; diff --git a/ps/ps-document.h b/ps/ps-document.h index 5bdd2823..f7c8e92d 100644 --- a/ps/ps-document.h +++ b/ps/ps-document.h @@ -47,8 +47,6 @@ struct _PSDocument { */ GdkGC *psgc; - GtkGSZoomMode zoom_mode; - GdkPixmap *bpixmap; /* Backing pixmap */ long message_window; /* Used by ghostview to receive messages from app */ @@ -98,9 +96,7 @@ struct _PSDocument { gboolean antialiased; /* Using antialiased display */ gboolean respect_eof; /* respect EOF comments? */ gint default_size; - gboolean override_size; gfloat xdpi, ydpi; - gboolean override_orientation; gint fallback_orientation; /* Orientation to use if override */ gint real_orientation; /* Real orientation from the document */ -- 2.43.5