summaryrefslogtreecommitdiff
path: root/plugins/filebrowser/pluma-file-browser-store.h
blob: 98b9f0974951b70f32eaded4d34679bb332fb2cb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
/*
 * pluma-file-browser-store.h - Pluma plugin providing easy file access
 * from the sidepanel
 *
 * Copyright (C) 2006 - Jesse van den Kieboom <jesse@icecrew.nl>
 * Copyright (C) 2012-2021 MATE Developers
 *
 * This program 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 2, or (at your option)
 * any later version.
 *
 * This program 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
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#ifndef __PLUMA_FILE_BROWSER_STORE_H__
#define __PLUMA_FILE_BROWSER_STORE_H__

#include <gtk/gtk.h>

G_BEGIN_DECLS
#define PLUMA_TYPE_FILE_BROWSER_STORE			(pluma_file_browser_store_get_type ())
#define PLUMA_FILE_BROWSER_STORE(obj)			(G_TYPE_CHECK_INSTANCE_CAST ((obj), PLUMA_TYPE_FILE_BROWSER_STORE, PlumaFileBrowserStore))
#define PLUMA_FILE_BROWSER_STORE_CONST(obj)		(G_TYPE_CHECK_INSTANCE_CAST ((obj), PLUMA_TYPE_FILE_BROWSER_STORE, PlumaFileBrowserStore const))
#define PLUMA_FILE_BROWSER_STORE_CLASS(klass)		(G_TYPE_CHECK_CLASS_CAST ((klass), PLUMA_TYPE_FILE_BROWSER_STORE, PlumaFileBrowserStoreClass))
#define PLUMA_IS_FILE_BROWSER_STORE(obj)		(G_TYPE_CHECK_INSTANCE_TYPE ((obj), PLUMA_TYPE_FILE_BROWSER_STORE))
#define PLUMA_IS_FILE_BROWSER_STORE_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE ((klass), PLUMA_TYPE_FILE_BROWSER_STORE))
#define PLUMA_FILE_BROWSER_STORE_GET_CLASS(obj)		(G_TYPE_INSTANCE_GET_CLASS ((obj), PLUMA_TYPE_FILE_BROWSER_STORE, PlumaFileBrowserStoreClass))

typedef enum
{
	PLUMA_FILE_BROWSER_STORE_COLUMN_ICON = 0,
	PLUMA_FILE_BROWSER_STORE_COLUMN_NAME,
	PLUMA_FILE_BROWSER_STORE_COLUMN_URI,
	PLUMA_FILE_BROWSER_STORE_COLUMN_FLAGS,
	PLUMA_FILE_BROWSER_STORE_COLUMN_EMBLEM,
	PLUMA_FILE_BROWSER_STORE_COLUMN_NUM
} PlumaFileBrowserStoreColumn;

typedef enum
{
	PLUMA_FILE_BROWSER_STORE_FLAG_IS_DIRECTORY = 1 << 0,
	PLUMA_FILE_BROWSER_STORE_FLAG_IS_HIDDEN    = 1 << 1,
	PLUMA_FILE_BROWSER_STORE_FLAG_IS_TEXT      = 1 << 2,
	PLUMA_FILE_BROWSER_STORE_FLAG_LOADED       = 1 << 3,
	PLUMA_FILE_BROWSER_STORE_FLAG_IS_FILTERED  = 1 << 4,
	PLUMA_FILE_BROWSER_STORE_FLAG_IS_DUMMY     = 1 << 5
} PlumaFileBrowserStoreFlag;

typedef enum
{
	PLUMA_FILE_BROWSER_STORE_RESULT_OK,
	PLUMA_FILE_BROWSER_STORE_RESULT_NO_CHANGE,
	PLUMA_FILE_BROWSER_STORE_RESULT_ERROR,
	PLUMA_FILE_BROWSER_STORE_RESULT_NO_TRASH,
	PLUMA_FILE_BROWSER_STORE_RESULT_MOUNTING,
	PLUMA_FILE_BROWSER_STORE_RESULT_NUM
} PlumaFileBrowserStoreResult;

typedef enum
{
	PLUMA_FILE_BROWSER_STORE_FILTER_MODE_NONE        = 0,
	PLUMA_FILE_BROWSER_STORE_FILTER_MODE_HIDE_HIDDEN = 1 << 0,
	PLUMA_FILE_BROWSER_STORE_FILTER_MODE_HIDE_BINARY = 1 << 1
} PlumaFileBrowserStoreFilterMode;

#define FILE_IS_DIR(flags)	(flags & PLUMA_FILE_BROWSER_STORE_FLAG_IS_DIRECTORY)
#define FILE_IS_HIDDEN(flags)	(flags & PLUMA_FILE_BROWSER_STORE_FLAG_IS_HIDDEN)
#define FILE_IS_TEXT(flags)	(flags & PLUMA_FILE_BROWSER_STORE_FLAG_IS_TEXT)
#define FILE_LOADED(flags)	(flags & PLUMA_FILE_BROWSER_STORE_FLAG_LOADED)
#define FILE_IS_FILTERED(flags)	(flags & PLUMA_FILE_BROWSER_STORE_FLAG_IS_FILTERED)
#define FILE_IS_DUMMY(flags)	(flags & PLUMA_FILE_BROWSER_STORE_FLAG_IS_DUMMY)

typedef struct _PlumaFileBrowserStore        PlumaFileBrowserStore;
typedef struct _PlumaFileBrowserStoreClass   PlumaFileBrowserStoreClass;
typedef struct _PlumaFileBrowserStorePrivate PlumaFileBrowserStorePrivate;

typedef gboolean (*PlumaFileBrowserStoreFilterFunc) (PlumaFileBrowserStore
						     * model,
						     GtkTreeIter * iter,
						     gpointer user_data);

struct _PlumaFileBrowserStore
{
	GObject parent;

	PlumaFileBrowserStorePrivate *priv;
};

struct _PlumaFileBrowserStoreClass {
	GObjectClass parent_class;

	/* Signals */
	void (*begin_loading)        (PlumaFileBrowserStore * model,
			              GtkTreeIter * iter);
	void (*end_loading)          (PlumaFileBrowserStore * model,
			              GtkTreeIter * iter);
	void (*error)                (PlumaFileBrowserStore * model,
	                              guint code,
		                      gchar * message);
	gboolean (*no_trash)	     (PlumaFileBrowserStore * model,
				      GList * files);
	void (*rename)		     (PlumaFileBrowserStore * model,
				      const gchar * olduri,
				      const gchar * newuri);
	void (*begin_refresh)	     (PlumaFileBrowserStore * model);
	void (*end_refresh)	     (PlumaFileBrowserStore * model);
	void (*unload)		     (PlumaFileBrowserStore * model,
				      const gchar * uri);
};

GType pluma_file_browser_store_get_type               (void) G_GNUC_CONST;
void _pluma_file_browser_store_register_type          (GTypeModule * module);

PlumaFileBrowserStore *pluma_file_browser_store_new   (gchar const *root);

PlumaFileBrowserStoreResult
pluma_file_browser_store_set_root_and_virtual_root    (PlumaFileBrowserStore * model,
						       gchar const *root,
			  			       gchar const *virtual_root);
PlumaFileBrowserStoreResult
pluma_file_browser_store_set_root                     (PlumaFileBrowserStore * model,
				                       gchar const *root);
PlumaFileBrowserStoreResult
pluma_file_browser_store_set_virtual_root             (PlumaFileBrowserStore * model,
					               GtkTreeIter * iter);
PlumaFileBrowserStoreResult
pluma_file_browser_store_set_virtual_root_from_string (PlumaFileBrowserStore * model,
                                                       gchar const *root);
PlumaFileBrowserStoreResult
pluma_file_browser_store_set_virtual_root_up          (PlumaFileBrowserStore * model);
PlumaFileBrowserStoreResult
pluma_file_browser_store_set_virtual_root_top         (PlumaFileBrowserStore * model);

gboolean
pluma_file_browser_store_get_iter_virtual_root        (PlumaFileBrowserStore * model,
                                                       GtkTreeIter * iter);
gboolean pluma_file_browser_store_get_iter_root       (PlumaFileBrowserStore * model,
						       GtkTreeIter * iter);
gchar * pluma_file_browser_store_get_root             (PlumaFileBrowserStore * model);
gchar * pluma_file_browser_store_get_virtual_root     (PlumaFileBrowserStore * model);

gboolean pluma_file_browser_store_iter_equal          (PlumaFileBrowserStore * model,
                                                       GtkTreeIter * iter1,
					               GtkTreeIter * iter2);

void pluma_file_browser_store_set_value               (PlumaFileBrowserStore * tree_model,
                                                       GtkTreeIter * iter,
                                                       gint column,
                                                       GValue * value);

void _pluma_file_browser_store_iter_expanded          (PlumaFileBrowserStore * model,
                                                       GtkTreeIter * iter);
void _pluma_file_browser_store_iter_collapsed         (PlumaFileBrowserStore * model,
                                                       GtkTreeIter * iter);

PlumaFileBrowserStoreFilterMode
pluma_file_browser_store_get_filter_mode              (PlumaFileBrowserStore * model);
void pluma_file_browser_store_set_filter_mode         (PlumaFileBrowserStore * model,
                                                       PlumaFileBrowserStoreFilterMode mode);
void pluma_file_browser_store_set_filter_func         (PlumaFileBrowserStore * model,
                                                       PlumaFileBrowserStoreFilterFunc func,
                                                       gpointer user_data);
void pluma_file_browser_store_refilter                (PlumaFileBrowserStore * model);
PlumaFileBrowserStoreFilterMode
pluma_file_browser_store_filter_mode_get_default      (void);

void pluma_file_browser_store_refresh                 (PlumaFileBrowserStore * model);
gboolean pluma_file_browser_store_rename              (PlumaFileBrowserStore * model,
                                                       GtkTreeIter * iter,
                                                       gchar const *new_name,
                                                       GError ** error);
PlumaFileBrowserStoreResult
pluma_file_browser_store_delete                       (PlumaFileBrowserStore * model,
                                                       GtkTreeIter * iter,
                                                       gboolean trash);
PlumaFileBrowserStoreResult
pluma_file_browser_store_delete_all                   (PlumaFileBrowserStore * model,
                                                       GList *rows,
                                                       gboolean trash);

gboolean pluma_file_browser_store_new_file            (PlumaFileBrowserStore * model,
                                                       GtkTreeIter * parent,
                                                       GtkTreeIter * iter);
gboolean pluma_file_browser_store_new_directory       (PlumaFileBrowserStore * model,
                                                       GtkTreeIter * parent,
                                                       GtkTreeIter * iter);

void pluma_file_browser_store_cancel_mount_operation  (PlumaFileBrowserStore *store);

G_END_DECLS
#endif				/* __PLUMA_FILE_BROWSER_STORE_H__ */

// ex:ts=8:noet: