fix CID 1596595: Resource leaks, and CID 1596594: (CHECKED_RETURN)
[claws.git] / src / mainwindow.h
1 /*
2  * Claws Mail -- a GTK based, lightweight, and fast e-mail client
3  *  Copyright (C) 1999-2023 the Claws Mail team and Hiroyuki Yamamoto
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 #ifndef __MAINWINDOW_H__
20 #define __MAINWINDOW_H__
21
22 #include <glib.h>
23
24 typedef struct _MainWindow  MainWindow;
25
26 #include "viewtypes.h"
27 #include "logwindow.h"
28 #include "procmsg.h"
29 #include "toolbar.h"
30
31 #define OFFLINE_SWITCH_HOOKLIST "offline_switch"
32 #define ACCOUNT_LIST_CHANGED_HOOKLIST "account_list_changed"
33 #define MAIN_WINDOW_CLOSE "mainwindow_close"
34 #define MAIN_WINDOW_GOT_ICONIFIED "mainwindow_iconified"
35 #define THEME_CHANGED_HOOKLIST "theme_changed"
36 typedef enum
37 {
38         M_UNLOCKED,
39         M_MSG_EXIST,
40         M_TARGET_EXIST,
41         M_SINGLE_TARGET_EXIST,
42         M_EXEC,
43         M_ALLOW_REEDIT,
44         M_HAVE_ACCOUNT,
45         M_THREADED,
46         M_UNTHREADED,
47         M_ALLOW_DELETE,
48         M_INC_ACTIVE,
49         M_SEND_ACTIVE,
50         M_NEWS,
51         M_HAVE_NEWS_ACCOUNT,
52         M_HIDE_READ_MSG,
53         M_DELAY_EXEC,
54         M_NOT_NEWS,
55         M_CAN_LEARN_SPAM,
56         M_ACTIONS_EXIST,
57         M_HAVE_QUEUED_MAILS,
58         M_WANT_SYNC,
59         M_TAGS_EXIST,
60         M_HAVE_PROCESSING,
61         M_SUMMARY_ISLIST,
62         M_IN_MSGLIST,
63         M_HAVE_MULTI_ACCOUNT,
64         M_FOLDER_SELECTED,
65         M_SESSION_PASSWORDS,
66         M_MASTER_PASSPHRASE,
67         M_DELETED_EXISTS,
68         M_NOT_TRASH,
69         M_HIDE_READ_THREADS,
70         M_HAVE_RETRIEVABLE_ACCOUNT,
71         M_HAVE_ANY_RETRIEVABLE_ACCOUNT,
72         M_NOT_DRAFT,
73         M_MSG_SELECTED,
74
75 /* reserved */
76     M_MAX_RESERVED
77 } SensitiveCond;
78
79 typedef guint64 SensitiveCondMask;
80
81 typedef enum
82 {
83         NORMAL_LAYOUT       = 0,
84         VERTICAL_LAYOUT     = 1 << 0,
85         WIDE_LAYOUT         = 1 << 1,
86         WIDE_MSGLIST_LAYOUT = 1 << 2,
87         SMALL_LAYOUT
88 } LayoutType;
89
90 typedef enum
91 {       
92         TOOLBAR_NONE            = 0,
93         TOOLBAR_ICON            = 1,
94         TOOLBAR_TEXT            = 2,
95         TOOLBAR_BOTH            = 3,
96         TOOLBAR_BOTH_HORIZ      = 4
97 } ToolbarStyle;
98
99 struct _MainWindow
100 {
101         GtkWidget *hpaned;
102         GtkWidget *vpaned;
103
104         GtkWidget *window;
105         GtkWidget *vbox;
106         GtkWidget *menubar;
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         LogWindow       *filtering_debugwin;
143
144         gint    progressindicator_hook;
145         
146         GtkWidget       *colorlabel_menu;
147         GtkWidget       *warning_btn;
148         GtkWidget       *tags_menu;
149         
150         gboolean         in_folder;
151         GtkActionGroup  *action_group;
152         GtkUIManager    *ui_manager;
153
154 #ifdef HAVE_LIBSM
155         gpointer smc_conn;
156 #endif
157 };
158
159 MainWindow *main_window_create          (void);
160
161 void main_window_update_actions_menu    (MainWindow     *mainwin);
162
163 void main_window_cursor_wait            (MainWindow     *mainwin);
164 void main_window_cursor_normal          (MainWindow     *mainwin);
165
166 void main_window_lock                   (MainWindow     *mainwin);
167 void main_window_unlock                 (MainWindow     *mainwin);
168
169 void main_window_reflect_prefs_all_real (gboolean        pixmap_theme_changed);
170 void main_window_reflect_prefs_all      (void);
171 void main_window_reflect_prefs_all_now  (void);
172 void main_window_reflect_prefs_custom_colors(MainWindow         *mainwindow);
173 void main_window_reflect_tags_changes(MainWindow        *mainwindow);
174 void main_window_set_summary_column     (void);
175 void main_window_set_folder_column      (void);
176 void main_window_set_account_menu       (GList          *account_list);
177 void main_window_set_account_menu_only_toolbar  (GList          *account_list);
178
179 /* Mailing list support */
180 void main_create_mailing_list_menu      (MainWindow *mainwin, MsgInfo *msginfo);
181 gint mailing_list_get_list_post_mailto  (gchar **url, gchar *mailto, gint maxlen);
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 gboolean main_window_empty_trash        (MainWindow     *mainwin,
191                                          gboolean        confirm,
192                                          gboolean        for_quit);
193
194 SensitiveCondMask main_window_get_mask(SensitiveCond cond, ...);
195
196 void main_window_set_menu_sensitive     (MainWindow     *mainwin);
197
198
199 void main_window_show                   (MainWindow     *mainwin);
200 void main_window_hide                   (MainWindow     *mainwin);
201 void main_window_popup                  (MainWindow     *mainwin);
202
203 SensitiveCondMask main_window_get_current_state   (MainWindow *mainwin);
204
205 void toolbar_set_compose_button               (Toolbar           *toolbar, 
206                                                ComposeButtonType  compose_btn_type);
207 void main_window_destroy_all                  (void);
208
209 void main_window_toggle_work_offline          (MainWindow        *mainwin, 
210                                                gboolean           offline,
211                                                gboolean           ask_sync);
212
213 MainWindow *mainwindow_get_mainwindow         (void);
214 void mainwindow_learn                         (MainWindow *mainwin,
215                                                gboolean is_spam);
216 void mainwindow_jump_to                       (const gchar       *target,
217                                                gboolean popup);
218 void mainwindow_show_error                    (void);
219 void mainwindow_clear_error                   (MainWindow *mainwin);
220 void mainwindow_delete_duplicated     (MainWindow *mainwin);
221 void mainwindow_delete_duplicated_all (MainWindow *mainwin);
222 gboolean mainwindow_is_obscured               (void);
223 void mainwindow_exit_folder                   (MainWindow *mainwin);
224 void mainwindow_enter_folder                  (MainWindow *mainwin);
225 void mainwindow_reset_paned                   (GtkPaned *paned);
226
227 void mainwin_accel_changed_cb (GtkAccelGroup *accelgroup, guint keyval, GdkModifierType modifier,
228                                   GClosure *closure, GtkMenuItem *item);
229
230 #endif /* __MAINWINDOW_H__ */