2011-11-11 [pawel] 3.7.10cvs83
[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         gint oldsize;
100
101         NoticeView *siginfoview;
102         MimeInfo *siginfo;
103         MimeInfo *spec_part;
104         GtkUIManager *ui_manager;
105         GtkActionGroup *action_group;
106 #ifdef USE_PTHREAD
107         SigCheckData *check_data;
108 #endif
109 };
110
111 struct _MimeViewerFactory
112 {
113         /**
114          * Array of supported content types.
115          * Must be NULL terminated and lower case
116          */
117         gchar **content_types;
118         gint priority;
119         
120         MimeViewer *(*create_viewer) (void);
121 };
122
123 struct _MimeViewer
124 {
125         MimeViewerFactory *factory;
126         
127         GtkWidget       *(*get_widget)          (MimeViewer *);
128         void            (*show_mimepart)        (MimeViewer *, const gchar *infile, MimeInfo *);
129         void            (*clear_viewer)         (MimeViewer *);
130         void            (*destroy_viewer)       (MimeViewer *);
131         gchar           *(*get_selection)       (MimeViewer *);
132         gboolean        (*scroll_page)          (MimeViewer *, gboolean up);
133         void            (*scroll_one_line)      (MimeViewer *, gboolean up);
134         gboolean        (*text_search)          (MimeViewer *, gboolean backward,
135                                                  const gchar *str, 
136                                                  gboolean case_sensitive);
137         void            (*print)                (MimeViewer *);
138         MimeView        *mimeview;
139 };
140
141 #ifdef __cplusplus
142 extern "C" {
143 #endif /* __cplusplus */
144
145
146 MimeView *mimeview_create       (MainWindow     *mainwin);
147 void mimeview_init              (MimeView       *mimeview);
148 void mimeview_show_message      (MimeView       *mimeview,
149                                  MimeInfo       *mimeinfo,
150                                  const gchar    *file);
151 gboolean mimeview_show_part     (MimeView       *mimeview, 
152                                  MimeInfo       *partinfo);
153 void mimeview_destroy           (MimeView       *mimeview);
154 void mimeview_update            (MimeView       *mimeview);
155 void mimeview_clear             (MimeView       *mimeview);
156
157 MimeInfo *mimeview_get_selected_part    (MimeView       *mimeview);
158
159 gboolean mimeview_pass_key_press_event  (MimeView       *mimeview,
160                                          GdkEventKey    *event);
161
162 void mimeview_register_viewer_factory   (MimeViewerFactory *factory);
163 void mimeview_unregister_viewer_factory (MimeViewerFactory *factory);
164 void mimeview_handle_cmd                (MimeView       *mimeview, 
165                                          const gchar    *cmd,
166                                          GdkEventButton *event,
167                                          gpointer        data);
168 void mimeview_select_mimepart_icon      (MimeView       *mimeview, 
169                                          MimeInfo       *partinfo);
170 gboolean mimeview_scroll_page           (MimeView       *mimeview, 
171                                          gboolean        up);
172 void mimeview_scroll_one_line           (MimeView       *mimeview, 
173                                          gboolean        up);
174 gint mimeview_get_selected_part_num     (MimeView       *mimeview);
175 void mimeview_select_part_num           (MimeView       *mimeview, 
176                                          gint            i);
177 gboolean mimeview_has_viewer_for_content_type
178                                         (MimeView       *mimeview,
179                                          const gchar    *content_type);
180 gboolean mimeview_tree_is_empty         (MimeView       *mimeview);
181
182 #ifdef __cplusplus
183 }
184 #endif /* __cplusplus */
185
186 #endif /* __MIMEVIEW_H__ */