1 #ifndef METATREE_H 2 #define METATREE_H 3 4 #include <gtk/gtk.h> 5 6 /* START_INCLUDE_H */ 7 #include "gsb_real.h" 8 /* END_INCLUDE_H */ 9 10 11 /** Interface between various tree data and metatree */ 12 typedef struct _MetatreeInterface MetatreeInterface; 13 14 struct _MetatreeInterface { 15 gint depth; 16 gint content; /* content of the metatree : 0 = payee, 1 = category, 2 = budget */ 17 gint (* tree_currency) (void); 18 /* Read operations */ 19 const gchar * meta_name; 20 const gchar * meta_name_minus; 21 const gchar * meta_sub_name; 22 const gchar * no_div_label; 23 const gchar * no_sub_div_label; 24 gint (* get_without_div_pointer) (void); 25 gint (* get_div_pointer_from_name) (const gchar *, gboolean); 26 gint (* get_sub_div_pointer_from_name) (int, const gchar *, gboolean); 27 gint (* div_nb_transactions) (gint); 28 gint (* sub_div_nb_transactions) (gint, 29 gint); 30 gchar * (* div_name) (gint); 31 gchar * (* sub_div_name) (gint, gint); 32 GsbReal (* div_balance) (gint); 33 GsbReal (* sub_div_balance) (gint, gint); 34 gint (* div_id) (gpointer); 35 gint (* sub_div_id) (gpointer); 36 GSList * (* div_list) (void); 37 GSList * (* div_sub_div_list) (gint); 38 gint (* div_type) (gint); 39 40 /* Transaction operations */ 41 gint (* transaction_div_id) (gint); 42 gint (* transaction_sub_div_id) (gint); 43 gboolean (* transaction_set_div_id) (gint, int); 44 gboolean (* transaction_set_sub_div_id) (gint, int); 45 gint (* scheduled_div_id) (int); 46 gint (* scheduled_sub_div_id) (int); 47 gboolean (* scheduled_set_div_id) (int, int); 48 gboolean (* scheduled_set_sub_div_id) (int, int); 49 50 /* Write operations on div */ 51 gint (* add_div) (void); 52 gint (* add_sub_div) (int); 53 gboolean (* remove_div) (int); 54 gboolean (* remove_sub_div) (int, int); 55 gboolean (* add_transaction_to_div) (gint, int); 56 void (* add_transaction_to_sub_div) (gint, int, int); 57 void (* remove_transaction_from_div) (int); 58 void (* remove_transaction_from_sub_div) (int); 59 60 /* sauvegarde dernière sélection */ 61 gboolean (* hold_position_set_path) (GtkTreePath *); 62 gboolean (* hold_position_set_expand) (gboolean); 63 }; 64 65 66 /* structure permettant de mémoriser la dernière sélection dans un metatree */ 67 struct MetatreeHoldPosition 68 { 69 GtkTreePath * path; 70 gboolean expand; 71 }; 72 73 74 enum MetaTreeColumns { 75 META_TREE_TEXT_COLUMN, 76 META_TREE_ACCOUNT_COLUMN, 77 META_TREE_BALANCE_COLUMN, 78 /* this is the number of the current row : either number of categ/budget/payee, 79 * either number of sub-categ/sub-budget, 80 * either number of transaction */ 81 META_TREE_POINTER_COLUMN, 82 /* number of categ/budget */ 83 META_TREE_NO_DIV_COLUMN, 84 /* number of the sub-categ/sub-budget */ 85 META_TREE_NO_SUB_DIV_COLUMN, 86 /* number of the transaction */ 87 META_TREE_NO_TRANSACTION_COLUMN, 88 META_TREE_FONT_COLUMN, 89 META_TREE_XALIGN_COLUMN, 90 META_TREE_DATE_COLUMN, 91 META_TREE_BACKGROUND_COLOR, 92 META_TREE_NUM_COLUMNS 93 }; 94 95 enum MetaTreeRowType { 96 META_TREE_DIV, 97 META_TREE_TRANS_S_S_DIV, 98 META_TREE_SUB_DIV, 99 META_TREE_TRANSACTION, 100 META_TREE_INVALID 101 }; 102 103 #define META_TREE_COLUMN_TYPES G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, \ 104 G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, \ 105 G_TYPE_INT, G_TYPE_FLOAT, G_TYPE_POINTER, GDK_TYPE_RGBA 106 107 108 /*START_DECLARATION*/ 109 void appui_sur_ajout_sub_division (GtkTreeModel *model); 110 gboolean division_activated (GtkTreeView *treeview, 111 GtkTreePath *path, 112 GtkTreeViewColumn *col, 113 gpointer userdata); 114 gboolean division_column_expanded (GtkTreeView *treeview, 115 GtkTreeIter *iter, 116 GtkTreePath *tree_path, 117 gpointer user_data) ; 118 gboolean division_column_collapsed (GtkTreeView *treeview, 119 GtkTreeIter *iter, 120 GtkTreePath *tree_path, 121 gpointer user_data); 122 gboolean division_drag_data_received (GtkTreeDragDest *drag_dest, 123 GtkTreePath *dest_path, 124 GtkSelectionData *selection_data); 125 gboolean division_row_drop_possible (GtkTreeDragDest *drag_dest, 126 GtkTreePath *dest_path, 127 GtkSelectionData *selection_data); 128 void expand_arbre_division (GtkWidget *bouton, 129 gint depth); 130 void fill_division_row (GtkTreeModel *model, 131 MetatreeInterface *iface, 132 GtkTreeIter *iter, 133 gint division); 134 void fill_sub_division_row (GtkTreeModel *model, 135 MetatreeInterface *iface, 136 GtkTreeIter *iter, 137 gint division, 138 gint sub_division); 139 GtkTreeIter * get_iter_from_div (GtkTreeModel *model, 140 int div, 141 int sub_div); 142 gint metatree_get_nbre_transactions_sans_sub_div (GtkWidget *tree_view); 143 enum MetaTreeRowType metatree_get_row_type_from_tree_view (GtkWidget *tree_view); 144 void metatree_manage_sub_divisions (GtkWidget *tree_view); 145 void metatree_new_division (GtkTreeModel *model); 146 void metatree_register_widget_as_linked (GtkTreeModel *model, 147 GtkWidget *widget, 148 const gchar *link_type); 149 void metatree_remove_transaction (GtkTreeView *tree_view, 150 MetatreeInterface *iface, 151 gint transaction, 152 gboolean delete_transaction); 153 gboolean metatree_selection_changed (GtkTreeSelection *selection, 154 GtkTreeModel *model); 155 void metatree_set_linked_widgets_sensitive (GtkTreeModel *model, 156 gboolean sensitive, 157 const gchar *link_type); 158 gboolean metatree_sort_column (GtkTreeModel *model, 159 GtkTreeIter *a, 160 GtkTreeIter *b, 161 gpointer user_data); 162 void metatree_transfer_identical_transactions (GtkWidget *tree_view); 163 gboolean supprimer_division (GtkTreeView *tree_view); 164 void update_transaction_in_tree (MetatreeInterface *iface, 165 GtkTreeModel *model, 166 gint transaction_number); 167 /*END_DECLARATION*/ 168 169 #endif 170