1 /*
2  * Claws Mail -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2016 Salvatore De Paolis & the Claws Mail Team
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef POPPLER_VIEWER_H
20 #define POPPLER_VIEWER_H
21 
22 #ifdef HAVE_CONFIG_H
23 #  include "config.h"
24 #endif
25 
26 //#include <unistd.h>
27 #include <stdio.h>
28 #include <gtk/gtk.h>
29 #include <gdk/gdkx.h>
30 #include <gdk/gdkkeysyms.h>
31 #include <poppler.h>
32 #include <version.h>
33 #include <plugin.h>
34 #include <messageview.h>
35 #include <mimeview.h>
36 #include <alertpanel.h>
37 #include <mimeview.h>
38 
39 /*#ifdef USE_PTHREAD
40  *#include <pthread.h>
41  * #endif*/
42 
43 #define ZOOM_FACTOR 0.25
44 #define ROTATION 90
45 #define ALPHA_CHANNEL 60
46 #define SELECTION_COLOR 0xFF00FF
47 
48 static gchar *msg = NULL;
49 
50 struct _PageResult
51 {
52 	GList *results;
53 	gint page_num;
54 };
55 
56 typedef struct _PageResult PageResult;
57 
58 struct _PdfViewer
59 {
60 	MimeViewer			mimeviewer;
61 	GtkWidget			*widgets_table;
62 	GtkWidget			*vbox;
63 	GtkWidget			*hbox;
64 	GtkWidget			*frame_index;
65 	GtkWidget			*pdf_view;
66 	GtkWidget			*scrollwin;
67 	GtkWidget			*scrollwin_index;
68 	GtkWidget			*pdf_view_ebox;
69 	GtkWidget			*icon_type_ebox;
70 	GtkWidget			*icon_type;
71 	GdkPixbuf			*icon_pixbuf;
72 	GtkWidget			*doc_label;
73 	GtkWidget			*cur_page;
74 	GtkWidget			*doc_index_pane;
75 	GtkWidget			*index_list;
76 	/* begin GtkButtons */
77 	GtkWidget			*first_page;
78 	GtkWidget			*last_page;
79 	GtkWidget			*prev_page;
80 	GtkWidget			*next_page;
81 	GtkWidget			*zoom_in;
82 	GtkWidget			*zoom_out;
83 	GtkWidget			*zoom_scroll;
84 	GtkWidget			*zoom_fit;
85 	GtkWidget			*zoom_width;
86 	GtkWidget			*rotate_left;
87 	GtkWidget			*rotate_right;
88 	GtkWidget			*print;
89 	GtkWidget			*doc_info;
90 	GtkWidget			*doc_index;
91 	/* end GtkButtons */
92 	GtkTable			*table_doc_info;
93 
94 	PopplerDocument		*pdf_doc;
95 	PopplerPage			*pdf_page;
96 	PopplerIndexIter	*pdf_index;
97 	PopplerRectangle	*last_rect;
98 	PopplerAction		*link_action;
99 	PageResult			*last_page_result;
100 	GtkAdjustment		*pdf_view_vadj;
101 	GtkAdjustment		*pdf_view_hadj;
102 	GtkTreeModel		*index_model;
103 
104 	GList				*link_map;
105 	GList				*page_results;
106 	GList				*text_found; /* GList of PageResults */
107 	gchar				*last_search;
108 	gint				 last_match;
109 	gint				 num_matches;
110 
111 	gchar				*target_filename;
112 	gchar				*filename;
113 	gchar				*fsname;
114 	gchar				*doc_info_text;
115 
116 	gint				res_cnt;
117 	gint				rotate;
118 	gint				num_pages;
119 	gdouble				zoom;
120 	gdouble				width;
121 	gdouble				height;
122 	gdouble				last_x;
123 	gdouble				last_y;
124 	gint				last_dir_x;
125 	gint				last_dir_y;
126 	gboolean			pdf_view_scroll;
127 	gboolean			in_link;
128 	MimeInfo			*mimeinfo;
129 	MimeInfo			*to_load;
130 
131 };
132 static gchar *content_types[] =
133 	{"application/pdf",
134 	 "application/postscript",
135 	 NULL};
136 typedef enum {
137 	TYPE_UNKNOWN,
138 	TYPE_PDF,
139 	TYPE_PS
140 } FileType;
141 
142 enum {
143 	INDEX_NAME,
144 	INDEX_PAGE,
145 	INDEX_TOP,
146 	N_INDEX_COLUMNS
147 };
148 
149 typedef struct _PdfViewer PdfViewer;
150 
151 #endif /* POPPLER_VIEWER_H */
152