1 /*
2  * pluma-file-browser-store.h - Pluma plugin providing easy file access
3  * from the sidepanel
4  *
5  * Copyright (C) 2006 - Jesse van den Kieboom <jesse@icecrew.nl>
6  * Copyright (C) 2012-2021 MATE Developers
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2, or (at your option)
11  * any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
21  */
22 
23 #ifndef __PLUMA_FILE_BROWSER_STORE_H__
24 #define __PLUMA_FILE_BROWSER_STORE_H__
25 
26 #include <gtk/gtk.h>
27 
28 G_BEGIN_DECLS
29 #define PLUMA_TYPE_FILE_BROWSER_STORE			(pluma_file_browser_store_get_type ())
30 #define PLUMA_FILE_BROWSER_STORE(obj)			(G_TYPE_CHECK_INSTANCE_CAST ((obj), PLUMA_TYPE_FILE_BROWSER_STORE, PlumaFileBrowserStore))
31 #define PLUMA_FILE_BROWSER_STORE_CONST(obj)		(G_TYPE_CHECK_INSTANCE_CAST ((obj), PLUMA_TYPE_FILE_BROWSER_STORE, PlumaFileBrowserStore const))
32 #define PLUMA_FILE_BROWSER_STORE_CLASS(klass)		(G_TYPE_CHECK_CLASS_CAST ((klass), PLUMA_TYPE_FILE_BROWSER_STORE, PlumaFileBrowserStoreClass))
33 #define PLUMA_IS_FILE_BROWSER_STORE(obj)		(G_TYPE_CHECK_INSTANCE_TYPE ((obj), PLUMA_TYPE_FILE_BROWSER_STORE))
34 #define PLUMA_IS_FILE_BROWSER_STORE_CLASS(klass)	(G_TYPE_CHECK_CLASS_TYPE ((klass), PLUMA_TYPE_FILE_BROWSER_STORE))
35 #define PLUMA_FILE_BROWSER_STORE_GET_CLASS(obj)		(G_TYPE_INSTANCE_GET_CLASS ((obj), PLUMA_TYPE_FILE_BROWSER_STORE, PlumaFileBrowserStoreClass))
36 
37 typedef enum
38 {
39 	PLUMA_FILE_BROWSER_STORE_COLUMN_ICON = 0,
40 	PLUMA_FILE_BROWSER_STORE_COLUMN_NAME,
41 	PLUMA_FILE_BROWSER_STORE_COLUMN_URI,
42 	PLUMA_FILE_BROWSER_STORE_COLUMN_FLAGS,
43 	PLUMA_FILE_BROWSER_STORE_COLUMN_EMBLEM,
44 	PLUMA_FILE_BROWSER_STORE_COLUMN_NUM
45 } PlumaFileBrowserStoreColumn;
46 
47 typedef enum
48 {
49 	PLUMA_FILE_BROWSER_STORE_FLAG_IS_DIRECTORY = 1 << 0,
50 	PLUMA_FILE_BROWSER_STORE_FLAG_IS_HIDDEN    = 1 << 1,
51 	PLUMA_FILE_BROWSER_STORE_FLAG_IS_TEXT      = 1 << 2,
52 	PLUMA_FILE_BROWSER_STORE_FLAG_LOADED       = 1 << 3,
53 	PLUMA_FILE_BROWSER_STORE_FLAG_IS_FILTERED  = 1 << 4,
54 	PLUMA_FILE_BROWSER_STORE_FLAG_IS_DUMMY     = 1 << 5
55 } PlumaFileBrowserStoreFlag;
56 
57 typedef enum
58 {
59 	PLUMA_FILE_BROWSER_STORE_RESULT_OK,
60 	PLUMA_FILE_BROWSER_STORE_RESULT_NO_CHANGE,
61 	PLUMA_FILE_BROWSER_STORE_RESULT_ERROR,
62 	PLUMA_FILE_BROWSER_STORE_RESULT_NO_TRASH,
63 	PLUMA_FILE_BROWSER_STORE_RESULT_MOUNTING,
64 	PLUMA_FILE_BROWSER_STORE_RESULT_NUM
65 } PlumaFileBrowserStoreResult;
66 
67 typedef enum
68 {
69 	PLUMA_FILE_BROWSER_STORE_FILTER_MODE_NONE        = 0,
70 	PLUMA_FILE_BROWSER_STORE_FILTER_MODE_HIDE_HIDDEN = 1 << 0,
71 	PLUMA_FILE_BROWSER_STORE_FILTER_MODE_HIDE_BINARY = 1 << 1
72 } PlumaFileBrowserStoreFilterMode;
73 
74 #define FILE_IS_DIR(flags)	(flags & PLUMA_FILE_BROWSER_STORE_FLAG_IS_DIRECTORY)
75 #define FILE_IS_HIDDEN(flags)	(flags & PLUMA_FILE_BROWSER_STORE_FLAG_IS_HIDDEN)
76 #define FILE_IS_TEXT(flags)	(flags & PLUMA_FILE_BROWSER_STORE_FLAG_IS_TEXT)
77 #define FILE_LOADED(flags)	(flags & PLUMA_FILE_BROWSER_STORE_FLAG_LOADED)
78 #define FILE_IS_FILTERED(flags)	(flags & PLUMA_FILE_BROWSER_STORE_FLAG_IS_FILTERED)
79 #define FILE_IS_DUMMY(flags)	(flags & PLUMA_FILE_BROWSER_STORE_FLAG_IS_DUMMY)
80 
81 typedef struct _PlumaFileBrowserStore        PlumaFileBrowserStore;
82 typedef struct _PlumaFileBrowserStoreClass   PlumaFileBrowserStoreClass;
83 typedef struct _PlumaFileBrowserStorePrivate PlumaFileBrowserStorePrivate;
84 
85 typedef gboolean (*PlumaFileBrowserStoreFilterFunc) (PlumaFileBrowserStore
86 						     * model,
87 						     GtkTreeIter * iter,
88 						     gpointer user_data);
89 
90 struct _PlumaFileBrowserStore
91 {
92 	GObject parent;
93 
94 	PlumaFileBrowserStorePrivate *priv;
95 };
96 
97 struct _PlumaFileBrowserStoreClass {
98 	GObjectClass parent_class;
99 
100 	/* Signals */
101 	void (*begin_loading)        (PlumaFileBrowserStore * model,
102 			              GtkTreeIter * iter);
103 	void (*end_loading)          (PlumaFileBrowserStore * model,
104 			              GtkTreeIter * iter);
105 	void (*error)                (PlumaFileBrowserStore * model,
106 	                              guint code,
107 		                      gchar * message);
108 	gboolean (*no_trash)	     (PlumaFileBrowserStore * model,
109 				      GList * files);
110 	void (*rename)		     (PlumaFileBrowserStore * model,
111 				      const gchar * olduri,
112 				      const gchar * newuri);
113 	void (*begin_refresh)	     (PlumaFileBrowserStore * model);
114 	void (*end_refresh)	     (PlumaFileBrowserStore * model);
115 	void (*unload)		     (PlumaFileBrowserStore * model,
116 				      const gchar * uri);
117 };
118 
119 GType pluma_file_browser_store_get_type               (void) G_GNUC_CONST;
120 void _pluma_file_browser_store_register_type          (GTypeModule * module);
121 
122 PlumaFileBrowserStore *pluma_file_browser_store_new   (gchar const *root);
123 
124 PlumaFileBrowserStoreResult
125 pluma_file_browser_store_set_root_and_virtual_root    (PlumaFileBrowserStore * model,
126 						       gchar const *root,
127 			  			       gchar const *virtual_root);
128 PlumaFileBrowserStoreResult
129 pluma_file_browser_store_set_root                     (PlumaFileBrowserStore * model,
130 				                       gchar const *root);
131 PlumaFileBrowserStoreResult
132 pluma_file_browser_store_set_virtual_root             (PlumaFileBrowserStore * model,
133 					               GtkTreeIter * iter);
134 PlumaFileBrowserStoreResult
135 pluma_file_browser_store_set_virtual_root_from_string (PlumaFileBrowserStore * model,
136                                                        gchar const *root);
137 PlumaFileBrowserStoreResult
138 pluma_file_browser_store_set_virtual_root_up          (PlumaFileBrowserStore * model);
139 PlumaFileBrowserStoreResult
140 pluma_file_browser_store_set_virtual_root_top         (PlumaFileBrowserStore * model);
141 
142 gboolean
143 pluma_file_browser_store_get_iter_virtual_root        (PlumaFileBrowserStore * model,
144                                                        GtkTreeIter * iter);
145 gboolean pluma_file_browser_store_get_iter_root       (PlumaFileBrowserStore * model,
146 						       GtkTreeIter * iter);
147 gchar * pluma_file_browser_store_get_root             (PlumaFileBrowserStore * model);
148 gchar * pluma_file_browser_store_get_virtual_root     (PlumaFileBrowserStore * model);
149 
150 gboolean pluma_file_browser_store_iter_equal          (PlumaFileBrowserStore * model,
151                                                        GtkTreeIter * iter1,
152 					               GtkTreeIter * iter2);
153 
154 void pluma_file_browser_store_set_value               (PlumaFileBrowserStore * tree_model,
155                                                        GtkTreeIter * iter,
156                                                        gint column,
157                                                        GValue * value);
158 
159 void _pluma_file_browser_store_iter_expanded          (PlumaFileBrowserStore * model,
160                                                        GtkTreeIter * iter);
161 void _pluma_file_browser_store_iter_collapsed         (PlumaFileBrowserStore * model,
162                                                        GtkTreeIter * iter);
163 
164 PlumaFileBrowserStoreFilterMode
165 pluma_file_browser_store_get_filter_mode              (PlumaFileBrowserStore * model);
166 void pluma_file_browser_store_set_filter_mode         (PlumaFileBrowserStore * model,
167                                                        PlumaFileBrowserStoreFilterMode mode);
168 void pluma_file_browser_store_set_filter_func         (PlumaFileBrowserStore * model,
169                                                        PlumaFileBrowserStoreFilterFunc func,
170                                                        gpointer user_data);
171 void pluma_file_browser_store_refilter                (PlumaFileBrowserStore * model);
172 PlumaFileBrowserStoreFilterMode
173 pluma_file_browser_store_filter_mode_get_default      (void);
174 
175 void pluma_file_browser_store_refresh                 (PlumaFileBrowserStore * model);
176 gboolean pluma_file_browser_store_rename              (PlumaFileBrowserStore * model,
177                                                        GtkTreeIter * iter,
178                                                        gchar const *new_name,
179                                                        GError ** error);
180 PlumaFileBrowserStoreResult
181 pluma_file_browser_store_delete                       (PlumaFileBrowserStore * model,
182                                                        GtkTreeIter * iter,
183                                                        gboolean trash);
184 PlumaFileBrowserStoreResult
185 pluma_file_browser_store_delete_all                   (PlumaFileBrowserStore * model,
186                                                        GList *rows,
187                                                        gboolean trash);
188 
189 gboolean pluma_file_browser_store_new_file            (PlumaFileBrowserStore * model,
190                                                        GtkTreeIter * parent,
191                                                        GtkTreeIter * iter);
192 gboolean pluma_file_browser_store_new_directory       (PlumaFileBrowserStore * model,
193                                                        GtkTreeIter * parent,
194                                                        GtkTreeIter * iter);
195 
196 void pluma_file_browser_store_cancel_mount_operation  (PlumaFileBrowserStore *store);
197 
198 G_END_DECLS
199 #endif				/* __PLUMA_FILE_BROWSER_STORE_H__ */
200 
201 // ex:ts=8:noet:
202