3 * Copyright (C) 2008 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org)
4 * Copyright (C) 2009 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/>.
27 #include <libx/base.h>
28 #include <libx/object.h>
29 #include <libx/image.h>
30 #include <libx/cursor.h>
31 #include <libx/text.h>
39 extern zde_win_t
*zde_win_last
;
40 extern zde_cursor_t
*zde_cursor
;
47 } __attribute__ ((__packed__
)) dirent_t
;
60 : "=g" (dirent
) :: "%eax");
63 void *handler_icon_reader (void *r
)
69 sprintf (desc
, "Reader - %s", r
);
71 /* create test window */
72 zde_win_t
*window
= create_window (desc
, 1);
77 int fd
= open (r
, O_RDONLY
);
82 int l
= lseek (fd
, 0, SEEK_END
);
84 lseek (fd
, 0, SEEK_SET
);
86 char *buf
= (char *) malloc (l
+1);
93 zde_dobj_text_t dobj_text
;
95 dobj_text
.data
= (char *) buf
;
100 create_dialog_object (ZDE_DOBJ_TYPE_TEXT
, &dobj_text
, 0, 0, window
);
102 while (!(window
->state
& WINDOW_STATE_CLOSE
)) {
105 if (window
!= zde_win_last
)
108 if (zde_cursor
->state
== XCURSOR_STATE_LBUTTON
) {
119 void *handler_icon_terminal (void *r
)
125 sprintf (desc
, "Terminal");
127 /* create test window */
128 zde_win_t
*window
= create_window (desc
, 1);
133 window
->sizex
= 6 * 80;
134 window
->sizey
= 9 * 65;
136 int fd
= open ("/dev/tty1", O_RDWR
);
141 if (fcntl (fd
, F_SETFL
, 0x2000) == -1) {
142 printf ("Cant set fd to terminal mode\n");
146 int l
= lseek (fd
, 0, SEEK_END
);
148 lseek (fd
, 0, SEEK_SET
);
150 char *buf
= (char *) malloc (l
+1);
155 char *buf2
= (char *) malloc (l
+1);
162 zde_dobj_text_t dobj_text
;
166 dobj_text
.data
= (char *) "tty";
169 zde_dobj_t
*dobj
= create_dialog_object (ZDE_DOBJ_TYPE_TEXT
, &dobj_text
, 0, 0, window
);
174 zde_dobj_text_t
*text
= (zde_dobj_text_t
*) dobj
->arg
;
179 while (!(window
->state
& WINDOW_STATE_CLOSE
)) {
182 if (window
!= zde_win_last
)
187 lseek (fd
, 0, SEEK_SET
);
192 unsigned m
= 80 * 65;
197 buf2
[pos
++] = buf
[i
*2];
212 text
->data
= (char *) buf2
;
216 c
[0] = kbd_getkey ();
221 if (zde_cursor
->state
== XCURSOR_STATE_LBUTTON
) {
233 void *handler_icon_exec (void *r
)
239 sprintf (desc
, "ZDE app - %s", r
);
241 /* create test window */
242 zde_win_t
*window
= create_window (desc
, 1);
247 zde_dobj_appcl_t dobj_appcl
;
249 dobj_appcl
.x
= window
->x
;
250 dobj_appcl
.y
= window
->y
;
251 dobj_appcl
.sizex
= window
->sizex
;
252 dobj_appcl
.sizey
= window
->sizey
;
256 create_dialog_object (ZDE_DOBJ_TYPE_APPCL
, &dobj_appcl
, 0, 0, window
);
258 unsigned l
= strlen (r
);
261 char *str
= (char *) strdup (r
);
263 for (i
= l
; i
> 1; i
--) {
270 chdir ((char *) "/");
272 chdir ((char *) str
);
274 sprintf (desc
, "exec %s", str
+i
+1);
282 while (!(window
->state
& WINDOW_STATE_CLOSE
)) {
285 if (window
!= zde_win_last
)
288 if (zde_cursor
->state
== XCURSOR_STATE_LBUTTON
) {
298 void *handler_icon_filesystem (void *r
)
304 sprintf (desc
, "Filesystem - %s", r
);
306 /* create test window */
307 zde_win_t
*window
= create_window (desc
, 0);
312 chdir ((char *) "/");
319 dirent_t
*dir
= dirent
;
327 if (dir
[id
].attrib
& VFS_FILEATTR_DIR
)
328 create_icon_window (dir
[id
].name
, 0, handler_icon_filesystem
, (void *) r
, window
);
329 if (dir
[id
].attrib
& VFS_FILEATTR_FILE
) {
330 if (dir
[id
].attrib
& VFS_FILEATTR_BIN
|| strstr (dir
[id
].name
, ".x"))
331 create_icon_window (dir
[id
].name
, 1, handler_icon_exec
, (void *) r
, window
);
333 create_icon_window (dir
[id
].name
, 1, handler_icon_reader
, (void *) r
, window
);
344 while (!(window
->state
& WINDOW_STATE_CLOSE
)) {
347 if (window
!= zde_win_last
)
350 if (zde_cursor
->state
== XCURSOR_STATE_LBUTTON
) {