gntfilesel.h
Go to the documentation of this file.
1 
5 /*
6  * GNT - The GLib Ncurses Toolkit
7  *
8  * GNT is the legal property of its developers, whose names are too numerous
9  * to list here. Please refer to the COPYRIGHT file distributed with this
10  * source distribution.
11  *
12  * This library is free software; you can redistribute it and/or modify
13  * it under the terms of the GNU General Public License as published by
14  * the Free Software Foundation; either version 2 of the License, or
15  * (at your option) any later version.
16  *
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  * GNU General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
25  */
26 
27 #ifndef GNT_FILE_SEL_H
28 #define GNT_FILE_SEL_H
29 
30 #include "gntwindow.h"
31 #include "gnt.h"
32 #include "gntcolors.h"
33 #include "gntkeys.h"
34 
35 #define GNT_TYPE_FILE_SEL (gnt_file_sel_get_gtype())
36 #define GNT_FILE_SEL(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GNT_TYPE_FILE_SEL, GntFileSel))
37 #define GNT_FILE_SEL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GNT_TYPE_FILE_SEL, GntFileSelClass))
38 #define GNT_IS_FILE_SEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNT_TYPE_FILE_SEL))
39 #define GNT_IS_FILE_SEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GNT_TYPE_FILE_SEL))
40 #define GNT_FILE_SEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GNT_TYPE_FILE_SEL, GntFileSelClass))
41 
42 #define GNT_FILE_SEL_FLAGS(obj) (GNT_FILE_SEL(obj)->priv.flags)
43 #define GNT_FILE_SEL_SET_FLAGS(obj, flags) (GNT_FILE_SEL_FLAGS(obj) |= flags)
44 #define GNT_FILE_SEL_UNSET_FLAGS(obj, flags) (GNT_FILE_SEL_FLAGS(obj) &= ~(flags))
45 
46 typedef struct _GntFileSel GntFileSel;
47 typedef struct _GntFileSelPriv GntFileSelPriv;
48 typedef struct _GntFileSelClass GntFileSelClass;
49 typedef struct _GntFile GntFile;
50 
52 {
53  GntWindow parent;
54 
55  GntWidget *dirs; /* list of files */
56  GntWidget *files; /* list of directories */
57  GntWidget *location; /* location entry */
58 
59  GntWidget *select; /* select button */
60  GntWidget *cancel; /* cancel button */
61 
62  char *current; /* Full path of the current location */
63  char *suggest; /* Suggested filename */
64  /* XXX: someone should make these useful */
65  gboolean must_exist; /* Make sure the selected file (the name entered in 'location') exists */
66  gboolean dirsonly; /* Show only directories */
67  gboolean multiselect;
68  GList *tags; /* List of tagged files when multiselect is set */
69 
70  gboolean (*read_fn)(const char *path, GList **files, GError **error);
71 };
72 
74 {
75  GntWindowClass parent;
76 
77  void (*file_selected)(GntFileSel *sel, const char *path, const char *filename);
78  void (*gnt_reserved1)(void);
79  void (*gnt_reserved2)(void);
80  void (*gnt_reserved3)(void);
81  void (*gnt_reserved4)(void);
82 };
83 
84 typedef enum _GntFileType
85 {
86  GNT_FILE_REGULAR,
87  GNT_FILE_DIR
88 } GntFileType;
89 
90 struct _GntFile
91 {
92  char *fullpath;
93  char *basename;
94  GntFileType type;
95  unsigned long size;
96 };
97 
98 G_BEGIN_DECLS
99 
103 GType gnt_file_sel_get_gtype(void);
104 
111 
120 gboolean gnt_file_sel_set_current_location(GntFileSel *sel, const char *path);
121 
129 void gnt_file_sel_set_dirs_only(GntFileSel *sel, gboolean dirs);
130 
139 
146 void gnt_file_sel_set_must_exist(GntFileSel *sel, gboolean must);
147 
157 
167 
177 
184 void gnt_file_sel_set_multi_select(GntFileSel *sel, gboolean set);
185 
192 void gnt_file_sel_set_suggested_filename(GntFileSel *sel, const char *suggest);
193 
200 void gnt_file_sel_set_read_fn(GntFileSel *sel, gboolean (*read_fn)(const char *path, GList **files, GError **error));
201 
210 GntFile* gnt_file_new(const char *name, unsigned long size);
211 
219 GntFile* gnt_file_new_dir(const char *name);
220 
221 G_END_DECLS
222 
223 #endif /* GNT_FILE_SEL_H */
224 
Colors API.
gboolean gnt_file_sel_get_must_exist(GntFileSel *sel)
Check whether the selector allows selecting non-existent files.
Window API.
GNT API.
void gnt_file_sel_set_multi_select(GntFileSel *sel, gboolean set)
Allow selecting multiple files.
G_BEGIN_DECLS GType gnt_file_sel_get_gtype(void)
Keys API.
void gnt_file_sel_set_must_exist(GntFileSel *sel, gboolean must)
Set whether a selected file must exist.
gboolean gnt_file_sel_set_current_location(GntFileSel *sel, const char *path)
Set the current location of the file selector.
void gnt_file_sel_set_suggested_filename(GntFileSel *sel, const char *suggest)
Set the suggested file to have selected at startup.
char * gnt_file_sel_get_selected_file(GntFileSel *sel)
Get the selected file in the selector.
GntFile * gnt_file_new_dir(const char *name)
Create a new GntFile for a directory.
GList * gnt_file_sel_get_selected_multi_files(GntFileSel *sel)
Get the list of selected files in the selector.
gboolean gnt_file_sel_get_dirs_only(GntFileSel *sel)
Check whether the file selector allows only selecting directories.
GntWidget * gnt_file_sel_new(void)
Create a new file selector.
void gnt_file_sel_set_dirs_only(GntFileSel *sel, gboolean dirs)
Set wheter to only allow selecting directories.
void gnt_file_sel_set_read_fn(GntFileSel *sel, gboolean(*read_fn)(const char *path, GList **files, GError **error))
Set custom functions to read the names of files.
GntFile * gnt_file_new(const char *name, unsigned long size)
Create a new GntFile.