Cleanup in elf.c with .bss section clean; adm command mounts cdrom instead of floppy...
[ZeXOS.git] / apps / wm / main.c
blob7813491ce1ee10d899d3ce8c1108de1d740d2641
1 /*
2 * ZeX/OS
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/>.
21 #include <stdio.h>
22 #include <string.h>
23 #include <stdlib.h>
24 #include <unistd.h>
25 #include <time.h>
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>
31 #include <pthread.h>
32 #include "window.h"
33 #include "cursor.h"
34 #include "button.h"
35 #include "menu.h"
36 #include "dialog.h"
37 #include "filemanager.h"
38 #include "config.h"
40 #define ESC 1
42 extern wmcursor *cursor;
44 void draw_clock ()
46 char sec[2], min[2], hour[2];
47 time_t t;
48 time_t ret = time (&t);
50 if (!ret)
51 return;
53 struct tm *ct = localtime (&t);
55 itoa (sec, ct->tm_sec, 10);
57 xtext_puts (0, 0, 3, sec);
60 unsigned iexit ()
62 xexit ();
63 exit (1);
64 return 1;
67 int main (int argc, char **argv)
69 /* ERROR message :( */
70 printf ("Please start this program under VESA mode, because it can crash\n");
72 if (!init_config ()) {
73 printf ("Something is wrong with init_config () sequence !\n");
74 exit (0);
75 return 0;
78 if (!init_cursor ()) {
79 printf ("Your mouse is crappy, try it again :P\n");
80 exit (0);
81 return 0;
84 if (!init_window ()) {
85 exit (0);
86 return 0;
89 if (!init_button ()) {
90 exit (0);
91 return 0;
94 if (!init_menu ()) {
95 exit (0);
96 return 0;
99 if (!init_dialog ()) {
100 exit (0);
101 return 0;
104 xinit ();
105 xcls (0);
106 printf ("PRD\n");
108 /*if (!init_filemanager ()) {
109 exit (0);
110 return 0;
113 init_tview ();
115 wmbutton *btn_menu = button_create (0, 588, 0, 0, 0, "ZeX/OS");
117 wmmenu *mainmenu = menu_create (0, 0, "Menu");
119 if (!mainmenu)
120 return 0;
122 wmmenuitem *item_filemanager = menu_additem (mainmenu, "Filemanager", 0);
123 wmmenuitem *item_terminal = menu_additem (mainmenu, "Terminal", 0);
124 wmmenuitem *item_authors = menu_additem (mainmenu, "Authors", 0);
125 menu_additem (mainmenu, "-----------", 0);
126 wmmenuitem *item_exit = menu_additem (mainmenu, "Exit", 0);
128 mainmenu->y = btn_menu->y-mainmenu->size_y;
130 if (!init_terminal ()) {
131 /* ERROR */
134 if (!init_authors ()) {
135 /* ERROR */
138 //ifilemanager ();
140 while (1) {
141 window_draw_all ();
143 if (button_flags (btn_menu) & BUTTON_FLAG_CLICKED)
144 menu_show (mainmenu);
146 //if (menuitem_flags (item_filemanager) & MENUITEM_FLAG_CLICKED)
147 // ifilemanager ();
149 if (menuitem_flags (item_terminal) & MENUITEM_FLAG_CLICKED)
150 iterminal ();
152 if (menuitem_flags (item_authors) & MENUITEM_FLAG_CLICKED)
153 iauthors ();
155 if (menuitem_flags (item_exit) & MENUITEM_FLAG_CLICKED)
156 iexit ();
159 filemanager_draw ();
161 tview_draw ();
163 terminal_handle ();
165 dialog_draw_all ();
167 authors_handle ();
169 button_draw_all ();
171 taskbar_draw ();
173 menu_draw_all ();
174 //draw_clock (); /* FIXME: freeze */
176 cursor_draw ();
178 schedule ();
180 xfbswap ();
183 return 1;