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 | * This file was generated by orbit-idl-2 for Voyager
|
---|
36 | *
|
---|
37 | *
|
---|
38 | * And remember, phase 3 is near...
|
---|
39 | */
|
---|
40 |
|
---|
41 | #define INCL_DOS
|
---|
42 | #include <os2.h>
|
---|
43 |
|
---|
44 | #include "nom.h"
|
---|
45 | #include <nomtk.h>
|
---|
46 |
|
---|
47 | #include <string.h>
|
---|
48 | #include "gtk/gtk.h"
|
---|
49 |
|
---|
50 | #warning !!!!! nomIsObj() must be globaly defined !!!!!
|
---|
51 | #define nomIsObj(a) ((a)!= 0)
|
---|
52 |
|
---|
53 | typedef struct _PRIVFOLDERDATA
|
---|
54 | {
|
---|
55 | GtkListStore *gstoreFldContents;
|
---|
56 | GtkWidget *gtkIconView;
|
---|
57 | }PRIVFOLDERDATA, *PPRIVFOLDERDATA;
|
---|
58 |
|
---|
59 | /* Gui stuff */
|
---|
60 | #include "nomguitk.h"
|
---|
61 | #include "nomfolderwindow.h"
|
---|
62 |
|
---|
63 | #include "wpfolder.ih"
|
---|
64 | #include "wpdatafile.h"
|
---|
65 | #include "desktop.h"
|
---|
66 | #include "helper.h"
|
---|
67 | #include "desktoptypes.h"
|
---|
68 |
|
---|
69 |
|
---|
70 | /* Enum for the folder store */
|
---|
71 | enum
|
---|
72 | {
|
---|
73 | COL_OBJECT_PTR,
|
---|
74 | COL_PATH,
|
---|
75 | COL_DISPLAY_NAME,
|
---|
76 | COL_PIXBUF,
|
---|
77 | COL_IS_DIRECTORY,
|
---|
78 | NUM_COLS
|
---|
79 | };
|
---|
80 |
|
---|
81 | static GtkListStore * fldr_CreateStore (void)
|
---|
82 | {
|
---|
83 | GtkListStore *store;
|
---|
84 |
|
---|
85 | store = gtk_list_store_new (NUM_COLS,
|
---|
86 | G_TYPE_POINTER,
|
---|
87 | G_TYPE_STRING,
|
---|
88 | G_TYPE_STRING,
|
---|
89 | GDK_TYPE_PIXBUF,
|
---|
90 | G_TYPE_BOOLEAN);
|
---|
91 | g_message("%s: store: %x", __FUNCTION__, store);
|
---|
92 | return store;
|
---|
93 | }
|
---|
94 |
|
---|
95 | static BOOL
|
---|
96 | fldr_fillStore (GtkListStore *store, const gchar* gchrPath)
|
---|
97 | {
|
---|
98 |
|
---|
99 | GDir *gDir;
|
---|
100 | const gchar *gchrCurrentEntry;
|
---|
101 | GtkTreeIter iter;
|
---|
102 |
|
---|
103 | nomPrintf("In %s: %s\n", __FUNCTION__, gchrPath);
|
---|
104 |
|
---|
105 | /* First clear the store */
|
---|
106 | gtk_list_store_clear (store);
|
---|
107 |
|
---|
108 | /* Now go through the directory and extract all the file
|
---|
109 | * information */
|
---|
110 | gDir = g_dir_open (gchrPath, 0, NULL);
|
---|
111 | if (!gDir)
|
---|
112 | return FALSE;
|
---|
113 |
|
---|
114 | while ((gchrCurrentEntry = g_dir_read_name (gDir))!= NULL)
|
---|
115 | {
|
---|
116 | gchar *path, *display_name;
|
---|
117 | gboolean is_dir;
|
---|
118 |
|
---|
119 | if (gchrCurrentEntry[0] != '\0')
|
---|
120 | {
|
---|
121 | path = g_build_filename (gchrPath, gchrCurrentEntry, NULL);
|
---|
122 | nomPrintf(" %s\n", path);
|
---|
123 |
|
---|
124 | display_name = g_filename_to_utf8 (gchrCurrentEntry, -1, NULL, NULL, NULL);
|
---|
125 | if(g_file_test (path, G_FILE_TEST_IS_DIR))
|
---|
126 | {
|
---|
127 | /* It's a folder */
|
---|
128 | WPFolder* wpFolder;
|
---|
129 |
|
---|
130 | wpFolder=WPFolderNew();
|
---|
131 | if(nomIsObj(wpFolder))
|
---|
132 | {
|
---|
133 | gtk_list_store_append (store, &iter);
|
---|
134 |
|
---|
135 | gtk_list_store_set (store, &iter,
|
---|
136 | COL_OBJECT_PTR, wpFolder,
|
---|
137 | COL_PATH, path,
|
---|
138 | COL_DISPLAY_NAME, display_name,
|
---|
139 | COL_IS_DIRECTORY, is_dir,
|
---|
140 | COL_PIXBUF, _wpQueryIcon(wpFolder, NULLHANDLE), //folder_pixbuf ,
|
---|
141 | -1);
|
---|
142 |
|
---|
143 | }/* if(nomIsObj(wpFolder)) */
|
---|
144 | }/* if(g_file_test (path, G_FILE_TEST_IS_DIR)) */
|
---|
145 | else
|
---|
146 | {
|
---|
147 | /* It's a file */
|
---|
148 | WPDataFile* wpDataFile;
|
---|
149 |
|
---|
150 | wpDataFile=WPDataFileNew();
|
---|
151 |
|
---|
152 | if(nomIsObj(wpDataFile))
|
---|
153 | {
|
---|
154 | gtk_list_store_append (store, &iter);
|
---|
155 |
|
---|
156 | #warning !!!! some problems with icon handling here !!!!
|
---|
157 | nomPrintf("Icon ptr: %x\n", _wpQueryIcon((WPObject*)wpDataFile, NULLHANDLE));
|
---|
158 | gtk_list_store_set (store, &iter,
|
---|
159 | COL_OBJECT_PTR, wpDataFile,
|
---|
160 | COL_PATH, path,
|
---|
161 | COL_DISPLAY_NAME, display_name,
|
---|
162 | COL_IS_DIRECTORY, is_dir,
|
---|
163 | COL_PIXBUF, _wpQueryIcon((WPObject*)wpDataFile, NULLHANDLE), //file_pixbuf,
|
---|
164 | -1);
|
---|
165 | }
|
---|
166 | }
|
---|
167 | g_free (path);
|
---|
168 | g_free (display_name);
|
---|
169 | }/* if (gchrCurrentEntry[0] != '\0') */
|
---|
170 | }/* while */
|
---|
171 |
|
---|
172 | g_dir_close(gDir);
|
---|
173 |
|
---|
174 | return TRUE;
|
---|
175 | }
|
---|
176 |
|
---|
177 | /* pszPath contains the fully qualified path (checked with WPS) */
|
---|
178 | NOM_Scope CORBA_boolean NOMLINK impl_WPFolder_wpPopulate(WPFolder* nomSelf, const CORBA_unsigned_long ulReserved,
|
---|
179 | const CORBA_char * pszPath, const CORBA_boolean fFoldersOnly,
|
---|
180 | CORBA_Environment *ev)
|
---|
181 | {
|
---|
182 | WPFolderData* nomThis=WPFolderGetData(nomSelf);
|
---|
183 | GtkListStore* gStore;
|
---|
184 | PPRIVFOLDERDATA priv;
|
---|
185 |
|
---|
186 | nomPrintf(" Entering %s with nomSelf: 0x%x. nomSelf is: %s. Path is %s\n",
|
---|
187 | __FUNCTION__, nomSelf , nomSelf->mtab->nomClassName, pszPath);
|
---|
188 |
|
---|
189 | g_return_val_if_fail(_privFolderData!=NULLHANDLE, FALSE); /* Huh! What happened in wpInitData()? */
|
---|
190 | g_log("WPFolder", G_LOG_LEVEL_DEBUG, "%s: Populating %s\n", __FUNCTION__, pszPath);
|
---|
191 |
|
---|
192 |
|
---|
193 | #if 0
|
---|
194 | /* Already populated? */
|
---|
195 | if(fFoldersOnly &&
|
---|
196 | (_wpQueryFldrFlags(somSelf) & (FOI_POPULATEDWITHFOLDERS | FOI_POPULATEDWITHALL)))
|
---|
197 | return TRUE;
|
---|
198 | else if(_wpQueryFldrFlags(somSelf) & FOI_POPULATEDWITHALL)
|
---|
199 | return TRUE;
|
---|
200 | #endif
|
---|
201 |
|
---|
202 | priv=_privFolderData;
|
---|
203 |
|
---|
204 | if(!priv->gstoreFldContents)
|
---|
205 | {
|
---|
206 | /* Create a store holding the folder contents */
|
---|
207 | gStore=fldr_CreateStore();
|
---|
208 | g_return_val_if_fail(gStore!=NULLHANDLE, FALSE);
|
---|
209 | priv->gstoreFldContents=gStore;
|
---|
210 | }
|
---|
211 |
|
---|
212 | /* Fill our store */
|
---|
213 | if(gStore)
|
---|
214 | fldr_fillStore(gStore, pszPath);
|
---|
215 | else
|
---|
216 | return FALSE;
|
---|
217 |
|
---|
218 | gtk_icon_view_set_model(GTK_ICON_VIEW (priv->gtkIconView), GTK_TREE_MODEL (priv->gstoreFldContents));
|
---|
219 |
|
---|
220 | /* We now set which model columns that correspond to the text
|
---|
221 | * and pixbuf of each item
|
---|
222 | */
|
---|
223 | gtk_icon_view_set_text_column (GTK_ICON_VIEW (priv->gtkIconView), COL_DISPLAY_NAME);
|
---|
224 | gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW (priv->gtkIconView), COL_PIXBUF);
|
---|
225 | gtk_icon_view_set_item_width (GTK_ICON_VIEW (priv->gtkIconView),
|
---|
226 | 100);
|
---|
227 |
|
---|
228 | g_object_unref (gStore);
|
---|
229 |
|
---|
230 | return FALSE;
|
---|
231 | }
|
---|
232 |
|
---|
233 | NOM_Scope gpointer NOMLINK impl_WPFolder_wpOpen(WPFolder* nomSelf, const gpointer ptrReserved,
|
---|
234 | const CORBA_unsigned_long ulView, const gpointer ptrParams,
|
---|
235 | CORBA_Environment *ev)
|
---|
236 | {
|
---|
237 | /* WPFolderData* nomThis=WPFolderGetData(nomSelf); */
|
---|
238 |
|
---|
239 | switch(ulView)
|
---|
240 | {
|
---|
241 | case OPEN_CONTENTS:
|
---|
242 | case OPEN_DEFAULT:
|
---|
243 | {
|
---|
244 | NOMFolderWindow * nomFldrWindow;
|
---|
245 |
|
---|
246 | #warning !!!!! Folder window must be inserted into inuse list !!!!!
|
---|
247 | nomFldrWindow=WPFolder_wpCreateFolderWindow(nomSelf, ev);
|
---|
248 | NOMFolderWindow_setWPFolderObject(nomFldrWindow, nomSelf, ev);
|
---|
249 |
|
---|
250 | #warning !!!!! Path taken from a test location !!!!!
|
---|
251 | WPFolder_wpPopulate(nomSelf, 0L, NOMPath_getCString(WPFolder_wpQueryRealName(nomSelf, TRUE, ev) , ev), FALSE, ev);
|
---|
252 | break;
|
---|
253 |
|
---|
254 | #if 0
|
---|
255 | char path[CCHMAXPATH];
|
---|
256 | ULONG ulSize;
|
---|
257 |
|
---|
258 | /* Get full path of folder */
|
---|
259 | ulSize=sizeof(path);
|
---|
260 |
|
---|
261 | if(!_wpQueryRealName(somSelf, path, &ulSize, TRUE))
|
---|
262 | return NULLHANDLE; /* Error */
|
---|
263 |
|
---|
264 | nomPrintf("%s: opening %s\n", __FUNCTION__, path);
|
---|
265 |
|
---|
266 | /* Create folder window */
|
---|
267 | hwndFolder=fldr_createFolderWindow(somSelf, path);
|
---|
268 |
|
---|
269 | if(!hwndFolder)
|
---|
270 | return NULLHANDLE;
|
---|
271 |
|
---|
272 | /* populate the folder */
|
---|
273 | _wpPopulate(somSelf, 0, path, FALSE); /* Contents or details. Tree isn't supported yet */
|
---|
274 |
|
---|
275 | break;
|
---|
276 | #endif
|
---|
277 | }/* default */
|
---|
278 | default:
|
---|
279 | g_return_val_if_reached(NULLHANDLE);
|
---|
280 | break;
|
---|
281 | }/* switch */
|
---|
282 | return NULLHANDLE;
|
---|
283 | }
|
---|
284 |
|
---|
285 | NOM_Scope gpointer NOMLINK impl_WPFolder_wpQueryIcon(WPFolder* nomSelf, CORBA_Environment *ev)
|
---|
286 | {
|
---|
287 | static const gchar *gchrIconName=NULLHANDLE;
|
---|
288 | static gpointer ptrIcon=NULLHANDLE;
|
---|
289 | GError *error=NULL;
|
---|
290 |
|
---|
291 | /* WPFolderData* nomThis=WPFolderGetData(nomSelf); */
|
---|
292 |
|
---|
293 | /* Load default wpObject icon */
|
---|
294 | if(!gchrIconName){
|
---|
295 | gchrIconName=g_build_filename(priv_getIconDir(), WPFOLDER_ICON_FILE, NULL);
|
---|
296 |
|
---|
297 | g_return_val_if_fail(g_file_test (gchrIconName, G_FILE_TEST_EXISTS), NULLHANDLE);
|
---|
298 | nomPrintf("IconFile: %s\n", gchrIconName);
|
---|
299 | // _hPointerCls = (HPOINTER)gdk_pixbuf_new_from_file (gchrIconName, &error);
|
---|
300 | ptrIcon=gdk_pixbuf_new_from_file (gchrIconName, &error);
|
---|
301 | }
|
---|
302 | return ptrIcon;
|
---|
303 |
|
---|
304 | /* WPFolder_wpQueryIcon_parent(nomSelf, ev); */
|
---|
305 | }
|
---|
306 |
|
---|
307 | /*
|
---|
308 | This method creates the folder window it doesn't query any files or creates
|
---|
309 | models and stuff.
|
---|
310 | */
|
---|
311 | NOM_Scope PNOMFolderWindow NOMLINK impl_WPFolder_wpCreateFolderWindow(WPFolder* nomSelf, CORBA_Environment *ev)
|
---|
312 | {
|
---|
313 | NOMFolderWindow * nomFldrWindow;
|
---|
314 | PPRIVFOLDERDATA priv;
|
---|
315 | WPFolderData *nomThis = WPFolderGetData(nomSelf);
|
---|
316 |
|
---|
317 | priv=(PPRIVFOLDERDATA)_privFolderData;
|
---|
318 |
|
---|
319 | nomFldrWindow=NOMFolderWindowNew();
|
---|
320 |
|
---|
321 | #warning !!!!! This is only for testing !!!!!
|
---|
322 | priv->gtkIconView=NOMFolderWindow_getContainerHandle(nomFldrWindow, ev);
|
---|
323 |
|
---|
324 | /* Show the new window */
|
---|
325 | NOMFolderWindow_show(nomFldrWindow, ev);
|
---|
326 |
|
---|
327 | return nomFldrWindow;
|
---|
328 | }
|
---|
329 |
|
---|
330 | NOM_Scope void NOMLINK impl_WPFolder_wpInitData(WPFolder* nomSelf, CORBA_Environment *ev)
|
---|
331 | {
|
---|
332 | gulong ulErr;
|
---|
333 | WPFolderData* nomThis=WPFolderGetData(nomSelf);
|
---|
334 |
|
---|
335 | WPFolder_wpInitData_parent((WPObject*)nomSelf, ev);
|
---|
336 |
|
---|
337 | nomPrintf(" Entering %s with nomSelf: 0x%x. nomSelf is: %s.\n",
|
---|
338 | __FUNCTION__, nomSelf , nomSelf->mtab->nomClassName);
|
---|
339 | _privFolderData=_wpAllocMem((WPObject*)nomSelf, sizeof(PRIVFOLDERDATA), (CORBA_unsigned_long*)&ulErr, NULLHANDLE);
|
---|
340 | }
|
---|
341 |
|
---|
342 |
|
---|
343 |
|
---|