Changeset 186


Ignore:
Timestamp:
Jan 13, 2007, 12:36:01 PM (19 years ago)
Author:
cinc
Message:

Folder viws are working now. Load of fixes and enhancements for it to work.

Location:
trunk
Files:
8 edited

Legend:

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

    r183 r186  
    6060
    6161  nomPrintf("thePath: ---> %s \n", fullPath);
    62   _pszFullPath=fullPath;
     62  _pszFullPath=g_strdup(fullPath);
    6363}
    6464
  • trunk/desktop/class_c/wpfolder.c

    r183 r186  
    4848#include "gtk/gtk.h"
    4949
    50 #warning !!!!! nomIsObj() must be globaly defined !!!!!
    51 #define nomIsObj(a) ((a)!= 0)
    52 
    5350typedef struct _PRIVFOLDERDATA
    5451{
     
    5653  GtkWidget    *gtkIconView;
    5754}PRIVFOLDERDATA, *PPRIVFOLDERDATA;
     55
     56typedef struct _FLDRGTREEKEY
     57{
     58  PGTree pGTree;
     59  gchar* chrKey;
     60}FLDRGTREEKEY, *PFLDRGTREEKEY;
    5861
    5962/* Gui stuff */
     
    6972#include "helper.h"
    7073
     74typedef struct _FLDRGTREEVALUE
     75{
     76  PGTree pGTree;
     77  WPObject* wpObject;
     78  const gchar* chrKey;
     79}FLDRGTREEVALUE, *PFLDRGTREEVALUE;
    7180
    7281
     
    92101                              GDK_TYPE_PIXBUF,
    93102                              G_TYPE_BOOLEAN);
    94   g_message("%s: store: %x", __FUNCTION__, store);
     103  g_message("%s: store: %x", __FUNCTION__, (UINT) store);
    95104  return store;
    96105}
    97106
     107#if 0
    98108static BOOL
    99109fldr_fillStore (GtkListStore *store, const gchar* gchrPath)
     
    132142
    133143              wpFolder=WPFolderNew();
    134               if(nomIsObj(wpFolder))
     144              if(nomIsObj((PNOMObject)wpFolder))
    135145                {
    136146                  gtk_list_store_append (store, &iter);
     
    153163              wpDataFile=WPDataFileNew();
    154164
    155               if(nomIsObj(wpDataFile))
     165              if(nomIsObj((PNOMObject)wpDataFile))
    156166                {
    157167                  gtk_list_store_append (store, &iter);
     
    177187  return TRUE;
    178188}
    179 
    180189/* pszPath contains the fully qualified path (checked with WPS) */
    181190NOM_Scope CORBA_boolean NOMLINK impl_WPFolder_wpPopulate(WPFolder* nomSelf, const CORBA_unsigned_long ulReserved,
     
    197206  /* Already populated? */
    198207  if(fFoldersOnly &&
    199      (_wpQueryFldrFlags(somSelf) & (FOI_POPULATEDWITHFOLDERS | FOI_POPULATEDWITHALL)))
     208     (_wpQueryFldrFlags(nomSelf) & (FOI_POPULATEDWITHFOLDERS | FOI_POPULATEDWITHALL)))
    200209    return TRUE;
    201   else if(_wpQueryFldrFlags(somSelf) & FOI_POPULATEDWITHALL)
     210  else if(_wpQueryFldrFlags(nomSelf) & FOI_POPULATEDWITHALL)
    202211    return TRUE;
    203212#endif
     
    233242  return FALSE;
    234243}
     244/* Insert an object into the folders object list */
     245void tst_insertObject(WPFolder* nomSelf, WPObject* wpObject, gchar* chrName)
     246{
     247  WPFolderData* nomThis=WPFolderGetData(nomSelf);
     248
     249  g_tree_insert(_fldrObjects, chrName, wpObject);
     250}
     251#endif
     252
     253static
     254gboolean fillStoreTraverseFunc(gpointer pKey, gpointer pTraverseValue, gpointer pData)
     255{
     256  GtkTreeIter iter;
     257  PFLDRGTREEVALUE pValue=pTraverseValue;
     258  gchar * display_name;
     259  GtkListStore *store=(GtkListStore *)pData;
     260
     261  g_message("In %s with %s %x", __FUNCTION__, (char*)pKey, (UINT)pValue->wpObject);
     262
     263#warning !!!!! Use Title here !!!!!
     264  display_name=pKey; 
     265
     266
     267  if(!strcmp("WPDataFile", pValue->wpObject->mtab->nomClassName)){
     268    WPDataFile* wpDataFile;
     269
     270    wpDataFile=(WPDataFile*)pValue->wpObject;
     271
     272    if(nomIsObj((PNOMObject)wpDataFile))
     273      {
     274        gtk_list_store_append (store, &iter);
     275       
     276#warning !!!! some problems with icon handling here !!!!
     277        //nomPrintf("Icon ptr: %x\n", _wpQueryIcon((WPObject*)wpDataFile, NULLHANDLE));
     278        gtk_list_store_set (store, &iter,
     279                            COL_OBJECT_PTR, wpDataFile,
     280                            COL_PATH, "",
     281                            COL_DISPLAY_NAME, display_name,
     282                            COL_IS_DIRECTORY, FALSE,
     283                            COL_PIXBUF, _wpQueryIcon((WPObject*)wpDataFile, NULLHANDLE), //file_pixbuf,
     284                            -1);
     285      }
     286  }
     287  else{
     288    WPFolder* wpFolder;
     289
     290    wpFolder=(WPFolder*)pValue->wpObject;
     291
     292    if(nomIsObj((NOMObject*)wpFolder)){
     293
     294      g_message("%d %s : %s, %s",
     295                __LINE__, __FUNCTION__, (char*)pKey,
     296                NOMPath_queryCString(WPFolder_wpQueryFileName(wpFolder, TRUE, NULLHANDLE), NULLHANDLE));
     297
     298
     299      gtk_list_store_append (store, &iter);
     300     
     301      gtk_list_store_set (store, &iter,
     302                          COL_OBJECT_PTR, wpFolder,
     303                          COL_PATH, "",
     304                          COL_DISPLAY_NAME, display_name,
     305                          COL_IS_DIRECTORY, TRUE,
     306                          COL_PIXBUF, _wpQueryIcon((WPObject*)wpFolder, NULLHANDLE), //folder_pixbuf ,
     307                          -1);
     308    }
     309  }
     310
     311  return FALSE; /* Traverse every item */
     312}
     313
     314static gboolean
     315fldr_fillStore (WPFolder* nomSelf, GtkListStore *store, const gchar* gchrPath)
     316{
     317  WPFolderData* nomThis=WPFolderGetData(nomSelf);
     318
     319  nomPrintf("In %s:  %s\n", __FUNCTION__, gchrPath);         
     320
     321  /* First clear the store */
     322  gtk_list_store_clear (store);
     323
     324  g_tree_foreach(_fldrObjects, (GTraverseFunc) fillStoreTraverseFunc, store);
     325
     326  return TRUE;
     327}
     328
     329
     330NOM_Scope gulong NOMLINK impl_WPFolder_wpAddToContent(WPFolder* nomSelf, const PWPObject wpObject,
     331                                                      const CORBA_char * chrFileName, CORBA_Environment *ev)
     332{
     333  WPFolderData* nomThis=WPFolderGetData(nomSelf);
     334  PFLDRGTREEVALUE pValue;
     335
     336  pValue=(PFLDRGTREEVALUE)NOMMalloc(sizeof(FLDRGTREEVALUE));
     337  pValue->pGTree=_fldrObjects;
     338  pValue->wpObject=wpObject;
     339  pValue->chrKey=chrFileName;
     340  g_tree_insert(_fldrObjects, chrFileName, pValue);
     341
     342#if 0
     343  PFLDRGTREEKEY pKey;
     344  pKey=(PFLDRGTREEKEY)NOMMalloc(sizeof(FLDRGTREEKEY));
     345  pKey->pGTree=_fldrObjects;
     346  pKey->chrKey=chrFileName;
     347  g_tree_insert(_fldrObjects, pKey, wpObject);
     348#endif
     349
     350  return 0;
     351}
     352
     353NOM_Scope PWPObject NOMLINK impl_WPFolder_wpQueryContent(WPFolder* nomSelf, CORBA_Environment *ev)
     354{
     355/* WPFolderData* nomThis=WPFolderGetData(nomSelf); */
     356  PWPObject nomRetval;
     357
     358  return nomRetval;
     359}
     360
     361
     362/* pszPath contains the fully qualified path (checked with WPS) */
     363NOM_Scope CORBA_boolean NOMLINK impl_WPFolder_wpPopulate(WPFolder* nomSelf, const CORBA_unsigned_long ulReserved,
     364                                                         const CORBA_char * pszPath, const CORBA_boolean fFoldersOnly,
     365                                                         CORBA_Environment *ev)
     366{
     367  /*  WPFolderData* nomThis=WPFolderGetData(nomSelf); */
     368  GDir *gDir;
     369  const gchar *gchrCurrentEntry;
     370  const gchar* gchrPath;
     371  PNOMPath fldrPath;
     372
     373  g_log("WPFolder", G_LOG_LEVEL_DEBUG, "%s: Populating %s (0x%x)\n", __FUNCTION__, pszPath, (UINT)nomSelf);
     374
     375  /* Already populated? */
     376  if(fFoldersOnly &&
     377     (_wpQueryFldrFlags(nomSelf, NULLHANDLE) & (FOI_POPULATEDWITHFOLDERS | FOI_POPULATEDWITHALL)))
     378    return TRUE;
     379  else if(_wpQueryFldrFlags(nomSelf, NULLHANDLE) & FOI_POPULATEDWITHALL)
     380    return TRUE;
     381
     382  /* Go through the directory and extract all the file
     383   * information */
     384  fldrPath=WPFolder_wpQueryFileName(nomSelf, TRUE, NULLHANDLE);
     385  gchrPath=NOMPath_queryCString(fldrPath, NULLHANDLE);
     386  gDir = g_dir_open(gchrPath, 0, NULL);
     387  if (!gDir)
     388    return FALSE;
     389
     390  while ((gchrCurrentEntry = g_dir_read_name (gDir))!= NULL)
     391    {
     392      gchar *path, *display_name;
     393
     394      if (gchrCurrentEntry[0] != '\0')
     395        {
     396          WPObject* wpObject;
     397
     398          path = g_build_filename (gchrPath, gchrCurrentEntry, NULL);
     399
     400          display_name = g_filename_to_utf8 (gchrCurrentEntry, -1, NULL, NULL, NULL);
     401
     402          if(g_file_test (path, G_FILE_TEST_IS_DIR))
     403            wpObject=(WPObject*)WPFolderNew(); /* It's a folder */
     404          else{
     405            if(!fFoldersOnly)
     406              wpObject=(WPObject*)WPDataFileNew(); /* It's a file */
     407            else
     408              wpObject=NULLHANDLE;
     409          }
     410          if(nomIsObj((PNOMObject)wpObject))
     411            {
     412              WPObject_wpSetTitleFromCString(wpObject, display_name, NULLHANDLE);
     413              WPFileSystem_tstSetFullPath((WPFileSystem*)wpObject, gchrCurrentEntry, NULLHANDLE);
     414              WPFileSystem_wpSetFolder(wpObject, nomSelf, NULLHANDLE);
     415              g_message("%d %s : %s (%x) , %s",
     416                        __LINE__, __FUNCTION__, gchrCurrentEntry, (UINT)wpObject,
     417                        NOMPath_queryCString(WPFolder_wpQueryFileName(wpObject, TRUE, NULLHANDLE), NULLHANDLE));
     418
     419              /* insert into contents list */
     420              WPFolder_wpAddToContent(nomSelf, wpObject, g_strdup(gchrCurrentEntry), NULLHANDLE);
     421            }/* if(nomIsObj(wpObject)) */
     422          g_free (path);
     423          g_free (display_name);
     424        }/* if (gchrCurrentEntry[0] != '\0') */
     425    }/* while */
     426  g_dir_close(gDir);
     427
     428  if(fFoldersOnly)
     429    _wpSetFldrFlags(nomSelf, FOI_POPULATEDWITHFOLDERS, FOI_POPULATEDWITHFOLDERS, NULLHANDLE);
     430  else
     431    _wpSetFldrFlags(nomSelf, FOI_POPULATEDWITHFOLDERS| FOI_POPULATEDWITHALL,
     432                    FOI_POPULATEDWITHFOLDERS| FOI_POPULATEDWITHALL, NULLHANDLE);
     433
     434  return TRUE;
     435}
     436
     437
     438/*
     439  This will change when NOMFolderWindow is migrated to WPFolderWindow.
     440 */
     441static
     442gboolean tempWPWindowDeleteHandler(GtkWidget* gtkWidget, GdkEvent* gdkEvent, gpointer pData)
     443{
     444  WPObject* wpObject;
     445  NOMFolderWindow* wpWindow;
     446
     447  PUSEITEM pUseItem=(PUSEITEM) pData;
     448
     449  /* This is also in the use item */
     450  wpWindow=(NOMFolderWindow*)g_object_get_data(G_OBJECT(gtkWidget), NOMOBJECT_KEY_STRING);
     451
     452  g_return_val_if_fail(NULLHANDLE!=wpWindow, FALSE);
     453
     454  /* This call will be different when using WPFolderWindow */
     455  //wpObject=NOMFolderWindow_wpQueryWPFolderObject(wpWindow, NULLHANDLE);
     456  wpObject=pUseItem->wpObject;
     457  g_return_val_if_fail(NULLHANDLE!=wpObject, FALSE);
     458
     459  WPObject_wpSaveDeferred(wpObject, NULLHANDLE);
     460
     461  WPObject_wpDeleteFromObjUseList(wpObject, pUseItem, NULLHANDLE);
     462
     463  return FALSE; /* Let other handlers run */
     464}
     465
    235466
    236467NOM_Scope gpointer NOMLINK impl_WPFolder_wpOpen(WPFolder* nomSelf, const PNOMFolderWindow nomFolder,
     
    238469                                                CORBA_Environment *ev)
    239470{
    240 /* WPFolderData* nomThis=WPFolderGetData(nomSelf); */
    241 
     471  WPFolderData* nomThis=WPFolderGetData(nomSelf);
     472  g_message("%d %s", __LINE__, __FUNCTION__);
    242473  switch(ulView)
    243474    {
     
    245476    case OPEN_DEFAULT:
    246477      {
    247         static NOMFolderWindow * nomFldrWindow;
    248 
     478        PUSEITEM pui;
     479        ULONG ulError;
     480        NOMFolderWindow * nomFldrWindow;
     481        gchar* pszPath;
     482        PPRIVFOLDERDATA priv;
     483        GtkListStore* gStore;
     484 
     485        pszPath=NOMPath_queryCString(WPFolder_wpQueryFileName(nomSelf, TRUE, NULLHANDLE), NULLHANDLE);
     486        g_message("%d %s, %s", __LINE__, __FUNCTION__, pszPath);
     487        WPFolder_wpPopulate(nomSelf, 0L, pszPath, FALSE,  NULLHANDLE);
     488
     489
     490        nomFldrWindow=WPFolder_wpCreateFolderWindow(nomSelf, ev);
     491#warning !!!!! There is WPWindow now. Use that for any WPS windows, Then this call must be changed
     492        NOMFolderWindow_setWPFolderObject(nomFldrWindow, nomSelf, NULLHANDLE);
     493
     494        /* Insert it into inuse list */
     495        pui=(PUSEITEM)WPFolder_wpAllocMem(nomSelf, sizeof(USEITEM)+sizeof(VIEWITEM), &ulError, ev);
     496        /* Fill the structures */
     497        pui->type=(gulong)USAGE_OPENVIEW;
     498        pui->wpObject=(PWPObject)nomSelf;
     499        pui++;
     500        ((VIEWITEM*)pui)->ulView=VIEW_CONTENTS;
     501        ((VIEWITEM*)pui)->nomWindow=(NOMWindow*)nomFldrWindow;
     502        pui--;
    249503#warning !!!!! Folder window must be inserted into inuse list !!!!!
    250         nomFldrWindow=WPFolder_wpCreateFolderWindow(nomSelf, ev);
    251         NOMFolderWindow_setWPFolderObject(nomFldrWindow, nomSelf, ev);
    252 
    253 #warning !!!!! Path taken from a test location !!!!!
    254         WPFolder_wpPopulate(nomSelf, 0L, NOMPath_queryCString(WPFolder_wpQueryFileName(nomSelf, TRUE, ev) , ev), FALSE,  ev);
    255         break;
    256 
    257 #if 0
    258         char path[CCHMAXPATH];
    259         ULONG ulSize;
     504        /* Make sure the view item is removed when the window is closed */
     505        g_signal_connect(G_OBJECT(NOMWindow_queryWindowHandle((NOMWindow*)nomFldrWindow, NULLHANDLE)),"delete-event",
     506                         G_CALLBACK(tempWPWindowDeleteHandler), (gpointer) pui);
     507        WPFolder_wpAddToObjUseList(nomSelf, pui, NULLHANDLE);
     508
     509        /* Now create a folder store and insert icons into the window */
     510        priv=_privFolderData;
     511        gStore=priv->gstoreFldContents;
     512
     513        if(!gStore)
     514          {
     515            /* Create a store holding the folder contents */
     516            gStore=fldr_CreateStore();
     517            g_return_val_if_fail(gStore!=NULLHANDLE, FALSE);
     518            priv->gstoreFldContents=gStore;
     519          }
     520
     521        /* Fill our store */
     522        if(gStore)
     523          fldr_fillStore(nomSelf, gStore, pszPath);
     524        else
     525          return FALSE;
    260526       
    261         /* Get full path of folder */
    262         ulSize=sizeof(path);
     527        gtk_icon_view_set_model(GTK_ICON_VIEW (priv->gtkIconView), GTK_TREE_MODEL (priv->gstoreFldContents));
    263528       
    264         if(!_wpQueryRealName(somSelf, path, &ulSize, TRUE))
    265           return NULLHANDLE; /* Error */
     529        /* We now set which model columns that correspond to the text
     530         * and pixbuf of each item
     531         */
     532        gtk_icon_view_set_text_column (GTK_ICON_VIEW (priv->gtkIconView), COL_DISPLAY_NAME);
     533        gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW (priv->gtkIconView), COL_PIXBUF);
     534        gtk_icon_view_set_item_width (GTK_ICON_VIEW (priv->gtkIconView), 100);
    266535       
    267         nomPrintf("%s: opening %s\n", __FUNCTION__, path);
     536        g_object_unref (gStore);
    268537       
    269         /* Create folder window */
    270         hwndFolder=fldr_createFolderWindow(somSelf, path);
    271        
    272         if(!hwndFolder)
    273           return NULLHANDLE;
    274 
    275         /* populate the folder */
    276         _wpPopulate(somSelf, 0, path, FALSE); /* Contents or details. Tree isn't supported yet */
    277 
    278         break;
    279 #endif
     538        return nomFldrWindow;
    280539      }/* default */
    281540    default:
     
    308567}
    309568
     569static void
     570itemActivated (GtkIconView *widget,
     571                GtkTreePath *treePath,
     572                gpointer     user_data)
     573{
     574  PNOMFolderWindow pWindow;
     575
     576  pWindow=(NOMFolderWindow*)user_data;
     577
     578  if(NULL!=treePath)
     579    {
     580      GtkTreeIter iter;
     581      GtkTreeModel* model;
     582      WPObject *wpObject;
     583
     584      /* Click on an icon */           
     585      model=gtk_icon_view_get_model(GTK_ICON_VIEW(widget));
     586      gtk_tree_model_get_iter(model , &iter, treePath);
     587     
     588      gtk_tree_model_get(model, &iter,
     589                         0, &wpObject,
     590                         -1);
     591      g_message("%s: %s", __FUNCTION__, wpObject->mtab->nomClassName);
     592      WPObject_wpOpen(wpObject, pWindow, OPEN_CONTENTS, NULL, NULL);
     593    }
     594}
     595
    310596/*
    311597  This method creates the folder window it doesn't query any files or creates
     
    325611  priv->gtkIconView=NOMFolderWindow_queryContainerHandle(nomFldrWindow, ev);
    326612
     613  /* Connect to the "item_activated" signal */
     614  g_signal_connect (priv->gtkIconView, "item-activated",
     615                    G_CALLBACK (itemActivated), nomSelf);
     616
     617  gtk_window_set_title (GTK_WINDOW (NOMFolderWindow_queryWindowHandle(nomFldrWindow, NULLHANDLE)),
     618                        NOMString_queryCString(WPFolder_wpQueryTitle(nomSelf, NULLHANDLE), NULLHANDLE));
    327619  /* Show the new window */
    328620  NOMFolderWindow_show(nomFldrWindow, ev);
     
    331623}
    332624
     625NOM_Scope gulong NOMLINK impl_WPFolder_wpQueryFldrFlags(WPFolder* nomSelf, CORBA_Environment *ev)
     626{
     627  WPFolderData* nomThis=WPFolderGetData(nomSelf);
     628
     629  return g_atomic_int_get(&_ulFldrFlags);
     630}
     631
     632NOM_Scope CORBA_boolean NOMLINK impl_WPFolder_wpSetFldrFlags(WPFolder* nomSelf, const gulong ulFlags,
     633                                                             const gulong ulMask, CORBA_Environment *ev)
     634{
     635  WPFolderData* nomThis=WPFolderGetData(nomSelf);
     636
     637  WPFolder_wpRequestObjectMutexSem(nomSelf, 0,ev);
     638
     639  _ulFldrFlags=(_ulFldrFlags & ~ulMask)| ulFlags;
     640
     641  WPFolder_wpReleaseObjectMutexSem(nomSelf,ev);
     642
     643  return TRUE;
     644}
     645
     646#if 0
     647static gint fldrCompareObjects(gconstpointer a, gconstpointer b, gpointer pUserData)
     648{
     649  return strcmp(((PFLDRGTREEKEY)a)->chrKey, ((PFLDRGTREEKEY)b)->chrKey);
     650}
     651#endif
     652
     653static void fldrCatchDuplicates(gpointer pOrgValue)
     654{
     655  PFLDRGTREEVALUE pValue;
     656  PFLDRGTREEVALUE pValueRemove;
     657
     658  pValue=(PFLDRGTREEVALUE)pOrgValue;
     659
     660  g_message("%d %s: value (object): %x %s", __LINE__, __FUNCTION__, (UINT)pValue->wpObject, pValue->chrKey);
     661
     662#warning !!!!! Duplicate handling is still kind of broken !!!!!
     663  /*
     664    When we end here another object with the same key was inserted. This may be due to populating
     665    all when we first just populated with folders. ATM we just remove the accidently inserted
     666    second data and reinsert the original data (which may be already used by now). The wrong data
     667    must be freed here later.
     668    We should check the lock counter if we really dealing with wrong insertion here before freeing.
     669    This way we might use this func also for freeing when normally removing objects. 
     670   */
     671  /* Remove the wrong data */
     672  pValueRemove=(PFLDRGTREEVALUE)g_tree_lookup(pValue->pGTree, pValue->chrKey);
     673  g_tree_steal(pValue->pGTree, pValue->chrKey); /* This does not free the stuff in this func */
     674  /* Reinsert the old one */
     675  g_tree_insert(pValue->pGTree, pValue->chrKey, pValue);
     676}
     677
    333678NOM_Scope void NOMLINK impl_WPFolder_wpInitData(WPFolder* nomSelf, CORBA_Environment *ev)
    334679{
     
    340685  nomPrintf("    Entering %s with nomSelf: 0x%x. nomSelf is: %s.\n",
    341686            __FUNCTION__, nomSelf , nomSelf->mtab->nomClassName);
    342   _privFolderData=_wpAllocMem((WPObject*)nomSelf, sizeof(PRIVFOLDERDATA), (CORBA_unsigned_long*)&ulErr, NULLHANDLE);
    343 }
    344 
    345 
    346 
     687  _privFolderData=_wpAllocMem((WPObject*)nomSelf, sizeof(PRIVFOLDERDATA),&ulErr, NULLHANDLE);
     688
     689  /* This balanced binary tree holds the objects in this folder. We create a tree
     690     which may be searched using the name of the file/directory */
     691  //_fldrObjects=g_tree_new((GCompareFunc)strcmp);
     692  _fldrObjects=g_tree_new_full((GCompareFunc)strcmp, nomSelf, NULL, (GDestroyNotify) fldrCatchDuplicates);
     693}
     694
     695
     696
  • trunk/desktop/class_c/wpobject.c

    r183 r186  
    185185{
    186186  WPObject* wpObject;
    187   WPNoteBook* wpNoteBook;
     187  WPWindow* wpWindow;
     188
    188189  PUSEITEM pUseItem=(PUSEITEM) pData;
    189190
    190   wpNoteBook=(WPNoteBook*)g_object_get_data(G_OBJECT(gtkWidget), NOMOBJECT_KEY_STRING);
    191 
    192   g_return_val_if_fail(NULLHANDLE!=wpNoteBook, FALSE);
    193 
    194   wpObject=WPNoteBook_wpQueryWPObject(wpNoteBook, NULLHANDLE);
     191  wpWindow=(WPWindow*)g_object_get_data(G_OBJECT(gtkWidget), NOMOBJECT_KEY_STRING);
     192
     193  g_return_val_if_fail(NULLHANDLE!=wpWindow, FALSE);
     194
     195  /* This is also in the use item */
     196  wpObject=WPNoteBook_wpQueryWPObject(wpWindow, NULLHANDLE);
    195197
    196198  g_return_val_if_fail(NULLHANDLE!=wpObject, FALSE);
     
    232234        pui--;
    233235        //g_message("   in %s wpNoteBook: %lx pui %lx", __FUNCTION__, wpNoteBook, pui);
     236        /* Make sure the view item is removed when the window is closed */
    234237        g_signal_connect(G_OBJECT(NOMWindow_queryWindowHandle((NOMWindow*)wpNoteBook, NULLHANDLE)),"delete-event",
    235238                         G_CALLBACK(defaultWPWindowDeleteHandler), (gpointer) pui);
     
    268271      {
    269272        pViewItem=WPObject_wpFindViewItem(nomSelf, VIEW_SETTINGS, NULLHANDLE, ev);
     273        if(pViewItem){
     274          //g_message("   in %s : OPEN_SETTINGS returning %x %x ...", __FUNCTION__, pViewItem, pViewItem->nomWindow);
     275          /* Bring the window to the foreground */
     276          NOMWindow_present(pViewItem->nomWindow, ev);
     277          return (gpointer)pViewItem->nomWindow;
     278        }
     279        break;
     280      }
     281    case OPEN_CONTENTS:
     282      {
     283#warning !!!!! This belongs into WPFolder !!!!!
     284        pViewItem=WPObject_wpFindViewItem(nomSelf, VIEW_CONTENTS, NULLHANDLE, ev);
    270285        if(pViewItem){
    271286          //g_message("   in %s : OPEN_SETTINGS returning %x %x ...", __FUNCTION__, pViewItem, pViewItem->nomWindow);
     
    449464}
    450465
    451 NOM_Scope PNOMString NOMLINK impl_WPObject_wpSetTitle(WPObject* nomSelf, const PNOMString pnomStrNewTitle, CORBA_Environment *ev)
    452 {
    453   WPObjectData* nomThis=WPObjectGetData(nomSelf);
    454   PNOMString tmpString=NOMStringNew();
     466NOM_Scope void NOMLINK impl_WPObject_wpSetTitle(WPObject* nomSelf, const PNOMString pnomStrNewTitle,
     467                                                      CORBA_Environment *ev)
     468{
     469  WPObjectData* nomThis=WPObjectGetData(nomSelf);
     470  PNOMString tmpString=(PNOMString)NOMString_new(pnomStrNewTitle, NULLHANDLE);
    455471  gpointer tmpPtr;
    456472
    457473  /* Create a new title */
    458   NOMString_assign(tmpString, pnomStrNewTitle, ev);
     474  NOMString_assign(tmpString, pnomStrNewTitle, NULLHANDLE);
    459475
    460476  /* It may happen that someone changed the title from another thread. We may either
     
    468484    tmpPtr=g_atomic_pointer_get(&_pnomStringTitle);
    469485  }while(!g_atomic_pointer_compare_and_exchange((gpointer*)&_pnomStringTitle, tmpPtr, (gpointer) tmpString));
    470 
    471   return pnomStrNewTitle;
     486}
     487
     488NOM_Scope void NOMLINK impl_WPObject_wpSetTitleFromCString(WPObject* nomSelf, const CORBA_char * chrNewTitle,
     489                                                           CORBA_Environment *ev)
     490{
     491  WPObjectData* nomThis=WPObjectGetData(nomSelf);
     492  PNOMString orgTitle;
     493  PNOMString tmpString;
     494
     495  orgTitle=(PNOMString)g_atomic_pointer_get(&_pnomStringTitle);
     496  tmpString=(PNOMString)NOMString_new(orgTitle, NULLHANDLE);
     497
     498  NOMString_assignCString(tmpString, chrNewTitle, NULLHANDLE);
     499  do{
     500    /* Get old NOMString containing old title */
     501    orgTitle=(PNOMString)g_atomic_pointer_get(&_pnomStringTitle);
     502  }while(!g_atomic_pointer_compare_and_exchange((gpointer*)&_pnomStringTitle,
     503                                                (gpointer)orgTitle, (gpointer) tmpString));
    472504}
    473505
  • trunk/desktop/idl/wpfolder.idl

    r183 r186  
    6767#endif
    6868
     69  gulong wpQueryFldrFlags();
     70  boolean wpSetFldrFlags(in gulong ulFlags, in gulong ulMask);
     71
     72  gulong wpAddToContent(in PWPObject wpObject, in string chrFileName);
     73  PWPObject wpQueryContent();
     74
    6975  NOMOVERRIDE(wpInitData);
    7076  NOMOVERRIDE(wpOpen);
    7177  NOMOVERRIDE(wpQueryIcon);
    7278
    73   NOMINSTANCEVAR(PPRIVFOLDERDATA privFolderData);
    74   NOMINSTANCEVAR(PNOMPath pnomPath_);
     79  NOMINSTANCEVAR(PPRIVFOLDERDATA privFolderData); /* This will go away... */
     80  NOMINSTANCEVAR(PGTree fldrObjects);
     81  NOMINSTANCEVAR(gulong ulFldrFlags);
    7582};
    7683
  • trunk/desktop/idl/wpobject.idl

    r183 r186  
    8484  unsigned long  wpReleaseObjectMutexSem();
    8585
    86   PNOMString wpSetTitle(in PNOMString pnomStrNewTitle);
     86  void wpSetTitle(in PNOMString pnomStrNewTitle);
    8787  PNOMString wpQueryTitle();
    8888
     
    116116  PWPFolder wpQueryFolder();
    117117
     118  void wpSetTitleFromCString(in string chrNewTitle);
     119
    118120  /* Methods overriden by this class */
    119121  NOMOVERRIDE(nomInit);
  • trunk/desktop/include/desktoptypes.h

    r176 r186  
    6969#define WPMENUID_PROPERTIES        112
    7070
     71/* Folder flags */
     72#define FOI_POPULATEDWITHALL       0x0001
     73#define FOI_POPULATEDWITHFOLDERS   0x0002
     74
    7175/* Misc types used with objects */
    7276typedef GSList *PGSList;
  • trunk/desktop/src/vdesktop.c

    r183 r186  
    9696  PNOMPath nomPath; 
    9797  PNOMPath np;
     98  gchar *chrDisplayName;
    9899
    99100  hReg=nomBeginRegisterDLLWithGC();
     
    145146  //dbgPrintf( "NOMClassMgrObject: %x", NOMClassMgrObject);
    146147
     148  /* Desktop directory oath */
    147149  nomPath=NOMPathNew();
    148150  NOMPath_assignCString(nomPath, desktopDir, NULLHANDLE);
     
    151153
    152154  /* Create root folder */
     155  np=NOMPath_queryPathBegin(nomPath, NULLHANDLE);
    153156  wpRootFolder=WPFolderNew();
    154   WPFolder_tstSetFullPath(wpRootFolder, NOMPath_queryCString(NOMPath_queryRoot(nomPath, NULLHANDLE),NULLHANDLE),
     157  WPFolder_tstSetFullPath(wpRootFolder, NOMPath_queryCString(NOMPath_queryRoot(np, NULLHANDLE),NULLHANDLE),
    155158                          NULLHANDLE);
     159  chrDisplayName = g_filename_to_utf8 (NOMPath_queryCString(np,NULLHANDLE), -1, NULL, NULL, NULL);
     160  WPFolder_wpSetTitleFromCString((WPObject*)wpRootFolder, chrDisplayName, NULLHANDLE);
     161
    156162  wpTempFolder=wpRootFolder;
    157 
    158163  nomPath=NOMPath_erasePathBegin(nomPath, NULLHANDLE);
    159164
     
    161166  while(NOMPath_length(nomPath, NULLHANDLE)>0)
    162167    {
    163       NOMPath* np;
    164168      WPFolder* wpFolder;
     169
    165170      np=NOMPath_queryPathBegin(nomPath, NULLHANDLE);
    166171
     
    168173      WPFolder_tstSetFullPath(wpFolder, NOMPath_queryCString(np,NULLHANDLE),
    169174                              NULLHANDLE);
     175      chrDisplayName = g_filename_to_utf8 (NOMPath_queryCString(np,NULLHANDLE), -1, NULL, NULL, NULL);
     176      WPFolder_wpSetTitleFromCString((WPObject*)wpFolder, chrDisplayName, NULLHANDLE);
    170177      WPFolder_wpSetFolder(wpFolder, wpTempFolder, NULLHANDLE);
     178      /* insert into contents list */
     179      WPFolder_wpAddToContent(wpTempFolder, (WPObject*) wpFolder,
     180                              NOMPath_copyCString(wpFolder, NULLHANDLE), NULLHANDLE);
     181     
    171182      wpTempFolder=wpFolder;
     183      /* Move to next path part */
    172184      nomPath=NOMPath_erasePathBegin(nomPath, NULLHANDLE);
    173       WPFolder_wpQueryFileName(wpFolder, TRUE, NULLHANDLE);
     185      //WPFolder_wpQueryFileName(wpFolder, TRUE, NULLHANDLE);
    174186      //g_message("   path: %s", NOMPath_queryCString(WPFolder_wpQueryFileName(wpFolder, TRUE, NULLHANDLE),
    175187      //                                            NULLHANDLE));
     
    184196  //WPFolder_tstSetFullPath(wpDesktop, desktopDir, NULLHANDLE);
    185197  //WPFolder_tstSetFullPath(wpDesktop, "r:", NULLHANDLE);
    186   WPFolder_wpOpen(wpDesktop, NULL, OPEN_DEFAULT,  NULL, NULL);
    187   /*    WPFolder_wpPopulate(wpObject, 0,"blabla 2", 0,  NULL);  */
    188    
    189 #if 0
    190   /* Folder toplevel window. */
    191   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
    192 
    193   /* FIXME: Set default size of folder frame. Will later use a stored value */
    194   gtk_window_set_default_size (GTK_WINDOW (window), 650, 400);
    195 
    196   g_signal_connect (GTK_WIDGET(window), "size-request",
    197                     G_CALLBACK (handleEvent), NULL/*nomSelf*/);
    198 
    199   gtk_widget_show(window);
    200   g_message("Window handle: %x", window);
    201 #endif
     198  WPFolder_wpOpen(wpDesktop, NULL, OPEN_CONTENTS,  NULL, NULL);
    202199
    203200  /* All GTK applications must have a gtk_main(). Control ends here
  • trunk/gui/class_c/nomfolderwindow.c

    r163 r186  
    4444#include <gtk/gtk.h>
    4545#include "nomguitk.h"
     46#include "nomwindow.h"
     47#include "desktoptypes.h"
     48
    4649#include "nomfolderwindow.ih"
    47 
    48 #warning !!!!! nomIsObj() must be globaly defined !!!!!
    49 #define nomIsObj(a) ((a)!= 0)
    50 
    5150
    5251NOM_Scope PGtkWidget NOMLINK impl_NOMFolderWindow_queryContainerHandle(NOMFolderWindow* nomSelf, CORBA_Environment *ev)
     
    7069  NOMFolderWindowData* nomThis=NOMFolderWindowGetData(nomSelf);
    7170
    72   if(!nomIsObj(pWPFolderObject))
     71  if(!nomIsObj((NOMObject*)pWPFolderObject))
    7372    return;
    7473
     
    8382}
    8483
     84#if 0
    8585static void
    8686itemActivated (GtkIconView *icon_view,
     
    9090  DosBeep(1500, 100);
    9191}
     92#endif
    9293
    9394/*
     
    164165}
    165166
    166 
     167#if 0
    167168static gboolean
    168169handleEvent (GtkWidget *widget, GdkEventButton *event, gpointer user_data)
    169170{
    170   DosBeep(5000, 100);
     171  DosBeep(500, 100);
    171172 
    172173  return FALSE;
    173174}
    174175
    175 extern gpointer *pGlobalMemInExe;
     176static void
     177itemActivated (GtkIconView *widget,
     178                GtkTreePath *treePath,
     179                gpointer     user_data)
     180{
     181  PNOMFolderWindow pWindow;
     182  //  GtkTreePath* treePath;
     183
     184  pWindow=(NOMFolderWindow*)user_data;
     185
     186  g_message("%s: %x %s", __FUNCTION__, treePath , gtk_tree_path_to_string(treePath));
     187
     188  return;
     189}
     190#endif
     191
    176192
    177193NOM_Scope void NOMLINK impl_NOMFolderWindow_nomInit(NOMFolderWindow* nomSelf, CORBA_Environment *ev)
     
    249265  gtk_icon_view_set_selection_mode (GTK_ICON_VIEW (icon_view),
    250266                                    GTK_SELECTION_MULTIPLE);
     267#if 0
    251268  /* Connect to the "item_activated" signal */
    252269  g_signal_connect (icon_view, "item-activated",
    253270                    G_CALLBACK (itemActivated), nomSelf);
     271#endif
    254272  //#endif
    255273
     
    276294  gtk_widget_grab_focus (icon_view);
    277295
    278   g_signal_connect (GTK_WIDGET(window), "size-request",
    279                     G_CALLBACK (handleEvent), nomSelf);
     296  //  g_signal_connect (GTK_WIDGET(window), "size-request",
     297  //                G_CALLBACK (handleEvent), nomSelf);
    280298
    281299  NOMFolderWindow_setWindowHandle(nomSelf, window, NULLHANDLE);
Note: See TracChangeset for help on using the changeset viewer.