2011-10-31 [pawel] 3.7.10cvs66
[claws.git] / src / mimeview.h
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2011 Hiroyuki Yamamoto and 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
20 #ifndef MIMEVIEW_H
21 #define MIMEVIEW_H
22
23 typedef struct _MimeView                MimeView;
24 typedef struct _MimeViewerFactory       MimeViewerFactory;
25 typedef struct _MimeViewer              MimeViewer;
26
27 #include <glib.h>
28 #include <gdk/gdk.h>
29 #include <gtk/gtk.h>
30 #if !GTK_CHECK_VERSION(3, 0, 0)
31 #include "gtk/gtksctree.h"
32 #endif
33 #ifdef USE_PTHREAD
34 #include <pthread.h>
35 #endif
36
37 #include "textview.h"
38 #include "messageview.h"
39 #include "procmime.h"
40 #include "noticeview.h"
41
42 typedef enum
43 {
44         MIMEVIEW_TEXT,
45         MIMEVIEW_VIEWER
46 } MimeViewType;
47
48 #ifdef USE_PTHREAD
49 typedef struct _SigCheckData SigCheckData;
50 struct _SigCheckData
51 {
52         pthread_t th;
53         pthread_t cancel_th;
54         gboolean th_init;
55         gboolean cancel_th_init;
56
57         MimeInfo *siginfo;
58         gboolean free_after_use;
59         gboolean destroy_mimeview;
60         gboolean timeout;
61 };
62 #endif
63
64 struct _MimeView
65 {
66         GtkWidget *hbox;
67         GtkWidget *paned;
68         GtkWidget *scrolledwin;
69         GtkWidget *ctree;
70         GtkWidget *mime_notebook;
71         GtkWidget *ctree_mainbox;
72         GtkWidget *icon_scroll;
73         GtkWidget *icon_vbox;
74         GtkWidget *icon_mainbox;
75         GtkWidget *mime_toggle;
76         GtkWidget *scrollbutton;
77         MimeViewType type;
78         gboolean ctree_mode;
79
80         GtkWidget *popupmenu;
81
82 #if !GTK_CHECK_VERSION(3, 0, 0)
83         GtkCMCTreeNode *opened;
84 #endif
85
86         TextView *textview;
87         MimeViewer *mimeviewer;
88
89         MessageView *messageview;
90
91         MimeInfo *mimeinfo;
92
93         gchar *file;
94
95         GSList *viewers;
96
97         GtkTargetList *target_list; /* DnD */
98
99         gint icon_count;
100         MainWindow *mainwin;
101 #if !GTK_CHECK_VERSION(2,12,0)
102         GtkTooltips *tooltips;
103 #endif
104         gint oldsize;
105
106         NoticeView *siginfoview;
107         MimeInfo *siginfo;
108         MimeInfo *spec_part;
109         GtkUIManager *ui_manager;
110         GtkActionGroup *action_group;
111 #ifdef USE_PTHREAD
112         SigCheckData *check_data;
113 #endif
114 };
115
116 struct _MimeViewerFactory
117 {
118         /**
119          * Array of supported content types.
120          * Must be NULL terminated and lower case
121          */
122         gchar **content_types;
123         gint priority;
124         
125         MimeViewer *(*create_viewer) (void);
126 };
127
128 struct _MimeViewer
129 {
130         MimeViewerFactory *factory;
131         
132         GtkWidget       *(*get_widget)          (MimeViewer *);
133         void            (*show_mimepart)        (MimeViewer *, const gchar *infile, MimeInfo *);
134         void            (*clear_viewer)         (MimeViewer *);
135         void            (*destroy_viewer)       (MimeViewer *);
136         gchar           *(*get_selection)       (MimeViewer *);
137         gboolean        (*scroll_page)          (MimeViewer *, gboolean up);
138         void            (*scroll_one_line)      (MimeViewer *, gboolean up);
139         gboolean        (*text_search)          (MimeViewer *, gboolean backward,
140                                                  const gchar *str, 
141                                                  gboolean case_sensitive);
142         void            (*print)                (MimeViewer *);
143         MimeView        *mimeview;
144 };
145
146 #ifdef __cplusplus
147 extern "C" {
148 #endif /* __cplusplus */
149
150
151 MimeView *mimeview_create       (MainWindow     *mainwin);
152 void mimeview_init              (MimeView       *mimeview);
153 void mimeview_show_message      (MimeView       *mimeview,
154                                  MimeInfo       *mimeinfo,
155                                  const gchar    *file);
156 gboolean mimeview_show_part     (MimeView       *mimeview, 
157                                  MimeInfo       *partinfo);
158 void mimeview_destroy           (MimeView       *mimeview);
159 void mimeview_update            (MimeView       *mimeview);
160 void mimeview_clear             (MimeView       *mimeview);
161
162 MimeInfo *mimeview_get_selected_part    (MimeView       *mimeview);
163
164 gboolean mimeview_pass_key_press_event  (MimeView       *mimeview,
165                                          GdkEventKey    *event);
166
167 void mimeview_register_viewer_factory   (MimeViewerFactory *factory);
168 void mimeview_unregister_viewer_factory (MimeViewerFactory *factory);
169 void mimeview_handle_cmd                (MimeView       *mimeview, 
170                                          const gchar    *cmd,
171                                          GdkEventButton *event,
172                                          gpointer        data);
173 void mimeview_select_mimepart_icon      (MimeView       *mimeview, 
174                                          MimeInfo       *partinfo);
175 gboolean mimeview_scroll_page           (MimeView       *mimeview, 
176                                          gboolean        up);
177 void mimeview_scroll_one_line           (MimeView       *mimeview, 
178                                          gboolean        up);
179 gint mimeview_get_selected_part_num     (MimeView       *mimeview);
180 void mimeview_select_part_num           (MimeView       *mimeview, 
181                                          gint            i);
182 gboolean mimeview_has_viewer_for_content_type
183                                         (MimeView       *mimeview,
184                                          const gchar    *content_type);
185
186 #ifdef __cplusplus
187 }
188 #endif /* __cplusplus */
189
190 #endif /* __MIMEVIEW_H__ */