Ignore:
Timestamp:
Jan 3, 2007, 10:27:53 AM (19 years ago)
Author:
cinc
Message:

Added code for object menus.

File:
1 edited

Legend:

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

    r152 r166  
    6363
    6464#include "wpobject.ih"
    65 
    6665#include "nomfolderwindow.h"
     66
     67/*************** Local vars ************************************/
     68
     69static nomId WPObjectNomId;
     70
     71/***************************************************************/
    6772
    6873NOM_Scope gpointer NOMLINK impl_WPObject_wpAllocMem(WPObject* nomSelf, const CORBA_unsigned_long cbBytes,
     
    146151  WPObjectData* nomThis=WPObjectGetData(nomSelf);
    147152
     153  /* Get our unique class ID. We need it for example when inserting menu items to
     154     specify the namespace. We query it here because getting a GQuark from a string
     155     is rather time consuming. The result is saved in a var for later use. */
     156  WPObjectNomId=g_quark_from_string("WPObject");
     157
    148158  /* Make sure a title exists (even if it's an empty string */
    149159  _pnomStringTitle=NOMStringNew();
     
    264274
    265275  /* And finally show it */
    266   gtk_menu_popup(GTK_MENU(NOMMenu_getMenuHandle(nomMenu,ev)), NULL, NULL, NULL, NULL, 0,
     276  gtk_menu_popup(GTK_MENU(NOMMenu_queryMenuHandle(nomMenu,ev)), NULL, NULL, NULL, NULL, 0,
    267277                 gtk_get_current_event_time());
     278
    268279  return nomMenu;
    269280}
    270281
    271 NOM_Scope void NOMLINK impl_WPObject_wpModifyMenu(WPObject* nomSelf, const PNOMFolderWindow nomFolder, const PNOMMenu nomMenu, const CORBA_unsigned_long ulMenuType, CORBA_Environment *ev)
    272 {
    273 /* WPObjectData* nomThis=WPObjectGetData(nomSelf); */
    274 
    275 }
    276 
    277 NOM_Scope void NOMLINK impl_WPObject_wpFilterMenu(WPObject* nomSelf, const PNOMFolderWindow nomFolder, const PNOMMenu nomMenu, const CORBA_unsigned_long ulMenuType, const CORBA_unsigned_long ulFlags, CORBA_Environment *ev)
     282NOM_Scope void NOMLINK impl_WPObject_wpModifyMenu(WPObject* nomSelf, const PNOMFolderWindow nomFolder,
     283                                                  const PNOMMenu nomMenu, const CORBA_unsigned_long ulMenuType,
     284                                                  CORBA_Environment *ev)
     285{
     286  NOMMenuItem* mItem;
     287  /*  WPObjectData* nomThis=WPObjectGetData(nomSelf); */
     288
     289  mItem=NOMMenuItemNew();
     290
     291  NOMMenuItem_setup(mItem, __FUNCTION__, WPObjectNomId, 0, ev);
     292  WPObject_wpInsertMenuItem(nomSelf, nomMenu, mItem, 0, ev);
     293
     294  mItem=NOMMenuItemNew();
     295  NOMMenuItem_setup(mItem, "Settings...", WPObjectNomId, WPMENUID_PROPERTIES, ev);
     296  WPObject_wpInsertMenuItem(nomSelf, nomMenu, mItem, 0, ev);
     297}
     298
     299NOM_Scope void NOMLINK impl_WPObject_wpFilterMenu(WPObject* nomSelf, const PNOMFolderWindow nomFolder,
     300                                                  const PNOMMenu nomMenu, const CORBA_unsigned_long ulMenuType,
     301                                                  const CORBA_unsigned_long ulFlags, CORBA_Environment *ev)
    278302{
    279303/* WPObjectData* nomThis=WPObjectGetData(nomSelf); */
     
    282306
    283307NOM_Scope CORBA_boolean NOMLINK impl_WPObject_wpMenuItemSelected(WPObject* nomSelf, const PNOMFolderWindow nomFolder,
    284                                                                  const PNOMMenu nomMenu,
    285                                                                  const CORBA_unsigned_long ulMenuType,
     308                                                                 const PNOMMenuItem nomMenuItem,
    286309                                                                 CORBA_Environment *ev)
    287310{
    288311/* WPObjectData* nomThis=WPObjectGetData(nomSelf); */
    289   CORBA_boolean nomRetval;
    290 
     312  CORBA_boolean nomRetval=FALSE;
     313
     314  /* We only handle items with in own name space */
     315  if(WPObjectNomId==NOMMenuItem_queryNameSpaceId(nomMenuItem, ev))
     316    {
     317      switch(NOMMenuItem_queryId(nomMenuItem, ev))
     318        {
     319        default:
     320          break;
     321        }
     322    }
    291323  return nomRetval;
    292324}
    293325
     326/*
     327  Callback for desktop menu items. This callback takes the object pointer and call wpMenuItemSelected()
     328  of the object.
     329 */
     330static void menuItemActivateCallBack(GtkMenuItem* gtkMenuItem, gpointer wpObject)
     331{
     332  PNOMMenuItem pItem;
     333
     334#if 0
     335  if(!nomIsObj((WPObject*)wpObject))
     336    return;
     337#endif
     338
     339  pItem=(PNOMMenuItem) g_object_get_data(G_OBJECT(gtkMenuItem), NOMOBJECT_KEY_STRING);
     340
     341  WPObject_wpMenuItemSelected((WPObject*) wpObject, NULLHANDLE,
     342                              pItem, NULLHANDLE);
     343}
     344
     345/*
     346  This method adds the correct callback function to the menuitem and inserts it into the given menu.
     347
     348  FIXME: position information for the menu item isn't used yet. The Item is always appended.
     349 
     350 */
    294351NOM_Scope void NOMLINK impl_WPObject_wpInsertMenuItem(WPObject* nomSelf, const PNOMMenu nomMenu,
    295                                                       const CORBA_unsigned_long ulId, CORBA_Environment *ev)
    296 {
    297 /* WPObjectData* nomThis=WPObjectGetData(nomSelf); */
    298 
    299 }
     352                                                      const PNOMMenuItem nomMenuItem,
     353                                                      const CORBA_unsigned_long ulPosition, CORBA_Environment *ev)
     354{
     355/* WPObjectData* nomThis=WPObjectGetData(nomSelf); */
     356
     357  g_signal_connect(NOMMenuItem_queryMenuItemHandle(nomMenuItem, ev), "activate",
     358                   (GCallback) menuItemActivateCallBack, (gpointer) nomSelf);
     359
     360  gtk_menu_shell_append(GTK_MENU_SHELL(NOMMenu_queryMenuHandle(nomMenu,ev)),
     361                        NOMMenuItem_queryMenuItemHandle(nomMenuItem, ev));
     362
     363}
     364
     365
     366
     367
Note: See TracChangeset for help on using the changeset viewer.