Changeset 194 for trunk/desktop/class_c/wpfolder.c
- Timestamp:
- Jan 16, 2007, 8:32:50 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/desktop/class_c/wpfolder.c
r191 r194 71 71 #include "desktop.h" 72 72 #include "helper.h" 73 #include "exception.h" 73 74 74 75 typedef struct _FLDRGTREEVALUE … … 76 77 PGTree pGTree; 77 78 WPObject* wpObject; 78 constgchar* chrKey;79 gchar* chrKey; 79 80 }FLDRGTREEVALUE, *PFLDRGTREEVALUE; 80 81 … … 111 112 /***************************************************************/ 112 113 113 #if 0114 static BOOL115 fldr_fillStore (GtkListStore *store, const gchar* gchrPath)116 {117 118 GDir *gDir;119 const gchar *gchrCurrentEntry;120 GtkTreeIter iter;121 122 nomPrintf("In %s: %s\n", __FUNCTION__, gchrPath);123 124 /* First clear the store */125 gtk_list_store_clear (store);126 127 /* Now go through the directory and extract all the file128 * information */129 gDir = g_dir_open (gchrPath, 0, NULL);130 if (!gDir)131 return FALSE;132 133 while ((gchrCurrentEntry = g_dir_read_name (gDir))!= NULL)134 {135 gchar *path, *display_name;136 gboolean is_dir;137 138 if (gchrCurrentEntry[0] != '\0')139 {140 path = g_build_filename (gchrPath, gchrCurrentEntry, NULL);141 nomPrintf(" %s\n", path);142 143 display_name = g_filename_to_utf8 (gchrCurrentEntry, -1, NULL, NULL, NULL);144 if(g_file_test (path, G_FILE_TEST_IS_DIR))145 {146 /* It's a folder */147 WPFolder* wpFolder;148 149 wpFolder=WPFolderNew();150 if(nomIsObj((PNOMObject)wpFolder))151 {152 gtk_list_store_append (store, &iter);153 154 gtk_list_store_set (store, &iter,155 COL_OBJECT_PTR, wpFolder,156 COL_PATH, path,157 COL_DISPLAY_NAME, display_name,158 COL_IS_DIRECTORY, is_dir,159 COL_PIXBUF, _wpQueryIcon(wpFolder, NULLHANDLE), //folder_pixbuf ,160 -1);161 162 }/* if(nomIsObj(wpFolder)) */163 }/* if(g_file_test (path, G_FILE_TEST_IS_DIR)) */164 else165 {166 /* It's a file */167 WPDataFile* wpDataFile;168 169 wpDataFile=WPDataFileNew();170 171 if(nomIsObj((PNOMObject)wpDataFile))172 {173 gtk_list_store_append (store, &iter);174 175 #warning !!!! some problems with icon handling here !!!!176 nomPrintf("Icon ptr: %x\n", _wpQueryIcon((WPObject*)wpDataFile, NULLHANDLE));177 gtk_list_store_set (store, &iter,178 COL_OBJECT_PTR, wpDataFile,179 COL_PATH, path,180 COL_DISPLAY_NAME, display_name,181 COL_IS_DIRECTORY, is_dir,182 COL_PIXBUF, _wpQueryIcon((WPObject*)wpDataFile, NULLHANDLE), //file_pixbuf,183 -1);184 }185 }186 g_free (path);187 g_free (display_name);188 }/* if (gchrCurrentEntry[0] != '\0') */189 }/* while */190 191 g_dir_close(gDir);192 193 return TRUE;194 }195 /* pszPath contains the fully qualified path (checked with WPS) */196 NOM_Scope CORBA_boolean NOMLINK impl_WPFolder_wpPopulate(WPFolder* nomSelf, const CORBA_unsigned_long ulReserved,197 const CORBA_char * pszPath, const CORBA_boolean fFoldersOnly,198 CORBA_Environment *ev)199 {200 WPFolderData* nomThis=WPFolderGetData(nomSelf);201 GtkListStore* gStore;202 PPRIVFOLDERDATA priv;203 204 nomPrintf(" Entering %s with nomSelf: 0x%x. nomSelf is: %s. Path is %s\n",205 __FUNCTION__, nomSelf , nomSelf->mtab->nomClassName, pszPath);206 207 g_return_val_if_fail(_privFolderData!=NULLHANDLE, FALSE); /* Huh! What happened in wpInitData()? */208 g_log("WPFolder", G_LOG_LEVEL_DEBUG, "%s: Populating %s\n", __FUNCTION__, pszPath);209 210 211 #if 0212 /* Already populated? */213 if(fFoldersOnly &&214 (_wpQueryFldrFlags(nomSelf) & (FOI_POPULATEDWITHFOLDERS | FOI_POPULATEDWITHALL)))215 return TRUE;216 else if(_wpQueryFldrFlags(nomSelf) & FOI_POPULATEDWITHALL)217 return TRUE;218 #endif219 220 priv=_privFolderData;221 222 if(!priv->gstoreFldContents)223 {224 /* Create a store holding the folder contents */225 gStore=fldr_CreateStore();226 g_return_val_if_fail(gStore!=NULLHANDLE, FALSE);227 priv->gstoreFldContents=gStore;228 }229 230 /* Fill our store */231 if(gStore)232 fldr_fillStore(gStore, pszPath);233 else234 return FALSE;235 236 gtk_icon_view_set_model(GTK_ICON_VIEW (priv->gtkIconView), GTK_TREE_MODEL (priv->gstoreFldContents));237 238 /* We now set which model columns that correspond to the text239 * and pixbuf of each item240 */241 gtk_icon_view_set_text_column (GTK_ICON_VIEW (priv->gtkIconView), COL_DISPLAY_NAME);242 gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW (priv->gtkIconView), COL_PIXBUF);243 gtk_icon_view_set_item_width (GTK_ICON_VIEW (priv->gtkIconView),244 100);245 246 g_object_unref (gStore);247 248 return FALSE;249 }250 #endif251 252 114 static 253 115 gboolean fillStoreTraverseFunc(gpointer pKey, gpointer pTraverseValue, gpointer pData) … … 258 120 GtkListStore *store=(GtkListStore *)pData; 259 121 260 g_message("In %s with %s %x", __FUNCTION__, (char*)pKey, (UINT)pValue->wpObject);122 // g_message("In %s with %s %x", __FUNCTION__, (char*)pKey, (UINT)pValue->wpObject); 261 123 262 124 #warning !!!!! Use Title here !!!!! 263 display_name= pKey;125 display_name=g_strdup(pKey); /* New string necessary? */ 264 126 265 127 … … 290 152 291 153 if(nomIsObj((NOMObject*)wpFolder)){ 292 154 #if 0 293 155 g_message("%d %s : %s, %s", 294 156 __LINE__, __FUNCTION__, (char*)pKey, 295 157 NOMPath_queryCString(WPFolder_wpQueryFileName(wpFolder, TRUE, NULLHANDLE), NULLHANDLE)); 296 158 #endif 297 159 298 160 gtk_list_store_append (store, &iter); … … 336 198 pValue->pGTree=_fldrObjects; 337 199 pValue->wpObject=wpObject; 338 pValue->chrKey=chrFileName; 339 g_tree_insert(_fldrObjects, chrFileName, pValue); 200 pValue->chrKey=g_strdup(chrFileName); 201 202 g_tree_insert(_fldrObjects, pValue->chrKey, pValue); 340 203 341 204 #if 0 … … 353 216 { 354 217 /* WPFolderData* nomThis=WPFolderGetData(nomSelf); */ 355 PWPObject nomRetval; 356 357 return nomRetval; 218 219 return NULLHANDLE; 358 220 } 359 221 … … 370 232 PNOMPath fldrPath; 371 233 372 g_log("WPFolder", G_LOG_LEVEL_DEBUG, "%s: Populating %s (0x%x)\n", __FUNCTION__, pszPath, (UINT)nomSelf);234 // g_log("WPFolder", G_LOG_LEVEL_DEBUG, "%s: Populating %s (0x%x)\n", __FUNCTION__, pszPath, (UINT)nomSelf); 373 235 374 236 /* Already populated? */ … … 409 271 if(nomIsObj((PNOMObject)wpObject)) 410 272 { 273 WPObject_wpLockObject(wpObject, NULLHANDLE); 411 274 WPObject_wpSetTitleFromCString(wpObject, display_name, NULLHANDLE); 412 275 WPFileSystem_tstSetFullPath((WPFileSystem*)wpObject, gchrCurrentEntry, NULLHANDLE); 413 276 WPFileSystem_wpSetFolder(wpObject, nomSelf, NULLHANDLE); 277 #if 9 414 278 g_message("%d %s : %s (%x) , %s", 415 279 __LINE__, __FUNCTION__, gchrCurrentEntry, (UINT)wpObject, 416 280 NOMPath_queryCString(WPFolder_wpQueryFileName(wpObject, TRUE, NULLHANDLE), NULLHANDLE)); 417 281 #endif 418 282 /* insert into contents list */ 419 WPFolder_wpAddToContent(nomSelf, wpObject, g _strdup(gchrCurrentEntry), NULLHANDLE);283 WPFolder_wpAddToContent(nomSelf, wpObject, gchrCurrentEntry, NULLHANDLE); 420 284 }/* if(nomIsObj(wpObject)) */ 421 285 g_free (path); … … 491 355 PPRIVFOLDERDATA priv; 492 356 GtkListStore* gStore; 493 357 GtkIconView* gtkIconView; 358 494 359 pszPath=NOMPath_queryCString(WPFolder_wpQueryFileName(nomSelf, TRUE, NULLHANDLE), NULLHANDLE); 495 360 g_message("%d %s, %s", __LINE__, __FUNCTION__, pszPath); … … 526 391 g_return_val_if_fail(gStore!=NULLHANDLE, FALSE); 527 392 priv->gstoreFldContents=gStore; 393 394 /* Fill our store */ 395 if(gStore) 396 fldr_fillStore(nomSelf, gStore, pszPath); 397 else 398 return FALSE; 528 399 } 529 530 /* Fill our store */ 531 if(gStore) 532 fldr_fillStore(nomSelf, gStore, pszPath); 533 else 534 return FALSE; 535 536 gtk_icon_view_set_model(GTK_ICON_VIEW (priv->gtkIconView), GTK_TREE_MODEL (priv->gstoreFldContents)); 537 400 401 gtkIconView=WPFolderWindow_wpQueryContainerHandle(wpFldrWindow, NULLHANDLE); 402 403 gtk_icon_view_set_model(GTK_ICON_VIEW (gtkIconView), 404 GTK_TREE_MODEL (priv->gstoreFldContents)); 405 538 406 /* We now set which model columns that correspond to the text 539 407 * and pixbuf of each item 540 408 */ 541 gtk_icon_view_set_text_column (GTK_ICON_VIEW ( priv->gtkIconView), COL_DISPLAY_NAME);542 gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW ( priv->gtkIconView), COL_PIXBUF);543 gtk_icon_view_set_item_width (GTK_ICON_VIEW ( priv->gtkIconView), 100);544 545 g_object_unref (gStore);409 gtk_icon_view_set_text_column (GTK_ICON_VIEW (gtkIconView), COL_DISPLAY_NAME); 410 gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW (gtkIconView), COL_PIXBUF); 411 gtk_icon_view_set_item_width (GTK_ICON_VIEW (gtkIconView), 100); 412 413 // g_object_unref (gStore); 546 414 547 415 return wpFldrWindow; … … 609 477 g_message("%s: %s", __FUNCTION__, wpObject->mtab->nomClassName); 610 478 /* WPObject_wpOpen(wpObject, pWindow, OPEN_CONTENTS, NULL, NULL); */ 611 WPObject_wpViewObject(wpObject, pWindow, OPEN_DEFAULT, 0, NULLHANDLE, NULL); 479 TRY(FLDR_ITEMACTIVATED) { 480 WPObject_wpViewObject(wpObject, pWindow, OPEN_DEFAULT, 0, NULLHANDLE, NULL); 481 } 482 CATCH{ 483 LOUD; 484 g_message("Line %d: Trap in %s", __LINE__, __FUNCTION__); 485 }END_CATCH(FLDR_ITEMACTIVATED); 612 486 } 613 487 } … … 627 501 wpFldrWindow=WPFolderWindowNew(); 628 502 629 #warning !!!!! This is only for testing !!!!!630 priv->gtkIconView=WPFolderWindow_wpQueryContainerHandle(wpFldrWindow, ev);631 632 503 /* Connect to the "item_activated" signal */ 633 g_signal_connect ( priv->gtkIconView, "item-activated",504 g_signal_connect (WPFolderWindow_wpQueryContainerHandle(wpFldrWindow, NULLHANDLE), "item-activated", 634 505 G_CALLBACK (itemActivated), nomSelf); 635 506 … … 719 590 720 591 592
Note:
See TracChangeset
for help on using the changeset viewer.