source: trunk/desktop/class_c/wpobject.c@ 175

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

Added inuse list methods and related code.

File size: 22.0 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 * This file was generated by orbit-idl-2 for Voyager
36 *
37 *
38 * And remember, phase 3 is near...
39 */
40#define INCL_DOS
41#define INCL_DOSERRORS
42#define INCL_DOSSEMAPHORES
43#include <os2.h>
44
45#include <nom.h>
46#include <nomtk.h>
47
48#include <string.h>
49#include <gtk/gtk.h>
50#include <nomguitk.h>
51
52/* We have to declare this here to make PNOMFolderWindow known
53 to wpDisplayMenu(). */
54#ifndef NOMFolderWindow
55typedef struct NOMFolderWindow_struct {
56 struct nomMethodTabStruct *mtab;
57 gulong body[1];
58} NOMFolderWindowObj;
59#define NOMFolderWindow NOMFolderWindowObj
60typedef NOMFolderWindow *PNOMFolderWindow;
61#endif
62
63#ifndef WPObject
64typedef struct WPObject_struct {
65 struct nomMethodTabStruct *mtab;
66 gulong body[1];
67} WPObjectObj;
68#define WPObject WPObjectObj
69typedef WPObject *PWPObject;
70#endif
71
72#include "nomwindow.h"
73#include "desktoptypes.h"
74
75#include "wpobject.ih"
76#include "nomfolderwindow.h"
77#include "wpnotebook.h"
78
79
80
81/*************** Local vars ************************************/
82
83static nomId WPObjectNomId;
84
85/***************************************************************/
86
87NOM_Scope gpointer NOMLINK impl_WPObject_wpAllocMem(WPObject* nomSelf, const gulong cbBytes,
88 gulong* prc, CORBA_Environment *ev)
89{
90
91/* WPObjectData* nomThis=WPObjectGetData(nomSelf); */
92 gpointer ptrMem=NULLHANDLE;
93 PUSEITEM pui;
94
95 /* Add mem for the inuse list structures */
96 ptrMem=NOMCalloc(1, cbBytes+sizeof(USEITEM)+sizeof(MEMORYITEM));
97
98 if(!ptrMem) {
99 if(prc)
100 *prc=(gulong)NOMERROR_NOT_ENOUGH_MEMORY;
101 return NULLHANDLE;
102 }
103
104 /* Fill the structures */
105 pui=(PUSEITEM)ptrMem;
106 pui->type=(ULONG)USAGE_MEMORY;
107 pui->wpObject=nomSelf;
108 pui++;
109 ((MEMORYITEM*)pui)->cbBuffer=cbBytes;
110
111 /* Add memory to in use list */
112 WPObject_wpAddToObjUseList(nomSelf, (PUSEITEM)ptrMem, ev);
113
114 return (gpointer)((PBYTE)ptrMem+sizeof(USEITEM)+sizeof(MEMORYITEM));
115}
116
117NOM_Scope CORBA_boolean NOMLINK impl_WPObject_wpFreeMem(WPObject* nomSelf, const gpointer pByte, CORBA_Environment *ev)
118{
119 gpointer ptrMem=NULLHANDLE;
120
121 if(!pByte)
122 return FALSE;
123
124 ptrMem=(gpointer)((PBYTE)pByte-sizeof(USEITEM)-sizeof(MEMORYITEM));
125
126 /* remove from inuse list */
127 WPObject_wpDeleteFromObjUseList(nomSelf, (PUSEITEM)ptrMem, ev );
128
129 NOMFree(ptrMem);
130 return TRUE; /* free can't fail */;
131}
132
133NOM_Scope void NOMLINK impl_WPObject_nomInit(WPObject* nomSelf, CORBA_Environment *ev)
134{
135 WPObjectData* nomThis=WPObjectGetData(nomSelf);
136
137 /* orbit-idl-c-stubs.c, VoyagerWriteProtoForParentCall line 84 */
138 WPObject_nomInit_parent((NOMObject*) nomSelf, ev);
139
140 nomPrintf(" Entering %s with nomSelf: 0x%x. nomSelf is: %s.\n",
141 __FUNCTION__, nomSelf , nomSelf->mtab->nomClassName);
142
143 /* Initialize important data before letting subclasses do their stuff */
144 //_gObjectMutex=g_mutex_new();
145 if(NO_ERROR!=DosCreateMutexSem(NULL, &_gObjectMutex, 0, FALSE))
146 {
147 g_error("Can't create a mutex for WPObject!");
148 }
149
150 _wpInitData(nomSelf, ev);
151}
152
153NOM_Scope void NOMLINK impl_WPObject_nomUninit(WPObject* nomSelf, CORBA_Environment *ev)
154{
155 WPObjectData* nomThis=WPObjectGetData(nomSelf);
156
157 _wpUnInitData(nomSelf, ev);
158
159 //g_mutex_free(_gObjectMutex);
160 DosCloseMutexSem(_gObjectMutex);
161 WPObject_nomUninit_parent((NOMObject*)nomSelf, ev);
162}
163
164NOM_Scope void NOMLINK impl_WPObject_wpInitData(WPObject* nomSelf, CORBA_Environment *ev)
165{
166 WPObjectData* nomThis=WPObjectGetData(nomSelf);
167
168 /* Get our unique class ID. We need it for example when inserting menu items to
169 specify the namespace. We query it here because getting a GQuark from a string
170 is rather time consuming. The result is saved in a var for later use. */
171 WPObjectNomId=g_quark_from_string("WPObject");
172
173 /* Make sure a title exists (even if it's an empty string */
174 _pnomStringTitle=NOMStringNew();
175}
176
177NOM_Scope void NOMLINK impl_WPObject_wpUnInitData(WPObject* nomSelf, CORBA_Environment *ev)
178{
179/* WPObjectData* nomThis=WPObjectGetData(nomSelf); */
180
181}
182
183
184NOM_Scope gpointer NOMLINK impl_WPObject_wpOpen(WPObject* nomSelf, const PNOMFolderWindow nomFolder,
185 const gulong ulView, const gpointer pParam, CORBA_Environment *ev)
186{
187/* WPObjectData* nomThis=WPObjectGetData(nomSelf); */
188
189 switch(ulView)
190 {
191 case OPEN_SETTINGS:
192 {
193 PUSEITEM pui;
194 gulong ulError;
195
196 WPNoteBook* wpNoteBook;
197 wpNoteBook=WPNoteBookNew();
198 _wpAddSettingsPages(nomSelf, wpNoteBook, ev);
199
200 /* Add a view item to inuse list */
201 pui=(PUSEITEM)WPObject_wpAllocMem(nomSelf, sizeof(USEITEM)+sizeof(VIEWITEM), &ulError, ev);
202 /* Fill the structures */
203
204 pui->type=(gulong)USAGE_OPENVIEW;
205 pui->wpObject=nomSelf;
206 pui++;
207 ((VIEWITEM*)pui)->ulView=VIEW_SETTINGS;
208 ((VIEWITEM*)pui)->nomWindow=(NOMWindow*)wpNoteBook;
209 g_message(" in %s viewItem: %x wpNoteBook 0x%04X", __FUNCTION__, pui, wpNoteBook);
210 pui--;
211
212 WPObject_wpAddToObjUseList(nomSelf, pui, ev);
213 WPNoteBook_show(wpNoteBook, ev);
214 return (gpointer) wpNoteBook;
215 }
216 default:
217 /* We are the very last in the chain of classes being called */
218 g_return_val_if_reached(NULLHANDLE);
219 break;
220 }
221 return NULLHANDLE;
222}
223
224NOM_Scope gpointer NOMLINK impl_WPObject_wpViewObject(WPObject* nomSelf, const PNOMFolderWindow nomFolder, const gulong ulView, const gpointer pParam, CORBA_Environment *ev)
225{
226/* WPObjectData* nomThis=WPObjectGetData(nomSelf); */
227 gpointer nomRetval=NULLHANDLE;
228
229
230 if((nomRetval=WPObject_wpSwitchTo(nomSelf, ulView, ev))!=NULLHANDLE){
231 /* Bring the window to the foreground */
232 // NOMWindow_show((NOMWindow*)nomRetval , ev);
233 return nomRetval;
234 }
235
236 g_message(" in %s with ulViev 0x%04X", __FUNCTION__, ulView);
237 return WPObject_wpOpen(nomSelf, nomFolder, ulView, pParam, ev);
238}
239
240NOM_Scope gpointer NOMLINK impl_WPObject_wpSwitchTo(WPObject* nomSelf, const gulong ulView, CORBA_Environment *ev)
241{
242/* WPObjectData* nomThis=WPObjectGetData(nomSelf); */
243 PVIEWITEM pViewItem;
244
245 g_message(" in %s with ulViev 0x%04X", __FUNCTION__, ulView);
246
247 switch(ulView)
248 {
249 case OPEN_SETTINGS:
250 {
251 g_message(" in %s : OPEN_SETTINGS", __FUNCTION__);
252 pViewItem=WPObject_wpFindViewItem(nomSelf, VIEW_SETTINGS, NULLHANDLE, ev);
253 if(pViewItem){
254 g_message(" in %s : OPEN_SETTINGS returning %x %x ...", __FUNCTION__, pViewItem, pViewItem->nomWindow);
255 NOMWindow_show(pViewItem->nomWindow, ev);
256 return (gpointer)pViewItem->nomWindow;
257 }
258 break;
259 }
260 default:
261 break;
262 }
263
264 return NULLHANDLE;
265}
266
267NOM_Scope CORBA_boolean NOMLINK impl_WPObject_wpRegisterView(WPObject* nomSelf, const PNOMWindow pWindow,
268 const PNOMString nomStrViewTitle, CORBA_Environment *ev)
269{
270/* WPObjectData* nomThis=WPObjectGetData(nomSelf); */
271
272 g_message("Method %s not implemented.", __FUNCTION__);
273 return FALSE;
274}
275
276NOM_Scope CORBA_boolean NOMLINK impl_WPObject_wpAddToObjUseList(WPObject* nomSelf, const PUSEITEM pUseItem,
277 CORBA_Environment *ev)
278{
279 WPObjectData* nomThis=WPObjectGetData(nomSelf);
280
281 if(!pUseItem)
282 return FALSE;
283
284 g_message(" in %s : %x", __FUNCTION__, pUseItem);
285
286 WPObject_wpRequestObjectMutexSem(nomSelf, 0,ev);
287
288 _glstObjectInUse=g_slist_append( _glstObjectInUse, (gpointer)pUseItem);
289
290 WPObject_wpReleaseObjectMutexSem(nomSelf,ev);
291
292 return TRUE;
293}
294
295NOM_Scope CORBA_boolean NOMLINK impl_WPObject_wpDeleteFromObjUseList(WPObject* nomSelf, const PUSEITEM pUseItem,
296 CORBA_Environment *ev)
297{
298 WPObjectData* nomThis=WPObjectGetData(nomSelf);
299
300 if(!pUseItem)
301 return FALSE;
302
303 WPObject_wpRequestObjectMutexSem(nomSelf, 0,ev);
304
305 _glstObjectInUse=g_slist_remove( _glstObjectInUse, (gpointer)pUseItem);
306
307 WPObject_wpReleaseObjectMutexSem(nomSelf,ev);
308
309 return TRUE;
310}
311
312
313NOM_Scope PUSEITEM NOMLINK impl_WPObject_wpFindUseItem(WPObject* nomSelf, const gulong ulType,
314 const PUSEITEM pCurrentUseItem, CORBA_Environment *ev)
315{
316 WPObjectData* nomThis=WPObjectGetData(nomSelf);
317 PUSEITEM pUseItem=NULLHANDLE;
318 GSList* tmpList;
319
320 if(NULLHANDLE==_glstObjectInUse)
321 return NULLHANDLE;
322
323 WPObject_wpRequestObjectMutexSem(nomSelf, 0,ev);
324 g_message(" in %s %d", __FUNCTION__, ulType);
325 if(NULLHANDLE==pCurrentUseItem)
326 tmpList=_glstObjectInUse;
327 else{
328 tmpList=g_slist_find(_glstObjectInUse, pCurrentUseItem);
329 tmpList=g_slist_next(tmpList);
330 }
331
332 while(tmpList)
333 {
334 pUseItem=(PUSEITEM)tmpList->data;
335
336 g_message(" a in %s type: %d", __FUNCTION__, pUseItem->type);
337
338 if(pUseItem && ulType==pUseItem->type)
339 break;
340 g_message(" b in %s type: %d", __FUNCTION__, pUseItem->type);
341 tmpList=g_slist_next(tmpList);
342 pUseItem=NULLHANDLE;
343 };
344
345 WPObject_wpReleaseObjectMutexSem(nomSelf,ev);
346
347 return pUseItem;
348}
349
350
351NOM_Scope PVIEWITEM NOMLINK impl_WPObject_wpFindViewItem(WPObject* nomSelf, const gulong flViews,
352 const PVIEWITEM pCurrentItem, CORBA_Environment *ev)
353{
354/* WPObjectData* nomThis=WPObjectGetData(nomSelf); */
355 PUSEITEM pUseItem;
356 PVIEWITEM pViewItem=NULLHANDLE;
357
358 if(!flViews)
359 return NULLHANDLE;
360 g_message(" in %s %d", __FUNCTION__, flViews);
361 if(NULLHANDLE==pCurrentItem)
362 pUseItem=WPObject_wpFindUseItem(nomSelf, USAGE_OPENVIEW, NULLHANDLE, ev);
363 else{
364 pUseItem=(PUSEITEM)pCurrentItem;
365 pUseItem--;
366 pUseItem=WPObject_wpFindUseItem(nomSelf, USAGE_OPENVIEW, pUseItem, ev);
367 }
368 while(pUseItem)
369 {
370 ++pUseItem;
371 pViewItem=(PVIEWITEM)pUseItem;
372 pUseItem--;
373 g_message(" a in %s %d", __FUNCTION__, flViews);
374 if(pViewItem->ulView & flViews)
375 break;
376 g_message(" b in %s %d", __FUNCTION__, flViews);
377 pUseItem=WPObject_wpFindUseItem(nomSelf, USAGE_OPENVIEW, pUseItem, ev);
378 pViewItem=NULLHANDLE;
379 }
380
381 return pViewItem;
382}
383
384
385NOM_Scope void NOMLINK impl_WPObject_wpLockObject(WPObject* nomSelf, CORBA_Environment *ev)
386{
387 WPObjectData* nomThis=WPObjectGetData(nomSelf);
388
389 g_atomic_int_inc(&_iLockCounter);
390}
391
392NOM_Scope CORBA_boolean NOMLINK impl_WPObject_wpUnlockObject(WPObject* nomSelf, CORBA_Environment *ev)
393{
394 WPObjectData* nomThis=WPObjectGetData(nomSelf);
395
396 /* We return TRUE if the counter is 0 */
397 if(g_atomic_int_dec_and_test(&_iLockCounter))
398 {
399 /* Counter is 0 so the object should go dormant */
400 return TRUE;
401 }
402 return FALSE;
403}
404
405NOM_Scope CORBA_boolean NOMLINK impl_WPObject_wpObjectIsLocked(WPObject* nomSelf, CORBA_Environment *ev)
406{
407 WPObjectData* nomThis=WPObjectGetData(nomSelf);
408
409 return g_atomic_int_get(&_iLockCounter) && TRUE;
410}
411
412NOM_Scope gpointer NOMLINK impl_WPObject_wpQueryIcon(WPObject* nomSelf, CORBA_Environment *ev)
413{
414/* WPObjectData* nomThis=WPObjectGetData(nomSelf); */
415
416 return NULLHANDLE;
417}
418
419NOM_Scope CORBA_unsigned_long NOMLINK impl_WPObject_wpRequestObjectMutexSem(WPObject* nomSelf,
420 const CORBA_unsigned_long ulReserved,
421 CORBA_Environment *ev)
422{
423 WPObjectData* nomThis=WPObjectGetData(nomSelf);
424
425 return DosRequestMutexSem(_gObjectMutex, -1L);
426}
427
428NOM_Scope CORBA_unsigned_long NOMLINK impl_WPObject_wpReleaseObjectMutexSem(WPObject* nomSelf, CORBA_Environment *ev)
429{
430 WPObjectData* nomThis=WPObjectGetData(nomSelf);
431 return DosReleaseMutexSem(_gObjectMutex);
432}
433
434NOM_Scope PNOMString NOMLINK impl_WPObject_wpSetTitle(WPObject* nomSelf, const PNOMString pnomStrNewTitle, CORBA_Environment *ev)
435{
436 WPObjectData* nomThis=WPObjectGetData(nomSelf);
437 PNOMString tmpString=NOMStringNew();
438 gpointer tmpPtr;
439
440 /* Create a new title */
441 NOMString_assignString(tmpString, pnomStrNewTitle, ev);
442
443 /* It may happen that someone changed the title from another thread. We may either
444 bail out then or just use our string as the mother of all strings. Since we are the last one
445 trying to change the title our string is presumably the correct one. At least we act
446 so :P. The memory holding the old string (which may not be the correct one anymore) is
447 still valid because we hold a pointer to it in tmpPtr. Garbage collection won't free it
448 under our feet. */
449 do{
450 /* Get old NOMString containing old title */
451 tmpPtr=g_atomic_pointer_get(&_pnomStringTitle);
452 }while(!g_atomic_pointer_compare_and_exchange((gpointer*)&_pnomStringTitle, tmpPtr, (gpointer) tmpString));
453
454 return pnomStrNewTitle;
455}
456
457NOM_Scope PNOMString NOMLINK impl_WPObject_wpQueryTitle(WPObject* nomSelf, CORBA_Environment *ev)
458{
459 gpointer tmpPtr;
460 WPObjectData* nomThis=WPObjectGetData(nomSelf);
461
462 /*
463 This string will remain valid as long as we use it. Even if someone changes the title
464 while we are in this method the garbage collector won't free it. The other thread
465 changing the title is working on a copy so no problem here. */
466 tmpPtr=g_atomic_pointer_get(&_pnomStringTitle);
467
468 return NOMString_copyString(tmpPtr, ev);
469}
470
471NOM_Scope CORBA_unsigned_long NOMLINK impl_WPObject_wpAddObjectGeneralPage(WPObject* nomSelf,
472 const PWPNoteBook wpNoteBook,
473 CORBA_Environment *ev)
474{
475/* WPObjectData* nomThis=WPObjectGetData(nomSelf); */
476 GtkWidget *frame;
477 GtkWidget *label;
478 GtkWidget *vbox;
479 GtkWidget *hbox;
480 GtkWidget *button;
481 GtkWidget *entry;
482
483 /* A vbox to layout the settings page */
484 vbox=gtk_vbox_new(FALSE, 0);
485
486 hbox=gtk_hbutton_box_new ();
487 gtk_button_box_set_layout (GTK_BUTTON_BOX (hbox), GTK_BUTTONBOX_SPREAD);
488 gtk_box_set_spacing (GTK_BOX (hbox), 2);
489
490 /* Create buttons */
491 button = gtk_button_new_from_stock (GTK_STOCK_OK);
492 gtk_container_add (GTK_CONTAINER (hbox), button);
493 button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
494 gtk_container_add (GTK_CONTAINER (hbox), button);
495 /* Put the buttons at the very bottom */
496 gtk_box_pack_end (GTK_BOX (vbox), hbox, FALSE, FALSE, 1);
497
498 /* The icon part */
499 frame = gtk_frame_new ("Current Icon");
500 gtk_container_set_border_width (GTK_CONTAINER (frame), 5);
501 gtk_widget_set_size_request(frame, 200, 100);
502 gtk_box_pack_end (GTK_BOX (vbox), frame, FALSE, FALSE, 1);
503
504 /* The Title part */
505 frame = gtk_frame_new ("Title");
506 gtk_container_set_border_width (GTK_CONTAINER (frame), 5);
507 entry=gtk_entry_new();
508 gtk_entry_set_max_length(GTK_ENTRY(entry), CCHMAXPATH);
509 gtk_container_add (GTK_CONTAINER (frame), entry);
510 gtk_box_pack_end (GTK_BOX (vbox), frame, FALSE, FALSE, 1);
511
512 /* The label for the tab */
513 label = gtk_label_new ("Icon");
514
515 gtk_widget_show_all (vbox);
516
517 NOMNoteBook_prependPage(WPNoteBook_wpQueryNoteBookObject(wpNoteBook, ev), vbox, label, ev);
518
519 return 1234;
520}
521
522NOM_Scope CORBA_boolean NOMLINK impl_WPObject_wpAddSettingsPages(WPObject* nomSelf, const PWPNoteBook wpNoteBook,
523 CORBA_Environment *ev)
524{
525/* WPObjectData* nomThis=WPObjectGetData(nomSelf); */
526
527 _wpAddObjectGeneralPage(nomSelf, wpNoteBook, ev);
528 return TRUE;
529}
530
531NOM_Scope CORBA_unsigned_long NOMLINK impl_WPObject_wpInsertSettingsPage(WPObject* nomSelf,
532 const PWPNoteBook wpNoteBook,
533 const gpointer ppageinfo,
534 CORBA_Environment *ev)
535{
536/* WPObjectData* nomThis=WPObjectGetData(nomSelf); */
537 CORBA_unsigned_long nomRetval;
538
539 return nomRetval;
540}
541
542
543NOM_Scope PNOMMenu NOMLINK impl_WPObject_wpDisplayMenu(WPObject* nomSelf, const PNOMFolderWindow nomFolder,
544 const gpointer gReserved, const CORBA_unsigned_long ulMenuType,
545 const CORBA_unsigned_long ulReserved, CORBA_Environment *ev)
546{
547/* WPObjectData* nomThis=WPObjectGetData(nomSelf); */
548 PNOMMenu nomMenu=NOMMenuNew();
549
550 /* Let classes insert menu items now */
551 WPObject_wpModifyMenu(nomSelf, nomFolder, nomMenu, ulMenuType, ev);
552
553 /* Let classes filter menu items now */
554 WPObject_wpFilterMenu(nomSelf, nomFolder, nomMenu, ulMenuType, 0, ev);
555
556 /* And finally show it */
557 gtk_menu_popup(GTK_MENU(NOMMenu_queryMenuHandle(nomMenu,ev)), NULL, NULL, NULL, NULL, 0,
558 gtk_get_current_event_time());
559
560 return nomMenu;
561}
562
563NOM_Scope void NOMLINK impl_WPObject_wpModifyMenu(WPObject* nomSelf, const PNOMFolderWindow nomFolder,
564 const PNOMMenu nomMenu, const CORBA_unsigned_long ulMenuType,
565 CORBA_Environment *ev)
566{
567 NOMMenuItem* mItem;
568 /* WPObjectData* nomThis=WPObjectGetData(nomSelf); */
569
570 mItem=NOMMenuItemNew();
571
572 NOMMenuItem_setup(mItem, __FUNCTION__, WPObjectNomId, 0, ev);
573 WPObject_wpInsertMenuItem(nomSelf, nomMenu, mItem, 0, ev);
574
575 mItem=NOMMenuItemNew();
576 NOMMenuItem_setup(mItem, "Settings...", WPObjectNomId, WPMENUID_PROPERTIES, ev);
577 WPObject_wpInsertMenuItem(nomSelf, nomMenu, mItem, 0, ev);
578}
579
580NOM_Scope void NOMLINK impl_WPObject_wpFilterMenu(WPObject* nomSelf, const PNOMFolderWindow nomFolder,
581 const PNOMMenu nomMenu, const CORBA_unsigned_long ulMenuType,
582 const CORBA_unsigned_long ulFlags, CORBA_Environment *ev)
583{
584/* WPObjectData* nomThis=WPObjectGetData(nomSelf); */
585
586}
587
588NOM_Scope CORBA_boolean NOMLINK impl_WPObject_wpMenuItemSelected(WPObject* nomSelf, const PNOMFolderWindow nomFolder,
589 const PNOMMenuItem nomMenuItem,
590 CORBA_Environment *ev)
591{
592/* WPObjectData* nomThis=WPObjectGetData(nomSelf); */
593
594 /* We only handle items with in own name space */
595 if(WPObjectNomId==NOMMenuItem_queryNameSpaceId(nomMenuItem, ev))
596 {
597 switch(NOMMenuItem_queryId(nomMenuItem, ev))
598 {
599 case WPMENUID_PROPERTIES:
600 {
601 WPObject_wpViewObject(nomSelf, nomFolder,
602 OPEN_SETTINGS, NULLHANDLE, ev);
603 return TRUE; /* We always return TRUE to show, we handled the menu item. It doesn't
604 matter if we actually succeeded with creating the settings notebook. */
605 }
606 default:
607 break;
608 }
609 }
610 return FALSE;
611}
612
613/*
614 Callback for desktop menu items. This callback takes the object pointer and call wpMenuItemSelected()
615 of the object.
616 */
617static void menuItemActivateCallBack(GtkMenuItem* gtkMenuItem, gpointer wpObject)
618{
619 PNOMMenuItem pItem;
620
621#if 0
622 if(!nomIsObj((WPObject*)wpObject))
623 return;
624#endif
625
626 pItem=(PNOMMenuItem) g_object_get_data(G_OBJECT(gtkMenuItem), NOMOBJECT_KEY_STRING);
627
628 WPObject_wpMenuItemSelected((WPObject*) wpObject, NULLHANDLE,
629 pItem, NULLHANDLE);
630}
631
632/*
633 This method adds the correct callback function to the menuitem and inserts it into the given menu.
634
635 FIXME: position information for the menu item isn't used yet. The Item is always appended.
636
637 */
638NOM_Scope void NOMLINK impl_WPObject_wpInsertMenuItem(WPObject* nomSelf, const PNOMMenu nomMenu,
639 const PNOMMenuItem nomMenuItem,
640 const CORBA_unsigned_long ulPosition, CORBA_Environment *ev)
641{
642/* WPObjectData* nomThis=WPObjectGetData(nomSelf); */
643
644 g_signal_connect(NOMMenuItem_queryMenuItemHandle(nomMenuItem, ev), "activate",
645 (GCallback) menuItemActivateCallBack, (gpointer) nomSelf);
646
647 gtk_menu_shell_append(GTK_MENU_SHELL(NOMMenu_queryMenuHandle(nomMenu,ev)),
648 NOMMenuItem_queryMenuItemHandle(nomMenuItem, ev));
649
650}
651
652
653
654
Note: See TracBrowser for help on using the repository browser.