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

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

Folder viws are working now. Load of fixes and enhancements for it to work.

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