toolbar.h (5653B)
1 /* 2 * Claws Mail -- a GTK based, lightweight, and fast e-mail client 3 * Copyright (C) 2001-2017 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 #ifndef __CUSTOM_TOOLBAR_H__ 20 #define __CUSTOM_TOOLBAR_H__ 21 22 #include "gtk/gtkutils.h" 23 24 #define SEPARATOR_PIXMAP "---" 25 26 typedef struct _Toolbar Toolbar; 27 typedef struct _ToolbarItem ToolbarItem; 28 typedef struct _ToolbarClawsActions ToolbarClawsActions; 29 30 typedef enum { 31 TOOLBAR_MAIN = 0, 32 TOOLBAR_COMPOSE, 33 TOOLBAR_MSGVIEW 34 } ToolbarType; 35 36 #define NUM_TOOLBARS 3 37 38 typedef enum 39 { 40 COMPOSEBUTTON_MAIL, 41 COMPOSEBUTTON_NEWS 42 } ComposeButtonType; 43 44 struct _Toolbar { 45 GtkWidget *toolbar; 46 47 GtkWidget *folders_btn; 48 GtkWidget *get_btn; 49 GtkWidget *getall_btn; 50 GtkWidget *send_btn; 51 52 GtkWidget *compose_mail_btn; 53 GtkWidget *compose_mail_icon; 54 55 GtkWidget *reply_btn; 56 GtkWidget *replysender_btn; 57 GtkWidget *replyall_btn; 58 GtkWidget *replylist_btn; 59 60 GtkWidget *fwd_btn; 61 62 GtkWidget *trash_btn; 63 GtkWidget *delete_btn; 64 GtkWidget *delete_dup_btn; 65 GtkWidget *prev_btn; 66 GtkWidget *next_btn; 67 GtkWidget *exec_btn; 68 69 GtkWidget *separator; 70 71 GtkWidget *cancel_inc_btn; 72 GtkWidget *cancel_send_btn; 73 GtkWidget *cancel_all_btn; 74 75 ComposeButtonType compose_btn_type; 76 77 /* compose buttons */ 78 GtkWidget *sendl_btn; 79 GtkWidget *draft_btn; 80 GtkWidget *insert_btn; 81 GtkWidget *attach_btn; 82 GtkWidget *sig_btn; 83 GtkWidget *repsig_btn; 84 GtkWidget *exteditor_btn; 85 GtkWidget *linewrap_current_btn; 86 GtkWidget *linewrap_all_btn; 87 GtkWidget *addrbook_btn; 88 89 GtkWidget *open_mail_btn; 90 GtkWidget *close_window_btn; 91 92 GtkWidget *preferences_btn; 93 94 GSList *action_list; 95 GSList *item_list; 96 }; 97 98 struct _ToolbarItem { 99 gint index; 100 gchar *file; 101 gchar *text; 102 ToolbarType type; 103 gpointer parent; 104 }; 105 106 #define TOOLBAR_DESTROY_ITEMS(item_list) \ 107 { \ 108 ToolbarItem *item; \ 109 while (item_list != NULL) { \ 110 item = (ToolbarItem*)item_list->data; \ 111 item_list = g_slist_remove(item_list, item); \ 112 toolbar_item_destroy(item); \ 113 }\ 114 g_slist_free(item_list);\ 115 } 116 117 #define TOOLBAR_DESTROY_ACTIONS(action_list) \ 118 { \ 119 ToolbarClawsActions *action; \ 120 while (action_list != NULL) { \ 121 action = (ToolbarClawsActions*)action_list->data;\ 122 action_list = \ 123 g_slist_remove(action_list, action);\ 124 if (action->name) \ 125 g_free(action->name); \ 126 g_free(action); \ 127 } \ 128 g_slist_free(action_list); \ 129 } 130 131 132 133 134 /* enum holds available actions for both 135 Compose Toolbar and Main Toolbar 136 */ 137 enum { 138 /* main toolbar */ 139 A_RECEIVE_ALL = 0, 140 A_RECEIVE_CUR, 141 A_SEND_QUEUED, 142 A_COMPOSE_EMAIL, 143 A_REPLY_MESSAGE, 144 A_REPLY_SENDER, 145 A_REPLY_ALL, 146 A_REPLY_ML, 147 A_OPEN_MAIL, 148 A_FORWARD, 149 A_TRASH, 150 A_DELETE_REAL, 151 A_DELETE_DUP, 152 A_EXECUTE, 153 A_GOTO_PREV, 154 A_GOTO_NEXT, 155 156 A_IGNORE_THREAD, 157 A_WATCH_THREAD, 158 A_MARK, 159 A_UNMARK, 160 A_LOCK, 161 A_UNLOCK, 162 A_ALL_READ, 163 A_ALL_UNREAD, 164 A_READ, 165 A_UNREAD, 166 A_RUN_PROCESSING, 167 168 A_GO_FOLDERS, 169 A_PREFERENCES, 170 171 /* compose toolbar */ 172 A_SEND, 173 A_SEND_LATER, 174 A_DRAFT, 175 A_INSERT, 176 A_ATTACH, 177 A_SIG, 178 A_REP_SIG, 179 A_EXTEDITOR, 180 A_LINEWRAP_CURRENT, 181 A_LINEWRAP_ALL, 182 A_ADDRBOOK, 183 A_PRIVACY_SIGN, 184 A_PRIVACY_ENCRYPT, 185 186 /* common items */ 187 A_CLAWS_ACTIONS, 188 A_CANCEL_INC, 189 A_CANCEL_SEND, 190 A_CANCEL_ALL, 191 A_CLOSE, 192 193 A_SEPARATOR, 194 195 N_ACTION_VAL 196 }; 197 198 struct _ToolbarClawsActions { 199 GtkWidget *widget; 200 gchar *name; 201 }; 202 203 204 GList *toolbar_get_action_items (ToolbarType source); 205 206 void toolbar_save_config_file (ToolbarType source); 207 void toolbar_read_config_file (ToolbarType source); 208 209 void toolbar_set_default (ToolbarType source); 210 void toolbar_clear_list (ToolbarType source); 211 212 GSList *toolbar_get_list (ToolbarType source); 213 void toolbar_set_list_item (ToolbarItem *t_item, 214 ToolbarType source); 215 216 gint toolbar_ret_val_from_descr (const gchar *descr); 217 gchar *toolbar_ret_descr_from_val (gint val); 218 219 void toolbar_main_set_sensitive (gpointer data); 220 void toolbar_comp_set_sensitive (gpointer data, 221 gboolean sensitive); 222 223 /* invoked by mainwindow entries and toolbar actions */ 224 void delete_msgview_cb (gpointer data, 225 guint action, 226 GtkWidget *widget); 227 void inc_mail_cb (gpointer data, 228 guint action, 229 GtkWidget *widget); 230 void inc_all_account_mail_cb (gpointer data, 231 guint action, 232 GtkWidget *widget); 233 void send_queue_cb (gpointer data, 234 guint action, 235 GtkWidget *widget); 236 void compose_mail_cb (gpointer data, 237 guint action, 238 GtkWidget *widget); 239 240 void toolbar_toggle (guint action, 241 gpointer data); 242 void toolbar_update (ToolbarType type, 243 gpointer data); 244 Toolbar *toolbar_create (ToolbarType type, 245 GtkWidget *container, 246 gpointer data); 247 void toolbar_set_style (GtkWidget *toolbar_wid, 248 GtkWidget *handlebox_wid, 249 guint action); 250 void toolbar_destroy (Toolbar *toolbar); 251 void toolbar_item_destroy (ToolbarItem *toolbar_item); 252 253 const gchar *toolbar_get_short_text (int action); 254 int toolbar_get_icon (int action); 255 gboolean toolbar_check_action_btns (ToolbarType type); 256 #endif /* __CUSTOM_TOOLBAR_H__ */