]> www.fi.muni.cz Git - evince.git/blobdiff - shell/ev-utils.c
[printing] Fix multipage even/odd printing issues
[evince.git] / shell / ev-utils.c
index 42d81f9b8be8c1b0ce3e4b07f48a6e361ed7b615..540836fde5c2902c0426d73234abc4752672ee2d 100644 (file)
@@ -27,8 +27,6 @@
 #include <math.h>
 #include <glib/gi18n.h>
 
 #include <math.h>
 #include <glib/gi18n.h>
 
-#define PRINT_CONFIG_FILENAME  "ev-print-config.xml"
-
 typedef struct
 {
   int size;
 typedef struct
 {
   int size;
@@ -213,98 +211,6 @@ ev_print_region_contents (GdkRegion *region)
        g_free (rectangles);
 }
 
        g_free (rectangles);
 }
 
-#ifdef WITH_GNOME_PRINT
-gboolean
-using_pdf_printer (GnomePrintConfig *config)
-{
-       const guchar *driver;
-
-       driver = gnome_print_config_get (
-               config, (const guchar *)"Settings.Engine.Backend.Driver");
-
-       if (driver) {
-               if (!strcmp ((const gchar *)driver, "gnome-print-pdf"))
-                       return TRUE;
-               else
-                       return FALSE;
-       }
-
-       return FALSE;
-}
-
-gboolean
-using_postscript_printer (GnomePrintConfig *config)
-{
-       const guchar *driver;
-       const guchar *transport;
-
-       driver = gnome_print_config_get (
-               config, (const guchar *)"Settings.Engine.Backend.Driver");
-
-       transport = gnome_print_config_get (
-               config, (const guchar *)"Settings.Transport.Backend");
-
-       if (driver) {
-               if (!strcmp ((const gchar *)driver, "gnome-print-ps"))
-                       return TRUE;
-               else
-                       return FALSE;
-       } else  if (transport) { /* these transports default to PostScript */
-               if (!strcmp ((const gchar *)transport, "CUPS"))
-                       return TRUE;
-               else if (!strcmp ((const gchar *)transport, "LPD"))
-                       return TRUE;
-               else if (!strcmp ((const gchar *)transport, "PAPI"))
-                       return TRUE;
-       }
-
-       return FALSE;
-}
-
-GnomePrintConfig *
-load_print_config_from_file (void)
-{
-       GnomePrintConfig *print_config = NULL;
-       char *file_name, *contents = NULL;
-
-       file_name = g_build_filename (ev_dot_dir (), PRINT_CONFIG_FILENAME,
-                                     NULL);
-
-       if (g_file_get_contents (file_name, &contents, NULL, NULL)) {
-               print_config = gnome_print_config_from_string (contents, 0);
-               g_free (contents);
-       }
-
-       if (print_config == NULL) {
-               print_config = gnome_print_config_default ();
-       }
-
-       g_free (file_name);
-
-       return print_config;
-}
-
-void
-save_print_config_to_file (GnomePrintConfig *config)
-{
-       char *file_name, *str;
-
-       g_return_if_fail (config != NULL);
-
-       str = gnome_print_config_to_string (config, 0);
-       if (str == NULL) return;
-
-       file_name = g_build_filename (ev_dot_dir (),
-                                     PRINT_CONFIG_FILENAME,
-                                     NULL);
-
-       g_file_set_contents (file_name, str, -1, NULL);
-
-       g_free (file_name);
-       g_free (str);
-}
-#endif /* WITH_GNOME_PRINT */
-
 static void
 ev_gui_sanitise_popup_position (GtkMenu *menu,
                                GtkWidget *widget,
 static void
 ev_gui_sanitise_popup_position (GtkMenu *menu,
                                GtkWidget *widget,
@@ -494,3 +400,43 @@ get_gdk_pixbuf_format_by_extension (gchar *uri)
        return NULL;
 }
 
        return NULL;
 }
 
+#define XDIGIT(c) ((c) <= '9' ? (c) - '0' : ((c) & 0x4F) - 'A' + 10)
+#define HEXCHAR(s) ((XDIGIT (s[1]) << 4) + XDIGIT (s[2]))
+
+static char *
+uri_decoded_copy (const char *part, int length)
+{
+       unsigned char *s, *d;
+       char *decoded = g_strndup (part, length);
+
+       s = d = (unsigned char *)decoded;
+       do {
+               if (*s == '%') {
+                       if (!g_ascii_isxdigit (s[1]) ||
+                           !g_ascii_isxdigit (s[2])) {
+                               g_free (decoded);
+                               return NULL;
+                       }
+                       *d++ = HEXCHAR (s);
+                       s += 2;
+               } else
+                       *d++ = *s;
+       } while (*s++);
+
+       return decoded;
+}
+
+char* escape_uri_for_display (const char *uri)
+{
+       GFile *file;
+       char *disp;
+       char *filename;
+
+       file = g_file_new_for_uri (uri);
+       filename = g_file_get_parse_name (file);
+       disp = uri_decoded_copy (filename, strlen (filename));
+       g_free (filename);
+       g_object_unref (file);
+
+       return disp;
+}