a32e03da1c9cf7a8b2fdc912820e9aa7caca9d11
[claws.git] / src / mimeview.h
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2006 Hiroyuki Yamamoto and the Sylpheed-Claws 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         MimeView        *mimeview;
126 };
127
128 #ifdef __cplusplus
129 extern "C" {
130 #endif /* __cplusplus */
131
132
133 MimeView *mimeview_create       (MainWindow     *mainwin);
134 void mimeview_init              (MimeView       *mimeview);
135 void mimeview_show_message      (MimeView       *mimeview,
136                                  MimeInfo       *mimeinfo,
137                                  const gchar    *file);
138 gboolean mimeview_show_part     (MimeView       *mimeview, 
139                                  MimeInfo       *partinfo);
140 void mimeview_destroy           (MimeView       *mimeview);
141 void mimeview_update            (MimeView       *mimeview);
142 void mimeview_clear             (MimeView       *mimeview);
143
144 MimeInfo *mimeview_get_selected_part    (MimeView       *mimeview);
145
146 void mimeview_check_signature           (MimeView       *mimeview);
147 void mimeview_pass_key_press_event      (MimeView       *mimeview,
148                                          GdkEventKey    *event);
149
150 void mimeview_register_viewer_factory   (MimeViewerFactory *factory);
151 void mimeview_unregister_viewer_factory (MimeViewerFactory *factory);
152 void mimeview_handle_cmd                (MimeView       *mimeview, 
153                                          const gchar    *cmd,
154                                          GdkEventButton *event,
155                                          gpointer        data);
156 void mimeview_select_mimepart_icon      (MimeView       *mimeview, 
157                                          MimeInfo       *partinfo);
158
159
160 #ifdef __cplusplus
161 }
162 #endif /* __cplusplus */
163
164 #endif /* __MIMEVIEW_H__ */