Ignore:
Timestamp:
Nov 25, 2006, 8:57:34 PM (19 years ago)
Author:
cinc
Message:

Started implementation of wpPopulate()

File:
1 edited

Legend:

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

    r103 r106  
    4646
    4747#include <string.h>
     48#include "gtk/gtk.h"
     49
     50#warning !!!!! nomIsObj() must be globaly defined !!!!!
     51#define nomIsObj(a) ((a)!= 0)
     52
     53typedef struct _PRIVFOLDERDATA
     54{
     55  GtkListStore *gstoreFldContents;
     56  GtkWidget    *gtkIconView;
     57}PRIVFOLDERDATA, *PPRIVFOLDERDATA;
     58
    4859#include "wpfolder.ih"
    49 
     60#include "wpdatafile.h"
     61
     62/* Enum for the folder store */
     63enum
     64{
     65  COL_PATH,
     66  COL_DISPLAY_NAME,
     67  COL_PIXBUF,
     68  COL_IS_DIRECTORY,
     69  NUM_COLS
     70};
     71
     72static GtkListStore * fldr_CreateStore (void)
     73{
     74  GtkListStore *store;
     75
     76  store = gtk_list_store_new (NUM_COLS,
     77                              G_TYPE_STRING,
     78                              G_TYPE_STRING,
     79                              GDK_TYPE_PIXBUF,
     80                              G_TYPE_BOOLEAN);
     81
     82  return store;
     83}
     84
     85static BOOL
     86fldr_fillStore (GtkListStore *store, const gchar* gchrPath)
     87{
     88
     89  GDir *gDir;
     90  const gchar *gchrCurrentEntry;
     91  GtkTreeIter iter;
     92 
     93  /* First clear the store */
     94  gtk_list_store_clear (store);
     95
     96  /* Now go through the directory and extract all the file
     97   * information */
     98  gDir = g_dir_open (gchrPath, 0, NULL);
     99  if (!gDir)
     100    return FALSE;
     101
     102  while ((gchrCurrentEntry = g_dir_read_name (gDir))!= NULL)
     103    {
     104      gchar *path, *display_name;
     105      gboolean is_dir;
     106
     107      if (gchrCurrentEntry[0] != '\0')
     108        {
     109          path = g_build_filename (gchrPath, gchrCurrentEntry, NULL);
     110          nomPrintf("  %s\n", path);         
     111
     112          display_name = g_filename_to_utf8 (gchrCurrentEntry, -1, NULL, NULL, NULL);
     113          if(g_file_test (path, G_FILE_TEST_IS_DIR))
     114            {
     115              /* It's a folder */
     116              WPFolder* wpFolder;
     117
     118              wpFolder=WPFolderNew();
     119              if(nomIsObj(wpFolder))
     120                {
     121                  gtk_list_store_append (store, &iter);
     122#if 0
     123                  gtk_list_store_set (store, &iter,
     124                                      COL_PATH, path,
     125                                      COL_DISPLAY_NAME, display_name,
     126                                      COL_IS_DIRECTORY, is_dir,
     127                                      COL_PIXBUF, _wpQueryIcon(wpFolder), //folder_pixbuf ,
     128                                      -1);
     129#endif
     130                }/* if(nomIsObj(wpFolder)) */
     131            }/* if(g_file_test (path, G_FILE_TEST_IS_DIR)) */
     132          else
     133            {
     134              /* It's a file */
     135              WPDataFile* wpDataFile;
     136
     137              wpDataFile=WPDataFileNew();
     138
     139              if(nomIsObj(wpDataFile))
     140                {
     141                  gtk_list_store_append (store, &iter);
     142#if 0
     143                  gtk_list_store_set (store, &iter,
     144                                      COL_PATH, path,
     145                                      COL_DISPLAY_NAME, display_name,
     146                                      COL_IS_DIRECTORY, is_dir,
     147                                      COL_PIXBUF, _wpQueryIcon(wpDataFile), //file_pixbuf,
     148                                      -1);
     149#endif
     150                }
     151            }
     152          g_free (path);
     153          g_free (display_name);
     154        }/* if (gchrCurrentEntry[0] != '\0') */
     155    }/* while */
     156
     157  g_dir_close(gDir);
     158
     159  return TRUE;
     160}
    50161
    51162/* pszPath contains the fully qualified path (checked with WPS) */
    52163NOM_Scope CORBA_boolean NOMLINK impl_WPFolder_wpPopulate(WPFolder* nomSelf, const CORBA_unsigned_long ulReserved, const CORBA_char * pszPath, const CORBA_boolean fFoldersOnly, CORBA_Environment *ev)
    53164{
    54 /* WPFolderData* nomThis=WPFolderGetData(nomSelf); */
    55   CORBA_boolean nomRetval;
     165 WPFolderData* nomThis=WPFolderGetData(nomSelf);
     166  GtkListStore* gStore;
     167  PPRIVFOLDERDATA priv;
    56168
    57169  nomPrintf("    Entering %s with nomSelf: 0x%x. nomSelf is: %s. Path is %s\n",
    58170            __FUNCTION__, nomSelf , nomSelf->mtab->nomClassName, pszPath);
    59171
    60   return nomRetval;
     172  g_return_val_if_fail(_privFolderData!=NULLHANDLE, FALSE);      /* Huh! What happened in wpInitData()? */
     173  g_log("WPFolder", G_LOG_LEVEL_DEBUG, "%s: Populating %s\n", __FUNCTION__, pszPath);
     174
     175#if 0
     176  /* Already populated? */
     177  if(fFoldersOnly &&
     178     (_wpQueryFldrFlags(somSelf) & (FOI_POPULATEDWITHFOLDERS | FOI_POPULATEDWITHALL)))
     179    return TRUE;
     180  else if(_wpQueryFldrFlags(somSelf) & FOI_POPULATEDWITHALL)
     181    return TRUE;
     182#endif
     183
     184  priv=_privFolderData;
     185
     186  if(!priv->gstoreFldContents)
     187    {
     188      /* Create a store holding the folder contents */
     189      gStore=fldr_CreateStore();
     190      g_return_val_if_fail(gStore!=NULLHANDLE, FALSE);
     191      priv->gstoreFldContents=gStore;
     192    }
     193
     194  /* Fill our store */
     195  fldr_fillStore(gStore, pszPath);
     196
     197#if 0
     198  gtk_icon_view_set_model(GTK_ICON_VIEW (priv->gtkIconView), GTK_TREE_MODEL (priv->gstoreFldContents));
     199  /* We now set which model columns that correspont to the text
     200   * and pixbuf of each item
     201   */
     202  gtk_icon_view_set_text_column (GTK_ICON_VIEW (priv->gtkIconView), COL_DISPLAY_NAME);
     203  gtk_icon_view_set_pixbuf_column (GTK_ICON_VIEW (priv->gtkIconView), COL_PIXBUF);
     204  gtk_icon_view_set_item_width (GTK_ICON_VIEW (priv->gtkIconView),
     205                                100);
     206
     207  g_object_unref (gStore);
     208#endif
     209  return FALSE;
    61210}
    62211
     
    64213NOM_Scope void NOMLINK impl_WPFolder_wpInitData(WPFolder* nomSelf, CORBA_Environment *ev)
    65214{
    66 /* WPFolderData* nomThis=WPFolderGetData(nomSelf); */
     215  gulong ulErr;
     216  WPFolderData* nomThis=WPFolderGetData(nomSelf);
    67217
    68218  /* orbit-idl-c-stubs.c, VoyagerWriteProtoForParentCall line 84 */
     
    71221  nomPrintf("    Entering %s with nomSelf: 0x%x. nomSelf is: %s.\n",
    72222            __FUNCTION__, nomSelf , nomSelf->mtab->nomClassName);
     223  _privFolderData=_wpAllocMem((WPObject*)nomSelf, sizeof(PRIVFOLDERDATA), (CORBA_unsigned_long*)&ulErr, NULLHANDLE);
    73224}
    74225
Note: See TracChangeset for help on using the changeset viewer.