tree_manipulation.h 3.89 KB
Newer Older
1 2 3
/**
 * tree_manipulation.h - GtkTreeView manipulation code for SciteProj
 *
4
 *  Copyright 2006 Roy Wood, 2009-2017 Andreas Rönnquist
5 6
 *
 * This file is part of SciteProj.
7
 *
8 9 10 11 12 13 14 15 16 17 18
 * SciteProj is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * SciteProj is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
19
 * along with SciteProj.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
 * If not, see <http://www.gnu.org/licenses/>.
 *
 */
#ifndef __HEADER_TREE_MANIPULATION_
#define __HEADER_TREE_MANIPULATION_


// Node relative-position indicators

enum NodePosition {
	ADD_BEFORE,
	ADD_AFTER,
	ADD_CHILD
};


// Mnemonic identifiers for the columns in the GtkTreeStore

38
enum {
39
	COLUMN_ITEMTYPE = 0,
40 41 42
	COLUMN_FILEPATH,
	COLUMN_FILENAME,
	COLUMN_FILESIZE,
43 44 45 46
	COLUMN_FONTWEIGHT,
	COLUMN_FONTWEIGHTSET,
	COLUMN_ICON,
	COLUMN_EXPANDED,
47
	COLUMN_FOLDER_CONTENT_LOADED,
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
	COLUMN_EOL
};


// The type of each row in the tree datamodel

enum {
	ITEMTYPE_GROUP,
	ITEMTYPE_FILE
};




// The types for each column in the tree datamodel

64 65 66 67 68 69 70 71 72 73
#define TYPE_ITEMTYPE					G_TYPE_UINT
#define TYPE_FILEPATH					G_TYPE_STRING
#define TYPE_FILENAME					G_TYPE_STRING
#define TYPE_FILESIZE					G_TYPE_STRING
#define TYPE_FONTWEIGHT					G_TYPE_INT
#define TYPE_FONTWEIGHTSET				G_TYPE_BOOLEAN
#define TYPE_ICON							GDK_TYPE_PIXBUF
#define TYPE_EXPANDED					G_TYPE_BOOLEAN
#define TYPE_FOLDER_CONTENT_LOADED	G_TYPE_BOOLEAN

74 75 76 77 78


typedef gint(*StringCompareFunction)(gconstpointer,gconstpointer);


79 80 81
// Set the Project filepath
gboolean set_project_filepath(const gchar *filepath, GError **err);

82 83 84 85 86 87 88 89 90 91 92
// Get the GTKTreeStore
GtkTreeStore* create_treestore(GError **err);

// Get the project file directory
const gchar* get_project_directory();
gchar* get_project_filepath();

// Allow user to select and add files to the project
gboolean add_files_to_project(GtkTreeIter *parentIter, GError **err);

// Add a file node to a GtkTreeModel
93
gboolean add_tree_file(GtkTreeIter *currentIter,
94 95 96 97 98
                       enum NodePosition position,
                       const gchar* filepath,
                       GtkTreeIter *newIter,
                       gboolean makeRelative,
                       GError **err);
99 100 101 102 103

//gboolean add_tree_filelist(GtkTreeIter *parentIter, GSList *fileList, GError **err);
gboolean add_tree_filelist(GtkTreeIter *parentIter, GSList *fileList, GError **err);

// Add a group node to a GtkTreeModel
104
gboolean add_tree_group(GtkTreeIter *parentIter,
105 106 107 108 109 110
                        enum NodePosition position,
                        const gchar* groupname,
                        const gchar* full_name,
                        gboolean expanded,
                        GtkTreeIter *newIter,
                        GError **err);
111 112 113 114 115 116 117 118

// Remove a node from a GtkTreeModel
gboolean remove_tree_node(GtkTreeIter *iter, GError **err);

gboolean set_tree_node_expanded(GtkTreeIter *iter, gboolean expanded, GError **err);

gboolean set_tree_node_icon(GtkTreeIter *iter, GdkPixbuf *pixbuf, GError **err);

119 120
gboolean set_tree_node_loaded(GtkTreeIter *iter, gboolean loaded, GError **err);

121
// Copy a node in the tree (including children)
122
gboolean copy_tree_node(GtkTreeIter *srcIter,
123 124 125 126
                        GtkTreeIter *dstIter,
                        enum NodePosition position,
                        GtkTreeIter *newIter,
                        GError **err);
127 128 129 130 131

gchar *get_path_string(GtkTreeIter *iter);

void sort_children(GtkTreeIter *node,GError **err,StringCompareFunction compare_func);

132
gboolean add_tree_folderlist(GtkTreeIter *iter, GSList *folder_list, gchar *folder_path);
133 134

#endif /*__HEADER_TREE_MANIPULATION_*/