3 * Copyright (C) 2007 Tomas 'ZeXx86' Jedrzejek (zexx86@gmail.com)
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 #include <libx/base.h>
25 #include <libx/object.h>
26 #include <libx/image.h>
27 #include <libx/cursor.h>
28 #include <libx/text.h>
32 #define VFS_FILEATTR_FILE 0x1
33 #define VFS_FILEATTR_DIR 0x2
34 #define VFS_FILEATTR_HIDDEN 0x4
35 #define VFS_FILEATTR_SYSTEM 0x8
36 #define VFS_FILEATTR_BIN 0x10
37 #define VFS_FILEATTR_READ 0x20
38 #define VFS_FILEATTR_WRITE 0x40
39 #define VFS_FILEATTR_MOUNTED 0x80
47 extern wmcursor
*cursor
;
49 unsigned winfm_act
= 0;
55 unsigned short *bitmap_folder
;
56 unsigned short *bitmap_file
;
64 : "=g" (dirent
) :: "%eax");
67 void chdir (char *dir
)
73 :: "b" (dir
) : "%eax", "memory");
76 unsigned filemanager_exit ()
87 winfm
= window_create ("Filemanager");
94 //winfm->hnd_exit = (unsigned *) &filemanager_exit;
97 unsigned filemanager_draw ()
99 if (!winfm_act
|| !winfm
)
102 /* when error or directory is clear */
104 if (cursor
->state
== XCURSOR_STATE_RBUTTON
) {
117 xtext_puts (winfm
->x
+1+(id
*42), winfm
->y
+44, 0, dirent
[id
].name
);
119 if ((winfm
->x
+33+(id
*42)) > winfm
->x
+winfm
->size_x
)
127 unsigned short *bitmap
= 0;
129 if (dirent
[id
].attrib
& VFS_FILEATTR_DIR
)
130 bitmap
= bitmap_folder
;
132 if (dirent
[id
].attrib
& VFS_FILEATTR_FILE
)
133 bitmap
= bitmap_file
;
138 for (i
= 0; i
< 32*32; i
++) {
146 if (bitmap
[pix
] != 0)
147 xpixel (winfm
->x
+1+k
+(id
*42), winfm
->y
+12+j
, (unsigned short) bitmap
[pix
]);
152 if (cursor
->state
== XCURSOR_STATE_LBUTTON
)
153 if (cursor
->x
> (signed) (winfm
->x
+1+(id
*42)) && cursor
->x
< (signed) (winfm
->x
+33+(id
*42)) &&
154 cursor
->y
> (signed) winfm
->y
+12 && cursor
->y
<= (signed) winfm
->y
+54) {
155 if (dirent
[id
].attrib
& VFS_FILEATTR_DIR
) {
156 if (dirent
[id
].name
[0] == '.') {
157 if (dirent
[id
].name
[1] == '.') {
169 chdir (dirent
[id
].name
);
178 if (dirent
[id
].attrib
& VFS_FILEATTR_FILE
) {
179 tview_open (dirent
[id
].name
);
185 if (cursor
->state
== XCURSOR_STATE_RBUTTON
) {
186 if (cursor
->x
> (signed) winfm
->x
&& cursor
->x
< (signed) winfm
->x
+(signed) winfm
->size_x
&&
187 cursor
->y
> (signed) winfm
->y
+11 && cursor
->y
<= (signed) winfm
->y
+(signed) winfm
->size_y
) {
201 if (!dirent
[id
].next
)
210 unsigned init_filemanager ()
213 bitmap_folder
= (unsigned short *) malloc (2100);
218 memset (bitmap_folder
, 0, 2048+70);
221 int fd
= open ("folder", O_RDONLY
);
224 puts ("error -> file 'folder' not found\n");
228 /*if (!read (fd, (unsigned char *) bitmap_folder, 2048+70)) {
229 puts ("error -> something was wrong !\n");
234 bitmap_file
= (unsigned short *) malloc (2100);
239 memset (bitmap_file
, 0, 2048+70);
242 fd
= open ("file", O_RDONLY
);
245 puts ("error -> file 'file' not found\n");
249 /*if (!read (fd, (unsigned char *) bitmap_file, 2048+70)) {
250 puts ("error -> something was wrong !\n");