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

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

Created metaclasses for current set of desktop classes.

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
35#define INCL_DOSPROCESS
36#define INCL_DOS
37#define INCL_DOSPROFILE
38#define INCL_DOSERRORS
39#define INCL_PM
40
41#include <os2.h>
42#include <stdio.h>
43#include <stdlib.h>
44#include <string.h>
45
46#include <gtk/gtk.h>
47#include "debug_window.h"
48#include <gc.h>
49
50#include "nom.h"
51#include "nomtk.h"
52#include "nomgc.h"
53#include "nomguitk.h"
54#include "nomwindow.h"
55#include "desktoptypes.h"
56
57#include "wpfolderwindow.h"
58#include "wpnotebook.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 here? */
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 pEnv=nomTkInit();
144
145 if(!pEnv) {
146 nomPrintf("Can't initialize NOM environment. Exit...\n");
147 return(1);
148 }
149
150 /* Init SOM */
151 NOMClassMgrObject=nomEnvironmentNew();
152 //dbgPrintf( "NOMClassMgrObject: %x", NOMClassMgrObject);
153
154 /* Desktop directory oath */
155 nomPath=NOMPathNew();
156 NOMPath_assignCString(nomPath, desktopDir, NULLHANDLE);
157 /* Make sure there's no '/' at the end */
158 nomPath=NOMPath_stripSeparator(nomPath, NULLHANDLE);
159
160 /* Create root folder */
161 np=NOMPath_queryPathBegin(nomPath, NULLHANDLE);
162 wpRootFolder=WPFolderNew();
163 WPFolder_wpLockObject(wpRootFolder, NULLHANDLE);
164 WPFolder_tstSetFullPath(wpRootFolder, NOMPath_queryCString(NOMPath_queryRoot(np, NULLHANDLE),NULLHANDLE),
165 NULLHANDLE);
166 chrDisplayName = g_filename_to_utf8 (NOMPath_queryCString(np,NULLHANDLE), -1, NULL, NULL, NULL);
167 WPFolder_wpSetTitleFromCString((WPObject*)wpRootFolder, chrDisplayName, NULLHANDLE);
168
169 wpTempFolder=wpRootFolder;
170 nomPath=NOMPath_erasePathBegin(nomPath, NULLHANDLE);
171
172 /* Now create all folders up the chain */
173 while(NOMPath_length(nomPath, NULLHANDLE)>0)
174 {
175 WPFolder* wpFolder;
176
177 np=NOMPath_queryPathBegin(nomPath, NULLHANDLE);
178
179 wpFolder=WPFolderNew();
180 WPFolder_wpLockObject(wpFolder, NULLHANDLE);
181 WPFolder_tstSetFullPath(wpFolder, NOMPath_queryCString(np,NULLHANDLE),
182 NULLHANDLE);
183 chrDisplayName = g_filename_to_utf8 (NOMPath_queryCString(np,NULLHANDLE), -1, NULL, NULL, NULL);
184 WPFolder_wpSetTitleFromCString((WPObject*)wpFolder, chrDisplayName, NULLHANDLE);
185 WPFolder_wpSetFolder(wpFolder, wpTempFolder, NULLHANDLE);
186
187 /* insert into contents list */
188 WPFolder_wpAddToContent(wpTempFolder, (WPObject*) wpFolder,
189 NOMPath_copyCString(np, NULLHANDLE), NULLHANDLE);
190
191 wpTempFolder=wpFolder;
192 /* Move to next path part */
193 nomPath=NOMPath_erasePathBegin(nomPath, NULLHANDLE);
194 //WPFolder_wpQueryFileName(wpFolder, TRUE, NULLHANDLE);
195 //g_message(" path: %s", NOMPath_queryCString(WPFolder_wpQueryFileName(wpFolder, TRUE, NULLHANDLE),
196 // NULLHANDLE));
197 };
198
199 g_message(" --> Desktop dir: %s", NOMPath_queryCString(WPFolder_wpQueryFileName(wpTempFolder, TRUE, NULLHANDLE),
200 NULLHANDLE));
201
202 /* Create desktop folder */
203 wpDesktop=wpTempFolder;//WPFolderNew();
204
205 //WPFolder_tstSetFullPath(wpDesktop, desktopDir, NULLHANDLE);
206 //WPFolder_tstSetFullPath(wpDesktop, "r:", NULLHANDLE);
207 g_message("WPFolder ID: %d", nomIdFromString("WPFolder"));
208 WPFolder_wpOpen(wpDesktop, NULL, OPEN_DEFAULT, 0, NULL, NULL);
209
210 /* All GTK applications must have a gtk_main(). Control ends here
211 * and waits for an event to occur (like a key press or
212 * mouse event). */
213 gtk_main ();
214
215
216#if 0
217 mem=g_malloc(1250000);
218 memset(mem, 0xaa, 10000);
219 // *pGlobalMemInExe=mem;
220 for(a=0;a<50;a++){
221 g_malloc(1250000);
222 printf("%x %x %x %x %d\n", *mem, *(mem+1), *(mem+2), *(mem+3), 0);
223 //printf("%x\n", *((ULONG*)pGlobalMemInExe));
224 }
225#endif
226
227 printf("And now we quit...\n");
228
229 return 0;
230}
Note: See TracBrowser for help on using the repository browser.