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

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

New methods and additions all over the place.

File size: 7.1 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 "nomfolderwindow.h"
58#include "wpobject.h"
59#include "wpfolder.h"
60#include "nomfilepath.h"
61
62
63int createQuitWindow(void);
64
65static gboolean
66handleEvent (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
67{
68
69 DosBeep(5000, 100);
70 //g_malloc(1250000);
71 //g_message("%s: allocated...", __FUNCTION__);
72 //WPObject_wpDisplayMenu(wpFolder, pWindow, NULL, 0, 0, NULL);
73
74 return FALSE;
75}
76
77WPFolder* wpRootFolder;
78
79/*
80 Main entry point. This function is called from the EMX wrapper. Be aware that gtk_init()
81 is already called in the wrapper.
82 */
83int _System main_loop()
84{
85 char desktopDir[CCHMAXPATH]={0};
86 PNOM_ENV pEnv;
87 NOMClassMgr *NOMClassMgrObject;
88 GtkWidget* window;
89 int a;
90 ULONG pMem;
91 HREGDLL hReg=NULLHANDLE;
92
93 /* Desktop folder */
94 WPFolder *wpDesktop;
95 WPFolder *wpTempFolder;
96 PNOMPath nomPath;
97 PNOMPath np;
98
99 hReg=nomBeginRegisterDLLWithGC();
100 if(NULLHANDLE==hReg)
101 return 1;
102
103 /* Register DLLs with the garbage collector */
104 g_assert(nomRegisterDLLByName(hReg, "GLIB2.DLL" ));
105 g_assert(nomRegisterDLLByName(hReg, "GOBJECT2.DLL"));
106 g_assert(nomRegisterDLLByName(hReg, "GMODULE2.DLL"));
107 g_assert(nomRegisterDLLByName(hReg, "GDK2.DLL"));
108 g_assert(nomRegisterDLLByName(hReg, "GDKPIX2.DLL"));
109 g_assert(nomRegisterDLLByName(hReg, "GTK2.DLL" ));
110 g_assert(nomRegisterDLLByName(hReg, "ATK.DLL" ));
111 g_assert(nomRegisterDLLByName(hReg, "NOBJTK.DLL"));
112 g_assert(nomRegisterDLLByName(hReg, "VDESKTOP.DLL"));
113 /* Add Pango here? */
114
115 nomEndRegisterDLLWithGC(hReg);
116
117 g_message("We started...\n");
118
119#if 0
120 /* Initialize thread subsystem */
121 if(!g_thread_supported())
122 g_thread_init(NULL);
123#endif
124
125 /* Create a window with a 'quit' button to terminate us */
126 createQuitWindow();
127
128 /* Query current dir */
129 g_strlcpy(desktopDir, g_get_current_dir(), sizeof(desktopDir));
130 g_message("Desktop: %s", desktopDir);
131
132 /*
133 Bootstrap our objects...
134 */
135 pEnv=nomTkInit();
136
137 if(!pEnv) {
138 nomPrintf("Can't initialize NOM environment. Exit...\n");
139 return(1);
140 }
141
142
143 /* Init SOM */
144 NOMClassMgrObject=nomEnvironmentNew();
145 //dbgPrintf( "NOMClassMgrObject: %x", NOMClassMgrObject);
146
147 nomPath=NOMPathNew();
148 NOMPath_assignCString(nomPath, desktopDir, NULLHANDLE);
149 /* Make sure there's no '/' at the end */
150 nomPath=NOMPath_stripSeparator(nomPath, NULLHANDLE);
151
152 /* Create root folder */
153 wpRootFolder=WPFolderNew();
154 WPFolder_tstSetFullPath(wpRootFolder, NOMPath_queryCString(NOMPath_queryRoot(nomPath, NULLHANDLE),NULLHANDLE),
155 NULLHANDLE);
156 wpTempFolder=wpRootFolder;
157
158 nomPath=NOMPath_erasePathBegin(nomPath, NULLHANDLE);
159
160 /* Now create all folders up the chain */
161 while(NOMPath_length(nomPath, NULLHANDLE)>0)
162 {
163 NOMPath* np;
164 WPFolder* wpFolder;
165 np=NOMPath_queryPathBegin(nomPath, NULLHANDLE);
166
167 wpFolder=WPFolderNew();
168 WPFolder_tstSetFullPath(wpFolder, NOMPath_queryCString(np,NULLHANDLE),
169 NULLHANDLE);
170 WPFolder_wpSetFolder(wpFolder, wpTempFolder, NULLHANDLE);
171 wpTempFolder=wpFolder;
172 nomPath=NOMPath_erasePathBegin(nomPath, NULLHANDLE);
173 WPFolder_wpQueryFileName(wpFolder, TRUE, NULLHANDLE);
174 //g_message(" path: %s", NOMPath_queryCString(WPFolder_wpQueryFileName(wpFolder, TRUE, NULLHANDLE),
175 // NULLHANDLE));
176 };
177
178 g_message(" --> Desktop dir: %s", NOMPath_queryCString(WPFolder_wpQueryFileName(wpTempFolder, TRUE, NULLHANDLE),
179 NULLHANDLE));
180
181 /* Create desktop folder */
182 wpDesktop=wpTempFolder;//WPFolderNew();
183
184 //WPFolder_tstSetFullPath(wpDesktop, desktopDir, NULLHANDLE);
185 //WPFolder_tstSetFullPath(wpDesktop, "r:", NULLHANDLE);
186 WPFolder_wpOpen(wpDesktop, NULL, OPEN_DEFAULT, NULL, NULL);
187 /* WPFolder_wpPopulate(wpObject, 0,"blabla 2", 0, NULL); */
188
189#if 0
190 /* Folder toplevel window. */
191 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
192
193 /* FIXME: Set default size of folder frame. Will later use a stored value */
194 gtk_window_set_default_size (GTK_WINDOW (window), 650, 400);
195
196 g_signal_connect (GTK_WIDGET(window), "size-request",
197 G_CALLBACK (handleEvent), NULL/*nomSelf*/);
198
199 gtk_widget_show(window);
200 g_message("Window handle: %x", window);
201#endif
202
203 /* All GTK applications must have a gtk_main(). Control ends here
204 * and waits for an event to occur (like a key press or
205 * mouse event). */
206 gtk_main ();
207
208
209#if 0
210 mem=g_malloc(1250000);
211 memset(mem, 0xaa, 10000);
212 // *pGlobalMemInExe=mem;
213 for(a=0;a<50;a++){
214 g_malloc(1250000);
215 printf("%x %x %x %x %d\n", *mem, *(mem+1), *(mem+2), *(mem+3), 0);
216 //printf("%x\n", *((ULONG*)pGlobalMemInExe));
217 }
218#endif
219
220 printf("And now we quit...\n");
221
222 return 0;
223}
224
225
226/*
227 Just a test function for making noise...
228 */
229void _System theBeep(void)
230{
231 DosBeep(2500,400);
232 DosBeep(500,200);
233 DosBeep(1500,200);
234 DosBeep(2500,400);
235 DosBeep(1500,200);
236 DosBeep(500,200);
237 DosBeep(2500,400);
238}
Note: See TracBrowser for help on using the repository browser.