2 * GNT - The GLib Ncurses Toolkit
4 * GNT is the legal property of its developers, whose names are too numerous
5 * to list here. Please refer to the COPYRIGHT file distributed with this
8 * This library 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 of the License, or
11 * (at your option) any later version.
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.
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 Street, Fifth Floor, Boston, MA 02111-1301 USA
23 #ifndef GNT_FILE_SEL_H
24 #define GNT_FILE_SEL_H
27 * @section_id: libgnt-gntfilesel
28 * @short_description: <filename>gntfilesel.h</filename>
29 * @title: File Selector
32 #include "gntwindow.h"
34 #include "gntcolors.h"
37 #define GNT_TYPE_FILE_SEL (gnt_file_sel_get_type())
38 #define GNT_FILE_SEL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GNT_TYPE_FILE_SEL, GntFileSel))
39 #define GNT_FILE_SEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GNT_TYPE_FILE_SEL, GntFileSelClass))
40 #define GNT_IS_FILE_SEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNT_TYPE_FILE_SEL))
41 #define GNT_IS_FILE_SEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GNT_TYPE_FILE_SEL))
42 #define GNT_FILE_SEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GNT_TYPE_FILE_SEL, GntFileSelClass))
44 #define GNT_FILE_SEL_FLAGS(obj) (GNT_FILE_SEL(obj)->priv.flags)
45 #define GNT_FILE_SEL_SET_FLAGS(obj, flags) (GNT_FILE_SEL_FLAGS(obj) |= flags)
46 #define GNT_FILE_SEL_UNSET_FLAGS(obj, flags) (GNT_FILE_SEL_FLAGS(obj) &= ~(flags))
48 #define GNT_TYPE_FILE (gnt_file_get_type())
50 typedef struct _GntFileSel GntFileSel
;
51 typedef struct _GntFileSelPriv GntFileSelPriv
;
52 typedef struct _GntFileSelClass GntFileSelClass
;
53 typedef struct _GntFile GntFile
;
59 GntWidget
*dirs
; /* list of files */
60 GntWidget
*files
; /* list of directories */
61 GntWidget
*location
; /* location entry */
63 GntWidget
*select
; /* select button */
64 GntWidget
*cancel
; /* cancel button */
66 char *current
; /* Full path of the current location */
67 char *suggest
; /* Suggested filename */
68 /* XXX: someone should make these useful */
69 gboolean must_exist
; /* Make sure the selected file (the name entered in 'location') exists */
70 gboolean dirsonly
; /* Show only directories */
72 GList
*tags
; /* List of tagged files when multiselect is set */
74 gboolean (*read_fn
)(const char *path
, GList
**files
, GError
**error
);
77 struct _GntFileSelClass
79 GntWindowClass parent
;
81 void (*file_selected
)(GntFileSel
*sel
, const char *path
, const char *filename
);
84 void (*gnt_reserved1
)(void);
85 void (*gnt_reserved2
)(void);
86 void (*gnt_reserved3
)(void);
87 void (*gnt_reserved4
)(void);
107 * gnt_file_sel_get_type:
109 * Returns: GType for GntFileSel.
111 GType
gnt_file_sel_get_type(void);
116 * Returns: The #GType for the #GntFile boxed structure.
118 GType
gnt_file_get_type(void);
123 * Create a new file selector.
125 * Returns: The newly created file selector.
127 GntWidget
* gnt_file_sel_new(void);
130 * gnt_file_sel_set_current_location:
131 * @sel: The file selector.
132 * @path: The current path of the selector.
134 * Set the current location of the file selector.
136 * Returns: %TRUE if the current location was successfully changed, %FALSE otherwise.
138 gboolean
gnt_file_sel_set_current_location(GntFileSel
*sel
, const char *path
);
141 * gnt_file_sel_set_dirs_only:
142 * @sel: The file selector.
143 * @dirs: %TRUE if only directories can be selected, %FALSE if files
144 * can also be selected.
146 * Set wheter to only allow selecting directories.
148 void gnt_file_sel_set_dirs_only(GntFileSel
*sel
, gboolean dirs
);
151 * gnt_file_sel_get_dirs_only:
152 * @sel: The file selector.
154 * Check whether the file selector allows only selecting directories.
156 * Returns: %TRUE if only directories can be selected.
158 gboolean
gnt_file_sel_get_dirs_only(GntFileSel
*sel
);
161 * gnt_file_sel_set_must_exist:
162 * @sel: The file selector.
163 * @must: %TRUE if the selected file must exist.
165 * Set whether a selected file must exist.
167 void gnt_file_sel_set_must_exist(GntFileSel
*sel
, gboolean must
);
170 * gnt_file_sel_get_must_exist:
171 * @sel: The file selector.
173 * Check whether the selector allows selecting non-existent files.
175 * Returns: %TRUE if the selected file must exist, %FALSE if a non-existent
176 * file can be selected.
178 gboolean
gnt_file_sel_get_must_exist(GntFileSel
*sel
);
181 * gnt_file_sel_get_selected_file:
182 * @sel: The file selector.
184 * Get the selected file in the selector.
186 * Returns: The path of the selected file. The caller should g_free the returned
189 char * gnt_file_sel_get_selected_file(GntFileSel
*sel
);
192 * gnt_file_sel_get_selected_multi_files:
193 * @sel: The file selector.
195 * Get the list of selected files in the selector.
197 * Returns: (transfer full) (element-type filename): A list of paths for the
198 * selected files. The caller must g_free() the contents of the list,
199 * and g_list_free() the list.
201 GList
* gnt_file_sel_get_selected_multi_files(GntFileSel
*sel
);
204 * gnt_file_sel_set_multi_select:
205 * @sel: The file selector.
206 * @set: %TRUE if selecting multiple files should be allowed.
208 * Allow selecting multiple files.
210 void gnt_file_sel_set_multi_select(GntFileSel
*sel
, gboolean set
);
213 * gnt_file_sel_set_suggested_filename:
214 * @sel: The file selector.
215 * @suggest: The suggested filename.
217 * Set the suggested file to have selected at startup.
219 void gnt_file_sel_set_suggested_filename(GntFileSel
*sel
, const char *suggest
);
222 * gnt_file_sel_set_read_fn:
223 * @sel: The file selector.
224 * @read_fn: The custom read function.
226 * Set custom functions to read the names of files.
228 void gnt_file_sel_set_read_fn(GntFileSel
*sel
, gboolean (*read_fn
)(const char *path
, GList
**files
, GError
**error
));
232 * @name: The name of the file.
233 * @size: The size of the file.
235 * Create a new GntFile.
237 * Returns: The newly created GntFile.
239 GntFile
* gnt_file_new(const char *name
, unsigned long size
);
243 * @name: The name of the directory.
245 * Create a new GntFile for a directory.
247 * Returns: The newly created GntFile.
249 GntFile
* gnt_file_new_dir(const char *name
);
253 #endif /* GNT_FILE_SEL_H */