[98] | 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>.
|
---|
[241] | 18 | * Portions created by the Initial Developer are Copyright (C) 2005-2007
|
---|
[98] | 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 ***** */
|
---|
[166] | 34 | #define INCL_DOSPROCESS
|
---|
[98] | 35 | #define INCL_DOS
|
---|
[166] | 36 | #define INCL_DOSPROFILE
|
---|
| 37 | #define INCL_DOSERRORS
|
---|
[183] | 38 |
|
---|
[98] | 39 | #include <os2.h>
|
---|
| 40 | #include <stdio.h>
|
---|
[141] | 41 | #include <stdlib.h>
|
---|
[166] | 42 | #include <string.h>
|
---|
[183] | 43 |
|
---|
[98] | 44 | #include <gtk/gtk.h>
|
---|
| 45 | #include "debug_window.h"
|
---|
[141] | 46 | #include <gc.h>
|
---|
[98] | 47 |
|
---|
| 48 | #include "nom.h"
|
---|
| 49 | #include "nomtk.h"
|
---|
[166] | 50 | #include "nomgc.h"
|
---|
| 51 | #include "nomguitk.h"
|
---|
[183] | 52 | #include "nomwindow.h"
|
---|
| 53 | #include "desktoptypes.h"
|
---|
| 54 |
|
---|
[191] | 55 | #include "wpfolderwindow.h"
|
---|
| 56 | #include "wpnotebook.h"
|
---|
[224] | 57 | #include "m_wpfolder.h"
|
---|
[191] | 58 | #include "wpfolder.h"
|
---|
[258] | 59 | #include "m_wprootfolder.h"
|
---|
| 60 | #include "wprootfolder.h"
|
---|
[98] | 61 | #include "wpobject.h"
|
---|
[191] | 62 |
|
---|
[183] | 63 | #include "nomfilepath.h"
|
---|
[98] | 64 |
|
---|
[183] | 65 |
|
---|
[98] | 66 | int createQuitWindow(void);
|
---|
| 67 |
|
---|
[166] | 68 | static gboolean
|
---|
| 69 | handleEvent (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
|
---|
| 70 | {
|
---|
[98] | 71 |
|
---|
[166] | 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 | }
|
---|
[102] | 79 |
|
---|
[183] | 80 | WPFolder* wpRootFolder;
|
---|
| 81 |
|
---|
[98] | 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 | */
|
---|
| 86 | int _System main_loop()
|
---|
| 87 | {
|
---|
[166] | 88 | char desktopDir[CCHMAXPATH]={0};
|
---|
| 89 | PNOM_ENV pEnv;
|
---|
| 90 | NOMClassMgr *NOMClassMgrObject;
|
---|
| 91 | HREGDLL hReg=NULLHANDLE;
|
---|
| 92 |
|
---|
| 93 | /* Desktop folder */
|
---|
| 94 | WPFolder *wpDesktop;
|
---|
[183] | 95 | WPFolder *wpTempFolder;
|
---|
| 96 | PNOMPath nomPath;
|
---|
| 97 | PNOMPath np;
|
---|
[186] | 98 | gchar *chrDisplayName;
|
---|
[183] | 99 |
|
---|
[258] | 100 | /* Register DLLs with the garbage collector */
|
---|
[166] | 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"));
|
---|
[194] | 114 | g_assert(nomRegisterDLLByName(hReg, "VOYFCLS.DLL"));
|
---|
[200] | 115 | //g_assert(nomRegisterDLLByName(hReg, "VOYWP.DLL"));
|
---|
[194] | 116 | g_assert(nomRegisterDLLByName(hReg, "VOYGUITK.DLL"));
|
---|
| 117 | // g_assert(nomRegisterDLLByName(hReg, "PBL-PNG.DLL"));
|
---|
| 118 | // g_assert(nomRegisterDLLByName(hReg, "BASIC-FC.DLL"));
|
---|
[224] | 119 | /* Add Pango */
|
---|
[194] | 120 | g_assert(nomRegisterDLLByName(hReg, "PANGO.DLL"));
|
---|
[166] | 121 | nomEndRegisterDLLWithGC(hReg);
|
---|
[141] | 122 |
|
---|
[166] | 123 | g_message("We started...\n");
|
---|
[141] | 124 |
|
---|
[113] | 125 | #if 0
|
---|
[258] | 126 | /* Initialize thread subsystem. This needs a multithreaded glib */
|
---|
[166] | 127 | if(!g_thread_supported())
|
---|
| 128 | g_thread_init(NULL);
|
---|
[113] | 129 | #endif
|
---|
[166] | 130 |
|
---|
[98] | 131 | /* Create a window with a 'quit' button to terminate us */
|
---|
[166] | 132 | createQuitWindow();
|
---|
| 133 |
|
---|
[98] | 134 | /* Query current dir */
|
---|
| 135 | g_strlcpy(desktopDir, g_get_current_dir(), sizeof(desktopDir));
|
---|
[183] | 136 | g_message("Desktop: %s", desktopDir);
|
---|
[98] | 137 |
|
---|
[166] | 138 | /*
|
---|
| 139 | Bootstrap our objects...
|
---|
| 140 | */
|
---|
[224] | 141 | #if 0
|
---|
[166] | 142 | pEnv=nomTkInit();
|
---|
[98] | 143 |
|
---|
[166] | 144 | if(!pEnv) {
|
---|
| 145 | nomPrintf("Can't initialize NOM environment. Exit...\n");
|
---|
| 146 | return(1);
|
---|
| 147 | }
|
---|
[224] | 148 | #endif
|
---|
[98] | 149 |
|
---|
[224] | 150 | /* Init NOM */
|
---|
[166] | 151 | NOMClassMgrObject=nomEnvironmentNew();
|
---|
[183] | 152 |
|
---|
[186] | 153 | /* Desktop directory oath */
|
---|
[183] | 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 */
|
---|
[186] | 160 | np=NOMPath_queryPathBegin(nomPath, NULLHANDLE);
|
---|
[258] | 161 | wpRootFolder=WPRootFolderNew();
|
---|
| 162 | WPRootFolder_wpLockObject(wpRootFolder, NULLHANDLE);
|
---|
| 163 | WPRootFolder_tstSetFullPath(wpRootFolder, NOMPath_queryCString(NOMPath_queryRoot(np, NULLHANDLE),NULLHANDLE),
|
---|
[183] | 164 | NULLHANDLE);
|
---|
[186] | 165 | chrDisplayName = g_filename_to_utf8 (NOMPath_queryCString(np,NULLHANDLE), -1, NULL, NULL, NULL);
|
---|
[258] | 166 | WPRootFolder_wpSetTitleFromCString((WPObject*)wpRootFolder, chrDisplayName, NULLHANDLE);
|
---|
[186] | 167 |
|
---|
[183] | 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;
|
---|
[186] | 175 |
|
---|
[183] | 176 | np=NOMPath_queryPathBegin(nomPath, NULLHANDLE);
|
---|
| 177 |
|
---|
| 178 | wpFolder=WPFolderNew();
|
---|
[194] | 179 | WPFolder_wpLockObject(wpFolder, NULLHANDLE);
|
---|
[183] | 180 | WPFolder_tstSetFullPath(wpFolder, NOMPath_queryCString(np,NULLHANDLE),
|
---|
| 181 | NULLHANDLE);
|
---|
[186] | 182 | chrDisplayName = g_filename_to_utf8 (NOMPath_queryCString(np,NULLHANDLE), -1, NULL, NULL, NULL);
|
---|
| 183 | WPFolder_wpSetTitleFromCString((WPObject*)wpFolder, chrDisplayName, NULLHANDLE);
|
---|
[183] | 184 | WPFolder_wpSetFolder(wpFolder, wpTempFolder, NULLHANDLE);
|
---|
[194] | 185 |
|
---|
[186] | 186 | /* insert into contents list */
|
---|
| 187 | WPFolder_wpAddToContent(wpTempFolder, (WPObject*) wpFolder,
|
---|
[258] | 188 | NULLHANDLE);
|
---|
[186] | 189 |
|
---|
[183] | 190 | wpTempFolder=wpFolder;
|
---|
[186] | 191 | /* Move to next path part */
|
---|
[183] | 192 | nomPath=NOMPath_erasePathBegin(nomPath, NULLHANDLE);
|
---|
[186] | 193 | //WPFolder_wpQueryFileName(wpFolder, TRUE, NULLHANDLE);
|
---|
[291] | 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),
|
---|
[183] | 197 | // NULLHANDLE));
|
---|
| 198 | };
|
---|
[291] | 199 | g_message(" --> Desktop dir:");
|
---|
| 200 | if(nomIsObj(wpTempFolder))
|
---|
| 201 | g_message("Valid");
|
---|
[183] | 202 |
|
---|
[291] | 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");
|
---|
[183] | 209 | g_message(" --> Desktop dir: %s", NOMPath_queryCString(WPFolder_wpQueryFileName(wpTempFolder, TRUE, NULLHANDLE),
|
---|
[291] | 210 | NULLHANDLE));
|
---|
[183] | 211 |
|
---|
[166] | 212 | /* Create desktop folder */
|
---|
[183] | 213 | wpDesktop=wpTempFolder;//WPFolderNew();
|
---|
[98] | 214 |
|
---|
[183] | 215 | //WPFolder_tstSetFullPath(wpDesktop, desktopDir, NULLHANDLE);
|
---|
| 216 | //WPFolder_tstSetFullPath(wpDesktop, "r:", NULLHANDLE);
|
---|
[191] | 217 | g_message("WPFolder ID: %d", nomIdFromString("WPFolder"));
|
---|
| 218 | WPFolder_wpOpen(wpDesktop, NULL, OPEN_DEFAULT, 0, NULL, NULL);
|
---|
[98] | 219 |
|
---|
[166] | 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 ();
|
---|
[98] | 224 |
|
---|
[166] | 225 |
|
---|
[258] | 226 | #warning !!!!! A call to NOMTerminate() or alike is missing
|
---|
[166] | 227 | printf("And now we quit...\n");
|
---|
| 228 |
|
---|
[98] | 229 | return 0;
|
---|
| 230 | }
|
---|