b4bf9a0969d660b7146e182530d9f7ef4d1c37ee
[claws.git] / src / mimeview.h
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2007 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 2 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, write to the Free Software
17  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
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/gtkwidget.h>
30 #include <gtk/gtkctree.h>
31 #include <gtk/gtktooltips.h>
32 #ifdef USE_PTHREAD
33 #include <pthread.h>
34 #endif
35
36 #include "textview.h"
37 #include "messageview.h"
38 #include "procmime.h"
39 #include "noticeview.h"
40
41 typedef enum
42 {
43         MIMEVIEW_TEXT,
44         MIMEVIEW_VIEWER
45 } MimeViewType;
46
47 #ifdef USE_PTHREAD
48 typedef struct _SigCheckData SigCheckData;
49 struct _SigCheckData
50 {
51         pthread_t th;
52         MimeInfo *siginfo;
53         gboolean free_after_use;
54         gboolean destroy_mimeview;
55         gboolean timeout;
56 };
57 #endif
58
59 struct _MimeView
60 {
61         GtkWidget *hbox;
62         GtkWidget *paned;
63         GtkWidget *scrolledwin;
64         GtkWidget *ctree;
65         GtkWidget *mime_notebook;
66         GtkWidget *ctree_mainbox;
67         GtkWidget *icon_scroll;
68         GtkWidget *icon_vbox;
69         GtkWidget *icon_mainbox;
70         GtkWidget *mime_toggle;
71         GtkWidget *scrollbutton;
72         MimeViewType type;
73
74         GtkWidget *popupmenu;
75         GtkItemFactory *popupfactory;
76
77         GtkCTreeNode *opened;
78
79         TextView *textview;
80         MimeViewer *mimeviewer;
81
82         MessageView *messageview;
83
84         MimeInfo *mimeinfo;
85
86         gchar *file;
87
88         GSList *viewers;
89
90         GtkTargetList *target_list; /* DnD */
91
92         gint icon_count;
93         MainWindow *mainwin;
94         GtkTooltips *tooltips;
95         gint oldsize;
96
97         NoticeView *siginfoview;
98         MimeInfo *siginfo;
99 #ifdef USE_PTHREAD
100         SigCheckData *check_data;
101 #endif
102         MimeInfo *spec_part;
103 };
104
105 struct _MimeViewerFactory
106 {
107         /**
108          * Array of supported content types.
109          * Must be NULL terminated and lower case
110          */
111         gchar **content_types;
112         gint priority;
113         
114         MimeViewer *(*create_viewer) (void);
115 };
116
117 struct _MimeViewer
118 {
119         MimeViewerFactory *factory;
120         
121         GtkWidget       *(*get_widget)          (MimeViewer *);
122         void            (*show_mimepart)        (MimeViewer *, const gchar *infile, MimeInfo *);
123         void            (*clear_viewer)         (MimeViewer *);
124         void            (*destroy_viewer)       (MimeViewer *);
125         gchar           *(*get_selection)       (MimeViewer *);
126         gboolean        (*scroll_page)          (MimeViewer *, gboolean up);
127         void            (*scroll_one_line)      (MimeViewer *, gboolean up);
128         MimeView        *mimeview;
129 };
130
131 #ifdef __cplusplus
132 extern "C" {
133 #endif /* __cplusplus */
134
135
136 MimeView *mimeview_create       (MainWindow     *mainwin);
137 void mimeview_init              (MimeView       *mimeview);
138 void mimeview_show_message      (MimeView       *mimeview,
139                                  MimeInfo       *mimeinfo,
140                                  const gchar    *file);
141 gboolean mimeview_show_part     (MimeView       *mimeview, 
142                                  MimeInfo       *partinfo);
143 void mimeview_destroy           (MimeView       *mimeview);
144 void mimeview_update            (MimeView       *mimeview);
145 void mimeview_clear             (MimeView       *mimeview);
146
147 MimeInfo *mimeview_get_selected_part    (MimeView       *mimeview);
148
149 void mimeview_check_signature           (MimeView       *mimeview);
150 void mimeview_pass_key_press_event      (MimeView       *mimeview,
151                                          GdkEventKey    *event);
152
153 void mimeview_register_viewer_factory   (MimeViewerFactory *factory);
154 void mimeview_unregister_viewer_factory (MimeViewerFactory *factory);
155 void mimeview_handle_cmd                (MimeView       *mimeview, 
156                                          const gchar    *cmd,
157                                          GdkEventButton *event,
158                                          gpointer        data);
159 void mimeview_select_mimepart_icon      (MimeView       *mimeview, 
160                                          MimeInfo       *partinfo);
161 gboolean mimeview_scroll_page           (MimeView       *mimeview, 
162                                          gboolean        up);
163 void mimeview_scroll_one_line           (MimeView       *mimeview, 
164                                          gboolean        up);
165 gint mimeview_get_selected_part_num     (MimeView       *mimeview);
166 void mimeview_select_part_num           (MimeView       *mimeview, 
167                                          gint            i);
168
169
170 #ifdef __cplusplus
171 }
172 #endif /* __cplusplus */
173
174 #endif /* __MIMEVIEW_H__ */