Create an item for a PtFileSel widget
PtFileSelItem_t * PtFSAllocItem( PtFileSelWidget_t *fs, int type, char const *info );
You can use this function to create a PtFileSelItem_t for the PtFileSel widget. It's useful if your application can display items that aren't physically part of the filesystem. The parameters are as follows:
This must contain a valid file type and is used to display the item's image.
An item pointer is returned. If you wish to store any information in the item, use the item->fullpath character pointer. It's used in most items to store the full path of the item, but this function initializes it to NULL.
The allocated item pointer if successful, or NULL if an error occurred.
Suppose you wish to add your own item. In the state callback, you can check the item's fullpath to see if it's the one you want to deal with and if so, add your own items afterwards. Just return Pt_END from the Pt_FS_STATE_START callback to prevent the widget from doing the expansion.
/* State callback. Use the reason to block the widget for large directory opens. */ int state_cb( PtWidget_t *widget, struct fs_dialog_modal *user, PtCallbackInfo_t *info) { PtArg_t args[3]; PtFileSelCallback_t *it; PtFileSelItem_t *new_item; it = (PtFileSelCallback_t *)(info->cbdata); if (it->reason == Pt_FS_STATE_START) { PtSetArg(&args[0], Pt_ARG_FLAGS, Pt_BLOCKED, Pt_BLOCKED); PtSetArg(&args[1], Pt_ARG_CURSOR_TYPE, Ph_CURSOR_CLOCK, 0); if ((strcmp(it->item->fullpath, "/Gamma") == 0) && (info->reason_subtype == Pt_TREE_EXPANDING)) { it->item->type = Pt_FS_DIR_OP; PtFSDamageItem(fs, it->item); new_item = PtFSAllocItem(fs, Pt_FS_FILE, "Fred Flintstone"); PtFSAddFirst(fs, new_item, it->item); return (Pt_END); } } else { PtSetArg(&args[0], Pt_ARG_FLAGS, ~Pt_BLOCKED, Pt_BLOCKED); PtSetArg(&args[1], Pt_ARG_CURSOR_TYPE, Ph_CURSOR_INHERIT, 0); } PtSetResources(widget, 2, args); return (Pt_CONTINUE); }
Photon
Safety: | |
---|---|
Interrupt handler | No |
Signal handler | No |
Thread | No |