cc3642712beb6512ed7baa76470f37cf2652ef79
[claws.git] / src / folderview.h
1 /*
2  * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3  * Copyright (C) 1999-2012 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 __FOLDERVIEW_H__
21 #define __FOLDERVIEW_H__
22
23 typedef struct _FolderViewPopup FolderViewPopup;
24 typedef struct _FolderColumnState       FolderColumnState;
25
26 #include <glib.h>
27 #include <gtk/gtk.h>
28 #include "gtk/gtksctree.h"
29
30 #include "mainwindow.h"
31 #include "viewtypes.h"
32 #include "folder.h"
33
34 typedef enum
35 {
36         F_COL_FOLDER,
37         F_COL_NEW,
38         F_COL_UNREAD,
39         F_COL_TOTAL
40 } FolderColumnType;
41
42 #define N_FOLDER_COLS   4
43
44 struct _FolderColumnState
45 {
46         FolderColumnType type;
47         gboolean visible;
48 };
49
50 struct _FolderView
51 {
52         GtkWidget *scrolledwin;
53         GtkWidget *ctree;
54
55         GHashTable *popups;
56
57         GtkCMCTreeNode *selected;
58         GtkCMCTreeNode *opened;
59
60         gboolean open_folder;
61
62         GdkColor color_new;
63         GdkColor color_op;
64
65         MainWindow   *mainwin;
66         SummaryView  *summaryview;
67
68         gint folder_update_callback_id;
69         gint folder_item_update_callback_id;
70         
71         /* DND states */
72         GSList *nodes_to_recollapse;
73         guint   drag_timer_id;          /* timer id */
74         FolderItem *drag_item;          /* dragged item */
75         GtkCMCTreeNode *drag_node;      /* drag node */
76         
77         GtkTargetList *target_list; /* DnD */
78         FolderColumnState col_state[N_FOLDER_COLS];
79         gint col_pos[N_FOLDER_COLS];
80         Folder *scanning_folder;
81         GtkUIManager *ui_manager;
82         GtkActionGroup *popup_common_action_group;
83         GtkActionGroup *popup_specific_action_group;
84         gint scroll_value;
85         guint deferred_refresh_id;
86         guint scroll_timeout_id;
87         guint postpone_select_id;
88 };
89
90 struct _FolderViewPopup
91 {
92         gchar                    *klass;
93         gchar                    *path;
94         GtkActionEntry           *entries;
95         gint                      n_entries;
96         GtkToggleActionEntry     *toggle_entries;
97         gint                      n_toggle_entries;
98         GtkRadioActionEntry      *radio_entries;
99         gint                      n_radio_entries;
100         gint                      radio_default;
101         void                    (*radio_callback)       (GtkAction *action, GtkRadioAction *current, gpointer data);
102         void                    (*add_menuitems)        (GtkUIManager *ui_manager, FolderItem *item);
103         void                    (*set_sensitivity)      (GtkUIManager *ui_manager, FolderItem *item);
104 };
105
106 void folderview_initialize              (void);
107 FolderView *folderview_create           (void);
108 void folderview_init                    (FolderView     *folderview);
109
110 void folderview_set                     (FolderView     *folderview);
111 void folderview_set_all                 (void);
112
113 void folderview_select                  (FolderView     *folderview,
114                                          FolderItem     *item);
115 void folderview_unselect                (FolderView     *folderview);
116 void folderview_select_next_with_flag   (FolderView     *folderview,
117                                          MsgPermFlags    flag,
118                                          gboolean        force_open);
119
120 FolderItem *folderview_get_selected_item(FolderView     *folderview);
121
122 void folderview_rescan_tree             (Folder         *folder,
123                                          gboolean        rebuild);
124 gint folderview_check_new               (Folder         *folder);
125 void folderview_check_new_all           (void);
126
127 void folderview_update_all_updated      (gboolean        update_summary);
128
129 void folderview_move_folder             (FolderView     *folderview,
130                                          FolderItem     *from_folder,
131                                          FolderItem     *to_folder,
132                                          gboolean        copy);
133
134 void folderview_set_target_folder_color (gint           color_op);
135
136 void folderview_reinit_fonts            (FolderView *folderview);
137
138 void folderview_reflect_prefs           (void);
139 void folderview_register_popup          (FolderViewPopup        *fpopup);
140 void folderview_unregister_popup        (FolderViewPopup        *fpopup);
141 void folderview_update_search_icon      (FolderItem             *item,  
142                                          gboolean                matches);
143 void folderview_set_column_order        (FolderView             *folderview);
144 void folderview_finish_dnd              (const gchar            *data, 
145                                          GdkDragContext         *drag_context,
146                                          guint                   time, 
147                                          FolderItem             *item);
148 void folderview_close_opened            (FolderView             *folderview);
149
150 #endif /* __FOLDERVIEW_H__ */