1 /* -*-mode:c; c-style:k&r; c-basic-offset:4; -*- */ 2 /* Balsa E-Mail Client 3 * Copyright (C) 1997-2013 Stuart Parmenter and others, 4 * See the file AUTHORS for a list. 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2, or (at your option) 9 * any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #ifndef __MAIN_WINDOW_H__ 21 #define __MAIN_WINDOW_H__ 22 23 #ifndef BALSA_VERSION 24 # error "Include config.h before this file." 25 #endif 26 27 #ifdef HAVE_NOTIFY 28 #include <libnotify/notify.h> 29 #endif 30 31 #include <glib.h> 32 33 #if GLIB_CHECK_VERSION(2, 32, 0) 34 #include <gio/gio.h> 35 #elif defined(HAVE_LIBNM_GLIB) 36 #include <nm-client.h> 37 #endif 38 39 #include "mailbox-node.h" 40 #include "toolbar-factory.h" 41 42 #define BALSA_TYPE_WINDOW (balsa_window_get_type ()) 43 #define BALSA_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, BALSA_TYPE_WINDOW, BalsaWindow)) 44 #define BALSA_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST (klass, BALSA_TYPE_WINDOW, BalsaWindowClass)) 45 #define BALSA_IS_WINDOW(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, BALSA_TYPE_WINDOW)) 46 #define BALSA_IS_WINDOW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE (klass, BALSA_TYPE_WINDOW)) 47 #define BALSA_WINDOW_GET_CLASS(window) \ 48 (G_TYPE_INSTANCE_GET_CLASS ((window), BALSA_TYPE_WINDOW, \ 49 BalsaWindowClass)) 50 51 /* Type values for mailbox checking */ 52 enum MailboxCheckType { 53 TYPE_BACKGROUND, 54 TYPE_CALLBACK 55 }; 56 57 typedef struct _BalsaWindow BalsaWindow; 58 typedef struct _BalsaWindowClass BalsaWindowClass; 59 typedef enum { 60 BALSA_PROGRESS_NONE = 0, 61 BALSA_PROGRESS_ACTIVITY, 62 BALSA_PROGRESS_INCREMENT 63 } BalsaWindowProgress; 64 65 66 struct _BalsaWindow { 67 GtkWindow window; 68 69 GtkWidget *toolbar; 70 GtkWidget *sos_bar; 71 GtkWidget *bottom_bar; 72 GtkWidget *progress_bar; 73 GtkWidget *statusbar; 74 GtkWidget *mblist; 75 GtkWidget *sos_entry; /* SenderOrSubject filter entry */ 76 GtkWidget *notebook; 77 GtkWidget *preview; /* message is child */ 78 GtkWidget *paned_master; 79 GtkWidget *paned_slave; 80 GtkWidget *current_index; 81 GtkWidget *filter_choice; 82 GtkWidget *vbox; 83 GtkWidget *content; 84 85 guint set_message_id; 86 87 GtkActionGroup *action_group; 88 GtkActionGroup *mailbox_action_group; 89 GtkActionGroup *message_action_group; 90 GtkActionGroup *current_message_action_group; 91 GtkActionGroup *modify_message_action_group; 92 93 /* Progress bar stuff: */ 94 BalsaWindowProgress progress_type; 95 guint activity_handler; 96 guint activity_counter; 97 GSList *activity_messages; 98 99 /* New mail notification: */ 100 GtkStatusIcon *new_mail_tray; 101 #ifdef HAVE_NOTIFY 102 NotifyNotification *new_mail_note; 103 #endif /* HAVE_NOTIFY */ 104 105 #if GLIB_CHECK_VERSION(2, 32, 0) 106 /* Support GNetworkMonitor: */ 107 gboolean network_available; 108 time_t last_check_time; 109 #elif defined(HAVE_LIBNM_GLIB) 110 /* NetworkManager state */ 111 NMState nm_state; 112 time_t last_check_time; 113 #endif /* defined(HAVE_LIBNM_GLIB) */ 114 }; 115 116 struct _BalsaWindowClass { 117 GtkWindowClass parent_class; 118 119 void (*open_mbnode) (BalsaWindow * window, 120 BalsaMailboxNode * mbnode, 121 gboolean set_current); 122 void (*close_mbnode) (BalsaWindow * window, BalsaMailboxNode * mbnode); 123 void (*identities_changed) (BalsaWindow * window); 124 }; 125 126 /* 127 * Constants for enable_empty_trash() 128 */ 129 typedef enum { 130 TRASH_EMPTY, /* guaranteed to be empty */ 131 TRASH_FULL, /* guaranteed to contain something */ 132 TRASH_CHECK /* uncertain, better check */ 133 } TrashState; 134 135 enum { 136 FILTER_SENDER = 0, 137 FILTER_RECIPIENT = 1 138 }; 139 140 GType balsa_window_get_type(void); 141 GtkWidget *balsa_window_new(void); 142 GtkWidget *balsa_window_find_current_index(BalsaWindow * window); 143 void balsa_window_update_book_menus(BalsaWindow *window); 144 void balsa_window_refresh(BalsaWindow * window); 145 void balsa_window_open_mbnode(BalsaWindow * window, 146 BalsaMailboxNode*mbnode, 147 gboolean set_current); 148 void balsa_window_close_mbnode(BalsaWindow * window, BalsaMailboxNode*mbnode); 149 void balsa_identities_changed(BalsaWindow *bw); 150 151 void balsa_window_update_tab(BalsaMailboxNode * mbnode); 152 void enable_empty_trash(BalsaWindow * window, TrashState status); 153 void balsa_window_enable_continue(BalsaWindow * window); 154 void balsa_change_window_layout(BalsaWindow *window); 155 gboolean mail_progress_notify_cb(GIOChannel * source, 156 GIOCondition condition, 157 BalsaWindow ** window); 158 gboolean send_progress_notify_cb(GIOChannel * source, 159 GIOCondition condition, 160 BalsaWindow ** window); 161 void check_new_messages_cb(GtkAction * action, gpointer data); 162 void check_new_messages_real(BalsaWindow * window, int type); 163 void check_new_messages_count(LibBalsaMailbox * mailbox, gboolean notify); 164 void empty_trash(BalsaWindow * window); 165 void update_view_menu(BalsaWindow * window); 166 BalsaToolbarModel *balsa_window_get_toolbar_model(void); 167 GtkUIManager *balsa_window_ui_manager_new(BalsaWindow * window); 168 void balsa_window_select_all(GtkWindow * window); 169 gboolean balsa_window_next_unread(BalsaWindow * window); 170 171 /* functions to manipulate the progress bars of the window */ 172 gboolean balsa_window_setup_progress(BalsaWindow * window, 173 const gchar * text); 174 void balsa_window_clear_progress(BalsaWindow* window); 175 void balsa_window_increment_progress(BalsaWindow * window, 176 gdouble fraction, gboolean flush); 177 void balsa_window_increase_activity(BalsaWindow * window, 178 const gchar * message); 179 void balsa_window_decrease_activity(BalsaWindow * window, 180 const gchar * message); 181 void balsa_window_set_statusbar(BalsaWindow * window, 182 LibBalsaMailbox * mailbox); 183 184 #if defined(__FILE__) && defined(__LINE__) 185 # ifdef __FUNCTION__ 186 # define BALSA_DEBUG_MSG(message) if (balsa_app.debug) fprintf(stderr, "[%lu] %12s | %4d | %30s: %s\n", (unsigned long) time(NULL), __FILE__, __LINE__, __FUNCTION__, message) 187 # define BALSA_DEBUG() if (balsa_app.debug) fprintf (stderr, "[%lu] %12s | %4d | %30s\n", (unsigned long) time(NULL), __FILE__, __LINE__, __FUNCTION__) 188 # else 189 # define BALSA_DEBUG_MSG(message) if (balsa_app.debug) fprintf(stderr, "[%lu] %12s | %4d: %s\n", (unsigned long) time(NULL), __FILE__, __LINE__, message) 190 # define BALSA_DEBUG() if (balsa_app.debug) fprintf(stderr, "[%lu] %12s | %4d\n", (unsigned long) time(NULL), __FILE__, __LINE__) 191 # endif 192 #endif 193 194 #endif /* __MAIN_WINDOW_H__ */ 195