3 * Copyright (C) 2007 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com)
4 * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com)
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 void chdir (char *dir
)
75 :: "b" (dir
) : "%eax", "memory");
78 unsigned filemanager_exit ()
89 winfm
= window_create ("Filemanager");
96 //winfm->hnd_exit = (unsigned *) &filemanager_exit;
99 unsigned filemanager_draw ()
101 if (!winfm_act
|| !winfm
)
104 /* when error or directory is clear */
106 if (cursor
->state
== XCURSOR_STATE_RBUTTON
) {
119 xtext_puts (winfm
->x
+1+(id
*42), winfm
->y
+44, 0, dirent
[id
].name
);
121 if ((winfm
->x
+33+(id
*42)) > winfm
->x
+winfm
->size_x
)
129 unsigned short *bitmap
= 0;
131 if (dirent
[id
].attrib
& VFS_FILEATTR_DIR
)
132 bitmap
= bitmap_folder
;
134 if (dirent
[id
].attrib
& VFS_FILEATTR_FILE
)
135 bitmap
= bitmap_file
;
140 for (i
= 0; i
< 32*32; i
++) {
148 if (bitmap
[pix
] != 0)
149 xpixel (winfm
->x
+1+k
+(id
*42), winfm
->y
+12+j
, (unsigned short) bitmap
[pix
]);
154 if (cursor
->state
== XCURSOR_STATE_LBUTTON
)
155 if (cursor
->x
> (signed) (winfm
->x
+1+(id
*42)) && cursor
->x
< (signed) (winfm
->x
+33+(id
*42)) &&
156 cursor
->y
> (signed) winfm
->y
+12 && cursor
->y
<= (signed) winfm
->y
+54) {
157 if (dirent
[id
].attrib
& VFS_FILEATTR_DIR
) {
158 if (dirent
[id
].name
[0] == '.') {
159 if (dirent
[id
].name
[1] == '.') {
171 chdir (dirent
[id
].name
);
180 if (dirent
[id
].attrib
& VFS_FILEATTR_FILE
) {
181 tview_open (dirent
[id
].name
);
187 if (cursor
->state
== XCURSOR_STATE_RBUTTON
) {
188 if (cursor
->x
> (signed) winfm
->x
&& cursor
->x
< (signed) winfm
->x
+(signed) winfm
->size_x
&&
189 cursor
->y
> (signed) winfm
->y
+11 && cursor
->y
<= (signed) winfm
->y
+(signed) winfm
->size_y
) {
203 if (!dirent
[id
].next
)
212 unsigned init_filemanager ()
215 bitmap_folder
= (unsigned short *) malloc (2100);
220 memset (bitmap_folder
, 0, 2048+70);
223 int fd
= open ("folder", O_RDONLY
);
226 puts ("error -> file 'folder' not found\n");
230 /*if (!read (fd, (unsigned char *) bitmap_folder, 2048+70)) {
231 puts ("error -> something was wrong !\n");
236 bitmap_file
= (unsigned short *) malloc (2100);
241 memset (bitmap_file
, 0, 2048+70);
244 fd
= open ("file", O_RDONLY
);
247 puts ("error -> file 'file' not found\n");
251 /*if (!read (fd, (unsigned char *) bitmap_file, 2048+70)) {
252 puts ("error -> something was wrong !\n");