]> www.fi.muni.cz Git - evince.git/blob - ps/ggvutils.c
display an error if the document doesn't support find (better ideas?)
[evince.git] / ps / ggvutils.c
1 /*
2  * ggv-utils.c: misc utility functions
3  *
4  * Copyright 2002 - 2005 The Free Software Foundation
5  *
6  * Author: Jaka Mocnik  <jaka@gnu.org>
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21  */
22
23 #include "config.h"
24
25 #include <glib/gi18n.h>
26 #include <libgnomevfs/gnome-vfs-utils.h>
27
28 #include "ggvutils.h"
29
30 GtkGSPaperSize ggv_paper_sizes[] = {
31   {N_("BBox"), 0, 0},
32   {N_("Letter"), 612, 792,},
33   {N_("Tabloid"), 792, 1224,},
34   {N_("Ledger"), 1224, 792,},
35   {N_("Legal"), 612, 1008,},
36   {N_("Statement"), 396, 612,},
37   {N_("Executive"), 540, 720,},
38   {N_("A0"), 2380, 3368,},
39   {N_("A1"), 1684, 2380,},
40   {N_("A2"), 1190, 1684,},
41   {N_("A3"), 842, 1190,},
42   {N_("A4"), 595, 842,},
43   {N_("A5"), 420, 595,},
44   {N_("B4"), 729, 1032,},
45   {N_("B5"), 516, 729,},
46   {N_("Folio"), 612, 936,},
47   {N_("Quarto"), 610, 780,},
48   {N_("10x14"), 720, 1008,},
49   {NULL, 0, 0}
50 };
51
52 const gchar *ggv_orientation_labels[] = {
53   N_("Portrait"),
54   N_("Landscape"),
55   N_("Upside Down"),
56   N_("Seascape"),
57   NULL,
58 };
59
60 gfloat ggv_zoom_levels[] = {
61   1.0 / 6.0, 1.0 / 5.0, 1.0 / 4.0, 1.0 / 3.0, 1.0 / 2.0, 3.0 / 4.0, 1.0,
62   3.0 / 2.0, 2.0, 3.0, 4.0, 5.0, 6.0
63 };
64
65 const gchar *ggv_zoom_level_names[] = {
66   "1:6", "1:5", "1:4", "1:3",
67   "1:2", "3:4", "1:1", "3:2",
68   "2:1", "3:1", "4:1", "5:1",
69   "6:1",
70 };
71
72 const gint ggv_max_zoom_levels = (sizeof(ggv_zoom_levels) / sizeof(gfloat)) - 1;
73
74 /* If file exists and is a regular file then return its length, else -1 */
75 gint
76 ggv_file_length(const gchar * filename)
77 {
78   struct stat stat_rec;
79
80   if(filename && (stat(filename, &stat_rec) == 0)
81      && S_ISREG(stat_rec.st_mode))
82     return stat_rec.st_size;
83   else
84     return -1;
85 }
86
87 /* Test if file exists, is a regular file and its length is > 0 */
88 gboolean
89 ggv_file_readable(const char *filename)
90 {
91   return (ggv_file_length(filename) > 0);
92 }