1 /* Mail Summary tree widget for Claws Mail */
2 
3 #ifndef __GTK_SCTREE_H__
4 #define __GTK_SCTREE_H__
5 
6 #include <gtk/gtk.h>
7 #include "gtk/gtkcmctree.h"
8 
9 /* This code is based on "gtkflist.{h,c}" from mc-4.5.42 .*/
10 
11 #define TYPE_GTK_SCTREE			(gtk_sctree_get_type ())
12 #define GTK_SCTREE(obj)			(G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_GTK_SCTREE, GtkSCTree))
13 #define GTK_SCTREE_CLASS(klass)		(G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_GTK_SCTREE, GtkSCTreeClass))
14 #define GTK_IS_SCTREE(obj)		(G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_GTK_SCTREE))
15 #define GTK_IS_SCTREE_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_GTK_SCTREE))
16 
17 
18 typedef struct _GtkSCTree GtkSCTree;
19 typedef struct _GtkSCTreeClass GtkSCTreeClass;
20 
21 struct _GtkSCTree {
22 	GtkCMCTree ctree;
23 
24 	/* The anchor row for range selections */
25 	GtkCMCTreeNode *anchor_row;
26 
27 	/* Mouse button and position saved on button press */
28 	gint dnd_press_button;
29 	gint dnd_press_x, dnd_press_y;
30 
31 	/* Delayed selection information */
32 	gint dnd_select_pending;
33 	guint dnd_select_pending_state;
34 	gint dnd_select_pending_row;
35 	gint selecting_range;
36 	gboolean sorting;
37 
38 	/* (dis)allow fancy color stripes */
39 	gboolean show_stripes;
40 	gboolean always_expand_recursively;
41 	gboolean force_additive_sel;
42 	gboolean *use_markup;
43 };
44 
45 struct _GtkSCTreeClass {
46     	GtkCMCTreeClass parent_class;
47 
48     	/* Signal: invoke the popup menu for rows */
49     	void (* row_popup_menu) (GtkSCTree *sctree, GdkEventButton *event);
50 
51     	/* Signal: invoke the popup menu for empty areas */
52     	void (* empty_popup_menu) (GtkSCTree *sctree, GdkEventButton *event);
53 
54 	/* Signal: open the file in the selected row */
55 	void (* open_row) (GtkSCTree *sctree);
56 
57     	/* Signal: initiate a drag and drop operation */
58     	void (* start_drag) (GtkSCTree *sctree, gint button, GdkEvent *event);
59 };
60 
61 
62 GType gtk_sctree_get_type (void);
63 
64 GtkWidget *gtk_sctree_new_with_titles	(gint		 columns,
65 					 gint		 tree_column,
66 					 gchar		*titles[]);
67 void gtk_sctree_select			(GtkSCTree	*sctree,
68 					 GtkCMCTreeNode	*node);
69 void gtk_sctree_select_with_state	(GtkSCTree	*sctree,
70 					 GtkCMCTreeNode	*node,
71 					 int		 state);
72 void gtk_sctree_unselect_all		(GtkSCTree	*sctree);
73 
74 void gtk_sctree_set_anchor_row		(GtkSCTree	*sctree,
75 					 GtkCMCTreeNode	*node);
76 
77 void gtk_sctree_remove_node		(GtkSCTree	*sctree,
78 					 GtkCMCTreeNode	*node);
79 
80 void gtk_sctree_set_stripes(GtkSCTree  *sctree, gboolean show_stripes);
81 void gtk_sctree_set_recursive_expand(GtkSCTree  *sctree, gboolean rec_exp);
82 
83 /***********************************************************
84  *             Tree sorting functions                      *
85  ***********************************************************/
86 
87 void gtk_sctree_sort_node (GtkCMCTree *ctree, GtkCMCTreeNode *node);
88 
89 void gtk_sctree_sort_recursive (GtkCMCTree *ctree, GtkCMCTreeNode *node);
90 
91 GtkCMCTreeNode* gtk_sctree_insert_node        (GtkCMCTree *ctree,
92                                              GtkCMCTreeNode *parent,
93                                              GtkCMCTreeNode *sibling,
94                                              gchar *text[],
95                                              guint8 spacing,
96                                              GdkPixbuf *pixbuf_closed,
97                                              GdkPixbuf *pixbuf_opened,
98                                              gboolean is_leaf,
99                                              gboolean expanded);
100 void        gtk_sctree_set_node_info        (GtkCMCTree *ctree,
101                                              GtkCMCTreeNode *node,
102                                              const gchar *text,
103                                              guint8 spacing,
104                                              GdkPixbuf *pixbuf_closed,
105                                              GdkPixbuf *pixbuf_opened,
106                                              gboolean is_leaf,
107                                              gboolean expanded);
108 GtkCMCTreeNode *
109 gtk_sctree_insert_gnode 		    (GtkCMCTree          *ctree,
110 					     GtkCMCTreeNode      *parent,
111 					     GtkCMCTreeNode      *sibling,
112 					     GNode             *gnode,
113 					     GtkCMCTreeGNodeFunc  func,
114 					     gpointer           data);
115 
116 void gtk_sctree_set_column_tooltip	    (GtkSCTree		*sctree,
117 					     int		 column,
118 					     const gchar 	*tip);
119 void gtk_sctree_set_use_markup		    (GtkSCTree		*sctree,
120 					     int		 column,
121 					     gboolean		 markup);
122 
123 /* This assumes that x and y coordinates are inside the clist_window.
124  * Returns true if the coordinates are inside a tree expander on
125  * one of the rows. */
126 gboolean
127 gtk_sctree_is_hot_spot (GtkSCTree *ctree,
128 		       gint      x,
129 		       gint      y);
130 #endif /* __GTK_SCTREE_H__ */
131