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

Last change on this file since 241 was 241, checked in by cinc, 18 years ago

WC2007 patches for drag and drop implementation.

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-2007
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
39#include <os2.h>
40#include <stdio.h>
41#include <stdlib.h>
42#include <string.h>
43
44#include <gtk/gtk.h>
45#include "debug_window.h"
46#include <gc.h>
47
48#include "nom.h"
49#include "nomtk.h"
50#include "nomgc.h"
51#include "nomguitk.h"
52#include "nomwindow.h"
53#include "desktoptypes.h"
54
55#include "wpfolderwindow.h"
56#include "wpnotebook.h"
57#include "m_wpfolder.h"
58#include "wpfolder.h"
59#include "wpobject.h"
60
61#include "nomfilepath.h"
62
63
64int createQuitWindow(void);
65
66static gboolean
67handleEvent (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
68{
69
70 DosBeep(5000, 100);
71 //g_malloc(1250000);
72 //g_message("%s: allocated...", __FUNCTION__);
73 //WPObject_wpDisplayMenu(wpFolder, pWindow, NULL, 0, 0, NULL);
74
75 return FALSE;
76}
77
78WPFolder* wpRootFolder;
79
80/*
81 Main entry point. This function is called from the EMX wrapper. Be aware that gtk_init()
82 is already called in the wrapper.
83 */
84int _System main_loop()
85{
86 char desktopDir[CCHMAXPATH]={0};
87 PNOM_ENV pEnv;
88 NOMClassMgr *NOMClassMgrObject;
89 GtkWidget* window;
90 int a;
91 ULONG pMem;
92 HREGDLL hReg=NULLHANDLE;
93
94 /* Desktop folder */
95 WPFolder *wpDesktop;
96 WPFolder *wpTempFolder;
97 PNOMPath nomPath;
98 PNOMPath np;
99 gchar *chrDisplayName;
100
101 hReg=nomBeginRegisterDLLWithGC();
102 if(NULLHANDLE==hReg)
103 return 1;
104
105 /* Register DLLs with the garbage collector */
106 g_assert(nomRegisterDLLByName(hReg, "GLIB2.DLL" ));
107 g_assert(nomRegisterDLLByName(hReg, "GOBJECT2.DLL"));
108 g_assert(nomRegisterDLLByName(hReg, "GMODULE2.DLL"));
109 g_assert(nomRegisterDLLByName(hReg, "GDK2.DLL"));
110 g_assert(nomRegisterDLLByName(hReg, "GDKPIX2.DLL"));
111 g_assert(nomRegisterDLLByName(hReg, "GTK2.DLL" ));
112 g_assert(nomRegisterDLLByName(hReg, "ATK.DLL" ));
113 g_assert(nomRegisterDLLByName(hReg, "NOBJTK.DLL"));
114 g_assert(nomRegisterDLLByName(hReg, "VDESKTOP.DLL"));
115 g_assert(nomRegisterDLLByName(hReg, "VOYFCLS.DLL"));
116 //g_assert(nomRegisterDLLByName(hReg, "VOYWP.DLL"));
117 g_assert(nomRegisterDLLByName(hReg, "VOYGUITK.DLL"));
118 // g_assert(nomRegisterDLLByName(hReg, "PBL-PNG.DLL"));
119 // g_assert(nomRegisterDLLByName(hReg, "BASIC-FC.DLL"));
120 /* Add Pango */
121 g_assert(nomRegisterDLLByName(hReg, "PANGO.DLL"));
122 nomEndRegisterDLLWithGC(hReg);
123
124 g_message("We started...\n");
125
126#if 0
127 /* Initialize thread subsystem */
128 if(!g_thread_supported())
129 g_thread_init(NULL);
130#endif
131
132 /* Create a window with a 'quit' button to terminate us */
133 createQuitWindow();
134
135 /* Query current dir */
136 g_strlcpy(desktopDir, g_get_current_dir(), sizeof(desktopDir));
137 g_message("Desktop: %s", desktopDir);
138
139 /*
140 Bootstrap our objects...
141 */
142#if 0
143 pEnv=nomTkInit();
144
145 if(!pEnv) {
146 nomPrintf("Can't initialize NOM environment. Exit...\n");
147 return(1);
148 }
149#endif
150
151 /* Init NOM */
152 NOMClassMgrObject=nomEnvironmentNew();
153 //dbgPrintf( "NOMClassMgrObject: %x", NOMClassMgrObject);
154
155 /* Desktop directory oath */
156 nomPath=NOMPathNew();
157 NOMPath_assignCString(nomPath, desktopDir, NULLHANDLE);
158 /* Make sure there's no '/' at the end */
159 nomPath=NOMPath_stripSeparator(nomPath, NULLHANDLE);
160
161 /* Create root folder */
162 np=NOMPath_queryPathBegin(nomPath, NULLHANDLE);
163 wpRootFolder=WPFolderNew();
164 WPFolder_wpLockObject(wpRootFolder, NULLHANDLE);
165 WPFolder_tstSetFullPath(wpRootFolder, NOMPath_queryCString(NOMPath_queryRoot(np, NULLHANDLE),NULLHANDLE),
166 NULLHANDLE);
167 chrDisplayName = g_filename_to_utf8 (NOMPath_queryCString(np,NULLHANDLE), -1, NULL, NULL, NULL);
168 WPFolder_wpSetTitleFromCString((WPObject*)wpRootFolder, chrDisplayName, NULLHANDLE);
169
170 wpTempFolder=wpRootFolder;
171 nomPath=NOMPath_erasePathBegin(nomPath, NULLHANDLE);
172
173 /* Now create all folders up the chain */
174 while(NOMPath_length(nomPath, NULLHANDLE)>0)
175 {
176 WPFolder* wpFolder;
177
178 np=NOMPath_queryPathBegin(nomPath, NULLHANDLE);
179
180 wpFolder=WPFolderNew();
181 WPFolder_wpLockObject(wpFolder, NULLHANDLE);
182 WPFolder_tstSetFullPath(wpFolder, NOMPath_queryCString(np,NULLHANDLE),
183 NULLHANDLE);
184 chrDisplayName = g_filename_to_utf8 (NOMPath_queryCString(np,NULLHANDLE), -1, NULL, NULL, NULL);
185 WPFolder_wpSetTitleFromCString((WPObject*)wpFolder, chrDisplayName, NULLHANDLE);
186 WPFolder_wpSetFolder(wpFolder, wpTempFolder, NULLHANDLE);
187
188 /* insert into contents list */
189 WPFolder_wpAddToContent(wpTempFolder, (WPObject*) wpFolder,
190 NOMPath_copyCString(np, NULLHANDLE), NULLHANDLE);
191
192 wpTempFolder=wpFolder;
193 /* Move to next path part */
194 nomPath=NOMPath_erasePathBegin(nomPath, NULLHANDLE);
195 //WPFolder_wpQueryFileName(wpFolder, TRUE, NULLHANDLE);
196 //g_message(" path: %s", NOMPath_queryCString(WPFolder_wpQueryFileName(wpFolder, TRUE, NULLHANDLE),
197 // NULLHANDLE));
198 };
199
200 g_message(" --> Desktop dir: %s", NOMPath_queryCString(WPFolder_wpQueryFileName(wpTempFolder, TRUE, NULLHANDLE),
201 NULLHANDLE));
202
203 /* Create desktop folder */
204 wpDesktop=wpTempFolder;//WPFolderNew();
205
206 //WPFolder_tstSetFullPath(wpDesktop, desktopDir, NULLHANDLE);
207 //WPFolder_tstSetFullPath(wpDesktop, "r:", NULLHANDLE);
208 g_message("WPFolder ID: %d", nomIdFromString("WPFolder"));
209 WPFolder_wpOpen(wpDesktop, NULL, OPEN_DEFAULT, 0, NULL, NULL);
210
211 /* All GTK applications must have a gtk_main(). Control ends here
212 * and waits for an event to occur (like a key press or
213 * mouse event). */
214 gtk_main ();
215
216
217#if 0
218 mem=g_malloc(1250000);
219 memset(mem, 0xaa, 10000);
220 // *pGlobalMemInExe=mem;
221 for(a=0;a<50;a++){
222 g_malloc(1250000);
223 printf("%x %x %x %x %d\n", *mem, *(mem+1), *(mem+2), *(mem+3), 0);
224 //printf("%x\n", *((ULONG*)pGlobalMemInExe));
225 }
226#endif
227
228 printf("And now we quit...\n");
229
230 return 0;
231}
Note: See TracBrowser for help on using the repository browser.