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

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

Migrated to new IDL compiler. Metaclasses are still missing.

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