Changeset 244
- Timestamp:
- Mar 10, 2007, 12:11:43 PM (18 years ago)
- Location:
- trunk/desktop
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/desktop/class_c/wpfilesystem.c
r243 r244 105 105 { 106 106 /* WPFileSystemData* nomThis=WPFileSystemGetData(nomSelf); */ 107 107 g_message(" %s", __FUNCTION__); 108 108 return WPFileSystem_wpMoveObject_parent(nomSelf, wpTargetFolder, ev); 109 109 return FALSE; -
trunk/desktop/class_c/wpfolder.c
r241 r244 77 77 #include "nomdraginfo.h" 78 78 79 /* 80 This struct is associated with the key in the contents tree of the 81 folder. 82 */ 79 83 typedef struct _FLDRGTREEVALUE 80 84 { 81 85 PGTree pGTree; 82 86 WPObject* wpObject; 83 gchar* chrKey; 87 gchar* chrKey; /* <-- is this really needed? */ 84 88 }FLDRGTREEVALUE, *PFLDRGTREEVALUE; 85 89 … … 95 99 }; 96 100 101 /*************** Local vars ************************************/ 102 103 /* This ID is used as a namespace */ 104 static nomId WPFolderNomId; 105 106 /***************************************************************/ 107 108 109 /* 110 Private function to create the store with the data for displaying 111 objects in the icon view. 112 */ 97 113 static GtkListStore * fldr_CreateStore (void) 98 114 { … … 104 120 G_TYPE_STRING, 105 121 GDK_TYPE_PIXBUF); 106 // g_message("%s: store: %x", __FUNCTION__, (UINT) store);107 122 return store; 108 123 } 109 124 110 /*************** Local vars ************************************/ 111 112 /* This ID is used as a namespace */ 113 static nomId WPFolderNomId; 114 115 /***************************************************************/ 125 116 126 /* 117 127 The folder is already populated, that means the internal folder list … … 122 132 gboolean fillStoreTraverseFunc(gpointer pKey, gpointer pTraverseValue, gpointer pData) 123 133 { 124 GtkTreeIter iter;134 WPFolder* wpFolder=(PWPFolder)pData; 125 135 PFLDRGTREEVALUE pValue=pTraverseValue; 126 gchar * display_name; 127 GtkListStore *store=(GtkListStore *)pData; 128 WPObject* wpObject; 129 130 // g_message("In %s with %s %x", __FUNCTION__, (char*)pKey, (UINT)pValue->wpObject); 131 132 #warning !!!!! Use Title here !!!!! 133 display_name=g_strdup(pKey); /* New string necessary? */ 134 135 wpObject=pValue->wpObject; 136 137 if(nomIsObj(wpObject)){ 138 #if 0 139 g_message("%d %s : %s, %s", 140 __LINE__, __FUNCTION__, (char*)pKey, 141 NOMPath_queryCString(WPFolder_wpQueryFileName(wpFolder, TRUE, NULLHANDLE), NULLHANDLE)); 142 #endif 143 144 gtk_list_store_append (store, &iter); 145 146 gtk_list_store_set (store, &iter, 147 COL_OBJECT_PTR, wpObject, 148 COL_PATH, "", 149 COL_DISPLAY_NAME, display_name, 150 COL_PIXBUF, _wpQueryIcon(wpObject, NULLHANDLE), 151 -1); 152 } 153 return FALSE; /* Traverse every item */ 154 } 136 137 WPFolder_wpAddToStore(wpFolder, pValue->wpObject, 138 NULLHANDLE); 139 return FALSE; 140 } 141 155 142 156 143 static gboolean 157 fldr_fillStore (WPFolder* nomSelf, GtkListStore *store , const gchar* gchrPath)144 fldr_fillStore (WPFolder* nomSelf, GtkListStore *store) 158 145 { 159 146 WPFolderData* nomThis=WPFolderGetData(nomSelf); 160 147 161 148 /* First clear the store */ 162 gtk_list_store_clear (store); 163 164 g_tree_foreach(_fldrObjects, (GTraverseFunc) fillStoreTraverseFunc, store); 149 if(_pListStore) 150 gtk_list_store_clear (_pListStore); 151 152 /* Go over all objects in the folder */ 153 g_tree_foreach(_fldrObjects, (GTraverseFunc) fillStoreTraverseFunc, nomSelf); 165 154 166 155 return TRUE; … … 168 157 169 158 159 /** 160 Implementation for method wpAddToContent(). 161 162 Each folder has a balanced binary tree (GTree) holding all the objects in it. 163 The key one may use to search the tree is the name of an object. The associated 164 data is a struct holding some more info e.g. the GTree* pointer. 165 Using the name as the key allows to quickly check for duplicates. 166 167 \sa wpAddToContent() 168 */ 170 169 NOM_Scope gulong NOMLINK impl_WPFolder_wpAddToContent(WPFolder* nomSelf, const PWPObject wpObject, 171 170 const CORBA_char * chrFileName, CORBA_Environment *ev) … … 177 176 pValue->pGTree=_fldrObjects; 178 177 pValue->wpObject=wpObject; 179 pValue->chrKey=g_strdup(chrFileName); 178 pValue->chrKey=NOMPath_copyCString( WPFileSystem_wpQueryFileName(wpObject, FALSE, NULLHANDLE) 179 , NULLHANDLE); 180 180 181 181 g_tree_insert(_fldrObjects, pValue->chrKey, pValue); 182 182 183 #if 0184 PFLDRGTREEKEY pKey;185 pKey=(PFLDRGTREEKEY)NOMMalloc(sizeof(FLDRGTREEKEY));186 pKey->pGTree=_fldrObjects;187 pKey->chrKey=chrFileName;188 g_tree_insert(_fldrObjects, pKey, wpObject);189 #endif190 191 183 return 0; 192 184 } 193 185 186 187 static gboolean fldrPrintListFunc(gpointer key, gpointer pValue, gpointer data) 188 { 189 190 g_message("%s: key %x (%s), value %x, data %d", __FUNCTION__, key, key, pValue, data); 191 return FALSE; 192 } 193 194 static void fldrPrintContentsList(GTree* fldrObjects) 195 { 196 g_tree_foreach(fldrObjects, (GTraverseFunc) fldrPrintListFunc, (gpointer)123); 197 } 198 199 194 200 NOM_Scope PWPObject NOMLINK impl_WPFolder_wpQueryContent(WPFolder* nomSelf, CORBA_Environment *ev) 195 201 { 196 /* WPFolderData* nomThis=WPFolderGetData(nomSelf); */ 202 WPFolderData* nomThis=WPFolderGetData(nomSelf); 203 204 fldrPrintContentsList(_fldrObjects); 197 205 198 206 return NULLHANDLE; 207 } 208 209 NOM_Scope CORBA_boolean NOMLINK impl_WPFolder_wpDeleteFromContent(WPFolder* nomSelf, 210 const PWPObject wpObject, 211 CORBA_Environment *ev) 212 { 213 WPFolderData* nomThis=WPFolderGetData(nomSelf); 214 215 /* The destroy function isn't called here. That doesn't matter because the GC 216 will delete our data struct. If we ever have some stuff in the struct which 217 needs freeing we have to think again because the destroy function used by 218 g_tree_remove() will reinsert any object coming by so g_tree_remove() can't 219 be used. */ 220 g_tree_steal(_fldrObjects, NOMPath_queryCString(WPFileSystem_wpQueryFileName(wpObject, FALSE, NULLHANDLE), 221 NULLHANDLE)); 222 223 224 return TRUE; 225 } 226 227 228 NOM_Scope PUSEITEM NOMLINK impl_WPFolder_wpAddToStore(WPFolder* nomSelf, const PWPObject wpObject, 229 CORBA_Environment *ev) 230 { 231 WPFolderData* nomThis=WPFolderGetData(nomSelf); 232 PUSEITEM pui; 233 ULONG ulError; 234 GtkTreeIter iter; 235 gchar * display_name; 236 237 if(!nomIsObj(wpObject)) 238 return NULLHANDLE; 239 240 if(!_pListStore) 241 return NULLHANDLE; 242 243 #warning !!!!! Use Title here? !!!!! 244 display_name=NOMPath_copyCString(WPFileSystem_wpQueryFileName(wpObject, FALSE, NULLHANDLE), 245 NULLHANDLE);/* Do we need a copy here? */ 246 247 gtk_list_store_append (_pListStore, &iter); 248 gtk_list_store_set (_pListStore, &iter, 249 COL_OBJECT_PTR, wpObject, 250 COL_PATH, "", 251 COL_DISPLAY_NAME, display_name, 252 COL_PIXBUF, _wpQueryIcon(wpObject, NULLHANDLE), 253 -1); 254 255 /* Insert a STOREITEM into the objects inuse inuse list to track in which stores 256 the object lives. This item is later used when an object must be removed from 257 a folder window. */ 258 pui=(PUSEITEM)_wpAllocMem(wpObject, sizeof(USEITEM)+sizeof(STOREITEM), &ulError, NULLHANDLE); 259 /* Fill the structures */ 260 pui->type=(gulong)USAGE_STORE; 261 pui->wpObject=(PWPObject)wpObject; 262 pui++; 263 ((STOREITEM*)pui)->treeIter=iter; 264 ((STOREITEM*)pui)->pListStore=_pListStore; 265 pui--; 266 /* Object list not the one of the folder */ 267 WPObject_wpAddToObjUseList(wpObject, pui, NULLHANDLE); 268 269 return pui; 270 } 271 272 273 NOM_Scope PUSEITEM NOMLINK impl_WPFolder_wpDeleteFromStore(WPFolder* nomSelf, const PWPObject wpObject, 274 CORBA_Environment *ev) 275 { 276 WPFolderData* nomThis=WPFolderGetData(nomSelf); 277 PUSEITEM pui; 278 279 /* Remove the object from the folder window. That means from the store. */ 280 if(_pListStore) 281 { 282 /* Each object which is added to a store */ 283 pui=_wpFindUseItem(wpObject, USAGE_STORE, 284 NULLHANDLE, NULLHANDLE); 285 while(pui){ 286 GtkTreeIter iter; 287 pui++; 288 iter=((STOREITEM*)pui)->treeIter; 289 if(((STOREITEM*)pui)->pListStore==_pListStore) 290 { 291 pui--; 292 gtk_list_store_remove( _pListStore, &iter); 293 _wpDeleteFromObjUseList(wpObject, pui, NULLHANDLE); 294 //_wpFreeMem(wpObject, pui, NULLHANDLE); 295 break; 296 } 297 pui--; 298 pui=_wpFindUseItem(wpObject, USAGE_STORE, 299 pui, NULLHANDLE); 300 } 301 } 302 return pui; 199 303 } 200 304 … … 210 314 const gchar* gchrPath; 211 315 PNOMPath fldrPath; 212 213 // g_log("WPFolder", G_LOG_LEVEL_DEBUG, "%s: Populating %s (0x%x)\n", __FUNCTION__, pszPath, (UINT)nomSelf);214 316 215 317 /* Already populated? */ … … 236 338 WPObject* wpObject; 237 339 340 /* Filenames are in a special encoding with GLib */ 238 341 path = g_build_filename (gchrPath, gchrCurrentEntry, NULL); 239 342 343 /* The name to show to the user */ 240 344 display_name = g_filename_to_utf8 (gchrCurrentEntry, -1, NULL, NULL, NULL); 241 345 … … 251 355 if(nomIsObj((PNOMObject)wpObject)) 252 356 { 357 /* First ref living as long as the folder is awake */ 253 358 WPObject_wpLockObject(wpObject, NULLHANDLE); 254 359 WPObject_wpSetTitleFromCString(wpObject, display_name, NULLHANDLE); … … 281 386 /* 282 387 This will change when NOMFolderWindow is migrated to WPFolderWindow. 388 389 This delete handler is called when the folder window is closed. It removes 390 the view item from the folders inuse list. 283 391 */ 284 392 static … … 301 409 /* Remove the open folder view from the inuse list */ 302 410 WPObject_wpDeleteFromObjUseList(wpObject, pUseItem, NULLHANDLE); 411 412 _wpFreeMem(wpObject, pUseItem, NULLHANDLE); 303 413 304 414 return FALSE; /* Let other handlers run */ … … 331 441 WPFolderWindow * wpFldrWindow; 332 442 gchar* pszPath; 333 PPRIVFOLDERDATA priv;334 GtkListStore* gStore;443 // PPRIVFOLDERDATA priv; 444 // GtkListStore* gStore; 335 445 GtkIconView* gtkIconView; 336 446 337 447 pszPath=NOMPath_queryCString(_wpQueryFileName(nomSelf, TRUE, NULLHANDLE), NULLHANDLE); 338 448 g_message("%d %s, %s", __LINE__, __FUNCTION__, pszPath); 449 /* Create the internal list of objects and make all these objects awake */ 339 450 WPFolder_wpPopulate(nomSelf, 0L, pszPath, FALSE, NULLHANDLE); 340 451 341 452 /* The folder window holding the objects */ 342 453 wpFldrWindow=WPFolder_wpCreateFolderWindow(nomSelf, NULLHANDLE); 343 454 344 /* Insert it into inuse list */455 /* Insert it into inuse list... */ 345 456 pui=(PUSEITEM)WPFolder_wpAllocMem(nomSelf, sizeof(USEITEM)+sizeof(VIEWITEM), &ulError, NULLHANDLE); 346 457 /* Fill the structures */ … … 352 463 ((VIEWITEM*)pui)->nameSpaceId=WPFolderNomId; 353 464 pui--; 354 355 465 /* Make sure the view item is removed when the window is closed */ 356 g_signal_connect(G_OBJECT(NOMWindow_queryWindowHandle((NOMWindow*)wpFldrWindow, NULLHANDLE)),"delete-event", 466 g_signal_connect(G_OBJECT(NOMWindow_queryWindowHandle((NOMWindow*)wpFldrWindow, NULLHANDLE)), 467 "delete-event", 357 468 G_CALLBACK(tempWPWindowDeleteHandler), (gpointer) pui); 358 469 WPFolder_wpAddToObjUseList(nomSelf, pui, NULLHANDLE); 359 470 471 #if 0 360 472 /* Now create a folder store and insert icons into the window */ 361 473 priv=_privFolderData; 362 gStore=priv->gstoreFldContents; 363 474 gStore=priv->gstoreFldContents; 364 475 if(!gStore) 365 476 { … … 375 486 return FALSE; 376 487 } 377 378 488 gtkIconView=WPFolderWindow_wpQueryContainerHandle(wpFldrWindow, NULLHANDLE); 379 380 489 gtk_icon_view_set_model(GTK_ICON_VIEW (gtkIconView), 381 490 GTK_TREE_MODEL (priv->gstoreFldContents)); 491 #endif 492 if(!_pListStore) 493 { 494 495 if(( _pListStore=fldr_CreateStore())==NULLHANDLE){ 496 g_warning("%s: Can't create store.", __FUNCTION__); 497 return FALSE; 498 } 499 /* Fill our store */ 500 fldr_fillStore(nomSelf, _pListStore); 501 } 502 503 gtkIconView=WPFolderWindow_wpQueryContainerHandle(wpFldrWindow, NULLHANDLE); 504 505 gtk_icon_view_set_model(GTK_ICON_VIEW (gtkIconView), 506 GTK_TREE_MODEL (_pListStore)); 382 507 383 508 /* We now set which model columns that correspond to the text … … 641 766 /* This balanced binary tree holds the objects in this folder. We create a tree 642 767 which may be searched using the name of the file/directory */ 643 //_fldrObjects=g_tree_new((GCompareFunc)strcmp); 644 _fldrObjects=g_tree_new_full((GCompareFunc)strcmp, nomSelf, NULL, 768 _fldrObjects=g_tree_new_full((GCompareDataFunc)strcmp, nomSelf, NULL, 645 769 (GDestroyNotify) fldrCatchDuplicates); 646 770 } … … 668 792 return 0; 669 793 794 /* That's the action the user selected by pressing a key during drop */ 670 795 gda=NOMDragInfo_queryChosenDropAction(nomDragInfo, NULLHANDLE); 671 796 … … 693 818 break; 694 819 } 820 /* Copy shouldn't be default I guess... */ 695 821 default: 696 822 { -
trunk/desktop/class_c/wpfolderwindow.c
r241 r244 142 142 /* Click on an icon */ 143 143 144 g_message("%s: %s", __FUNCTION__, gtk_tree_path_to_string(treePath));144 //g_message("%s: %s", __FUNCTION__, gtk_tree_path_to_string(treePath)); 145 145 146 146 model=gtk_icon_view_get_model(GTK_ICON_VIEW(widget)); 147 g_message("%s: model: %x", __FUNCTION__, (UINT)model);147 //g_message("%s: model: %x", __FUNCTION__, (UINT)model); 148 148 149 gtk_tree_model_get_iter(model , &iter, treePath); 149 gtk_tree_model_get_iter(model , &iter, treePath); 150 //g_message("%s: iter.stamp: %x %x %x %x", __FUNCTION__, (UINT)iter.stamp, (UINT) iter.user_data 151 // , (UINT)iter.user_data2, (UINT)iter.user_data3); 150 152 gtk_tree_model_get(model, &iter, 0, &wpObject, -1); 151 153 … … 236 238 } 237 239 rc=WPObject_wpDragOver(wpObject, wgtThis, nomDragInfo, NULL); 238 g_message("rc: %d", rc); 240 239 241 if(dragContext->targets) 240 242 { … … 544 546 guint uiTargetInfo, guint t, gpointer ptrUserData) 545 547 { 546 DosBeep(100, 100);548 547 549 g_message("%s", __FUNCTION__); 548 g_message(" info: %d, userData: %x", uiTargetInfo, ptrUserData);550 // g_message(" info: %d, userData: %x", uiTargetInfo, ptrUserData); 549 551 550 552 switch(uiTargetInfo) -
trunk/desktop/class_c/wpobject.c
r241 r244 250 250 //g_message(" in %s wpNoteBook: %lx pui %lx", __FUNCTION__, wpNoteBook, pui); 251 251 /* Make sure the view item is removed when the window is closed */ 252 g_signal_connect(G_OBJECT(NOMWindow_queryWindowHandle((NOMWindow*)wpNoteBook, NULLHANDLE)),"delete-event", 252 g_signal_connect(G_OBJECT(NOMWindow_queryWindowHandle((NOMWindow*)wpNoteBook, NULLHANDLE)), 253 "delete-event", 253 254 G_CALLBACK(defaultWPWindowDeleteHandler), (gpointer) pui); 254 255 WPObject_wpAddToObjUseList(nomSelf, pui, ev); … … 418 419 else{ 419 420 pUseItem=(PUSEITEM)pCurrentItem; 420 pUseItem--; 421 pUseItem--; /* Note that VIEWITEM comes after the USEITEM structure */ 421 422 pUseItem=WPObject_wpFindUseItem(nomSelf, USAGE_OPENVIEW, pUseItem, ev); 422 423 } … … 426 427 ++pUseItem; 427 428 pViewItem=(PVIEWITEM)pUseItem; 428 pUseItem--; 429 pUseItem--; /* Note that VIEWITEM comes after the USEITEM structure */ 429 430 //g_message(" a in %s %d", __FUNCTION__, flViews); 430 431 if((pViewItem->ulView == ulView) && (pViewItem->nameSpaceId==nameSpaceId)) … … 811 812 } 812 813 814 813 815 NOM_Scope CORBA_boolean NOMLINK impl_WPObject_wpMoveObject(WPObject* nomSelf, 814 816 const PWPFolder wpTargetFolder, … … 816 818 { 817 819 /* WPObjectData* nomThis=WPObjectGetData(nomSelf); */ 818 g_message("Calling %s, not implemented yet", __FUNCTION__); 820 WPFolder * wpFolder; 821 PUSEITEM pui; 822 823 if(!nomIsObj(wpTargetFolder)) 824 return FALSE; 825 826 /* Get folder holding the object */ 827 wpFolder=WPObject_wpQueryFolder(nomSelf, NULLHANDLE); 828 829 g_message("Parent folder is %s", 830 NOMPath_queryCString(WPFolder_wpQueryFileName(wpFolder, TRUE, NULLHANDLE), 831 NULLHANDLE)); 832 833 /* Remove it from the parent folders content list. */ 834 WPFolder_wpDeleteFromContent(wpFolder, nomSelf, NULLHANDLE); 835 836 /* Remove it from the folders model thus any folder window. */ 837 pui=_wpDeleteFromStore(wpFolder, nomSelf, NULLHANDLE); 838 _wpFreeMem(nomSelf, pui, NULLHANDLE); 839 840 g_message("Target folder is %s", 841 NOMPath_queryCString(WPFolder_wpQueryFileName(wpTargetFolder, TRUE, NULLHANDLE), 842 NULLHANDLE)); 843 844 /* Insert into the new folder */ 845 _wpAddToContent(wpTargetFolder, nomSelf, NULLHANDLE, NULLHANDLE); 846 _wpAddToStore(wpTargetFolder, nomSelf, NULLHANDLE); 819 847 820 848 return FALSE; … … 828 856 /* WPObjectData* nomThis=WPObjectGetData(nomSelf); */ 829 857 830 g_message("Calling %s, not implmnted yet", __FUNCTION__); 858 g_message("Calling %s, not implmented yet", __FUNCTION__); 859 831 860 return FALSE; 832 861 } -
trunk/desktop/idl/wpfolder.idl
r237 r244 67 67 PWPObject wpQueryContent(); 68 68 69 /** 70 Delete an object from the internal list of objects held by 71 the folder. 72 73 \param wpObject The object to be removed. 74 75 \return TRUE on success FALSE otherwise. 76 77 \sa wpQueryContents(), wpAddToContents() 78 */ 79 boolean wpDeleteFromContent(in PWPObject wpObject); 80 81 PUSEITEM wpAddToStore(in PWPObject wpObject); 82 PUSEITEM wpDeleteFromStore(in PWPObject wpObject); 83 69 84 NOMOVERRIDE(wpInitData); 70 85 NOMOVERRIDE(wpOpen); … … 72 87 NOMOVERRIDE(wpQueryDefaultView); 73 88 NOMOVERRIDE(wpDragOver); 89 NOMOVERRIDE(wpDrop); 74 90 75 91 NOMINSTANCEVAR(PPRIVFOLDERDATA privFolderData); /* This will go away... */ 76 92 NOMINSTANCEVAR(PGTree fldrObjects); 77 93 NOMINSTANCEVAR(gulong ulFldrFlags); 94 NOMINSTANCEVAR(PGtkListStore pListStore); 78 95 }; 79 96 -
trunk/desktop/idl/wpnativetypes.idl
r175 r244 43 43 native PUSEITEM; /* For inuse list */ 44 44 native PVIEWITEM; /* For inuse list */ 45 native PGtkListStore; 45 46 46 47 #endif /* WPFOLDERTYPES_IDL_INCLUDED */ -
trunk/desktop/idl/wpobject.idl
r241 r244 89 89 will be collected later. 90 90 91 \par How to override: 92 This method is usually not overriden. 93 94 \param pByte Block of memory to be freed. 91 \remark It is save to call this method with a NULL memory pointer. 92 93 \par How to override: 94 This method is usually not overriden. 95 96 \param pByte Block of memory to be freed. This may be NULL. 95 97 \return TRUE if successful. 96 98 -
trunk/desktop/include/desktoptypes.h
r191 r244 44 44 } VIEWITEM, *PVIEWITEM; 45 45 46 /* USAGE_STORE */ 47 typedef struct _STOREITEM { 48 GtkTreeIter treeIter; 49 GtkListStore *pListStore; 50 }STOREITEM, *PSTOREITEM; 46 51 47 52 #define USAGE_MEMORY 1 48 53 #define USAGE_OPENVIEW 5 54 #define USAGE_STORE 7 49 55 50 56 #define OPEN_DEFAULT 0 … … 84 90 typedef GSList *PGSList; 85 91 typedef GMutex *PGMutex; 86 92 typedef GtkListStore *PGtkListStore; 87 93 /* Errors */ 88 94 #define NOMERROR_NOT_ENOUGH_MEMORY 8
Note:
See TracChangeset
for help on using the changeset viewer.