Ignore:
Timestamp:
Jan 14, 2007, 1:54:49 PM (19 years ago)
Author:
cinc
Message:

More object view methods and improvements.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/desktop/class_c/wpobject.c

    r189 r191  
    149149     specify the namespace. We query it here because getting a GQuark from a string
    150150     is rather time consuming. The result is saved in a var for later use. */
    151   WPObjectNomId=g_quark_from_string("WPObject");
     151  WPObjectNomId=nomIdFromString("WPObject"); //g_quark_from_string("WPObject");
    152152
    153153  /* Make sure a title exists (even if it's an empty string */
     
    186186
    187187NOM_Scope gpointer NOMLINK impl_WPObject_wpOpen(WPObject* nomSelf, const PWPFolderWindow nomFolder,
    188                                                 const gulong ulView, const gpointer pParam, CORBA_Environment *ev)
    189 {
    190 /* WPObjectData* nomThis=WPObjectGetData(nomSelf); */
    191 
    192   switch(ulView)
     188                                                const gulong ulView, const nomId nameSpaceId,
     189                                                const gpointer pParam, CORBA_Environment *ev)
     190{
     191  /* WPObjectData* nomThis=WPObjectGetData(nomSelf); */
     192  nomId nSpaceId=nameSpaceId;
     193  gulong ulV=ulView;
     194
     195  /* Special parameter representing a double click or "I just don't know" ;-) */
     196  if(OPEN_DEFAULT==ulView)
     197    ulV=WPObject_wpQueryDefaultView(nomSelf, &nSpaceId, NULLHANDLE);
     198
     199  /* We only handle items with in own name space */
     200  if(WPObjectNomId==nSpaceId)
    193201    {
    194     case OPEN_SETTINGS:
    195       {
    196         PUSEITEM pui;
    197         gulong ulError;
    198 
    199         WPNoteBook* wpNoteBook;
    200         wpNoteBook=WPNoteBookNew();
    201         WPNoteBook_wpSetWPObject(wpNoteBook, nomSelf, NULLHANDLE);
    202 
    203         _wpAddSettingsPages(nomSelf, wpNoteBook, ev);
    204 
    205         /* Add a view item to inuse list */
    206         pui=(PUSEITEM)WPObject_wpAllocMem(nomSelf, sizeof(USEITEM)+sizeof(VIEWITEM), &ulError, ev);
    207         /* Fill the structures */
    208 
    209         pui->type=(gulong)USAGE_OPENVIEW;
    210         pui->wpObject=nomSelf;
    211         pui++;
    212         ((VIEWITEM*)pui)->ulView=VIEW_SETTINGS;
    213         ((VIEWITEM*)pui)->nomWindow=(NOMWindow*)wpNoteBook;
    214         pui--;
    215         //g_message("   in %s wpNoteBook: %lx pui %lx", __FUNCTION__, wpNoteBook, pui);
    216         /* Make sure the view item is removed when the window is closed */
    217         g_signal_connect(G_OBJECT(NOMWindow_queryWindowHandle((NOMWindow*)wpNoteBook, NULLHANDLE)),"delete-event",
    218                          G_CALLBACK(defaultWPWindowDeleteHandler), (gpointer) pui);
    219         WPObject_wpAddToObjUseList(nomSelf, pui, ev);
    220         WPNoteBook_show(wpNoteBook, ev);
    221         return (gpointer) wpNoteBook;
    222       }
    223     default:
    224       /* We are the very last in the chain of classes being called */
    225       g_return_val_if_reached(NULLHANDLE);
    226       break;
     202      switch(ulV)
     203        {
     204        case OPEN_SETTINGS:
     205          {
     206            PUSEITEM pui;
     207            gulong ulError;
     208            WPNoteBook* wpNoteBook;
     209
     210            if(CCVIEW_ON==WPObject_wpQueryConcurrentView(nomSelf, NULLHANDLE)){
     211              /* Concurrent view is ignored for the settings. */
     212              if((wpNoteBook=WPObject_wpSwitchTo(nomSelf, ulV, nSpaceId, NULLHANDLE))!=NULLHANDLE)
     213                return wpNoteBook;
     214            }
     215            wpNoteBook=WPNoteBookNew();
     216            WPNoteBook_wpSetWPObject(wpNoteBook, nomSelf, NULLHANDLE);
     217           
     218            _wpAddSettingsPages(nomSelf, wpNoteBook, ev);
     219           
     220            /* Add a view item to inuse list */
     221            pui=(PUSEITEM)WPObject_wpAllocMem(nomSelf, sizeof(USEITEM)+sizeof(VIEWITEM), &ulError, ev);
     222            /* Fill the structures */
     223           
     224            pui->type=(gulong)USAGE_OPENVIEW;
     225            pui->wpObject=nomSelf;
     226            pui++;
     227            ((VIEWITEM*)pui)->ulView=OPEN_SETTINGS;
     228            ((VIEWITEM*)pui)->nomWindow=(NOMWindow*)wpNoteBook;
     229            ((VIEWITEM*)pui)->nameSpaceId=WPObjectNomId;
     230            pui--;
     231            //g_message("   in %s wpNoteBook: %lx pui %lx", __FUNCTION__, wpNoteBook, pui);
     232            /* Make sure the view item is removed when the window is closed */
     233            g_signal_connect(G_OBJECT(NOMWindow_queryWindowHandle((NOMWindow*)wpNoteBook, NULLHANDLE)),"delete-event",
     234                             G_CALLBACK(defaultWPWindowDeleteHandler), (gpointer) pui);
     235            WPObject_wpAddToObjUseList(nomSelf, pui, ev);
     236            WPNoteBook_show(wpNoteBook, ev);
     237            return (gpointer) wpNoteBook;
     238          }
     239        default:
     240          /* We are the very last in the chain of classes being called */
     241          g_return_val_if_reached(NULLHANDLE);
     242          break;
     243        }
    227244    }
    228245  return NULLHANDLE;
     
    230247
    231248NOM_Scope gpointer NOMLINK impl_WPObject_wpViewObject(WPObject* nomSelf, const PWPFolderWindow nomFolder,
    232                                                       const gulong ulView, const gpointer pParam,
    233                                                       CORBA_Environment *ev)
     249                                                      const gulong ulView, const nomId nameSpaceId,
     250                                                      const gpointer pParam, CORBA_Environment *ev)
    234251{
    235252/* WPObjectData* nomThis=WPObjectGetData(nomSelf); */
    236253  gpointer nomRetval=NULLHANDLE;
    237 
    238 
    239   if((nomRetval=WPObject_wpSwitchTo(nomSelf, ulView, ev))!=NULLHANDLE)
     254  nomId nSpaceId=nameSpaceId;
     255  gulong ulV=ulView;
     256
     257  /* Special parameter representing a double click or "I just don't know" ;-) */
     258  if(OPEN_DEFAULT==ulView)
     259    ulV=WPObject_wpQueryDefaultView(nomSelf, &nSpaceId, NULLHANDLE);
     260
     261  if(CCVIEW_ON==WPObject_wpQueryConcurrentView(nomSelf, NULLHANDLE))
     262    return WPObject_wpOpen(nomSelf, nomFolder, ulV, nSpaceId, pParam, NULLHANDLE);
     263
     264  if((nomRetval=WPObject_wpSwitchTo(nomSelf, ulV, nSpaceId, NULLHANDLE))!=NULLHANDLE)
    240265    return nomRetval;
    241266
    242   return WPObject_wpOpen(nomSelf, nomFolder, ulView, pParam, ev);
    243 }
    244 
    245 NOM_Scope gpointer NOMLINK impl_WPObject_wpSwitchTo(WPObject* nomSelf, const gulong ulView, CORBA_Environment *ev)
    246 {
    247 /* WPObjectData* nomThis=WPObjectGetData(nomSelf); */
     267  return WPObject_wpOpen(nomSelf, nomFolder, ulV, nSpaceId, pParam, NULLHANDLE);
     268}
     269
     270NOM_Scope gpointer NOMLINK impl_WPObject_wpSwitchTo(WPObject* nomSelf, const gulong ulView, const nomId nameSpaceId,
     271                                                    CORBA_Environment *ev)
     272{
     273  /* WPObjectData* nomThis=WPObjectGetData(nomSelf); */
    248274  PVIEWITEM pViewItem;
    249275
    250   switch(ulView)
    251     {
    252     case OPEN_SETTINGS:
    253       {
    254         pViewItem=WPObject_wpFindViewItem(nomSelf, VIEW_SETTINGS, NULLHANDLE, ev);
    255         if(pViewItem){
    256           //g_message("   in %s : OPEN_SETTINGS returning %x %x ...", __FUNCTION__, pViewItem, pViewItem->nomWindow);
    257           /* Bring the window to the foreground */
    258           NOMWindow_present(pViewItem->nomWindow, ev);
    259           return (gpointer)pViewItem->nomWindow;
    260         }
    261         break;
    262       }
    263     case OPEN_CONTENTS:
    264       {
    265 #warning !!!!! This belongs into WPFolder !!!!!
    266         pViewItem=WPObject_wpFindViewItem(nomSelf, VIEW_CONTENTS, NULLHANDLE, ev);
    267         if(pViewItem){
    268           //g_message("   in %s : OPEN_SETTINGS returning %x %x ...", __FUNCTION__, pViewItem, pViewItem->nomWindow);
    269           /* Bring the window to the foreground */
    270           NOMWindow_present(pViewItem->nomWindow, ev);
    271           return (gpointer)pViewItem->nomWindow;
    272         }
    273         break;
    274       }
    275     default:
    276       break;
    277     }
     276  pViewItem=WPObject_wpFindViewItem(nomSelf, ulView, nameSpaceId, NULLHANDLE, NULLHANDLE);
     277
     278  if(pViewItem){
     279    /* Bring the window to the foreground */
     280    NOMWindow_present(pViewItem->nomWindow, ev);
     281    return (gpointer)pViewItem->nomWindow;
     282  }/* if() */
    278283
    279284  return NULLHANDLE;
     
    363368
    364369
    365 NOM_Scope PVIEWITEM NOMLINK impl_WPObject_wpFindViewItem(WPObject* nomSelf, const gulong flViews,
     370NOM_Scope PVIEWITEM NOMLINK impl_WPObject_wpFindViewItem(WPObject* nomSelf, const gulong ulView,
     371                                                         const nomId nameSpaceId,
    366372                                                         const PVIEWITEM pCurrentItem, CORBA_Environment *ev)
    367373{
     
    370376  PVIEWITEM pViewItem=NULLHANDLE;
    371377
    372   if(!flViews)
     378
     379  if(!ulView)
    373380    return NULLHANDLE;
    374381
     
    380387    pUseItem=WPObject_wpFindUseItem(nomSelf, USAGE_OPENVIEW,  pUseItem, ev);
    381388  }
     389
    382390  while(pUseItem)
    383391    {
     
    386394      pUseItem--;
    387395      //g_message("        a in %s %d", __FUNCTION__, flViews);
    388       if(pViewItem->ulView & flViews)
     396      if((pViewItem->ulView == ulView) && (pViewItem->nameSpaceId==nameSpaceId))
    389397        break;
    390398
     
    396404}
    397405
     406NOM_Scope gulong NOMLINK impl_WPObject_wpQueryDefaultView(WPObject* nomSelf, const pnomId pNameSpaceId,
     407                                                          CORBA_Environment *ev)
     408{
     409/* WPObjectData* nomThis=WPObjectGetData(nomSelf); */
     410
     411  *pNameSpaceId=WPObjectNomId;
     412
     413  return OPEN_SETTINGS;
     414}
     415
     416NOM_Scope CORBA_boolean NOMLINK impl_WPObject_wpSetDefaultView(WPObject* nomSelf, const gulong ulView,
     417                                                               const nomId nameSpaceId, CORBA_Environment *ev)
     418{
     419/* WPObjectData* nomThis=WPObjectGetData(nomSelf); */
     420  CORBA_boolean nomRetval=FALSE;
     421
     422  g_message("%d %s not implemented", __LINE__, __FUNCTION__);
     423  return nomRetval;
     424}
     425
     426NOM_Scope void NOMLINK impl_WPObject_wpSetConcurrentView(WPObject* nomSelf, const gulong ulCCView,
     427                                                         CORBA_Environment *ev)
     428{
     429/* WPObjectData* nomThis=WPObjectGetData(nomSelf); */
     430
     431  g_message("%d %s not implemented", __LINE__, __FUNCTION__);
     432
     433}
     434
     435NOM_Scope gulong NOMLINK impl_WPObject_wpQueryConcurrentView(WPObject* nomSelf, CORBA_Environment *ev)
     436{
     437  /* WPObjectData* nomThis=WPObjectGetData(nomSelf); */
     438
     439  return CCVIEW_ON;
     440}
    398441
    399442NOM_Scope void NOMLINK impl_WPObject_wpLockObject(WPObject* nomSelf, CORBA_Environment *ev)
     
    623666/* WPObjectData* nomThis=WPObjectGetData(nomSelf); */
    624667
    625   /* We only handle items with in own name space */
     668  /* We only handle items within own name space */
    626669  if(WPObjectNomId==NOMMenuItem_queryNameSpaceId(nomMenuItem, ev))
    627670    {
     
    631674          {
    632675            WPObject_wpViewObject(nomSelf, nomFolder,
    633                             OPEN_SETTINGS, NULLHANDLE, ev);
     676                            OPEN_SETTINGS, WPObjectNomId, NULLHANDLE, NULLHANDLE);
    634677            return TRUE; /* We always return TRUE to show, we handled the menu item. It doesn't
    635678                          matter if we actually succeeded with creating the settings notebook. */
     
    714757}
    715758
     759
     760
     761
Note: See TracChangeset for help on using the changeset viewer.