gntfilesel.h

Go to the documentation of this file.
00001 
00005 /*
00006  * GNT - The GLib Ncurses Toolkit
00007  *
00008  * GNT is the legal property of its developers, whose names are too numerous
00009  * to list here.  Please refer to the COPYRIGHT file distributed with this
00010  * source distribution.
00011  *
00012  * This library is free software; you can redistribute it and/or modify
00013  * it under the terms of the GNU General Public License as published by
00014  * the Free Software Foundation; either version 2 of the License, or
00015  * (at your option) any later version.
00016  *
00017  * This program is distributed in the hope that it will be useful,
00018  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020  * GNU General Public License for more details.
00021  *
00022  * You should have received a copy of the GNU General Public License
00023  * along with this program; if not, write to the Free Software
00024  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
00025  */
00026 
00027 #ifndef GNT_FILE_SEL_H
00028 #define GNT_FILE_SEL_H
00029 
00030 #include "gntwindow.h"
00031 #include "gnt.h"
00032 #include "gntcolors.h"
00033 #include "gntkeys.h"
00034 
00035 #define GNT_TYPE_FILE_SEL               (gnt_file_sel_get_gtype())
00036 #define GNT_FILE_SEL(obj)               (G_TYPE_CHECK_INSTANCE_CAST((obj), GNT_TYPE_FILE_SEL, GntFileSel))
00037 #define GNT_FILE_SEL_CLASS(klass)       (G_TYPE_CHECK_CLASS_CAST((klass), GNT_TYPE_FILE_SEL, GntFileSelClass))
00038 #define GNT_IS_FILE_SEL(obj)            (G_TYPE_CHECK_INSTANCE_TYPE((obj), GNT_TYPE_FILE_SEL))
00039 #define GNT_IS_FILE_SEL_CLASS(klass)    (G_TYPE_CHECK_CLASS_TYPE((klass), GNT_TYPE_FILE_SEL))
00040 #define GNT_FILE_SEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GNT_TYPE_FILE_SEL, GntFileSelClass))
00041 
00042 #define GNT_FILE_SEL_FLAGS(obj)             (GNT_FILE_SEL(obj)->priv.flags)
00043 #define GNT_FILE_SEL_SET_FLAGS(obj, flags)      (GNT_FILE_SEL_FLAGS(obj) |= flags)
00044 #define GNT_FILE_SEL_UNSET_FLAGS(obj, flags)    (GNT_FILE_SEL_FLAGS(obj) &= ~(flags))
00045 
00046 typedef struct _GntFileSel          GntFileSel;
00047 typedef struct _GntFileSelPriv      GntFileSelPriv;
00048 typedef struct _GntFileSelClass     GntFileSelClass;
00049 typedef struct _GntFile             GntFile;
00050 
00051 struct _GntFileSel
00052 {
00053     GntWindow parent;
00054 
00055     GntWidget *dirs;     /* list of files */
00056     GntWidget *files;    /* list of directories */
00057     GntWidget *location; /* location entry */
00058 
00059     GntWidget *select;   /* select button */
00060     GntWidget *cancel;   /* cancel button */
00061 
00062     char *current; /* Full path of the current location */
00063     char *suggest; /* Suggested filename */
00064     /* XXX: someone should make these useful */
00065     gboolean must_exist; /* Make sure the selected file (the name entered in 'location') exists */
00066     gboolean dirsonly;   /* Show only directories */
00067     gboolean multiselect;
00068     GList *tags;         /* List of tagged files when multiselect is set */
00069 
00070     gboolean (*read_fn)(const char *path, GList **files, GError **error);
00071 };
00072 
00073 struct _GntFileSelClass
00074 {
00075     GntWindowClass parent;
00076 
00077     void (*file_selected)(GntFileSel *sel, const char *path, const char *filename);
00078     void (*gnt_reserved1)(void);
00079     void (*gnt_reserved2)(void);
00080     void (*gnt_reserved3)(void);
00081     void (*gnt_reserved4)(void);
00082 };
00083 
00084 typedef enum _GntFileType
00085 {
00086     GNT_FILE_REGULAR,
00087     GNT_FILE_DIR
00088 } GntFileType;
00089 
00090 struct _GntFile
00091 {
00092     char *fullpath;
00093     char *basename;
00094     GntFileType type;
00095     unsigned long size;
00096 };
00097 
00098 G_BEGIN_DECLS
00099 
00103 GType gnt_file_sel_get_gtype(void);
00104 
00110 GntWidget * gnt_file_sel_new(void);
00111 
00120 gboolean gnt_file_sel_set_current_location(GntFileSel *sel, const char *path);
00121 
00129 void gnt_file_sel_set_dirs_only(GntFileSel *sel, gboolean dirs);
00130 
00138 gboolean gnt_file_sel_get_dirs_only(GntFileSel *sel);
00139 
00146 void gnt_file_sel_set_must_exist(GntFileSel *sel, gboolean must);
00147 
00156 gboolean gnt_file_sel_get_must_exist(GntFileSel *sel);
00157 
00166 char * gnt_file_sel_get_selected_file(GntFileSel *sel);
00167 
00176 GList * gnt_file_sel_get_selected_multi_files(GntFileSel *sel);
00177 
00184 void gnt_file_sel_set_multi_select(GntFileSel *sel, gboolean set);
00185 
00192 void gnt_file_sel_set_suggested_filename(GntFileSel *sel, const char *suggest);
00193 
00200 void gnt_file_sel_set_read_fn(GntFileSel *sel, gboolean (*read_fn)(const char *path, GList **files, GError **error));
00201 
00210 GntFile* gnt_file_new(const char *name, unsigned long size);
00211 
00219 GntFile* gnt_file_new_dir(const char *name);
00220 
00221 G_END_DECLS
00222 
00223 #endif /* GNT_FILE_SEL_H */
00224