2007-01-17 [colin] 2.7.1cvs16
[claws.git] / src / mainwindow.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 __MAINWINDOW_H__
21 #define __MAINWINDOW_H__
22
23 #include <glib.h>
24
25 typedef struct _MainWindow  MainWindow;
26
27 #include "folderview.h"
28 #include "summaryview.h"
29 #include "headerview.h"
30 #include "messageview.h"
31 #include "logwindow.h"
32 #include "toolbar.h"
33
34 #define OFFLINE_SWITCH_HOOKLIST "offline_switch"
35 #define ACCOUNT_LIST_CHANGED_HOOKLIST "account_list_changed"
36
37 typedef enum
38 {
39         M_UNLOCKED            = 1 << 0,
40         M_MSG_EXIST           = 1 << 1,
41         M_TARGET_EXIST        = 1 << 2,
42         M_SINGLE_TARGET_EXIST = 1 << 3,
43         M_EXEC                = 1 << 4,
44         M_ALLOW_REEDIT        = 1 << 5,
45         M_HAVE_ACCOUNT        = 1 << 6,
46         M_THREADED            = 1 << 7,
47         M_UNTHREADED          = 1 << 8,
48         M_ALLOW_DELETE        = 1 << 9,
49         M_INC_ACTIVE          = 1 << 10,
50         M_NEWS                = 1 << 11,
51         M_HAVE_NEWS_ACCOUNT   = 1 << 12,
52         M_HIDE_READ_MSG       = 1 << 13,
53         M_DELAY_EXEC          = 1 << 14,
54         M_NOT_NEWS            = 1 << 15,
55         M_CAN_LEARN_SPAM      = 1 << 16,
56         M_ACTIONS_EXIST       = 1 << 17,
57         M_HAVE_QUEUED_MAILS   = 1 << 18,
58         M_WANT_SYNC           = 1 << 19
59 } SensitiveCond;
60
61 typedef enum
62 {
63         SEPARATE_NONE    = 0,
64         SEPARATE_FOLDER  = 1 << 0,
65         SEPARATE_MESSAGE = 1 << 1,
66         SEPARATE_BOTH    = (SEPARATE_FOLDER | SEPARATE_MESSAGE)
67 } SeparateType;
68
69 typedef enum
70 {
71         TOOLBAR_NONE            = 0,
72         TOOLBAR_ICON            = 1,
73         TOOLBAR_TEXT            = 2,
74         TOOLBAR_BOTH            = 3,
75         TOOLBAR_BOTH_HORIZ      = 4
76 } ToolbarStyle;
77
78 struct _MainWindow
79 {
80         SeparateType type;
81
82         union CompositeWin {
83                 struct 
84                 {
85                         GtkWidget *hpaned;
86                         GtkWidget *vpaned;
87                 } sep_none;
88                 struct {
89                         GtkWidget *folderwin;
90                         GtkWidget *vpaned;
91                 } sep_folder;
92                 struct {
93                         GtkWidget *messagewin;
94                         GtkWidget *hpaned;
95                 } sep_message;
96                 struct {
97                         GtkWidget *folderwin;
98                         GtkWidget *messagewin;
99                 } sep_both;
100         } win;
101
102         GtkWidget *window;
103         GtkWidget *vbox;
104         GtkWidget *menubar;
105
106         GtkItemFactory *menu_factory;
107
108         /* Toolbar handlebox */
109         GtkWidget *handlebox;
110         Toolbar *toolbar;
111
112         /* body */
113         GtkWidget *vbox_body;
114         GtkWidget *hbox_stat;
115         GtkWidget *statusbar;
116         GtkWidget *progressbar;
117         GtkWidget *statuslabel;
118         GtkWidget *ac_button;
119         GtkWidget *ac_label;
120         GtkWidget *ac_menu;
121         GtkWidget *online_switch;
122         GtkWidget *offline_switch;
123         GtkWidget *online_pixmap;
124         GtkWidget *offline_pixmap;
125
126         /* context IDs for status bar */
127         gint mainwin_cid;
128         gint folderview_cid;
129         gint summaryview_cid;
130         gint messageview_cid;
131
132         ToolbarStyle toolbar_style;
133
134         guint lock_count;
135         guint menu_lock_count;
136         guint cursor_count;
137
138         FolderView      *folderview;
139         SummaryView     *summaryview;
140         MessageView     *messageview;
141         LogWindow       *logwin;
142
143         gint    progressindicator_hook;
144         
145         GtkWidget       *colorlabel_menu;
146         GtkWidget       *warning_btn;
147         
148 #ifdef HAVE_LIBSM
149         gpointer smc_conn;
150 #endif
151 };
152
153 MainWindow *main_window_create          (SeparateType    type);
154
155 void main_window_destroy                (MainWindow *mainwin);
156
157 void main_window_update_actions_menu    (MainWindow     *mainwin);
158
159 void main_window_cursor_wait            (MainWindow     *mainwin);
160 void main_window_cursor_normal          (MainWindow     *mainwin);
161
162 void main_window_lock                   (MainWindow     *mainwin);
163 void main_window_unlock                 (MainWindow     *mainwin);
164
165 void main_window_reflect_prefs_all_real (gboolean        pixmap_theme_changed);
166 void main_window_reflect_prefs_all      (void);
167 void main_window_reflect_prefs_all_now  (void);
168 void main_window_reflect_prefs_custom_colors(MainWindow         *mainwindow);
169 void main_window_set_summary_column     (void);
170 void main_window_set_folder_column      (void);
171 void main_window_set_account_menu       (GList          *account_list);
172 void main_window_set_account_menu_only_toolbar  (GList          *account_list);
173
174 GtkWidget *main_window_get_folder_window        (MainWindow     *mainwin);
175 GtkWidget *main_window_get_message_window       (MainWindow     *mainwin);
176
177 /* Mailing list support */
178 void main_create_mailing_list_menu      (MainWindow *mainwin, MsgInfo *msginfo);
179 gint mailing_list_get_list_post_mailto  (gchar **url, gchar *mailto, gint maxlen);
180
181 void main_window_separation_change      (MainWindow     *mainwin,
182                                          SeparateType    type);
183
184 void main_window_toggle_message_view    (MainWindow *mainwin);
185
186 void main_window_get_size               (MainWindow     *mainwin);
187 void main_window_get_position           (MainWindow     *mainwin);
188
189 void main_window_progress_on            (MainWindow     *mainwin);
190 void main_window_progress_off           (MainWindow     *mainwin);
191 void main_window_progress_set           (MainWindow     *mainwin,
192                                          gint            cur,
193                                          gint            total);
194
195 void main_window_empty_trash            (MainWindow     *mainwin,
196                                          gboolean        confirm);
197 void main_window_add_mailbox            (MainWindow     *mainwin);
198
199 void main_window_set_menu_sensitive     (MainWindow     *mainwin);
200
201
202 void main_window_show                   (MainWindow     *mainwin);
203 void main_window_hide                   (MainWindow     *mainwin);
204 void main_window_popup                  (MainWindow     *mainwin);
205
206 void main_window_toolbar_set_compose_button     (MainWindow *mainwin, 
207                                                  ComposeButtonType compose_btn_type);
208
209 SensitiveCond main_window_get_current_state   (MainWindow *mainwin);
210
211 void toolbar_set_compose_button               (Toolbar           *toolbar, 
212                                                ComposeButtonType  compose_btn_type);
213 void main_window_destroy_all                  (void);
214
215 void main_window_toggle_work_offline          (MainWindow        *mainwin, 
216                                                gboolean           offline,
217                                                gboolean           ask_sync);
218
219 /* public so it can be disabled from summaryview */
220 gboolean mainwindow_key_pressed               (GtkWidget         *widget, 
221                                                GdkEventKey       *event,
222                                                gpointer           data);
223 MainWindow *mainwindow_get_mainwindow         (void);
224 void mainwindow_learn                         (MainWindow *mainwin,
225                                                gboolean is_spam);
226 void mainwindow_jump_to                       (const gchar       *target);
227 void mainwindow_show_error                    (void);
228 void mainwindow_clear_error                   (MainWindow *mainwin);
229 #endif /* __MAINWINDOW_H__ */