source: trunk/desktop/src/vdesktop.c@ 224

Last change on this file since 224 was 224, checked in by cinc, 19 years ago

Added doxygen documentation.

File size: 7.6 KB
Line 
1/* ***** BEGIN LICENSE BLOCK *****
2* Version: CDDL 1.0/LGPL 2.1
3*
4* The contents of this file are subject to the COMMON DEVELOPMENT AND
5* DISTRIBUTION LICENSE (CDDL) Version 1.0 (the "License"); you may not use
6* this file except in compliance with the License. You may obtain a copy of
7* the License at http://www.sun.com/cddl/
8*
9* Software distributed under the License is distributed on an "AS IS" basis,
10* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11* for the specific language governing rights and limitations under the
12* License.
13*
14* The Original Code is "NOM" Netlabs Object Model
15*
16* The Initial Developer of the Original Code is
17* netlabs.org: Chris Wohlgemuth <cinc-ml@netlabs.org>.
18* Portions created by the Initial Developer are Copyright (C) 2005-2006
19* the Initial Developer. All Rights Reserved.
20*
21* Contributor(s):
22*
23* Alternatively, the contents of this file may be used under the terms of
24* the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
25* case the provisions of the LGPL are applicable instead of those above. If
26* you wish to allow use of your version of this file only under the terms of
27* the LGPL, and not to allow others to use your version of this file under
28* the terms of the CDDL, indicate your decision by deleting the provisions
29* above and replace them with the notice and other provisions required by the
30* LGPL. If you do not delete the provisions above, a recipient may use your
31* version of this file under the terms of any one of the CDDL or the LGPL.
32*
33* ***** END LICENSE BLOCK ***** */
34#define INCL_DOSPROCESS
35#define INCL_DOS
36#define INCL_DOSPROFILE
37#define INCL_DOSERRORS
38#define INCL_PM
39
40#include <os2.h>
41#include <stdio.h>
42#include <stdlib.h>
43#include <string.h>
44
45#include <gtk/gtk.h>
46#include "debug_window.h"
47#include <gc.h>
48
49#include "nom.h"
50#include "nomtk.h"
51#include "nomgc.h"
52#include "nomguitk.h"
53#include "nomwindow.h"
54#include "desktoptypes.h"
55
56#include "wpfolderwindow.h"
57#include "wpnotebook.h"
58#include "m_wpfolder.h"
59#include "wpfolder.h"
60#include "wpobject.h"
61
62#include "nomfilepath.h"
63
64
65int createQuitWindow(void);
66
67static gboolean
68handleEvent (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
69{
70
71 DosBeep(5000, 100);
72 //g_malloc(1250000);
73 //g_message("%s: allocated...", __FUNCTION__);
74 //WPObject_wpDisplayMenu(wpFolder, pWindow, NULL, 0, 0, NULL);
75
76 return FALSE;
77}
78
79WPFolder* wpRootFolder;
80
81/*
82 Main entry point. This function is called from the EMX wrapper. Be aware that gtk_init()
83 is already called in the wrapper.
84 */
85int _System main_loop()
86{
87 char desktopDir[CCHMAXPATH]={0};
88 PNOM_ENV pEnv;
89 NOMClassMgr *NOMClassMgrObject;
90 GtkWidget* window;
91 int a;
92 ULONG pMem;
93 HREGDLL hReg=NULLHANDLE;
94
95 /* Desktop folder */
96 WPFolder *wpDesktop;
97 WPFolder *wpTempFolder;
98 PNOMPath nomPath;
99 PNOMPath np;
100 gchar *chrDisplayName;
101
102 hReg=nomBeginRegisterDLLWithGC();
103 if(NULLHANDLE==hReg)
104 return 1;
105
106 /* Register DLLs with the garbage collector */
107 g_assert(nomRegisterDLLByName(hReg, "GLIB2.DLL" ));
108 g_assert(nomRegisterDLLByName(hReg, "GOBJECT2.DLL"));
109 g_assert(nomRegisterDLLByName(hReg, "GMODULE2.DLL"));
110 g_assert(nomRegisterDLLByName(hReg, "GDK2.DLL"));
111 g_assert(nomRegisterDLLByName(hReg, "GDKPIX2.DLL"));
112 g_assert(nomRegisterDLLByName(hReg, "GTK2.DLL" ));
113 g_assert(nomRegisterDLLByName(hReg, "ATK.DLL" ));
114 g_assert(nomRegisterDLLByName(hReg, "NOBJTK.DLL"));
115 g_assert(nomRegisterDLLByName(hReg, "VDESKTOP.DLL"));
116 g_assert(nomRegisterDLLByName(hReg, "VOYFCLS.DLL"));
117 //g_assert(nomRegisterDLLByName(hReg, "VOYWP.DLL"));
118 g_assert(nomRegisterDLLByName(hReg, "VOYGUITK.DLL"));
119 // g_assert(nomRegisterDLLByName(hReg, "PBL-PNG.DLL"));
120 // g_assert(nomRegisterDLLByName(hReg, "BASIC-FC.DLL"));
121 /* Add Pango */
122 g_assert(nomRegisterDLLByName(hReg, "PANGO.DLL"));
123 nomEndRegisterDLLWithGC(hReg);
124
125 g_message("We started...\n");
126
127#if 0
128 /* Initialize thread subsystem */
129 if(!g_thread_supported())
130 g_thread_init(NULL);
131#endif
132
133 /* Create a window with a 'quit' button to terminate us */
134 createQuitWindow();
135
136 /* Query current dir */
137 g_strlcpy(desktopDir, g_get_current_dir(), sizeof(desktopDir));
138 g_message("Desktop: %s", desktopDir);
139
140 /*
141 Bootstrap our objects...
142 */
143#if 0
144 pEnv=nomTkInit();
145
146 if(!pEnv) {
147 nomPrintf("Can't initialize NOM environment. Exit...\n");
148 return(1);
149 }
150#endif
151
152 /* Init NOM */
153 NOMClassMgrObject=nomEnvironmentNew();
154 //dbgPrintf( "NOMClassMgrObject: %x", NOMClassMgrObject);
155
156 /* Desktop directory oath */
157 nomPath=NOMPathNew();
158 NOMPath_assignCString(nomPath, desktopDir, NULLHANDLE);
159 /* Make sure there's no '/' at the end */
160 nomPath=NOMPath_stripSeparator(nomPath, NULLHANDLE);
161
162 /* Create root folder */
163 np=NOMPath_queryPathBegin(nomPath, NULLHANDLE);
164 wpRootFolder=WPFolderNew();
165 WPFolder_wpLockObject(wpRootFolder, NULLHANDLE);
166 WPFolder_tstSetFullPath(wpRootFolder, NOMPath_queryCString(NOMPath_queryRoot(np, NULLHANDLE),NULLHANDLE),
167 NULLHANDLE);
168 chrDisplayName = g_filename_to_utf8 (NOMPath_queryCString(np,NULLHANDLE), -1, NULL, NULL, NULL);
169 WPFolder_wpSetTitleFromCString((WPObject*)wpRootFolder, chrDisplayName, NULLHANDLE);
170
171 wpTempFolder=wpRootFolder;
172 nomPath=NOMPath_erasePathBegin(nomPath, NULLHANDLE);
173
174 /* Now create all folders up the chain */
175 while(NOMPath_length(nomPath, NULLHANDLE)>0)
176 {
177 WPFolder* wpFolder;
178
179 np=NOMPath_queryPathBegin(nomPath, NULLHANDLE);
180
181 wpFolder=WPFolderNew();
182 WPFolder_wpLockObject(wpFolder, NULLHANDLE);
183 WPFolder_tstSetFullPath(wpFolder, NOMPath_queryCString(np,NULLHANDLE),
184 NULLHANDLE);
185 chrDisplayName = g_filename_to_utf8 (NOMPath_queryCString(np,NULLHANDLE), -1, NULL, NULL, NULL);
186 WPFolder_wpSetTitleFromCString((WPObject*)wpFolder, chrDisplayName, NULLHANDLE);
187 WPFolder_wpSetFolder(wpFolder, wpTempFolder, NULLHANDLE);
188
189 /* insert into contents list */
190 WPFolder_wpAddToContent(wpTempFolder, (WPObject*) wpFolder,
191 NOMPath_copyCString(np, NULLHANDLE), NULLHANDLE);
192
193 wpTempFolder=wpFolder;
194 /* Move to next path part */
195 nomPath=NOMPath_erasePathBegin(nomPath, NULLHANDLE);
196 //WPFolder_wpQueryFileName(wpFolder, TRUE, NULLHANDLE);
197 //g_message(" path: %s", NOMPath_queryCString(WPFolder_wpQueryFileName(wpFolder, TRUE, NULLHANDLE),
198 // NULLHANDLE));
199 };
200
201 g_message(" --> Desktop dir: %s", NOMPath_queryCString(WPFolder_wpQueryFileName(wpTempFolder, TRUE, NULLHANDLE),
202 NULLHANDLE));
203
204 /* Create desktop folder */
205 wpDesktop=wpTempFolder;//WPFolderNew();
206
207 //WPFolder_tstSetFullPath(wpDesktop, desktopDir, NULLHANDLE);
208 //WPFolder_tstSetFullPath(wpDesktop, "r:", NULLHANDLE);
209 g_message("WPFolder ID: %d", nomIdFromString("WPFolder"));
210 WPFolder_wpOpen(wpDesktop, NULL, OPEN_DEFAULT, 0, NULL, NULL);
211
212 /* All GTK applications must have a gtk_main(). Control ends here
213 * and waits for an event to occur (like a key press or
214 * mouse event). */
215 gtk_main ();
216
217
218#if 0
219 mem=g_malloc(1250000);
220 memset(mem, 0xaa, 10000);
221 // *pGlobalMemInExe=mem;
222 for(a=0;a<50;a++){
223 g_malloc(1250000);
224 printf("%x %x %x %x %d\n", *mem, *(mem+1), *(mem+2), *(mem+3), 0);
225 //printf("%x\n", *((ULONG*)pGlobalMemInExe));
226 }
227#endif
228
229 printf("And now we quit...\n");
230
231 return 0;
232}
Note: See TracBrowser for help on using the repository browser.