f10548de242ffcf07c4bc975b434419717eebd3e
[claws.git] / src / mainwindow.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 __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 #define MAIN_WINDOW_CLOSE "mainwindow_close"
37 #define MAIN_WINDOW_GOT_ICONIFIED "mainwindow_iconified"
38 #define THEME_CHANGED_HOOKLIST "theme_changed"
39 typedef enum
40 {
41         M_UNLOCKED            = 1 << 0,
42         M_MSG_EXIST           = 1 << 1,
43         M_TARGET_EXIST        = 1 << 2,
44         M_SINGLE_TARGET_EXIST = 1 << 3,
45         M_EXEC                = 1 << 4,
46         M_ALLOW_REEDIT        = 1 << 5,
47         M_HAVE_ACCOUNT        = 1 << 6,
48         M_THREADED            = 1 << 7,
49         M_UNTHREADED          = 1 << 8,
50         M_ALLOW_DELETE        = 1 << 9,
51         M_INC_ACTIVE          = 1 << 10,
52         M_NEWS                = 1 << 11,
53         M_HAVE_NEWS_ACCOUNT   = 1 << 12,
54         M_HIDE_READ_MSG       = 1 << 13,
55         M_DELAY_EXEC          = 1 << 14,
56         M_NOT_NEWS            = 1 << 15,
57         M_CAN_LEARN_SPAM      = 1 << 16,
58         M_ACTIONS_EXIST       = 1 << 17,
59         M_HAVE_QUEUED_MAILS   = 1 << 18,
60         M_WANT_SYNC           = 1 << 19,
61         M_TAGS_EXIST          = 1 << 20,
62         M_HAVE_PROCESSING     = 1 << 21,
63         M_SUMMARY_ISLIST      = 1 << 22,
64         M_IN_MSGLIST          = 1 << 23,
65         M_HAVE_MULTI_ACCOUNT  = 1 << 24,
66         M_FOLDER_SELECTED     = 1 << 25,
67         M_SESSION_PASSWORDS   = 1 << 26,
68         M_DELETED_EXISTS      = 1 << 27,
69         M_NOT_TRASH           = 1 << 28,
70         M_HIDE_READ_THREADS   = 1 << 29,
71         M_HAVE_RETRIEVABLE_ACCOUNT = 1 << 30,
72         M_HAVE_ANY_RETRIEVABLE_ACCOUNT = 1 << 31
73 } SensitiveCond;
74
75 typedef enum
76 {
77         NORMAL_LAYOUT    = 0,
78         VERTICAL_LAYOUT  = 1 << 0,
79         WIDE_LAYOUT = 1 << 1,
80         WIDE_MSGLIST_LAYOUT = 1 << 2,
81         SMALL_LAYOUT
82 } LayoutType;
83
84 typedef enum
85 {       
86         TOOLBAR_NONE            = 0,
87         TOOLBAR_ICON            = 1,
88         TOOLBAR_TEXT            = 2,
89         TOOLBAR_BOTH            = 3,
90         TOOLBAR_BOTH_HORIZ      = 4
91 } ToolbarStyle;
92
93 struct _MainWindow
94 {
95         GtkWidget *hpaned;
96         GtkWidget *vpaned;
97
98         GtkWidget *window;
99         GtkWidget *vbox;
100         GtkWidget *menubar;
101
102         /* Toolbar handlebox */
103         GtkWidget *handlebox;
104         Toolbar *toolbar;
105
106         /* body */
107         GtkWidget *vbox_body;
108         GtkWidget *hbox_stat;
109         GtkWidget *statusbar;
110         GtkWidget *progressbar;
111         GtkWidget *statuslabel;
112         GtkWidget *ac_button;
113         GtkWidget *ac_label;
114         GtkWidget *ac_menu;
115         GtkWidget *online_switch;
116         GtkWidget *offline_switch;
117         GtkWidget *online_pixmap;
118         GtkWidget *offline_pixmap;
119
120         /* context IDs for status bar */
121         gint mainwin_cid;
122         gint folderview_cid;
123         gint summaryview_cid;
124         gint messageview_cid;
125
126         ToolbarStyle toolbar_style;
127
128         guint lock_count;
129         guint menu_lock_count;
130         guint cursor_count;
131
132         FolderView      *folderview;
133         SummaryView     *summaryview;
134         MessageView     *messageview;
135         LogWindow       *logwin;
136         LogWindow       *filtering_debugwin;
137
138         gint    progressindicator_hook;
139         
140         GtkWidget       *colorlabel_menu;
141         GtkWidget       *warning_btn;
142         GtkWidget       *tags_menu;
143         
144         gboolean         in_folder;
145         GtkActionGroup  *action_group;
146         GtkUIManager    *ui_manager;
147
148 #ifdef HAVE_LIBSM
149         gpointer smc_conn;
150 #endif
151 };
152
153 MainWindow *main_window_create          (void);
154
155 void main_window_update_actions_menu    (MainWindow     *mainwin);
156
157 void main_window_cursor_wait            (MainWindow     *mainwin);
158 void main_window_cursor_normal          (MainWindow     *mainwin);
159
160 void main_window_lock                   (MainWindow     *mainwin);
161 void main_window_unlock                 (MainWindow     *mainwin);
162
163 void main_window_reflect_prefs_all_real (gboolean        pixmap_theme_changed);
164 void main_window_reflect_prefs_all      (void);
165 void main_window_reflect_prefs_all_now  (void);
166 void main_window_reflect_prefs_custom_colors(MainWindow         *mainwindow);
167 void main_window_reflect_tags_changes(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 /* Mailing list support */
174 void main_create_mailing_list_menu      (MainWindow *mainwin, MsgInfo *msginfo);
175 gint mailing_list_get_list_post_mailto  (gchar **url, gchar *mailto, gint maxlen);
176
177 void main_window_toggle_message_view    (MainWindow *mainwin);
178
179 void main_window_get_size               (MainWindow     *mainwin);
180 void main_window_get_position           (MainWindow     *mainwin);
181
182 void main_window_progress_on            (MainWindow     *mainwin);
183 void main_window_progress_off           (MainWindow     *mainwin);
184 gboolean main_window_empty_trash        (MainWindow     *mainwin,
185                                          gboolean        confirm,
186                                          gboolean        for_quit);
187
188 void main_window_set_menu_sensitive     (MainWindow     *mainwin);
189
190
191 void main_window_show                   (MainWindow     *mainwin);
192 void main_window_hide                   (MainWindow     *mainwin);
193 void main_window_popup                  (MainWindow     *mainwin);
194
195 SensitiveCond main_window_get_current_state   (MainWindow *mainwin);
196
197 void toolbar_set_compose_button               (Toolbar           *toolbar, 
198                                                ComposeButtonType  compose_btn_type);
199 void main_window_destroy_all                  (void);
200
201 void main_window_toggle_work_offline          (MainWindow        *mainwin, 
202                                                gboolean           offline,
203                                                gboolean           ask_sync);
204
205 MainWindow *mainwindow_get_mainwindow         (void);
206 void mainwindow_learn                         (MainWindow *mainwin,
207                                                gboolean is_spam);
208 void mainwindow_jump_to                       (const gchar       *target,
209                                                gboolean popup);
210 void mainwindow_show_error                    (void);
211 void mainwindow_clear_error                   (MainWindow *mainwin);
212 gboolean mainwindow_is_obscured               (void);
213 void mainwindow_exit_folder                   (MainWindow *mainwin);
214 void mainwindow_enter_folder                  (MainWindow *mainwin);
215 void mainwindow_reset_paned                   (GtkPaned *paned);
216
217 #ifdef MAEMO
218 gboolean maemo_mainwindow_is_fullscreen               (GtkWidget *widget);
219 void maemo_window_full_screen_if_needed               (GtkWindow *window);
220 void maemo_connect_key_press_to_mainwindow    (GtkWindow *window);
221 void mainwindow_maemo_led_set(gboolean state);
222 #endif
223
224 void mainwin_accel_changed_cb (GtkAccelGroup *accelgroup, guint keyval, GdkModifierType modifier,
225                                   GClosure *closure, GtkMenuItem *item);
226
227 #endif /* __MAINWINDOW_H__ */