2006-11-16 [paul] 2.6.0cvs51
[claws.git] / src / mainwindow.h
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2006 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 } SensitiveCond;
59
60 typedef enum
61 {
62         SEPARATE_NONE    = 0,
63         SEPARATE_FOLDER  = 1 << 0,
64         SEPARATE_MESSAGE = 1 << 1,
65         SEPARATE_BOTH    = (SEPARATE_FOLDER | SEPARATE_MESSAGE)
66 } SeparateType;
67
68 typedef enum
69 {
70         TOOLBAR_NONE            = 0,
71         TOOLBAR_ICON            = 1,
72         TOOLBAR_TEXT            = 2,
73         TOOLBAR_BOTH            = 3,
74         TOOLBAR_BOTH_HORIZ      = 4
75 } ToolbarStyle;
76
77 struct _MainWindow
78 {
79         SeparateType type;
80
81         union CompositeWin {
82                 struct 
83                 {
84                         GtkWidget *hpaned;
85                         GtkWidget *vpaned;
86                 } sep_none;
87                 struct {
88                         GtkWidget *folderwin;
89                         GtkWidget *vpaned;
90                 } sep_folder;
91                 struct {
92                         GtkWidget *messagewin;
93                         GtkWidget *hpaned;
94                 } sep_message;
95                 struct {
96                         GtkWidget *folderwin;
97                         GtkWidget *messagewin;
98                 } sep_both;
99         } win;
100
101         GtkWidget *window;
102         GtkWidget *vbox;
103         GtkWidget *menubar;
104
105         GtkItemFactory *menu_factory;
106
107         /* Toolbar handlebox */
108         GtkWidget *handlebox;
109         Toolbar *toolbar;
110
111         /* body */
112         GtkWidget *vbox_body;
113         GtkWidget *hbox_stat;
114         GtkWidget *statusbar;
115         GtkWidget *progressbar;
116         GtkWidget *statuslabel;
117         GtkWidget *ac_button;
118         GtkWidget *ac_label;
119         GtkWidget *ac_menu;
120         GtkWidget *online_switch;
121         GtkWidget *offline_switch;
122         GtkWidget *online_pixmap;
123         GtkWidget *offline_pixmap;
124
125         /* context IDs for status bar */
126         gint mainwin_cid;
127         gint folderview_cid;
128         gint summaryview_cid;
129         gint messageview_cid;
130
131         ToolbarStyle toolbar_style;
132
133         guint lock_count;
134         guint menu_lock_count;
135         guint cursor_count;
136
137         FolderView      *folderview;
138         SummaryView     *summaryview;
139         MessageView     *messageview;
140         LogWindow       *logwin;
141
142         gint    progressindicator_hook;
143         
144         GtkWidget       *colorlabel_menu;
145         GtkWidget       *warning_btn;
146         
147 #ifdef HAVE_LIBSM
148         gpointer smc_conn;
149 #endif
150 };
151
152 MainWindow *main_window_create          (SeparateType    type);
153
154 void main_window_destroy                (MainWindow *mainwin);
155
156 void main_window_update_actions_menu    (MainWindow     *mainwin);
157
158 void main_window_cursor_wait            (MainWindow     *mainwin);
159 void main_window_cursor_normal          (MainWindow     *mainwin);
160
161 void main_window_lock                   (MainWindow     *mainwin);
162 void main_window_unlock                 (MainWindow     *mainwin);
163
164 void main_window_reflect_prefs_all_real (gboolean        pixmap_theme_changed);
165 void main_window_reflect_prefs_all      (void);
166 void main_window_reflect_prefs_all_now  (void);
167 void main_window_reflect_prefs_custom_colors(MainWindow         *mainwindow);
168 void main_window_set_summary_column     (void);
169 void main_window_set_folder_column      (void);
170 void main_window_set_account_menu       (GList          *account_list);
171 void main_window_set_account_menu_only_toolbar  (GList          *account_list);
172
173 GtkWidget *main_window_get_folder_window        (MainWindow     *mainwin);
174 GtkWidget *main_window_get_message_window       (MainWindow     *mainwin);
175
176 /* Mailing list support */
177 void main_create_mailing_list_menu      (MainWindow *mainwin, MsgInfo *msginfo);
178 gint mailing_list_get_list_post_mailto  (gchar **url, gchar *mailto, gint maxlen);
179
180 void main_window_separation_change      (MainWindow     *mainwin,
181                                          SeparateType    type);
182
183 void main_window_toggle_message_view    (MainWindow *mainwin);
184
185 void main_window_get_size               (MainWindow     *mainwin);
186 void main_window_get_position           (MainWindow     *mainwin);
187
188 void main_window_progress_on            (MainWindow     *mainwin);
189 void main_window_progress_off           (MainWindow     *mainwin);
190 void main_window_progress_set           (MainWindow     *mainwin,
191                                          gint            cur,
192                                          gint            total);
193
194 void main_window_empty_trash            (MainWindow     *mainwin,
195                                          gboolean        confirm);
196 void main_window_add_mailbox            (MainWindow     *mainwin);
197
198 void main_window_set_menu_sensitive     (MainWindow     *mainwin);
199
200
201 void main_window_show                   (MainWindow     *mainwin);
202 void main_window_hide                   (MainWindow     *mainwin);
203 void main_window_popup                  (MainWindow     *mainwin);
204
205 void main_window_toolbar_set_compose_button     (MainWindow *mainwin, 
206                                                  ComposeButtonType compose_btn_type);
207
208 SensitiveCond main_window_get_current_state   (MainWindow *mainwin);
209
210 void toolbar_set_compose_button               (Toolbar           *toolbar, 
211                                                ComposeButtonType  compose_btn_type);
212 void main_window_destroy_all                  (void);
213
214 void main_window_toggle_work_offline          (MainWindow        *mainwin, 
215                                                gboolean           offline,
216                                                gboolean           ask_sync);
217
218 /* public so it can be disabled from summaryview */
219 gboolean mainwindow_key_pressed               (GtkWidget         *widget, 
220                                                GdkEventKey       *event,
221                                                gpointer           data);
222 MainWindow *mainwindow_get_mainwindow         (void);
223 void mainwindow_learn                         (MainWindow *mainwin,
224                                                gboolean is_spam);
225 void mainwindow_jump_to                       (const gchar       *target);
226 void mainwindow_show_error                    (void);
227 void mainwindow_clear_error                   (MainWindow *mainwin);
228 #endif /* __MAINWINDOW_H__ */