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