1 /* filebrowser.c - draws an interactive file browser
2 Copyright (C) 1996-2017 Paul Sheer
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307, USA.
18 */
19
20 #include <config.h>
21 #include <stdio.h>
22 #include <my_string.h>
23 #include <stdlib.h>
24 #include <stdarg.h>
25
26 #include <sys/types.h>
27 #include <sys/stat.h>
28
29 #ifdef HAVE_UNISTD_H
30 #include <unistd.h>
31 #endif
32
33 #ifdef HAVE_FCNTL_H
34 #include <fcntl.h>
35 #endif
36
37 #include <X11/Intrinsic.h>
38 #include "lkeysym.h"
39
40 #include "stringtools.h"
41 #include "app_glob.c"
42
43 #include "coolwidget.h"
44 #include "editcmddef.h"
45
46 #include "mad.h"
47
48 extern struct look *look;
49
50 #define GETFILE_GET_DIRECTORY 1
51 #define GETFILE_GET_EXISTING_FILE 2
52 #define GETFILE_BROWSER 4
53
54 #define FILE_BROWSER_START_WIDTH 40
55 #define FILE_BROWSER_START_HEIGHT 15
56
57 int option_file_browser_width = FILE_BROWSER_START_WIDTH;
58 int option_file_browser_height = FILE_BROWSER_START_HEIGHT;
59
CDrawBrowser(const char * ident,Window parent,int x,int y,const char * dir,const char * file,const char * label)60 void CDrawBrowser (const char *ident, Window parent, int x, int y,
61 const char *dir, const char *file, const char *label)
62 {
63 (*look->draw_browser) (ident, parent, x, y, dir, file, label);
64 }
65
CGetFile(Window parent,int x,int y,const char * dir,const char * file,const char * label)66 char *CGetFile (Window parent, int x, int y,
67 const char *dir, const char *file, const char *label)
68 {
69 return (*look->get_file_or_dir) (parent, x, y, dir, file, label, 0);
70 }
71
CGetDirectory(Window parent,int x,int y,const char * dir,const char * file,const char * label)72 char *CGetDirectory (Window parent, int x, int y,
73 const char *dir, const char *file, const char *label)
74 {
75 return (*look->get_file_or_dir) (parent, x, y, dir, file, label, GETFILE_GET_DIRECTORY);
76 }
77
CGetSaveFile(Window parent,int x,int y,const char * dir,const char * file,const char * label)78 char *CGetSaveFile (Window parent, int x, int y,
79 const char *dir, const char *file, const char *label)
80 {
81 return (*look->get_file_or_dir) (parent, x, y, dir, file, label, 0);
82 }
83
CGetLoadFile(Window parent,int x,int y,const char * dir,const char * file,const char * label)84 char *CGetLoadFile (Window parent, int x, int y,
85 const char *dir, const char *file, const char *label)
86 {
87 return (*look->get_file_or_dir) (parent, x, y, dir, file, label, GETFILE_GET_EXISTING_FILE);
88 }
89
90
91