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

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

More object view methods and improvements.

File size: 7.4 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 /* Add Pango here? */
117
118 nomEndRegisterDLLWithGC(hReg);
119
120 g_message("We started...\n");
121
122#if 0
123 /* Initialize thread subsystem */
124 if(!g_thread_supported())
125 g_thread_init(NULL);
126#endif
127
128 /* Create a window with a 'quit' button to terminate us */
129 createQuitWindow();
130
131 /* Query current dir */
132 g_strlcpy(desktopDir, g_get_current_dir(), sizeof(desktopDir));
133 g_message("Desktop: %s", desktopDir);
134
135 /*
136 Bootstrap our objects...
137 */
138 pEnv=nomTkInit();
139
140 if(!pEnv) {
141 nomPrintf("Can't initialize NOM environment. Exit...\n");
142 return(1);
143 }
144
145 /* Init SOM */
146 NOMClassMgrObject=nomEnvironmentNew();
147 //dbgPrintf( "NOMClassMgrObject: %x", NOMClassMgrObject);
148
149 /* Desktop directory oath */
150 nomPath=NOMPathNew();
151 NOMPath_assignCString(nomPath, desktopDir, NULLHANDLE);
152 /* Make sure there's no '/' at the end */
153 nomPath=NOMPath_stripSeparator(nomPath, NULLHANDLE);
154
155 /* Create root folder */
156 np=NOMPath_queryPathBegin(nomPath, NULLHANDLE);
157 wpRootFolder=WPFolderNew();
158 WPFolder_tstSetFullPath(wpRootFolder, NOMPath_queryCString(NOMPath_queryRoot(np, NULLHANDLE),NULLHANDLE),
159 NULLHANDLE);
160 chrDisplayName = g_filename_to_utf8 (NOMPath_queryCString(np,NULLHANDLE), -1, NULL, NULL, NULL);
161 WPFolder_wpSetTitleFromCString((WPObject*)wpRootFolder, chrDisplayName, NULLHANDLE);
162
163 wpTempFolder=wpRootFolder;
164 nomPath=NOMPath_erasePathBegin(nomPath, NULLHANDLE);
165
166 /* Now create all folders up the chain */
167 while(NOMPath_length(nomPath, NULLHANDLE)>0)
168 {
169 WPFolder* wpFolder;
170
171 np=NOMPath_queryPathBegin(nomPath, NULLHANDLE);
172
173 wpFolder=WPFolderNew();
174 WPFolder_tstSetFullPath(wpFolder, NOMPath_queryCString(np,NULLHANDLE),
175 NULLHANDLE);
176 chrDisplayName = g_filename_to_utf8 (NOMPath_queryCString(np,NULLHANDLE), -1, NULL, NULL, NULL);
177 WPFolder_wpSetTitleFromCString((WPObject*)wpFolder, chrDisplayName, NULLHANDLE);
178 WPFolder_wpSetFolder(wpFolder, wpTempFolder, NULLHANDLE);
179 /* insert into contents list */
180 WPFolder_wpAddToContent(wpTempFolder, (WPObject*) wpFolder,
181 NOMPath_copyCString(wpFolder, NULLHANDLE), NULLHANDLE);
182
183 wpTempFolder=wpFolder;
184 /* Move to next path part */
185 nomPath=NOMPath_erasePathBegin(nomPath, NULLHANDLE);
186 //WPFolder_wpQueryFileName(wpFolder, TRUE, NULLHANDLE);
187 //g_message(" path: %s", NOMPath_queryCString(WPFolder_wpQueryFileName(wpFolder, TRUE, NULLHANDLE),
188 // NULLHANDLE));
189 };
190
191 g_message(" --> Desktop dir: %s", NOMPath_queryCString(WPFolder_wpQueryFileName(wpTempFolder, TRUE, NULLHANDLE),
192 NULLHANDLE));
193
194 /* Create desktop folder */
195 wpDesktop=wpTempFolder;//WPFolderNew();
196
197 //WPFolder_tstSetFullPath(wpDesktop, desktopDir, NULLHANDLE);
198 //WPFolder_tstSetFullPath(wpDesktop, "r:", NULLHANDLE);
199 g_message("WPFolder ID: %d", nomIdFromString("WPFolder"));
200 WPFolder_wpOpen(wpDesktop, NULL, OPEN_DEFAULT, 0, NULL, NULL);
201
202 /* All GTK applications must have a gtk_main(). Control ends here
203 * and waits for an event to occur (like a key press or
204 * mouse event). */
205 gtk_main ();
206
207
208#if 0
209 mem=g_malloc(1250000);
210 memset(mem, 0xaa, 10000);
211 // *pGlobalMemInExe=mem;
212 for(a=0;a<50;a++){
213 g_malloc(1250000);
214 printf("%x %x %x %x %d\n", *mem, *(mem+1), *(mem+2), *(mem+3), 0);
215 //printf("%x\n", *((ULONG*)pGlobalMemInExe));
216 }
217#endif
218
219 printf("And now we quit...\n");
220
221 return 0;
222}
223
224
225/*
226 Just a test function for making noise...
227 */
228void _System theBeep(void)
229{
230 DosBeep(2500,400);
231 DosBeep(500,200);
232 DosBeep(1500,200);
233 DosBeep(2500,400);
234 DosBeep(1500,200);
235 DosBeep(500,200);
236 DosBeep(2500,400);
237}
Note: See TracBrowser for help on using the repository browser.