3 * Copyright (C) 2007 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org)
4 * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org)
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
26 #include <libx/base.h>
27 #include <libx/object.h>
28 #include <libx/image.h>
29 #include <libx/cursor.h>
30 #include <libx/text.h>
34 #define VFS_FILEATTR_FILE 0x1
35 #define VFS_FILEATTR_DIR 0x2
36 #define VFS_FILEATTR_HIDDEN 0x4
37 #define VFS_FILEATTR_SYSTEM 0x8
38 #define VFS_FILEATTR_BIN 0x10
39 #define VFS_FILEATTR_READ 0x20
40 #define VFS_FILEATTR_WRITE 0x40
41 #define VFS_FILEATTR_MOUNTED 0x80
49 extern wmcursor
*cursor
;
51 unsigned winfm_act
= 0;
57 unsigned short *bitmap_folder
;
58 unsigned short *bitmap_file
;
66 : "=g" (dirent
) :: "%eax");
69 unsigned filemanager_exit ()
80 winfm
= window_create ("Filemanager");
87 //winfm->hnd_exit = (unsigned *) &filemanager_exit;
90 unsigned filemanager_draw ()
92 if (!winfm_act
|| !winfm
)
95 /* when error or directory is clear */
97 if (cursor
->state
== XCURSOR_STATE_RBUTTON
) {
110 xtext_puts (winfm
->x
+1+(id
*42), winfm
->y
+44, 0, dirent
[id
].name
);
112 if ((winfm
->x
+33+(id
*42)) > winfm
->x
+winfm
->size_x
)
120 unsigned short *bitmap
= 0;
122 if (dirent
[id
].attrib
& VFS_FILEATTR_DIR
)
123 bitmap
= bitmap_folder
;
125 if (dirent
[id
].attrib
& VFS_FILEATTR_FILE
)
126 bitmap
= bitmap_file
;
131 for (i
= 0; i
< 32*32; i
++) {
139 if (bitmap
[pix
] != 0)
140 xpixel (winfm
->x
+1+k
+(id
*42), winfm
->y
+12+j
, (unsigned short) bitmap
[pix
]);
145 if (cursor
->state
== XCURSOR_STATE_LBUTTON
)
146 if (cursor
->x
> (signed) (winfm
->x
+1+(id
*42)) && cursor
->x
< (signed) (winfm
->x
+33+(id
*42)) &&
147 cursor
->y
> (signed) winfm
->y
+12 && cursor
->y
<= (signed) winfm
->y
+54) {
148 if (dirent
[id
].attrib
& VFS_FILEATTR_DIR
) {
149 if (dirent
[id
].name
[0] == '.') {
150 if (dirent
[id
].name
[1] == '.') {
162 chdir (dirent
[id
].name
);
171 if (dirent
[id
].attrib
& VFS_FILEATTR_FILE
) {
172 tview_open (dirent
[id
].name
);
178 if (cursor
->state
== XCURSOR_STATE_RBUTTON
) {
179 if (cursor
->x
> (signed) winfm
->x
&& cursor
->x
< (signed) winfm
->x
+(signed) winfm
->size_x
&&
180 cursor
->y
> (signed) winfm
->y
+11 && cursor
->y
<= (signed) winfm
->y
+(signed) winfm
->size_y
) {
194 if (!dirent
[id
].next
)
203 unsigned init_filemanager ()
206 bitmap_folder
= (unsigned short *) malloc (2100);
211 memset (bitmap_folder
, 0, 2048+70);
214 int fd
= open ("folder", O_RDONLY
);
217 puts ("error -> file 'folder' not found\n");
221 /*if (!read (fd, (unsigned char *) bitmap_folder, 2048+70)) {
222 puts ("error -> something was wrong !\n");
227 bitmap_file
= (unsigned short *) malloc (2100);
232 memset (bitmap_file
, 0, 2048+70);
235 fd
= open ("file", O_RDONLY
);
238 puts ("error -> file 'file' not found\n");
242 /*if (!read (fd, (unsigned char *) bitmap_file, 2048+70)) {
243 puts ("error -> something was wrong !\n");